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

An in-memory implementation of Pib. More...

#include <pib-memory.hpp>

Inheritance diagram for ndn::security::PibMemory:
Collaboration diagram for ndn::security::PibMemory:

Classes

class  Error
 

Public Member Functions

 PibMemory ()
 
virtual void setTpmLocator (const std::string &tpmLocator) override
 Set the corresponding TPM information to tpmLocator. More...
 
virtual std::string getTpmLocator () const override
 Get TPM Locator. More...
 
virtual bool hasIdentity (const Name &identity) const override
 Check the existence of an identity. More...
 
virtual void addIdentity (const Name &identity) override
 Add an identity. More...
 
virtual void removeIdentity (const Name &identity) override
 Remove an identity. More...
 
virtual std::set< NamegetIdentities () const override
 Get the name of all the identities. More...
 
virtual void setDefaultIdentity (const Name &identityName) override
 Set an identity with name identityName as the default identity. More...
 
virtual Name getDefaultIdentity () const override
 Get the default identity. More...
 
virtual bool hasKey (const Name &identity, const name::Component &keyId) const override
 Check the existence of a key. More...
 
virtual void addKey (const Name &identity, const name::Component &keyId, const PublicKey &publicKey) override
 Add a key. More...
 
virtual void removeKey (const Name &identity, const name::Component &keyId) override
 Remove a key. More...
 
virtual PublicKey getKeyBits (const Name &identity, const name::Component &keyId) const override
 Get the key bits of a key. More...
 
virtual std::set< name::ComponentgetKeysOfIdentity (const Name &identity) const override
 Get all the key ids of an identity with name identity. More...
 
virtual void setDefaultKeyOfIdentity (const Name &identity, const name::Component &keyId) override
 Set an key with id keyId as the default key of an identity with name identity. More...
 
virtual name::Component getDefaultKeyOfIdentity (const Name &identity) const override
 Get the id of the default key of an identity with name identity. More...
 
virtual bool hasCertificate (const Name &certName) const override
 Check the existence of a certificate with name certName. More...
 
virtual void addCertificate (const IdentityCertificate &certificate) override
 Add a certificate. More...
 
virtual void removeCertificate (const Name &certName) override
 Remove a certificate with name certName. More...
 
virtual IdentityCertificate getCertificate (const Name &certName) const override
 Get a certificate with name certName. More...
 
virtual std::set< NamegetCertificatesOfKey (const Name &identity, const name::Component &keyId) const override
 Get a list of certificate names of a key with id keyId of identity. More...
 
virtual void setDefaultCertificateOfKey (const Name &identity, const name::Component &keyId, const Name &certName) override
 Set a cert with name certName as the default of a key with id keyId of identity. More...
 
virtual IdentityCertificate getDefaultCertificateOfKey (const Name &identity, const name::Component &keyId) const override
 Get the default certificate of a key with id keyId of identity. More...
 
- Public Member Functions inherited from ndn::security::PibImpl
virtual ~PibImpl ()
 

Detailed Description

An in-memory implementation of Pib.

All the contents in Pib are stored in memory and have the same lifetime as the implementation instance.

Definition at line 36 of file pib-memory.hpp.

Constructor & Destructor Documentation

§ PibMemory()

ndn::security::PibMemory::PibMemory ( )

Definition at line 28 of file pib-memory.cpp.

Referenced by ndn::security::PibMemory::Error::Error().

Member Function Documentation

§ setTpmLocator()

void ndn::security::PibMemory::setTpmLocator ( const std::string &  tpmLocator)
overridevirtual

Set the corresponding TPM information to tpmLocator.

If the provided tpmLocator is different from the existing one, the content in PIB will be cleaned up, otherwise nothing will be changed.

Parameters
tpmLocatorThe name for the new TPM locator

Implements ndn::security::PibImpl.

Definition at line 34 of file pib-memory.cpp.

Referenced by ndn::security::PibMemory::Error::Error().

§ getTpmLocator()

std::string ndn::security::PibMemory::getTpmLocator ( ) const
overridevirtual

Get TPM Locator.

Implements ndn::security::PibImpl.

Definition at line 40 of file pib-memory.cpp.

Referenced by ndn::security::PibMemory::Error::Error().

§ hasIdentity()

bool ndn::security::PibMemory::hasIdentity ( const Name identity) const
overridevirtual

Check the existence of an identity.

Parameters
identityThe name of the identity.
Returns
true if the identity exists, otherwise false.

Implements ndn::security::PibImpl.

Definition at line 46 of file pib-memory.cpp.

Referenced by ndn::security::PibMemory::Error::Error().

§ addIdentity()

void ndn::security::PibMemory::addIdentity ( const Name identity)
overridevirtual

Add an identity.

If the identity already exists, do nothing. If no default identity has been set, set the added one as default identity.

