26 #include <boost/filesystem.hpp> 27 #include <boost/range/adaptor/map.hpp> 28 #include <boost/range/algorithm/copy.hpp> 29 #include <boost/range/iterator_range.hpp> 37 namespace fs = boost::filesystem;
40 : m_certs(certContainer)
87 const boost::filesystem::path& path,
88 time::nanoseconds refreshPeriod,
bool isDir)
92 , m_refreshPeriod(refreshPeriod)
94 if (refreshPeriod <= time::nanoseconds::zero()) {
95 BOOST_THROW_EXCEPTION(std::runtime_error(
"Refresh period for the dynamic group must be positive"));
98 NDN_LOG_TRACE(
"Create dynamic trust anchor group " <<
id <<
" for file/dir " << path
99 <<
" with refresh time " << refreshPeriod);
114 auto loadCert = [
this, &oldAnchorNames] (
const fs::path& file) {
115 auto cert = io::load<Certificate>(file.string());
116 if (cert !=
nullptr) {
122 oldAnchorNames.erase(cert->getName());
131 if (fs::exists(m_path)) {
132 std::for_each(fs::directory_iterator(m_path), fs::directory_iterator(), loadCert);
137 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.
The certificate following the certificate format naming convention.
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
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.