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);
81 Identity::removeKey(
const name::Component& keyId)
85 if (m_hasDefaultKey && m_defaultKey.
getKeyId() == keyId)
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);
126 Identity::setDefaultKey(
const v1::PublicKey& publicKey,
const name::Component& keyId)
128 const Key& keyEntry = addKey(publicKey, keyId);
129 return setDefaultKey(keyEntry.getKeyId());
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
147 return !(this->operator!());
153 return (m_impl ==
nullptr);
157 Identity::validityCheck()
const
159 if (m_impl ==
nullptr)
160 BOOST_THROW_EXCEPTION(std::domain_error(
"Invalid Identity instance"));
Copyright (c) 2013-2016 Regents of the University of California.
const KeyContainer & getKeys() const
Get all the keys for this Identity.
bool operator!() const
Check if the Identity instance is invalid.
const Block & computeDigest() const
Class representing a wire element of NDN-TLV packet format.
const_iterator end() const
const Name & getName() const
Get the name of the identity.
represents a semantic error
A handler to search or enumerate keys of an identity.
std::string toUri() const
Encode this name as a URI.
Identity()
Default Constructor.
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.
const uint8_t * wire() const
Key getKey(const name::Component &keyId) const
Get a key with id keyId.
const name::Component & getKeyId() const
Get the key id of the key.
Key & getDefaultKey() const
Get the default key for this Identity.