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

represents an identity More...

#include <identity.hpp>

Collaboration diagram for ndn::security::Identity:

Public Member Functions

 Identity ()
 Default Constructor. More...
 
const NamegetName () const
 Get the name of the identity. More...
 
Key getKey (const name::Component &keyId) const
 Get a key with id . More...
 
const KeyContainergetKeys () const
 Get all the keys for this Identity. More...
 
KeygetDefaultKey () 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...
 
KeysetDefaultKey (const name::Component &keyId)
 Set the key with id keyId as the default key. More...
 
KeysetDefaultKey (const 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 PublicKey& publicKey
 
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::ComponentkeyId = EMPTY_KEY_ID)
 
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE __pad1__: Identity(const Name& identityName
 
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE shared_ptr< PibImplimpl
 
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
 

Detailed Description

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.

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

Definition at line 44 of file identity.hpp.

Constructor & Destructor Documentation

◆ Identity()

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.

Member Function Documentation

◆ getName()

const Name & ndn::security::Identity::getName ( ) const

Get the name of the identity.

Definition at line 53 of file identity.cpp.

References validityCheck().

Referenced by ndn::security::Pib::removeIdentity().

◆ getKey()

Key ndn::security::Identity::getKey ( const name::Component keyId) const

Get a key with id .

Parameters
identityNameThe name for the identity to get.
Exceptions
Pib::Errorif the identity does not exist.

Definition at line 93 of file identity.cpp.

References keyId, and validityCheck().

◆ getKeys()

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

Get all the keys for this Identity.

Definition at line 101 of file identity.cpp.

References validityCheck().

◆ getDefaultKey()

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

Get the default key for this Identity.

Exceptions
Pib::Errorif the default key does not exist.

Definition at line 133 of file identity.cpp.

References validityCheck().

◆ operator bool()

ndn::security::Identity::operator bool ( ) const

Check if the Identity instance is valid.

Definition at line 145 of file identity.cpp.

◆ operator!()

bool ndn::security::Identity::operator! ( ) const

Check if the Identity instance is invalid.

Definition at line 151 of file identity.cpp.

◆ removeKey()

void ndn::security::Identity::removeKey ( const name::Component keyId)

Remove a key.

Parameters
keyIdThe key id component of the key to delete.

Definition at line 81 of file identity.cpp.

References ndn::security::Key::getKeyId(), keyId, and validityCheck().

◆ setDefaultKey() [1/2]

Key & ndn::security::Identity::setDefaultKey ( const name::Component keyId)

Set the key with id keyId as the default key.

Parameters
keyIdThe key id component of the default key.
Returns
The default key
Exceptions
Pib::Errorif the key does not exist.

Definition at line 114 of file identity.cpp.

References keyId, and validityCheck().

Referenced by setDefaultKey().

◆ setDefaultKey() [2/2]

Key & ndn::security::Identity::setDefaultKey ( const 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.

Parameters
publicKeyThe public key to add.
keyIdThe key id component of the default key.
Returns
the default key

Definition at line 126 of file identity.cpp.

References ndn::security::Key::getKeyId(), keyId, and setDefaultKey().

◆ validityCheck()

void ndn::security::Identity::validityCheck ( ) const

Check the validity of this instance.

Exceptions
std::domain_errorif the instance is invalid

Definition at line 157 of file identity.cpp.

Referenced by getDefaultKey(), getKey(), getKeys(), getName(), removeKey(), and setDefaultKey().

Friends And Related Function Documentation

◆ Pib

friend class Pib
friend

Definition at line 47 of file identity.hpp.

◆ IdentityContainer

friend class IdentityContainer
friend

Definition at line 48 of file identity.hpp.

◆ KeyChain

friend class KeyChain
friend

Definition at line 49 of file identity.hpp.

Member Data Documentation

◆ __pad0__

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::security::Identity::__pad0__

Definition at line 119 of file identity.hpp.

◆ keyId

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 getKey(), removeKey(), and setDefaultKey().

◆ __pad1__

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::security::Identity::__pad1__

Definition at line 161 of file identity.hpp.

◆ impl

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE shared_ptr<PibImpl> ndn::security::Identity::impl

Definition at line 161 of file identity.hpp.

◆ needInit

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE shared_ptr<PibImpl> bool ndn::security::Identity::needInit = false)

Definition at line 161 of file identity.hpp.

◆ EMPTY_KEY_ID

const name::Component ndn::security::Identity::EMPTY_KEY_ID
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.


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