Parameters
identityThe name of the identity to add.

Implements ndn::security::PibImpl.

Definition at line 52 of file pib-memory.cpp.

Referenced by addKey(), ndn::security::PibMemory::Error::Error(), and setDefaultIdentity().

§ removeIdentity()

void ndn::security::PibMemory::removeIdentity ( const Name identity)
overridevirtual

Remove an identity.

If the identity does not exist, do nothing. Remove related keys and certificates as well.

Parameters
identityThe name of the identity to remove.

Implements ndn::security::PibImpl.

Definition at line 63 of file pib-memory.cpp.

References getKeysOfIdentity(), and removeKey().

Referenced by ndn::security::PibMemory::Error::Error().

§ getIdentities()

std::set< Name > ndn::security::PibMemory::getIdentities ( ) const
overridevirtual

Get the name of all the identities.

Implements ndn::security::PibImpl.

Definition at line 76 of file pib-memory.cpp.

Referenced by ndn::security::PibMemory::Error::Error().

§ setDefaultIdentity()

void ndn::security::PibMemory::setDefaultIdentity ( const Name identityName)
overridevirtual

Set an identity with name identityName as the default identity.

Since adding an identity only requires the identity name, create the identity if it does not exist.

Parameters
identityNameThe name for the default identity.

Implements ndn::security::PibImpl.

Definition at line 82 of file pib-memory.cpp.

References addIdentity().

Referenced by ndn::security::PibMemory::Error::Error().

§ getDefaultIdentity()

Name ndn::security::PibMemory::getDefaultIdentity ( ) const
overridevirtual

Get the default identity.

Returns
The name for the default identity.
Exceptions
Pib::Errorif no default identity.

Implements ndn::security::PibImpl.

Definition at line 90 of file pib-memory.cpp.

Referenced by ndn::security::PibMemory::Error::Error().

§ hasKey()

bool ndn::security::PibMemory::hasKey ( const Name identity,
const name::Component keyId 
) const
overridevirtual

Check the existence of a key.

Parameters
identityThe name of the belonged identity.
keyIdThe key id component.
Returns
true if the key exists, otherwise false. Return false if the identity does not exist

Implements ndn::security::PibImpl.

Definition at line 99 of file pib-memory.cpp.

Referenced by ndn::security::PibMemory::Error::Error(), getKeyBits(), and setDefaultKeyOfIdentity().

§ addKey()

void ndn::security::PibMemory::addKey ( const Name identity,
const name::Component keyId,
const PublicKey publicKey 
)
overridevirtual

Add a key.

If the key already exists, do nothing. If the identity does not exist, add the identity as well. If no default key of the identity has been set, set the added one as default key of the identity.

Parameters
identityThe name of the belonged identity.
keyIdThe key id component.
publicKeyThe public key bits.

Implements ndn::security::PibImpl.

Definition at line 105 of file pib-memory.cpp.

References addIdentity().

Referenced by addCertificate(), and ndn::security::PibMemory::Error::Error().

§ removeKey()

void ndn::security::PibMemory::removeKey ( const Name identity,
const name::Component keyId 
)
overridevirtual

Remove a key.

If the key does not exist, do nothing. Remove related certificates as well.

Parameters
identityThe name of the belonged identity.
keyIdThe key id component.

Implements ndn::security::PibImpl.

Definition at line 117 of file pib-memory.cpp.

References getCertificatesOfKey(), and removeCertificate().

Referenced by ndn::security::PibMemory::Error::Error(), and removeIdentity().

§ getKeyBits()

PublicKey ndn::security::PibMemory::getKeyBits ( const Name identity,
const name::Component keyId 
) const
overridevirtual

Get the key bits of a key.

Parameters
identityThe name of the belonged identity.
keyIdThe key id component.
Returns
key bits
Exceptions
Pib::Errorif the key does not exist.

Implements ndn::security::PibImpl.

Definition at line 131 of file pib-memory.cpp.

References hasKey().

Referenced by ndn::security::PibMemory::Error::Error().

§ getKeysOfIdentity()

std::set< name::Component > ndn::security::PibMemory::getKeysOfIdentity ( const Name identity) const
overridevirtual

Get all the key ids of an identity with name identity.

The returned key ids can be used to create a KeyContainer. With key id, identity name, backend implementation, one can create a Key frontend instance.

Returns
the key id name component set. If the identity does not exist, return an empty set.

Implements ndn::security::PibImpl.

Definition at line 141 of file pib-memory.cpp.

References ndn::Name::getPrefix().

Referenced by ndn::security::PibMemory::Error::Error(), and removeIdentity().

§ setDefaultKeyOfIdentity()

void ndn::security::PibMemory::setDefaultKeyOfIdentity ( const Name identity,
const name::Component keyId 
)
overridevirtual

Set an key with id keyId as the default key of an identity with name identity.

