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

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

#include <pib-memory.hpp>

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

Public Member Functions

 PibMemory (const std::string &location="")
 Create memory based PIB backend. More...
 
void setTpmLocator (const std::string &tpmLocator) override
 Set the corresponding TPM information to tpmLocator. More...
 
std::string getTpmLocator () const override
 Get TPM Locator. More...
 
bool hasIdentity (const Name &identity) const override
 Check the existence of an identity. More...
 
void addIdentity (const Name &identity) override
 Add an identity. More...
 
void removeIdentity (const Name &identity) override
 Remove an identity and related keys and certificates. More...
 
void clearIdentities () override
 Erasing all certificates, keys, and identities. More...
 
std::set< NamegetIdentities () const override
 Get the name of all the identities. More...
 
void setDefaultIdentity (const Name &identityName) override
 Set an identity with name identityName as the default identity. More...
 
Name getDefaultIdentity () const override
 Get the default identity. More...
 
bool hasKey (const Name &keyName) const override
 Check the existence of a key with keyName. More...
 
void addKey (const Name &identity, const Name &keyName, span< const uint8_t > key) override
 Add a key. More...
 
void removeKey (const Name &keyName) override
 Remove a key with keyName and related certificates. More...
 
Buffer getKeyBits (const Name &keyName) const override
 Get the key bits of a key with name keyName. More...
 
std::set< NamegetKeysOfIdentity (const Name &identity) const override
 Get all the key names of an identity with name identity. More...
 
void setDefaultKeyOfIdentity (const Name &identity, const Name &keyName) override
 Set an key with keyName as the default key of an identity with name identity. More...
 
Name getDefaultKeyOfIdentity (const Name &identity) const override
 
bool hasCertificate (const Name &certName) const override
 Check the existence of a certificate with name certName. More...
 
void addCertificate (const Certificate &certificate) override
 Add a certificate. More...
 
void removeCertificate (const Name &certName) override
 Remove a certificate with name certName. More...
 
Certificate getCertificate (const Name &certName) const override
 Get a certificate with name certName. More...
 
std::set< NamegetCertificatesOfKey (const Name &keyName) const override
 Get a list of certificate names of a key with id keyName. More...
 
void setDefaultCertificateOfKey (const Name &keyName, const Name &certName) override
 Set a cert with name certName as the default of a key with keyName. More...
 
Certificate getDefaultCertificateOfKey (const Name &keyName) const override
 
- Public Member Functions inherited from ndn::security::pib::PibImpl
virtual ~PibImpl ()=default
 

Static Public Member Functions

static const std::string & getScheme ()
 

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 37 of file pib-memory.hpp.

Constructor & Destructor Documentation

◆ PibMemory()

ndn::security::pib::PibMemory::PibMemory ( const std::string &  location = "")
explicit

Create memory based PIB backend.

Parameters
locationNot used (required by the PIB-registration interface)

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

Member Function Documentation

◆ getScheme()

const std::string & ndn::security::pib::PibMemory::getScheme ( )
static

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

◆ setTpmLocator()

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

Set the corresponding TPM information to tpmLocator.

This method does not reset contents of the PIB

Implements ndn::security::pib::PibImpl.

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

◆ getTpmLocator()

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

Get TPM Locator.

Implements ndn::security::pib::PibImpl.

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

◆ hasIdentity()

bool ndn::security::pib::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::pib::PibImpl.

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

Referenced by setDefaultIdentity().

◆ addIdentity()

void ndn::security::pib::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::pib::PibImpl.

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

Referenced by addKey().

◆ removeIdentity()

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

Remove an identity and related keys and certificates.

If the default identity is being removed, no default identity will be selected. If the identity does not exist, do nothing.

Parameters
identityThe name of the identity to remove.

Implements ndn::security::pib::PibImpl.

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

References ndn::Name::clear(), getKeysOfIdentity(), and removeKey().

◆ clearIdentities()

void ndn::security::pib::PibMemory::clearIdentities ( )
overridevirtual

Erasing all certificates, keys, and identities.

Implements ndn::security::pib::PibImpl.

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

References ndn::Name::clear().

◆ getIdentities()

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

Get the name of all the identities.

Implements ndn::security::pib::PibImpl.

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

◆ setDefaultIdentity()

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

Set an identity with name identityName as the default identity.

Parameters
identityNameThe name for the default identity.
Exceptions
ErrorIf identityName identity does not exist.

Implements ndn::security::pib::PibImpl.

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

References hasIdentity(), NDN_THROW, and ndn::Name::toUri().

◆ getDefaultIdentity()

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

Get the default identity.

Returns
The name for the default identity.
Exceptions
Pib::Errorno default identity.

Implements ndn::security::pib::PibImpl.

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

References NDN_THROW.

◆ hasKey()

bool ndn::security::pib::PibMemory::hasKey ( const Name keyName) const
overridevirtual

Check the existence of a key with keyName.

Returns
true if the key exists, otherwise false. Return false if the identity does not exist

