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);
45 auto group = m_groups.find(groupId);
46 if (group == m_groups.end()) {
47 std::tie(group, std::ignore) = m_groups.insert(make_shared<StaticTrustAnchorGroup>(m_anchors, groupId));
50 if (staticGroup ==
nullptr) {
51 BOOST_THROW_EXCEPTION(
Error(
"Cannot add static anchor to a non-static anchor group " + groupId));
53 staticGroup->add(std::move(cert));
58 time::nanoseconds refreshPeriod,
bool isDir)
60 if (m_groups.count(groupId) != 0) {
61 BOOST_THROW_EXCEPTION(
Error(
"Cannot create dynamic group, because group " + groupId +
" already exists"));
64 m_groups.insert(make_shared<DynamicTrustAnchorGroup>(m_anchors, groupId, path, refreshPeriod, isDir));
72 auto cert = m_anchors.lower_bound(keyName);
73 if (cert == m_anchors.end() || !keyName.
isPrefixOf(cert->getName()))
83 for (
auto cert = m_anchors.lower_bound(interest.
getName());
96 auto group = m_groups.find(groupId);
97 if (group == m_groups.end()) {
98 BOOST_THROW_EXCEPTION(
Error(
"Trust anchor group " + groupId +
" does not exist"));
106 return m_anchors.size();
110 TrustAnchorContainer::refresh()
112 for (
auto it = m_groups.begin(); it != m_groups.end(); ++it) {
113 m_groups.modify(it, [] (shared_ptr<TrustAnchorGroup>& group) { group->refresh(); });
const Name & getName() const
Copyright (c) 2013-2016 Regents of the University of California.
The certificate following the certificate format naming convention.
const Certificate * find(const Name &keyName) const
Search for certificate across all groups (longest prefix match)
size_t size() const
Get number of trust anchors across all groups.
void insert(const std::string &groupId, Certificate &&cert)
Insert a static trust anchor.
represents an Interest packet
TrustAnchorGroup & getGroup(const std::string &groupId) const
Get trusted anchor group.
represents a container for trust anchors.
A group of trust anchors.
Static trust anchor group.
Name abstraction to represent an absolute name.
bool matchesData(const Data &data) const
Check if Interest can be satisfied by data.
bool isPrefixOf(const Name &name) const
Check if the N components of this name are the same as the first N components of the given name...