ndn::security::pib::Key Class Reference

A frontend handle of a key instance. More...

#include <ndn-cxx/security/pib/key.hpp>

Public Member Functions

 Key ()
 Default Constructor. More...
 
 Key (weak_ptr< detail::KeyImpl > impl)
 Create a Key with a backend implementation impl. More...
 
v2::Certificate getCertificate (const Name &certName) const
 Get a certificate with certName. More...
 
const CertificateContainergetCertificates () const
 Get all certificates for this key. More...
 
const v2::CertificategetDefaultCertificate () const
 Get the default certificate for this Key. More...
 
const NamegetIdentity () const
 Get the name of the belonging identity. More...
 
KeyType getKeyType () const
 Get key type. More...
 
const NamegetName () const
 Get key name. More...
 
const BuffergetPublicKey () const
 Get public key bits. More...
 
 operator bool () const
 Check if the Key instance is valid. More...
 

Friends

bool operator!= (const Key &, const Key &)
 
class v2::KeyChain
 

Detailed Description

A frontend handle of a key instance.

Key is at the second level in PIB's Identity-Key-Certificate hierarchy. A Key has a Name (identity + "KEY" + 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.

Definition at line 49 of file key.hpp.

Constructor & Destructor Documentation

ndn::security::pib::Key::Key ( )
default

Default Constructor.

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

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

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

ndn::security::pib::Key::Key ( weak_ptr< detail::KeyImpl >  impl)
explicit

Create a Key with a backend implementation impl.

This method should only be used by KeyContainer.

Definition at line 32 of file key.cpp.

Member Function Documentation

v2::Certificate ndn::security::pib::Key::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 74 of file key.cpp.

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

Get all certificates for this key.

Definition at line 80 of file key.cpp.

const v2::Certificate & ndn::security::pib::Key::getDefaultCertificate ( ) const

Get the default certificate for this Key.

Exceptions
Pib::Errorthe default certificate does not exist.

Definition at line 98 of file key.cpp.

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

Get the name of the belonging identity.

Definition at line 44 of file key.cpp.

KeyType ndn::security::pib::Key::getKeyType ( ) const

Get key type.

Definition at line 50 of file key.cpp.

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

Get key name.

Definition at line 38 of file key.cpp.

const Buffer & ndn::security::pib::Key::getPublicKey ( ) const

Get public key bits.

Definition at line 56 of file key.cpp.

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

Check if the Key instance is valid.

Definition at line 103 of file key.cpp.

Friends And Related Function Documentation

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

Definition at line 121 of file key.cpp.

friend class v2::KeyChain
friend

Definition at line 178 of file key.hpp.