NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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 PublicKeygetPublicKey () const
 Get public key. More...
 
IdentityCertificate getCertificate (const Name &certName) const
 Get a certificate. More...
 
const CertificateContainergetCertificates () const
 Get all the certificates for this key. More...
 
const 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 IdentityCertificatesetDefaultCertificate (const Name &certName)
 Set the default certificate. More...
 
const IdentityCertificatesetDefaultCertificate (const 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 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 PublicKeypublicKey
 
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component const 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

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

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

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

Get the name of the key.

Definition at line 71 of file key.cpp.

References validityCheck().

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

Get the name of the belonging identity.

Definition at line 79 of file key.cpp.

References validityCheck().

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

const PublicKey & ndn::security::Key::getPublicKey ( ) const
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().

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

Get all the certificates for this key.

Definition at line 138 of file key.cpp.

References validityCheck().

const 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 170 of file key.cpp.

References validityCheck().

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

Check if the Key instance is valid.

Definition at line 182 of file key.cpp.

References operator!().

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

Check if the Key instance is invalid.

Definition at line 188 of file key.cpp.

Referenced by operator bool().

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

const 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 152 of file key.cpp.

References validityCheck().

Referenced by setDefaultCertificate().

const IdentityCertificate & ndn::security::Key::setDefaultCertificate ( const 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 163 of file key.cpp.

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

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

Check the validity of this instance.

Exceptions
std::domain_errorif the instance is invalid

Definition at line 194 of file key.cpp.

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

Friends And Related Function Documentation

friend class Identity
friend

Definition at line 48 of file key.hpp.

friend class KeyContainer
friend

Definition at line 49 of file key.hpp.

friend class KeyChain
friend

Definition at line 50 of file key.hpp.

Member Data Documentation

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::security::Key::__pad0__

Definition at line 125 of file key.hpp.

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE ndn::security::Key::__pad1__

Definition at line 168 of file key.hpp.

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

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

Definition at line 168 of file key.hpp.

Referenced by Key().

NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const name::Component const 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: