27 #include <boost/filesystem.hpp> 28 #include <boost/range/adaptor/map.hpp> 29 #include <boost/range/algorithm/copy.hpp> 30 #include <boost/range/iterator_range.hpp> 38 namespace fs = boost::filesystem;
41 : m_certs(certContainer)
88 const boost::filesystem::path& path,
89 time::nanoseconds refreshPeriod,
bool isDir)
93 , m_refreshPeriod(refreshPeriod)
95 if (refreshPeriod <= time::nanoseconds::zero()) {
96 BOOST_THROW_EXCEPTION(std::runtime_error(
"Refresh period for the dynamic group must be positive"));
99 NDN_LOG_TRACE(
"Create dynamic trust anchor group " <<
id <<
" for file/dir " << path
100 <<
" with refresh time " << refreshPeriod);
115 auto loadCert = [
this, &oldAnchorNames] (
const fs::path& file) {
116 auto cert = io::load<Certificate>(file.string());
117 if (cert !=
nullptr) {
123 oldAnchorNames.erase(cert->getName());
132 if (fs::exists(m_path)) {
133 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.
The certificate following the certificate format naming convention.
virtual void refresh()
Request certificate refresh.
static time_point now() noexcept
virtual ~TrustAnchorGroup()
Catch-all error for security policy errors that don't fit in other categories.
#define NDN_LOG_INIT(name)
declare a log module
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.
void add(Certificate &&cert)
Load static anchor cert.
#define NDN_LOG_TRACE(expression)
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.