26 #if BOOST_VERSION >= 107200 27 #include <boost/filesystem/directory.hpp> 29 #include <boost/filesystem/operations.hpp> 30 #include <boost/range/adaptor/map.hpp> 31 #include <boost/range/algorithm/copy.hpp> 32 #include <boost/range/iterator_range.hpp> 40 namespace fs = boost::filesystem;
43 : m_certs(certContainer)
90 const boost::filesystem::path& path,
95 , m_refreshPeriod(refreshPeriod)
97 if (refreshPeriod <= time::nanoseconds::zero()) {
98 NDN_THROW(std::runtime_error(
"Refresh period for the dynamic group must be positive"));
101 NDN_LOG_TRACE(
"Create dynamic trust anchor group " <<
id <<
" for file/dir " << path
102 <<
" with refresh time " << refreshPeriod);
117 auto loadCert = [
this, &oldAnchorNames] (
const fs::path& file) {
118 auto cert = io::load<Certificate>(file.string());
119 if (cert !=
nullptr) {
125 oldAnchorNames.erase(cert->getName());
133 else if (fs::exists(m_path)) {
134 std::for_each(fs::directory_iterator(m_path), fs::directory_iterator(), loadCert);
138 for (
const auto& oldAnchorName : oldAnchorNames) {
TrustAnchorGroup(CertContainerInterface &certContainer, const std::string &id)
Create an anchor group.
Copyright (c) 2011-2015 Regents of the University of California.
Represents an NDN certificate following the version 2.0 format.
virtual void refresh()
Request certificate refresh.
static time_point now() noexcept
virtual ~TrustAnchorGroup()
std::set< Name > m_anchorNames
A group of trust anchors.
void refresh() override
Request certificate refresh.
virtual void add(Certificate &&cert)=0
CertContainerInterface & m_certs
Represents an absolute name.
#define NDN_LOG_TRACE(expression)
void add(Certificate &&cert)
Load static anchor cert.
#define NDN_LOG_INIT(name)
declare a log module
void remove(const Name &certName)
Remove static anchor certName.
virtual void remove(const Name &certName)=0
boost::chrono::nanoseconds nanoseconds
DynamicTrustAnchorGroup(CertContainerInterface &certContainer, const std::string &id, const boost::filesystem::path &path, time::nanoseconds refreshPeriod, bool isDir=false)
Create a dynamic trust anchor group.
StaticTrustAnchorGroup(CertContainerInterface &certContainer, const std::string &id)
Create a static trust anchor group.