Parameters
identityThe name of the belonged identity.
keyIdThe key id component.
Exceptions
Pib::Errorif the key does not exist.

Implements ndn::security::PibImpl.

Definition at line 152 of file pib-memory.cpp.

References hasKey().

Referenced by ndn::security::PibMemory::Error::Error().

§ getDefaultKeyOfIdentity()

name::Component ndn::security::PibMemory::getDefaultKeyOfIdentity ( const Name identity) const
overridevirtual

Get the id of the default key of an identity with name identity.

Parameters
identityThe name of the belonged identity.
Exceptions
Pib::Errorif no default key or the identity does not exist.

Implements ndn::security::PibImpl.

Definition at line 163 of file pib-memory.cpp.

References ndn::Name::append().

Referenced by ndn::security::PibMemory::Error::Error().

§ hasCertificate()

bool ndn::security::PibMemory::hasCertificate ( const Name certName) const
overridevirtual

Check the existence of a certificate with name certName.

Parameters
certNameThe name of the certificate.
Returns
true if the certificate exists, otherwise false.

Implements ndn::security::PibImpl.

Definition at line 181 of file pib-memory.cpp.

Referenced by ndn::security::PibMemory::Error::Error(), getCertificate(), and setDefaultCertificateOfKey().

§ addCertificate()

void ndn::security::PibMemory::addCertificate ( const IdentityCertificate certificate)
overridevirtual

Add a certificate.

If the certificate already exists, do nothing. If the key or identity do not exist, add them as well. If no default certificate of the key has been set, set the added one as default certificate of the key.

Parameters
certificateThe certificate to add.

Implements ndn::security::PibImpl.

Definition at line 187 of file pib-memory.cpp.

References addKey(), ndn::Name::get(), ndn::Data::getName(), ndn::Name::getPrefix(), ndn::Certificate::getPublicKeyInfo(), and ndn::IdentityCertificate::getPublicKeyName().

Referenced by ndn::security::PibMemory::Error::Error().

§ removeCertificate()

void ndn::security::PibMemory::removeCertificate ( const Name certName)
overridevirtual

Remove a certificate with name certName.

If the certificate does not exist, do nothing.

Parameters
certNameThe name of the certificate.

Implements ndn::security::PibImpl.

Definition at line 201 of file pib-memory.cpp.

References ndn::IdentityCertificate::certificateNameToPublicKeyName().

Referenced by ndn::security::PibMemory::Error::Error(), and removeKey().

§ getCertificate()

IdentityCertificate ndn::security::PibMemory::getCertificate ( const Name certName) const
overridevirtual

Get a certificate with name certName.

Parameters
certNameThe name of the certificate.
Returns
the certificate.
Exceptions
Pib::Errorif the certificate does not exist.

Implements ndn::security::PibImpl.

Definition at line 208 of file pib-memory.cpp.

References hasCertificate().

Referenced by ndn::security::PibMemory::Error::Error().

§ getCertificatesOfKey()

std::set< Name > ndn::security::PibMemory::getCertificatesOfKey ( const Name identity,
const name::Component keyId 
) const
overridevirtual

Get a list of certificate names of a key with id keyId of identity.

The returned certificate names can be used to create a CertificateContainer. With certificate name and backend implementation, one can obtain the certificate directly.

Parameters
identityThe name of the belonging identity.
keyIdThe key id.
Returns
The certificate name set. If the key does not exist, return an empty set.

Implements ndn::security::PibImpl.

Definition at line 218 of file pib-memory.cpp.

Referenced by ndn::security::PibMemory::Error::Error(), and removeKey().

§ setDefaultCertificateOfKey()

void ndn::security::PibMemory::setDefaultCertificateOfKey ( const Name identity,
const name::Component keyId,
const Name certName 
)
overridevirtual

Set a cert with name certName as the default of a key with id keyId of identity.

Parameters
identityThe name of the belonging identity.
keyIdThe key id.
certNameThe name of the certificate.
Exceptions
Pib::Errorif the certificate with name certName does not exist.

Implements ndn::security::PibImpl.

Definition at line 231 of file pib-memory.cpp.

References hasCertificate().

Referenced by ndn::security::PibMemory::Error::Error().

§ getDefaultCertificateOfKey()

IdentityCertificate ndn::security::PibMemory::getDefaultCertificateOfKey ( const Name identity,
const name::Component keyId 
) const
overridevirtual

Get the default certificate of a key with id keyId of identity.

Parameters
identityThe name of the belonging identity.
keyIdThe key id.
Returns
a pointer to the certificate, null if no default certificate for the key.
Exceptions
Pib::Errorif the default certificate does not exist.

Implements ndn::security::PibImpl.

Definition at line 241 of file pib-memory.cpp.

Referenced by ndn::security::PibMemory::Error::Error().


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