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());
Copyright (c) 2011-2015 Regents of the University of California.
std::string toUri() const
Get URI representation of the name.
represents a semantic error
void remove(const Name &keyName)
Remove a key with keyName from the container.
const Key & setDefaultKey(const Name &keyName)
Set the key with id keyName.
const KeyContainer & getKeys() const
Get all keys for this Identity.
Container of keys of an identity.
A frontend handle of a key instance.
Key get(const Name &keyName) const
Get a key with keyName from the container.
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.
bool isConsistent() const
Check if the container is consistent with the backend storage.
Represents an absolute name.
const Name & getName() const
Get key name.
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).
Key getKey(const Name &keyName) const
Get a key with id keyName.
const Key & getDefaultKey() const
Get the default key for this Identity.