ndn::security::pib::detail::KeyImpl Class Reference

Backend instance of Key. More...

#include <key-impl.hpp>

Inheritance diagram for ndn::security::pib::detail::KeyImpl:
[legend]
Collaboration diagram for ndn::security::pib::detail::KeyImpl:
[legend]

Public Member Functions

 KeyImpl (const Name &keyName, const uint8_t *key, size_t keyLen, shared_ptr< PibImpl > impl)
 Create a KeyImpl with keyName. More...
 
 KeyImpl (const Name &keyName, shared_ptr< PibImpl > impl)
 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 one with certName as the default certificate. More...
 
const v2::CertificatesetDefaultCertificate (const v2::Certificate &certificate)
 Add certificate and set it as the default certificate of the 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 45 of file key-impl.hpp.

Constructor & Destructor Documentation

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

Create a KeyImpl with keyName.

If the key does not exist in the backend, create it in backend.

Parameters
keyNameThe name of the key.
keyThe public key to add.
keyLenThe length of the key.
implThe Pib backend implementation.
Exceptions
Pib::Errora key with the same keyName already exists.

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

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

Create a KeyImpl with keyName.

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

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

Member Function Documentation

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.

Exceptions
std::invalid_argumentcertificate name does not match key name
Pib::Errora certificate with the same name already exists

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

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

Get a certificate with certName.

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

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

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

Get all the certificates for this key.

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

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 132 of file key-impl.cpp.

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

Get the name of the belonging identity.

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

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

Get key type.

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

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

Get the name of the key.

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

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

Get public key bits.

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

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

Remove a certificate with certName.

Exceptions
std::invalid_argumentcertName does not match key name

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

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

Set an existing one with certName as the default certificate.

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

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

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

Add certificate and set it as the default certificate of the key.

Exceptions
std::invalid_argumentcertificate does not match key name
Pib::Errorthe certificate with the same name already exists.
Returns
the default certificate

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