represents a container for trust anchors. More...
#include <trust-anchor-container.hpp>
Classes | |
class | Error |
Public Member Functions | |
void | insert (const std::string &groupId, Certificate &&cert) |
Insert a static trust anchor. More... | |
void | insert (const std::string &groupId, const boost::filesystem::path &path, time::nanoseconds refreshPeriod, bool isDir=false) |
Insert dynamic trust anchors from path. More... | |
void | clear () |
Remove all static or dynamic anchors. More... | |
const Certificate * | find (const Name &keyName) const |
Search for certificate across all groups (longest prefix match) More... | |
const Certificate * | find (const Interest &interest) const |
Find certificate given interest. More... | |
TrustAnchorGroup & | getGroup (const std::string &groupId) const |
Get trusted anchor group. More... | |
size_t | size () const |
Get number of trust anchors across all groups. More... | |
represents a container for trust anchors.
There are two kinds of anchors:
Trust anchors are organized in groups. Each group has a unique group id. The same anchor certificate (same name without considering the implicit digest) can be inserted into multiple groups, but no more than once into each.
Dynamic groups are created using the appropriate TrustAnchorContainer::insert method. Once created, the dynamic anchor group cannot be updated.
The returned pointer to Certificate from find
methods is only guaranteed to be valid until the next invocation of find
and may be invalidated afterwards.
Definition at line 55 of file trust-anchor-container.hpp.
void ndn::security::v2::TrustAnchorContainer::insert | ( | const std::string & | groupId, |
Certificate && | cert | ||
) |
Insert a static trust anchor.
groupId | Certificate group id. |
cert | Certificate to insert. |
If cert
(same name without considering implicit digest) already exists in the group groupId
, this method has no effect.
Error | groupId is a dynamic anchor group . |
Definition at line 47 of file trust-anchor-container.cpp.
References nonstd::optional_lite::std11::move(), and NDN_THROW.
Referenced by ndn::security::v2::CertificateStorage::loadAnchor().
void ndn::security::v2::TrustAnchorContainer::insert | ( | const std::string & | groupId, |
const boost::filesystem::path & | path, | ||
time::nanoseconds | refreshPeriod, | ||
bool | isDir = false |
||
) |
Insert dynamic trust anchors from path.
groupId | Certificate group id, must not be empty. |
path | Specifies the path to load the trust anchors. |
refreshPeriod | Refresh period for the trust anchors, must be positive. Relevant trust anchors will only be updated when find is called |
isDir | Tells whether the path is a directory or a single file. |
std::invalid_argument | refreshPeriod is not positive |
Error | a group with groupId already exists |
Definition at line 62 of file trust-anchor-container.cpp.
References NDN_THROW.
void ndn::security::v2::TrustAnchorContainer::clear | ( | ) |
Remove all static or dynamic anchors.
Definition at line 74 of file trust-anchor-container.cpp.
Referenced by ndn::security::v2::CertificateStorage::resetAnchors().
const Certificate * ndn::security::v2::TrustAnchorContainer::find | ( | const Name & | keyName | ) | const |
Search for certificate across all groups (longest prefix match)
keyName | Key name prefix for searching the certificate. |
find
methods. Definition at line 81 of file trust-anchor-container.cpp.
References ndn::Name::isPrefixOf().
Referenced by ndn::security::v2::CertificateStorage::findTrustedCert(), and ndn::security::v2::CertificateStorage::isCertKnown().
const Certificate * ndn::security::v2::TrustAnchorContainer::find | ( | const Interest & | interest | ) | const |
Find certificate given interest.
interest | The input interest packet. |
find
methods.Definition at line 93 of file trust-anchor-container.cpp.
References ndn::Interest::getName(), ndn::Name::isPrefixOf(), and ndn::Interest::matchesData().
TrustAnchorGroup & ndn::security::v2::TrustAnchorContainer::getGroup | ( | const std::string & | groupId | ) | const |
Get trusted anchor group.
Error | groupId does not exist |
Definition at line 108 of file trust-anchor-container.cpp.
References NDN_THROW.
size_t ndn::security::v2::TrustAnchorContainer::size | ( | ) | const |
Get number of trust anchors across all groups.
Definition at line 118 of file trust-anchor-container.cpp.