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>
38 namespace fs = boost::filesystem;
41 : m_certs(certContainer)
88 const boost::filesystem::path& path,
93 , m_refreshPeriod(refreshPeriod)
95 if (refreshPeriod <= time::nanoseconds::zero()) {
96 NDN_THROW(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());
131 else if (fs::exists(m_path)) {
132 std::for_each(fs::directory_iterator(m_path), fs::directory_iterator(), loadCert);
136 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.
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 refresh() override
Request certificate refresh.
void add(Certificate &&cert)
Load static anchor cert.
void remove(const Name &certName)
Remove static anchor certName.
StaticTrustAnchorGroup(CertContainerInterface &certContainer, const std::string &id)
Create a static trust anchor group.
A group of trust anchors.
TrustAnchorGroup(CertContainerInterface &certContainer, const std::string &id)
Create an anchor group.
virtual ~TrustAnchorGroup()
CertContainerInterface & m_certs
std::set< Name > m_anchorNames
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.
Contains the ndn-cxx security framework.
::boost::chrono::nanoseconds nanoseconds