32 : m_hasDefaultKey(false)
33 , m_needRefreshKeys(false)
39 : m_name(identityName)
40 , m_hasDefaultKey(
false)
41 , m_needRefreshKeys(
true)
47 m_impl->addIdentity(m_name);
48 else if (!m_impl->hasIdentity(m_name))
49 BOOST_THROW_EXCEPTION(
Pib::Error(
"Identity: " + m_name.
toUri() +
" does not exist"));
71 if (!m_needRefreshKeys && m_keys.
find(actualKeyId) == m_keys.
end()) {
74 m_needRefreshKeys =
true;
77 return Key(m_name, actualKeyId, publicKey, m_impl);
86 m_hasDefaultKey =
false;
88 m_impl->removeKey(m_name, keyId);
89 m_needRefreshKeys =
true;
97 return Key(m_name, keyId, m_impl);
105 if (m_needRefreshKeys) {
106 m_keys =
KeyContainer(m_name, m_impl->getKeysOfIdentity(m_name), m_impl);
107 m_needRefreshKeys =
false;
118 m_defaultKey =
Key(m_name, keyId, m_impl);
119 m_hasDefaultKey =
true;
121 m_impl->setDefaultKeyOfIdentity(m_name, keyId);
128 const Key& keyEntry = addKey(publicKey, keyId);
137 if (!m_hasDefaultKey) {
138 m_defaultKey =
Key(m_name, m_impl->getDefaultKeyOfIdentity(m_name), m_impl);
139 m_hasDefaultKey =
true;
145 Identity::operator bool()
const 153 return (m_impl ==
nullptr);
159 if (m_impl ==
nullptr)
160 BOOST_THROW_EXCEPTION(std::domain_error(
"Invalid Identity instance"));
Key & getDefaultKey() const
Get the default key for this Identity.
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component & keyId
Copyright (c) 2011-2015 Regents of the University of California.
std::string toUri() const
Encode this name as a URI.
const name::Component & getKeyId() const
Get the key id of the key.
bool operator!() const
Check if the Identity instance is invalid.
const KeyContainer & getKeys() const
Get all the keys for this Identity.
const uint8_t * wire() const
Class representing a wire element of NDN-TLV packet format.
Key & setDefaultKey(const name::Component &keyId)
Set the key with id keyId as the default key.
represents a semantic error
A handler to search or enumerate keys of an identity.
const_iterator end() const
Identity()
Default Constructor.
void validityCheck() const
Check the validity of this instance.
const Name & getName() const
Get the name of the identity.
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE shared_ptr< PibImpl > impl
void removeKey(const name::Component &keyId)
Remove a key.
const Block & computeDigest() const
Name abstraction to represent an absolute name.
static const name::Component EMPTY_KEY_ID
The default value of keyId when add a new key.
const_iterator find(const name::Component &keyId) const
Component holds a read-only name component value.
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE shared_ptr< PibImpl > bool needInit
Key getKey(const name::Component &keyId) const
Get a key with id keyId.