NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::security::pib::detail::IdentityImpl Class Reference

Backend instance of Identity. More...

#include <identity-impl.hpp>

Inheritance diagram for ndn::security::pib::detail::IdentityImpl:
Collaboration diagram for ndn::security::pib::detail::IdentityImpl:

Public Member Functions

 IdentityImpl (const Name &identityName, shared_ptr< PibImpl > pibImpl, bool needInit=false)
 Create an Identity with identityName. More...
 
const NamegetName () 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 KeyContainergetKeys () const
 Get all keys for this Identity. More...
 
const KeysetDefaultKey (const Name &keyName)
 Set the key with id keyName. More...
 
const KeysetDefaultKey (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 KeygetDefaultKey () const
 Get the default key for this Identity. More...
 

Detailed Description

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.

Exceptions
PibImpl::Errorwhen underlying implementation has non-semantic error.

Definition at line 43 of file identity-impl.hpp.

Constructor & Destructor Documentation

◆ IdentityImpl()

ndn::security::pib::detail::IdentityImpl::IdentityImpl ( const Name identityName,
shared_ptr< PibImpl pibImpl,
bool  needInit = false 
)

Create an Identity with identityName.

Parameters
identityNameThe name of the Identity.
pibImplThe PIB backend implementation.
needInitIf 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().

Member Function Documentation

◆ getName()

const Name& ndn::security::pib::detail::IdentityImpl::getName ( ) const
inline

Get the name of the identity.

Definition at line 60 of file identity-impl.hpp.

◆ addKey()

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.

Returns
the added key.
Exceptions
std::invalid_argumentkey 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 setDefaultKey().

◆ removeKey()

void ndn::security::pib::detail::IdentityImpl::removeKey ( const Name keyName)

Remove a key with keyName.

Exceptions
std::invalid_argumentkeyName 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().

◆ getKey()

Key ndn::security::pib::detail::IdentityImpl::getKey ( const Name keyName) const

Get a key with id keyName.

Exceptions
std::invalid_argumentkeyName does not match identity
Pib::Errorthe 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().

◆ getKeys()

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().

◆ setDefaultKey() [1/2]

const Key & ndn::security::pib::detail::IdentityImpl::setDefaultKey ( const Name keyName)

Set the key with id keyName.

Exceptions
std::invalid_argumentkeyName does not match identity
Pib::Errorthe key does not exist.
Returns
The default key

Definition at line 80 of file identity-impl.cpp.

References ndn::security::pib::KeyContainer::get(), and ndn::security::pib::KeyContainer::isConsistent().

Referenced by setDefaultKey().

◆ setDefaultKey() [2/2]

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.

Exceptions
std::invalid_argumentkeyName does not match identity
Pib::Errorthe key with the same name already exists
Returns
the default key

Definition at line 91 of file identity-impl.cpp.

References addKey(), and setDefaultKey().

◆ getDefaultKey()

const Key & ndn::security::pib::detail::IdentityImpl::getDefaultKey ( ) const

Get the default key for this Identity.

Exceptions
Pib::Errorthe 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().


The documentation for this class was generated from the following files: