An in-memory implementation of Pib. More...
#include <pib-memory.hpp>
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< Name > | getIdentities () 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::Component > | getKeysOfIdentity (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< Name > | getCertificatesOfKey (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 () |
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.
ndn::security::PibMemory::PibMemory | ( | ) |
Definition at line 28 of file pib-memory.cpp.
Referenced by ndn::security::PibMemory::Error::Error().
|
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.
tpmLocator | The 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().
|
overridevirtual |
Get TPM Locator.
Implements ndn::security::PibImpl.
Definition at line 40 of file pib-memory.cpp.
Referenced by ndn::security::PibMemory::Error::Error().
|
overridevirtual |
Check the existence of an identity.
identity | The name of the identity. |
Implements ndn::security::PibImpl.
Definition at line 46 of file pib-memory.cpp.
Referenced by ndn::security::PibMemory::Error::Error().
|
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.
identity | The 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().
|
overridevirtual |
Remove an identity.
If the identity does not exist, do nothing. Remove related keys and certificates as well.
identity | The 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().
|
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().
|
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.
identityName | The 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().
|
overridevirtual |
Get the default identity.
Pib::Error | if no default identity. |
Implements ndn::security::PibImpl.
Definition at line 90 of file pib-memory.cpp.
Referenced by ndn::security::PibMemory::Error::Error().
|
overridevirtual |
Check the existence of a key.
identity | The name of the belonged identity. |
keyId | The key id component. |
Implements ndn::security::PibImpl.
Definition at line 99 of file pib-memory.cpp.
Referenced by ndn::security::PibMemory::Error::Error(), getKeyBits(), and setDefaultKeyOfIdentity().
|
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.
identity | The name of the belonged identity. |
keyId | The key id component. |
publicKey | The 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().
|
overridevirtual |
Remove a key.
If the key does not exist, do nothing. Remove related certificates as well.
identity | The name of the belonged identity. |
keyId | The 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().
|
overridevirtual |
Get the key bits of a key.
identity | The name of the belonged identity. |
keyId | The key id component. |
Pib::Error | if 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().
|
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.
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().
|
overridevirtual |
Set an key with id keyId
as the default key of an identity with name identity
.
identity | The name of the belonged identity. |
keyId | The key id component. |
Pib::Error | if 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().
|
overridevirtual |
Get the id of the default key of an identity with name identity
.
identity | The name of the belonged identity. |
Pib::Error | if 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().
|
overridevirtual |
Check the existence of a certificate with name certName
.
certName | The name of the certificate. |
Implements ndn::security::PibImpl.
Definition at line 181 of file pib-memory.cpp.
Referenced by ndn::security::PibMemory::Error::Error(), getCertificate(), and setDefaultCertificateOfKey().
|
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.
certificate | The 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().
|
overridevirtual |
Remove a certificate with name certName
.
If the certificate does not exist, do nothing.
certName | The 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().
|
overridevirtual |
Get a certificate with name certName
.
certName | The name of the certificate. |
Pib::Error | if 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().
|
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.
identity | The name of the belonging identity. |
keyId | The key id. |
Implements ndn::security::PibImpl.
Definition at line 218 of file pib-memory.cpp.
Referenced by ndn::security::PibMemory::Error::Error(), and removeKey().
|
overridevirtual |
Set a cert with name certName
as the default of a key with id keyId
of identity
.
identity | The name of the belonging identity. |
keyId | The key id. |
certName | The name of the certificate. |
Pib::Error | if 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().
|
overridevirtual |
Get the default certificate of a key with id keyId
of identity
.
identity | The name of the belonging identity. |
keyId | The key id. |
Pib::Error | if 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().