24 #include <boost/filesystem.hpp> 31 TrustAnchorContainer::AnchorContainer::add(Certificate&& cert)
33 AnchorContainerBase::insert(std::move(cert));
37 TrustAnchorContainer::AnchorContainer::remove(
const Name& certName)
39 AnchorContainerBase::erase(certName);
43 TrustAnchorContainer::AnchorContainer::clear()
45 AnchorContainerBase::clear();
51 auto group = m_groups.find(groupId);
52 if (group == m_groups.end()) {
53 std::tie(group, std::ignore) = m_groups.insert(make_shared<StaticTrustAnchorGroup>(m_anchors, groupId));
55 auto* staticGroup = dynamic_cast<StaticTrustAnchorGroup*>(&**group);
56 if (staticGroup ==
nullptr) {
57 BOOST_THROW_EXCEPTION(
Error(
"Cannot add static anchor to a non-static anchor group " + groupId));
59 staticGroup->add(std::move(cert));
64 time::nanoseconds refreshPeriod,
bool isDir)
66 if (m_groups.count(groupId) != 0) {
67 BOOST_THROW_EXCEPTION(
Error(
"Cannot create dynamic group, because group " + groupId +
" already exists"));
70 m_groups.insert(make_shared<DynamicTrustAnchorGroup>(m_anchors, groupId, path, refreshPeriod, isDir));
83 const_cast<TrustAnchorContainer*>(
this)->refresh();
85 auto cert = m_anchors.lower_bound(keyName);
86 if (cert == m_anchors.end() || !keyName.
isPrefixOf(cert->getName()))
95 const_cast<TrustAnchorContainer*>(
this)->refresh();
97 for (
auto cert = m_anchors.lower_bound(interest.
getName());
110 auto group = m_groups.find(groupId);
111 if (group == m_groups.end()) {
112 BOOST_THROW_EXCEPTION(
Error(
"Trust anchor group " + groupId +
" does not exist"));
120 return m_anchors.size();
124 TrustAnchorContainer::refresh()
126 for (
auto it = m_groups.begin(); it != m_groups.end(); ++it) {
127 m_groups.modify(it, [] (
const auto& group) { group->refresh(); });
Copyright (c) 2011-2015 Regents of the University of California.
The certificate following the certificate format naming convention.
void insert(const std::string &groupId, Certificate &&cert)
Insert a static trust anchor.
bool isPrefixOf(const Name &other) const
Check if this name is a prefix of another name.
size_t size() const
Get number of trust anchors across all groups.
Represents an Interest packet.
A group of trust anchors.
const Certificate * find(const Name &keyName) const
Search for certificate across all groups (longest prefix match)
bool matchesData(const Data &data) const
Check if Interest can be satisfied by data.
Represents an absolute name.
TrustAnchorGroup & getGroup(const std::string &groupId) const
Get trusted anchor group.
void clear()
Remove all static or dynamic anchors.
const Name & getName() const