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

Backend instance of Key. More...

#include <key-impl.hpp>

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

Public Member Functions

 KeyImpl (const Name &keyName, const uint8_t *key, size_t keyLen, shared_ptr< PibImpl > pibImpl)
 Create a KeyImpl with keyName. More...
 
 KeyImpl (const Name &keyName, shared_ptr< PibImpl > pibImpl)
 Create a KeyImpl with keyName. More...
 
const NamegetName () const
 Get the name of the key. More...
 
const NamegetIdentity () const
 Get the name of the belonging identity. More...
 
KeyType getKeyType () const
 Get key type. More...
 
const BuffergetPublicKey () const
 Get public key bits. More...
 
void addCertificate (const v2::Certificate &certificate)
 Add certificate. More...
 
void removeCertificate (const Name &certName)
 Remove a certificate with certName. More...
 
v2::Certificate getCertificate (const Name &certName) const
 Get a certificate with certName. More...
 
const CertificateContainergetCertificates () const
 Get all the certificates for this key. More...
 
const v2::CertificatesetDefaultCertificate (const Name &certName)
 Set an existing certificate with name certName as the default certificate. More...
 
const v2::CertificatesetDefaultCertificate (const v2::Certificate &certificate)
 Add certificate and set it as the default certificate for this key. More...
 
const v2::CertificategetDefaultCertificate () const
 Get the default certificate for this key. More...
 

Detailed Description

Backend instance of Key.

An Key has only one backend instance, but may have multiple frontend handles. Each frontend handle is associated with the only one backend KeyImpl.

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

Definition at line 44 of file key-impl.hpp.

Constructor & Destructor Documentation

◆ KeyImpl() [1/2]

ndn::security::pib::detail::KeyImpl::KeyImpl ( const Name keyName,
const uint8_t *  key,
size_t  keyLen,
shared_ptr< PibImpl pibImpl 
)

Create a KeyImpl with keyName.

If the key does not exist in the backend, it will be added. If a key with the same name already exists, it will be overwritten.

Parameters
keyNameThe name of the key.
keyThe public key to add.
keyLenThe length of the key.
pibImplThe Pib backend implementation.
Exceptions
std::invalid_argumentkey is invalid.

Definition at line 32 of file key-impl.cpp.

References ndn::security::transform::PublicKey::getKeyType(), ndn::security::transform::PublicKey::loadPkcs8(), and NDN_THROW_NESTED.

◆ KeyImpl() [2/2]

ndn::security::pib::detail::KeyImpl::KeyImpl ( const Name keyName,
shared_ptr< PibImpl pibImpl 
)

Create a KeyImpl with keyName.

Parameters
keyNameThe name of the key.
pibImplThe Pib backend implementation.
Exceptions
Pib::Errorthe key does not exist.

Definition at line 54 of file key-impl.cpp.

References ndn::security::transform::PublicKey::getKeyType(), and ndn::security::transform::PublicKey::loadPkcs8().

Member Function Documentation

◆ getName()

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

Get the name of the key.

Definition at line 74 of file key-impl.hpp.

◆ getIdentity()

const Name& ndn::security::pib::detail::KeyImpl::getIdentity ( ) const
inline

Get the name of the belonging identity.

Definition at line 83 of file key-impl.hpp.

◆ getKeyType()

KeyType ndn::security::pib::detail::KeyImpl::getKeyType ( ) const
inline

Get key type.

Definition at line 92 of file key-impl.hpp.

◆ getPublicKey()

const Buffer& ndn::security::pib::detail::KeyImpl::getPublicKey ( ) const
inline

Get public key bits.

Definition at line 101 of file key-impl.hpp.

◆ addCertificate()

void ndn::security::pib::detail::KeyImpl::addCertificate ( const v2::Certificate certificate)

Add certificate.

If no default certificate is set before, the new certificate will be set as the default certificate of the key.

If a certificate with the same name (without implicit digest) already exists, it will be overwritten.

Exceptions
std::invalid_argumentthe certificate name does not match the key name.

Definition at line 71 of file key-impl.cpp.

References ndn::security::pib::CertificateContainer::add(), and ndn::security::pib::CertificateContainer::isConsistent().

Referenced by setDefaultCertificate().

◆ removeCertificate()

void ndn::security::pib::detail::KeyImpl::removeCertificate ( const Name certName)

Remove a certificate with certName.

Exceptions
std::invalid_argumentcertName does not match the key name.

Definition at line 78 of file key-impl.cpp.

References ndn::Data::getName(), ndn::security::pib::CertificateContainer::isConsistent(), and ndn::security::pib::CertificateContainer::remove().

◆ getCertificate()

v2::Certificate ndn::security::pib::detail::KeyImpl::getCertificate ( const Name certName) const

Get a certificate with certName.

Exceptions
std::invalid_argumentcertName does not match the key name.
Pib::Errorthe certificate does not exist.

Definition at line 89 of file key-impl.cpp.

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

◆ getCertificates()

const CertificateContainer & ndn::security::pib::detail::KeyImpl::getCertificates ( ) const

Get all the certificates for this key.

Definition at line 96 of file key-impl.cpp.

References ndn::security::pib::CertificateContainer::isConsistent().

◆ setDefaultCertificate() [1/2]

const v2::Certificate & ndn::security::pib::detail::KeyImpl::setDefaultCertificate ( const Name certName)

Set an existing certificate with name certName as the default certificate.

Exceptions
std::invalid_argumentcertName does not match the key name.
Pib::Errorthe certificate does not exist.
Returns
the default certificate

Definition at line 103 of file key-impl.cpp.

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

Referenced by setDefaultCertificate().

◆ setDefaultCertificate() [2/2]

const v2::Certificate & ndn::security::pib::detail::KeyImpl::setDefaultCertificate ( const v2::Certificate certificate)

Add certificate and set it as the default certificate for this key.

If a certificate with the same name (without implicit digest) already exists, it will be overwritten.

Exceptions
std::invalid_argumentcertificate does not match the key name.
Returns
the default certificate

Definition at line 114 of file key-impl.cpp.

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

◆ getDefaultCertificate()

const v2::Certificate & ndn::security::pib::detail::KeyImpl::getDefaultCertificate ( ) const

Get the default certificate for this key.

Exceptions
Pib::Errorthe default certificate does not exist.

Definition at line 121 of file key-impl.cpp.

References ndn::security::pib::CertificateContainer::isConsistent(), and ndn::Data::wireEncode().


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