Backend instance of Identity. More...
#include <identity-impl.hpp>
Public Member Functions | |
IdentityImpl (const Name &identityName, shared_ptr< PibImpl > pibImpl, bool needInit=false) | |
Create an Identity with identityName . More... | |
const Name & | getName () const |
Get the name of the identity. More... | |
Key | addKey (const uint8_t *key, size_t keyLen, const Name &keyName) |
Add a key of keyLen bytes with keyName (in PKCS#8 format). More... | |
void | removeKey (const Name &keyName) |
Remove a key with keyName . More... | |
Key | getKey (const Name &keyName) const |
Get a key with id keyName . More... | |
const KeyContainer & | getKeys () const |
Get all keys for this Identity. More... | |
const Key & | setDefaultKey (const Name &keyName) |
Set the key with id keyName . More... | |
const Key & | setDefaultKey (const uint8_t *key, size_t keyLen, const Name &keyName) |
Add key of keyLen bytes with keyName and set it as the default key. More... | |
const Key & | getDefaultKey () const |
Get the default key for this Identity. More... | |
Backend instance of Identity.
An Identity has only one backend instance, but may have multiple frontend handles. Each frontend handle is associated with the only one backend IdentityImpl.
PibImpl::Error | when underlying implementation has non-semantic error. |
Definition at line 43 of file identity-impl.hpp.
ndn::security::pib::detail::IdentityImpl::IdentityImpl | ( | const Name & | identityName, |
shared_ptr< PibImpl > | pibImpl, | ||
bool | needInit = false |
||
) |
Create an Identity with identityName
.
identityName | The name of the Identity. |
pibImpl | The PIB backend implementation. |
needInit | If true, create the identity in backend when the identity does not exist. Otherwise, throw Pib::Error when the identity does not exist. |
Definition at line 31 of file identity-impl.cpp.
References ndn::Name::toUri().
|
inline |
Get the name of the identity.
Definition at line 60 of file identity-impl.hpp.
References addKey(), getDefaultKey(), getKey(), getKeys(), removeKey(), and setDefaultKey().
Key ndn::security::pib::detail::IdentityImpl::addKey | ( | const uint8_t * | key, |
size_t | keyLen, | ||
const Name & | keyName | ||
) |
Add a key
of keyLen
bytes with keyName
(in PKCS#8 format).
If no default key is set before, the new key will be set as the default key of the identity. If a key with the same name already exists, overwrite the key.
std::invalid_argument | key name does not match identity |
Definition at line 48 of file identity-impl.cpp.
References ndn::security::pib::KeyContainer::add(), and ndn::security::pib::KeyContainer::isConsistent().
Referenced by getName(), and setDefaultKey().
void ndn::security::pib::detail::IdentityImpl::removeKey | ( | const Name & | keyName | ) |
Remove a key with keyName
.
std::invalid_argument | keyName does not match identity |
Definition at line 55 of file identity-impl.cpp.
References ndn::security::pib::Key::getName(), ndn::security::pib::KeyContainer::isConsistent(), and ndn::security::pib::KeyContainer::remove().
Referenced by getName().
Get a key with id keyName
.
std::invalid_argument | keyName does not match identity |
Pib::Error | the key does not exist. |
Definition at line 66 of file identity-impl.cpp.
References ndn::security::pib::KeyContainer::get(), and ndn::security::pib::KeyContainer::isConsistent().
Referenced by getName().
const KeyContainer & ndn::security::pib::detail::IdentityImpl::getKeys | ( | ) | const |
Get all keys for this Identity.
Definition at line 73 of file identity-impl.cpp.
References ndn::security::pib::KeyContainer::isConsistent().
Referenced by getName().
Set the key with id keyName
.
std::invalid_argument | keyName does not match identity |
Pib::Error | the key does not exist. |
Definition at line 80 of file identity-impl.cpp.
References ndn::security::pib::KeyContainer::get(), and ndn::security::pib::KeyContainer::isConsistent().
Referenced by getName(), and setDefaultKey().
const Key & ndn::security::pib::detail::IdentityImpl::setDefaultKey | ( | const uint8_t * | key, |
size_t | keyLen, | ||
const Name & | keyName | ||
) |
Add key
of keyLen
bytes with keyName
and set it as the default key.
std::invalid_argument | keyName does not match identity |
Pib::Error | the key with the same name already exists |
Definition at line 91 of file identity-impl.cpp.
References addKey(), and setDefaultKey().
const Key & ndn::security::pib::detail::IdentityImpl::getDefaultKey | ( | ) | const |
Get the default key for this Identity.
Pib::Error | the default key does not exist. |
Definition at line 98 of file identity-impl.cpp.
References ndn::security::pib::KeyContainer::get(), ndn::security::pib::Key::getName(), and ndn::security::pib::KeyContainer::isConsistent().
Referenced by getName().