36 const CertificateContainer& container) noexcept
38 , m_container(&container)
45 BOOST_ASSERT(m_container !=
nullptr);
46 return m_container->
get(*m_it);
52 bool isThisEnd = m_container ==
nullptr || m_it == m_container->m_certNames.end();
53 bool isOtherEnd = other.m_container ==
nullptr || other.m_it == other.m_container->m_certNames.end();
56 return !isOtherEnd && m_container->m_pib == other.m_container->m_pib && m_it == other.m_it;
59 CertificateContainer::CertificateContainer(
const Name& keyName, shared_ptr<PibImpl> pibImpl)
61 , m_pib(std::move(pibImpl))
63 BOOST_ASSERT(m_pib !=
nullptr);
64 m_certNames = m_pib->getCertificatesOfKey(keyName);
70 return {m_certNames.find(certName), *
this};
78 "does not match key `" + m_keyName.
toUri() +
"`"));
82 bool isNew = m_certNames.insert(certName).second;
83 NDN_LOG_DEBUG((isNew ?
"Adding " :
"Replacing ") << certName);
85 m_pib->addCertificate(certificate);
86 m_certs[certName] = certificate;
93 NDN_THROW(std::invalid_argument(
"Certificate name `" + certName.
toUri() +
"` "
94 "does not match key `" + m_keyName.
toUri() +
"`"));
97 if (m_certNames.erase(certName) > 0) {
99 m_certs.erase(certName);
103 BOOST_ASSERT(m_certs.find(certName) == m_certs.end());
105 m_pib->removeCertificate(certName);
112 NDN_THROW(std::invalid_argument(
"Certificate name `" + certName.
toUri() +
"` "
113 "does not match key `" + m_keyName.
toUri() +
"`"));
116 auto it = m_certs.find(certName);
117 if (it != m_certs.end()) {
121 auto ret = m_certs.emplace(certName, m_pib->getCertificate(certName));
122 return ret.first->second;
128 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.
bool operator==(const const_iterator &other) const
const_iterator find(const Name &certName) const
Certificate get(const Name &certName) const
Return a certificate by name.
void remove(const Name &certName)
Remove a certificate with certName from the container.
bool isConsistent() const
Check if the container is consistent with the backend storage.
void add(const Certificate &certificate)
Add certificate into the container.
Represents an NDN certificate.
Name getKeyName() const
Get key name.
#define NDN_CXX_ASSERT_FORWARD_ITERATOR(T)
Assert T is a forward iterator.
#define NDN_LOG_DEBUG(expression)
Log at DEBUG level.
#define NDN_LOG_INIT(name)
Define a non-member log module.
Name extractKeyNameFromCertName(const Name &certName)
Extract key name from the certificate name certName.