ndn::security::Key Class Reference

represents a key More...

#include <key.hpp>

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...
 

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

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.

Member Function Documentation

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.

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

Get all the certificates for this key.

Definition at line 138 of file key.cpp.

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.

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

Get the name of the belonging identity.

Definition at line 79 of file key.cpp.

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

Get the key id of the key.

Definition at line 87 of file key.cpp.

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

Get the name of the key.

Definition at line 71 of file key.cpp.

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

Get public key.

Definition at line 95 of file key.cpp.

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

Check if the Key instance is valid.

Definition at line 181 of file key.cpp.

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

Check if the Key instance is invalid.

Definition at line 187 of file key.cpp.

Friends And Related Function Documentation

friend class Identity
friend

Definition at line 48 of file key.hpp.

friend class KeyChain
friend

Definition at line 50 of file key.hpp.

friend class KeyContainer
friend

Definition at line 49 of file key.hpp.