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

represents a key More...

#include <key.hpp>

Collaboration diagram for ndn::security::Key:

Public Member Functions

 Key ()
 Default Constructor. More...
 
const NamegetName () const
 Get the name of the key. More...
 
const NamegetIdentity () const
 Get the name of the belonging identity. More...
 
const name::ComponentgetKeyId () const
 Get the key id of the key. More...
 
const v1::PublicKeygetPublicKey () const
 Get public key. More...
 
v1::IdentityCertificate getCertificate (const Name &certName) const
 Get a certificate. More...
 
const CertificateContainergetCertificates () const
 Get all the certificates for this key. More...
 
const v1::IdentityCertificategetDefaultCertificate () const
 Get the default certificate for this Key. More...
 
 operator bool () const
 Check if the Key instance is valid. More...
 
bool operator! () const
 Check if the Key instance is invalid. More...
 
void removeCertificate (const Name &certName)
 Remove a certificate. More...
 
const v1::IdentityCertificatesetDefaultCertificate (const Name &certName)
 Set the default certificate. More...
 
const v1::IdentityCertificatesetDefaultCertificate (const v1::IdentityCertificate &certificate)
 Set the default certificate. More...
 
 Key (const Name &identityName, const name::Component &keyId, shared_ptr< PibImpl > impl)
 Create an KeyEntry with identityName and keyId. More...
 
void validityCheck () const
 Check the validity of this instance. More...
 

Public Attributes

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE __pad0__: void addCertificate(const v1::IdentityCertificate& certificate)
 
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE __pad1__: Key(const Name& identityName
 
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::ComponentkeyId
 
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component const v1::PublicKeypublicKey
 
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component const v1::PublicKey shared_ptr< PibImplimpl
 

Friends

class Identity
 
class KeyContainer
 
class KeyChain
 

Detailed Description

represents a key

Key is at the second level in PIB's Identity-Key-Certificate hierarchy. An Key has a Name (identity + keyId), and contains one or more certificates, one of which is set as the default certificate of this key. A certificate can be directly accessed from a Key object.

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

Definition at line 45 of file key.hpp.

Constructor & Destructor Documentation

◆ Key() [1/2]

ndn::security::Key::Key ( )

Default Constructor.

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

Key key; try { key = Identity.getKey(...); } catch (Pib::Error&) { ... }

A Key instance created using the constructor is invalid. Calling a member method on an invalid Key instance may cause an std::domain_error.

Definition at line 29 of file key.cpp.

References ndn::Name::append(), impl, keyId, publicKey, and validityCheck().

◆ Key() [2/2]

ndn::security::Key::Key ( const Name identityName,
const name::Component keyId,
shared_ptr< PibImpl impl 
)

Create an KeyEntry with identityName and keyId.

Parameters
identityNameThe name of the Identity.
keyIdThe key id of the key.
implThe actual backend implementation.
Exceptions
Pib::Errorif the key does not exist.

Definition at line 54 of file key.cpp.

References ndn::Name::append(), and validityCheck().

Member Function Documentation

◆ getName()

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

Get the name of the key.

Definition at line 71 of file key.cpp.

References validityCheck().

◆ getIdentity()

const Name & ndn::security::Key::getIdentity ( ) const

Get the name of the belonging identity.

Definition at line 79 of file key.cpp.

References validityCheck().

◆ getKeyId()

const name::Component & ndn::security::Key::getKeyId ( ) const

Get the key id of the key.

Definition at line 87 of file key.cpp.

References validityCheck().

Referenced by ndn::security::Identity::removeKey(), and ndn::security::Identity::setDefaultKey().

◆ getPublicKey()

const v1::PublicKey & ndn::security::Key::getPublicKey ( ) const

◆ getCertificate()

v1::IdentityCertificate ndn::security::Key::getCertificate ( const Name certName) const

Get a certificate.

Returns
the certificate
Exceptions
Pib::Errorif the certificate does not exist.

Definition at line 130 of file key.cpp.

References validityCheck().

◆ getCertificates()

const CertificateContainer & ndn::security::Key::getCertificates ( ) const

Get all the certificates for this key.

Definition at line 138 of file key.cpp.

References validityCheck().

◆ getDefaultCertificate()

const v1::IdentityCertificate & ndn::security::Key::getDefaultCertificate ( ) const

Get the default certificate for this Key.

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

Definition at line 169 of file key.cpp.

References validityCheck().

◆ operator bool()

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

Check if the Key instance is valid.

Definition at line 181 of file key.cpp.

References operator!().

◆ operator!()

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

Check if the Key instance is invalid.

Definition at line 187 of file key.cpp.

Referenced by operator bool().

◆ removeCertificate()

void ndn::security::Key::removeCertificate ( const Name certName)

Remove a certificate.

Parameters
certNameThe name of the certificate to delete.

Definition at line 118 of file key.cpp.

References ndn::Data::getName(), and validityCheck().

◆ setDefaultCertificate() [1/2]

const v1::IdentityCertificate & ndn::security::Key::setDefaultCertificate ( const Name certName)

Set the default certificate.

Parameters
certNameThe name of the default certificate of the key.
Returns
the default certificate
Exceptions
Pib::Errorif the certificate does not exist.

Definition at line 151 of file key.cpp.

References validityCheck().

Referenced by setDefaultCertificate().

◆ setDefaultCertificate() [2/2]

const v1::IdentityCertificate & ndn::security::Key::setDefaultCertificate ( const v1::IdentityCertificate certificate)

Set the default certificate.

If the certificate does not exist, add it and set it as the default certificate of the key. If the certificate exists, simply set it as the default certificate of the key.

Parameters
certificateThe certificate to add.
Returns
the default certificate

Definition at line 162 of file key.cpp.

References ndn::Data::getName(), and setDefaultCertificate().

◆ validityCheck()

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

Check the validity of this instance.

Exceptions
std::domain_errorif the instance is invalid

Definition at line 193 of file key.cpp.

Referenced by getCertificate(), getCertificates(), getDefaultCertificate(), getIdentity(), getKeyId(), getName(), getPublicKey(), Key(), removeCertificate(), and setDefaultCertificate().

Friends And Related Function Documentation

◆ Identity

friend class Identity
friend

Definition at line 48 of file key.hpp.

◆ KeyContainer

friend class KeyContainer
friend

Definition at line 49 of file key.hpp.

◆ KeyChain

friend class KeyChain
friend

Definition at line 50 of file key.hpp.

Member Data Documentation

◆ __pad0__

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::security::Key::__pad0__

Definition at line 125 of file key.hpp.

◆ __pad1__

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::security::Key::__pad1__

Definition at line 168 of file key.hpp.

◆ keyId

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component& ndn::security::Key::keyId

Definition at line 168 of file key.hpp.

Referenced by Key().

◆ publicKey

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component const v1::PublicKey& ndn::security::Key::publicKey

Definition at line 168 of file key.hpp.

Referenced by Key().

◆ impl

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component const v1::PublicKey shared_ptr<PibImpl> ndn::security::Key::impl

Definition at line 168 of file key.hpp.

Referenced by Key().


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