30 : m_hasDefaultCertificate(false)
31 , m_needRefreshCerts(false)
41 , m_hasDefaultCertificate(
false)
42 , m_needRefreshCerts(
true)
50 m_impl->addIdentity(m_id);
51 m_impl->addKey(m_id, m_keyId, publicKey);
55 shared_ptr<PibImpl> impl)
58 , m_hasDefaultCertificate(false)
59 , m_needRefreshCerts(true)
67 m_key = m_impl->getKeyBits(m_id, m_keyId);
107 if (!m_needRefreshCerts &&
108 m_certificates.
find(certificate.
getName()) == m_certificates.
end()) {
111 m_needRefreshCerts =
true;
114 m_impl->addCertificate(certificate);
122 if (m_hasDefaultCertificate && m_defaultCertificate.
getName() == certName)
123 m_hasDefaultCertificate =
false;
125 m_impl->removeCertificate(certName);
126 m_needRefreshCerts =
true;
134 return m_impl->getCertificate(certName);
142 if (m_needRefreshCerts) {
144 m_needRefreshCerts =
false;
147 return m_certificates;
155 m_defaultCertificate = m_impl->getCertificate(certName);
156 m_impl->setDefaultCertificateOfKey(m_id, m_keyId, certName);
157 m_hasDefaultCertificate =
true;
158 return m_defaultCertificate;
164 addCertificate(certificate);
173 if (!m_hasDefaultCertificate) {
174 m_defaultCertificate = m_impl->getDefaultCertificateOfKey(m_id, m_keyId);
175 m_hasDefaultCertificate =
true;
178 return m_defaultCertificate;
181 Key::operator bool()
const 189 return (m_impl ==
nullptr);
195 if (m_impl ==
nullptr)
196 BOOST_THROW_EXCEPTION(std::domain_error(
"Invalid Key instance"));
const v1::IdentityCertificate & setDefaultCertificate(const Name &certName)
Set the default certificate.
Copyright (c) 2011-2015 Regents of the University of California.
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component const v1::PublicKey & publicKey
void validityCheck() const
Check the validity of this instance.
const name::Component & getKeyId() const
Get the key id of the key.
const Name & getName() const
Get name of the Data packet.
const_iterator end() const
bool operator!() const
Check if the Key instance is invalid.
A handler to search or enumerate certificates of a key.
Key()
Default Constructor.
const Name & getIdentity() const
Get the name of the belonging identity.
const CertificateContainer & getCertificates() const
Get all the certificates for this key.
const v1::PublicKey & getPublicKey() const
Get public key.
const Name & getName() const
Get the name of the key.
v1::IdentityCertificate getCertificate(const Name &certName) const
Get a certificate.
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component const v1::PublicKey shared_ptr< PibImpl > impl
Name abstraction to represent an absolute name.
const v1::IdentityCertificate & getDefaultCertificate() const
Get the default certificate for this Key.
Component holds a read-only name component value.
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component & keyId
Name & append(const uint8_t *value, size_t valueLength)
Append a new component, copying from value of length valueLength.
const_iterator find(const Name &certName) const
void removeCertificate(const Name &certName)
Remove a certificate.