23 #include "../pib-impl.hpp" 25 #include "../../transform/public-key.hpp" 36 , m_pib(
std::move(pibImpl))
37 , m_certificates(keyName, m_pib)
38 , m_isDefaultCertificateLoaded(false)
40 BOOST_ASSERT(m_pib !=
nullptr);
47 BOOST_THROW_EXCEPTION(std::invalid_argument(
"Invalid key bits"));
51 m_pib->addKey(m_identity, m_keyName, key, keyLen);
57 , m_pib(
std::move(pibImpl))
58 , m_certificates(keyName, m_pib)
59 , m_isDefaultCertificateLoaded(false)
61 BOOST_ASSERT(m_pib !=
nullptr);
63 m_key = m_pib->getKeyBits(m_keyName);
66 key.
loadPkcs8(m_key.data(), m_key.size());
74 m_certificates.
add(certificate);
82 if (m_isDefaultCertificateLoaded && m_defaultCertificate.
getName() == certName)
83 m_isDefaultCertificateLoaded =
false;
85 m_certificates.
remove(certName);
92 return m_certificates.
get(certName);
99 return m_certificates;
107 m_defaultCertificate = m_certificates.
get(certName);
108 m_pib->setDefaultCertificateOfKey(m_keyName, certName);
109 m_isDefaultCertificateLoaded =
true;
110 return m_defaultCertificate;
125 if (!m_isDefaultCertificateLoaded) {
126 m_defaultCertificate = m_pib->getDefaultCertificateOfKey(m_keyName);
127 m_isDefaultCertificateLoaded =
true;
129 BOOST_ASSERT(m_pib->getDefaultCertificateOfKey(m_keyName).wireEncode() == m_defaultCertificate.
wireEncode());
131 return m_defaultCertificate;
Copyright (c) 2011-2015 Regents of the University of California.
The certificate following the certificate format naming convention.
void remove(const Name &certName)
Remove a certificate with certName from the container.
const v2::Certificate & setDefaultCertificate(const Name &certName)
Set an existing certificate with name certName as the default certificate.
Catch-all error for security policy errors that don't fit in other categories.
const CertificateContainer & getCertificates() const
Get all the certificates for this key.
size_t wireEncode(EncodingImpl< TAG > &encoder, bool wantUnsignedPortionOnly=false) const
Fast encoding or block size estimation.
Container of certificates of a key.
bool isConsistent() const
Check if the container is consistent with the backend storage.
Represents an absolute name.
void removeCertificate(const Name &certName)
Remove a certificate with certName.
const Name & getName() const
Get name.
void add(const v2::Certificate &certificate)
Add certificate into the container.
v2::Certificate getCertificate(const Name &certName) const
Get a certificate with certName.
v2::Certificate get(const Name &certName) const
Get a certificate with certName from the container.
Name extractIdentityFromKeyName(const Name &keyName)
Extract identity namespace from the key name keyName.
void addCertificate(const v2::Certificate &certificate)
Add certificate.
KeyImpl(const Name &keyName, const uint8_t *key, size_t keyLen, shared_ptr< PibImpl > pibImpl)
Create a KeyImpl with keyName.
const v2::Certificate & getDefaultCertificate() const
Get the default certificate for this key.