31 CertificateContainer::const_iterator::equals(
const const_iterator& other)
const noexcept
33 bool isThisEnd = m_container ==
nullptr || m_it == m_container->m_certNames.end();
34 bool isOtherEnd = other.m_container ==
nullptr || other.m_it == other.m_container->m_certNames.end();
37 return !isOtherEnd && m_container->m_pib == other.m_container->m_pib && m_it == other.m_it;
40 CertificateContainer::CertificateContainer(
const Name& keyName, shared_ptr<PibImpl> pibImpl)
42 , m_pib(std::move(pibImpl))
44 BOOST_ASSERT(m_pib !=
nullptr);
45 m_certNames = m_pib->getCertificatesOfKey(keyName);
48 CertificateContainer::const_iterator
49 CertificateContainer::find(
const Name& certName)
const
51 return {m_certNames.find(certName), *
this};
59 "does not match key `" + m_keyName.toUri() +
"`"));
63 bool isNew = m_certNames.insert(certName).second;
64 NDN_LOG_DEBUG((isNew ?
"Adding " :
"Replacing ") << certName);
66 m_pib->addCertificate(certificate);
67 m_certs[certName] = certificate;
71 CertificateContainer::remove(
const Name& certName)
74 NDN_THROW(std::invalid_argument(
"Certificate name `" + certName.
toUri() +
"` "
75 "does not match key `" + m_keyName.toUri() +
"`"));
78 if (m_certNames.erase(certName) > 0) {
80 m_certs.erase(certName);
84 BOOST_ASSERT(m_certs.find(certName) == m_certs.end());
86 m_pib->removeCertificate(certName);
90 CertificateContainer::get(
const Name& certName)
const
93 NDN_THROW(std::invalid_argument(
"Certificate name `" + certName.
toUri() +
"` "
94 "does not match key `" + m_keyName.toUri() +
"`"));
97 if (
auto it = m_certs.find(certName); it != m_certs.end()) {
101 auto ret = m_certs.emplace(certName, m_pib->getCertificate(certName));
102 return ret.first->second;
106 CertificateContainer::isConsistent()
const
108 return m_certNames == m_pib->getCertificatesOfKey(m_keyName);
const Name & getName() const noexcept
Get the Data name.
Represents an absolute name.
void toUri(std::ostream &os, name::UriFormat format=name::UriFormat::DEFAULT) const
Write URI representation of the name to the output stream.
Represents an NDN certificate.
Name getKeyName() const
Get key name.
#define NDN_LOG_DEBUG(expression)
Log at DEBUG level.
#define NDN_LOG_INIT(name)
Define a non-member log module.
Contains the ndn-cxx security framework.
Name extractKeyNameFromCertName(const Name &certName)
Extract key name from the certificate name certName.