Implements ndn::security::pib::PibImpl.

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

Referenced by getKeyBits(), and setDefaultKeyOfIdentity().

◆ addKey()

void ndn::security::pib::PibMemory::addKey ( const Name identity,
const Name keyName,
span< const uint8_t >  key 
)
overridevirtual

Add a key.

If a key with the same name already exists, overwrite the key. If the identity does not exist, it will be created. If no default key of the identity has been set, set the added one as default key of the identity. If no default identity has been set, identity becomes the default.

Parameters
identityThe name of the identity that will own the added key.
keyNameThe key name.
keyThe public key bits.

Implements ndn::security::pib::PibImpl.

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

References addIdentity().

Referenced by addCertificate().

◆ removeKey()

void ndn::security::pib::PibMemory::removeKey ( const Name keyName)
overridevirtual

Remove a key with keyName and related certificates.

If the key does not exist, do nothing.

Implements ndn::security::pib::PibImpl.

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

References ndn::security::v2::extractIdentityFromKeyName(), getCertificatesOfKey(), and removeCertificate().

Referenced by removeIdentity().

◆ getKeyBits()

Buffer ndn::security::pib::PibMemory::getKeyBits ( const Name keyName) const
overridevirtual

Get the key bits of a key with name keyName.

Returns
key bits
Exceptions
Pib::Errorthe key does not exist.

Implements ndn::security::pib::PibImpl.

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

References hasKey(), NDN_THROW, and ndn::Name::toUri().

◆ getKeysOfIdentity()

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

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

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

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

Implements ndn::security::pib::PibImpl.

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

References ndn::security::v2::extractIdentityFromKeyName().

Referenced by removeIdentity().

◆ setDefaultKeyOfIdentity()

void ndn::security::pib::PibMemory::setDefaultKeyOfIdentity ( const Name identity,
const Name keyName 
)
overridevirtual

Set an key with keyName as the default key of an identity with name identity.

Exceptions
Pib::Errorthe key does not exist.

Implements ndn::security::pib::PibImpl.

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

References hasKey(), NDN_THROW, and ndn::Name::toUri().

◆ getDefaultKeyOfIdentity()

Name ndn::security::pib::PibMemory::getDefaultKeyOfIdentity ( const Name identity) const
overridevirtual
Returns
The name of the default key of an identity with name identity.
Exceptions
Pib::Errorno default key or the identity does not exist.

Implements ndn::security::pib::PibImpl.

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

References NDN_THROW, and ndn::Name::toUri().

◆ hasCertificate()

bool ndn::security::pib::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::pib::PibImpl.

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

Referenced by getCertificate(), and setDefaultCertificateOfKey().

◆ addCertificate()

void ndn::security::pib::PibMemory::addCertificate ( const Certificate &  certificate)
overridevirtual

Add a certificate.

If a certificate with the same name (without implicit digest) already exists, overwrite the certificate. If the key or identity does not exist, they will be created. If no default certificate of the key has been set, set the added one as default certificate of the key. If no default key was set for the identity, it will be set as default key for the identity. If no default identity was selected, the certificate's identity becomes default.

Parameters
certificateThe certificate to add.

Implements ndn::security::pib::PibImpl.

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

References addKey().

◆ removeCertificate()

void ndn::security::pib::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::pib::PibImpl.

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

References ndn::security::v2::extractKeyNameFromCertName().

Referenced by removeKey().

◆ getCertificate()

Certificate ndn::security::pib::PibMemory::getCertificate ( const Name certName) const
overridevirtual

Get a certificate with name certName.

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

Implements ndn::security::pib::PibImpl.

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

References hasCertificate(), NDN_THROW, and ndn::Name::toUri().

◆ getCertificatesOfKey()

std::set< Name > ndn::security::pib::PibMemory::getCertificatesOfKey ( const Name keyName) const
overridevirtual

Get a list of certificate names of a key with id keyName.

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

Returns
The certificate name set. If the key does not exist, return an empty set.

Implements ndn::security::pib::PibImpl.

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

References ndn::security::v2::extractKeyNameFromCertName().

Referenced by removeKey().

◆ setDefaultCertificateOfKey()

void ndn::security::pib::PibMemory::setDefaultCertificateOfKey ( const Name keyName,
const Name certName 
)
overridevirtual

Set a cert with name certName as the default of a key with keyName.

Exceptions
Pib::Errorthe certificate with name certName does not exist.

Implements ndn::security::pib::PibImpl.

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

References hasCertificate(), NDN_THROW, and ndn::Name::toUri().

◆ getDefaultCertificateOfKey()

Certificate ndn::security::pib::PibMemory::getDefaultCertificateOfKey ( const Name keyName) const
overridevirtual
Returns
Get the default certificate of a key with keyName.
Exceptions
Pib::Errorthe default certificate does not exist.

Implements ndn::security::pib::PibImpl.

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

References NDN_THROW, and ndn::Name::toUri().


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