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) {
Represents an absolute name.
virtual void remove(const Name &certName)=0
virtual void add(Certificate &&cert)=0
Represents an NDN certificate following the version 2.0 format.
void refresh() override
Request certificate refresh.
DynamicTrustAnchorGroup(CertContainerInterface &certContainer, const std::string &id, const boost::filesystem::path &path, time::nanoseconds refreshPeriod, bool isDir=false)
Create a dynamic trust anchor group.
void add(Certificate &&cert)
Load static anchor cert.
StaticTrustAnchorGroup(CertContainerInterface &certContainer, const std::string &id)
Create a static trust anchor group.
void remove(const Name &certName)
Remove static anchor certName.
A group of trust anchors.
std::set< Name > m_anchorNames
TrustAnchorGroup(CertContainerInterface &certContainer, const std::string &id)
Create an anchor group.
CertContainerInterface & m_certs
virtual ~TrustAnchorGroup()
virtual void refresh()
Request certificate refresh.
static time_point now() noexcept
#define NDN_LOG_TRACE(expression)
Log at TRACE level.
#define NDN_LOG_INIT(name)
Define a non-member log module.
boost::chrono::nanoseconds nanoseconds