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

A frontend handle of an Identity. More...

#include <identity.hpp>

Collaboration diagram for ndn::security::pib::Identity:

Public Member Functions

 Identity ()
 Default Constructor. More...
 
 Identity (weak_ptr< detail::IdentityImpl > impl)
 Create an Identity with a backend implementation impl. More...
 
const NamegetName () const
 Get the name of the identity. 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 KeygetDefaultKey () const
 Get the default key for this Identity. More...
 
 operator bool () const
 
void removeKey (const Name &keyName) const
 Remove a key with keyName. More...
 
const KeysetDefaultKey (const Name &keyName) const
 Set an existing key with name keyName as the default key. More...
 
const KeysetDefaultKey (span< const uint8_t > key, const Name &keyName) const
 Add key with name keyName and set it as the default key. More...
 

Public Attributes

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE __pad0__: Key addKey(span<const uint8_t> key
 
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const Name &keyName const
 

Friends

bool operator!= (const Identity &, const Identity &)
 

Detailed Description

A frontend handle of an Identity.

Identity is at the top level in PIB's Identity-Key-Certificate hierarchy. An identity has a Name, and contains zero or more keys, at most one of which is set as the default key of this identity. Properties of a key can be accessed after obtaining a Key object.

Definition at line 47 of file identity.hpp.

Constructor & Destructor Documentation

◆ Identity() [1/2]

ndn::security::pib::Identity::Identity ( )
default

Default Constructor.

Identity created using this default constructor is just a place holder. It can obtain an actual instance from Pib::getIdentity(...). A typical usage would be for exception handling:

Identity id; try { id = pib.getIdentity(...); } catch (const Pib::Error&) { ... }

An Identity instance created using this constructor is invalid. Calling a member method on an invalid Identity instance may cause an std::domain_error.

◆ Identity() [2/2]

ndn::security::pib::Identity::Identity ( weak_ptr< detail::IdentityImpl impl)
explicit

Create an Identity with a backend implementation impl.

This method should only be used by IdentityContainer.

Definition at line 31 of file identity.cpp.

Member Function Documentation

◆ getName()

◆ getKey()

Key ndn::security::pib::Identity::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 55 of file identity.cpp.

Referenced by ndn::security::v2::KeyChain::importSafeBag().

◆ getKeys()

const KeyContainer & ndn::security::pib::Identity::getKeys ( ) const

Get all keys for this identity.

Definition at line 61 of file identity.cpp.

Referenced by ndn::security::v2::KeyChain::deleteIdentity().

◆ getDefaultKey()

const Key & ndn::security::pib::Identity::getDefaultKey ( ) const

Get the default key for this Identity.

Exceptions
Pib::Errorthe default key does not exist.

Definition at line 79 of file identity.cpp.

Referenced by ndn::security::v2::parseLocatorUri().

◆ operator bool()

ndn::security::pib::Identity::operator bool ( ) const
explicit
Returns
True if the identity instance is valid

Definition at line 84 of file identity.cpp.

References NDN_THROW.

◆ removeKey()

void ndn::security::pib::Identity::removeKey ( const Name keyName) const

Remove a key with keyName.

Exceptions
std::invalid_argumentkeyName does not match identity

Definition at line 49 of file identity.cpp.

Referenced by ndn::security::v2::KeyChain::deleteKey().

◆ setDefaultKey() [1/2]

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

Set an existing key with name keyName as the default key.

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

Definition at line 67 of file identity.cpp.

Referenced by ndn::security::v2::KeyChain::setDefaultKey().

◆ setDefaultKey() [2/2]

const Key & ndn::security::pib::Identity::setDefaultKey ( span< const uint8_t >  key,
const Name keyName 
) const

Add key with name keyName and set it as the default key.

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

Definition at line 73 of file identity.cpp.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const Identity ,
const Identity  
)
friend

Definition at line 101 of file identity.cpp.

Member Data Documentation

◆ __pad0__

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::security::pib::Identity::__pad0__

Definition at line 120 of file identity.hpp.

◆ const

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const Name& keyName ndn::security::pib::Identity::const

Definition at line 120 of file identity.hpp.


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