represents an identity More...
#include <identity.hpp>
Public Member Functions | |
Identity () | |
Default Constructor. More... | |
const Name & | getName () const |
Get the name of the identity. More... | |
Key | getKey (const name::Component &keyId) const |
Get a key with id keyId . More... | |
const KeyContainer & | getKeys () const |
Get all the keys for this Identity. More... | |
Key & | getDefaultKey () const |
Get the default key for this Identity. More... | |
operator bool () const | |
Check if the Identity instance is valid. More... | |
bool | operator! () const |
Check if the Identity instance is invalid. More... | |
void | removeKey (const name::Component &keyId) |
Remove a key. More... | |
Key & | setDefaultKey (const name::Component &keyId) |
Set the key with id keyId as the default key. More... | |
Key & | setDefaultKey (const v1::PublicKey &publicKey, const name::Component &keyId=EMPTY_KEY_ID) |
Set the default key. More... | |
void | validityCheck () const |
Check the validity of this instance. More... | |
Public Attributes | |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE | __pad0__: Key addKey(const v1::PublicKey& publicKey |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component & | keyId = EMPTY_KEY_ID) |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE | __pad1__: Identity(const Name& identityName |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE shared_ptr< PibImpl > | impl |
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE shared_ptr< PibImpl > bool | needInit = false) |
Static Public Attributes | |
static const name::Component | EMPTY_KEY_ID |
The default value of keyId when add a new key. More... | |
Friends | |
class | Pib |
class | IdentityContainer |
class | KeyChain |
represents an identity
Identity is at the top level in PIB's Identity-Key-Certificate hierarchy. An identity has a Name, and contains one or more keys, one of which is set as the default key of this identity. Properties of a key can be accessed after obtaining a Key object.
PibImpl::Error | when underlying implementation has non-semantic error. |
Definition at line 44 of file identity.hpp.
ndn::security::Identity::Identity | ( | ) |
Default Constructor.
Identity created using this default constructor is just a place holder. It must obtain an actual instance from Pib::getIdentity(...). A typical usage would be for exception handling:
Identity id; try { id = pib.getIdentity(...); } catch (Pib::Error&) { ... }
An Identity instance created using the constructor is invalid. Calling a member method on an invalid Identity instance may cause an std::domain_error.
Definition at line 31 of file identity.cpp.
References impl, needInit, ndn::Name::toUri(), and validityCheck().
const Name & ndn::security::Identity::getName | ( | ) | const |
Get the name of the identity.
Definition at line 53 of file identity.cpp.
References ndn::security::v1::PublicKey::computeDigest(), EMPTY_KEY_ID, ndn::security::KeyContainer::end(), ndn::security::KeyContainer::find(), keyId, ndn::Block::size(), validityCheck(), and ndn::Block::wire().
Key ndn::security::Identity::getKey | ( | const name::Component & | keyId | ) | const |
Get a key with id keyId
.
keyId | The id of the key to get. |
Pib::Error | if the key does not exist. |
Definition at line 93 of file identity.cpp.
References validityCheck().
const KeyContainer & ndn::security::Identity::getKeys | ( | ) | const |
Get all the keys for this Identity.
Definition at line 101 of file identity.cpp.
References validityCheck().
Key & ndn::security::Identity::getDefaultKey | ( | ) | const |
Get the default key for this Identity.
Pib::Error | if the default key does not exist. |
Definition at line 133 of file identity.cpp.
References validityCheck().
ndn::security::Identity::operator bool | ( | ) | const |
Check if the Identity instance is valid.
Definition at line 145 of file identity.cpp.
References operator!().
bool ndn::security::Identity::operator! | ( | ) | const |
Check if the Identity instance is invalid.
Definition at line 151 of file identity.cpp.
Referenced by operator bool().
void ndn::security::Identity::removeKey | ( | const name::Component & | keyId | ) |
Remove a key.
keyId | The key id component of the key to delete. |
Definition at line 81 of file identity.cpp.
References ndn::security::Key::getKeyId(), keyId, and validityCheck().
Key & ndn::security::Identity::setDefaultKey | ( | const name::Component & | keyId | ) |
Set the key with id keyId
as the default key.
keyId | The key id component of the default key. |
Pib::Error | if the key does not exist. |
Definition at line 114 of file identity.cpp.
References validityCheck().
Referenced by setDefaultKey().
Key & ndn::security::Identity::setDefaultKey | ( | const v1::PublicKey & | publicKey, |
const name::Component & | keyId = EMPTY_KEY_ID |
||
) |
Set the default key.
If the key does not exist, add the key and set it as the default of the Identity. If the key exists, simply set it as the default key of the Identity.
publicKey | The public key to add. |
keyId | The key id component of the default key. |
Definition at line 126 of file identity.cpp.
References ndn::security::Key::getKeyId(), and setDefaultKey().
void ndn::security::Identity::validityCheck | ( | ) | const |
Check the validity of this instance.
std::domain_error | if the instance is invalid |
Definition at line 157 of file identity.cpp.
Referenced by getDefaultKey(), getKey(), getKeys(), getName(), Identity(), removeKey(), and setDefaultKey().
|
friend |
Definition at line 47 of file identity.hpp.
|
friend |
Definition at line 48 of file identity.hpp.
|
friend |
Definition at line 49 of file identity.hpp.
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::security::Identity::__pad0__ |
Definition at line 119 of file identity.hpp.
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component& ndn::security::Identity::keyId = EMPTY_KEY_ID) |
Definition at line 119 of file identity.hpp.
Referenced by getName(), and removeKey().
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::security::Identity::__pad1__ |
Definition at line 161 of file identity.hpp.
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE shared_ptr<PibImpl> ndn::security::Identity::impl |
Definition at line 161 of file identity.hpp.
Referenced by Identity().
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE shared_ptr<PibImpl> bool ndn::security::Identity::needInit = false) |
Definition at line 161 of file identity.hpp.
Referenced by Identity().
|
static |
The default value of keyId when add a new key.
An empty keyId implies that the key digest should be used as the actual keyId.
Definition at line 177 of file identity.hpp.
Referenced by getName().