23 #include "../pib-impl.hpp" 32 : m_name(identityName)
33 , m_pib(
std::move(pibImpl))
34 , m_keys(identityName, m_pib)
35 , m_isDefaultKeyLoaded(false)
37 BOOST_ASSERT(m_pib !=
nullptr);
40 m_pib->addIdentity(m_name);
42 else if (!m_pib->hasIdentity(m_name)) {
43 BOOST_THROW_EXCEPTION(
Pib::Error(
"Identity " + m_name.
toUri() +
" does not exist"));
51 return m_keys.
add(key, keyLen, keyName);
59 if (m_isDefaultKeyLoaded && m_defaultKey.
getName() == keyName)
60 m_isDefaultKeyLoaded =
false;
69 return m_keys.
get(keyName);
84 m_defaultKey = m_keys.
get(keyName);
85 m_isDefaultKeyLoaded =
true;
86 m_pib->setDefaultKeyOfIdentity(m_name, keyName);
93 addKey(key, keyLen, keyName);
102 if (!m_isDefaultKeyLoaded) {
103 m_defaultKey = m_keys.
get(m_pib->getDefaultKeyOfIdentity(m_name));
104 m_isDefaultKeyLoaded =
true;
106 BOOST_ASSERT(m_pib->getDefaultKeyOfIdentity(m_name) == m_defaultKey.
getName());
const Name & getName() const
Get key name.
Copyright (c) 2011-2015 Regents of the University of California.
represents a semantic error
void remove(const Name &keyName)
Remove a key with keyName from the container.
bool isConsistent() const
Check if the container is consistent with the backend storage.
const KeyContainer & getKeys() const
Get all keys for this Identity.
const Key & setDefaultKey(const Name &keyName)
Set the key with id keyName.
Catch-all error for security policy errors that don't fit in other categories.
std::string toUri() const
Get URI representation of the name.
Key getKey(const Name &keyName) const
Get a key with id keyName.
Container of keys of an identity.
A frontend handle of a key instance.
IdentityImpl(const Name &identityName, shared_ptr< PibImpl > pibImpl, bool needInit=false)
Create an Identity with identityName.
Key add(const uint8_t *key, size_t keyLen, const Name &keyName)
Add key of keyLen bytes with keyName into the container.
Represents an absolute name.
Key get(const Name &keyName) const
Get a key with keyName from the container.
void removeKey(const Name &keyName)
Remove a key with keyName.
Key addKey(const uint8_t *key, size_t keyLen, const Name &keyName)
Add a key of keyLen bytes with keyName (in PKCS#8 format).
const Key & getDefaultKey() const
Get the default key for this Identity.