Pib backend implementation based on SQLite3 database. More...
#include <pib-sqlite3.hpp>
Public Member Functions | |
PibSqlite3 (const std::string &dir="") | |
Constructor of PibSqlite3. More... | |
~PibSqlite3 () | |
Destruct and cleanup internal state. More... | |
virtual void | setTpmLocator (const std::string &tpmLocator) final |
Set the corresponding TPM information to tpmLocator . More... | |
virtual std::string | getTpmLocator () const final |
Get TPM Locator. More... | |
virtual bool | hasIdentity (const Name &identity) const final |
Check the existence of an identity. More... | |
virtual void | addIdentity (const Name &identity) final |
Add an identity. More... | |
virtual void | removeIdentity (const Name &identity) final |
Remove an identity. More... | |
virtual std::set< Name > | getIdentities () const final |
Get the name of all the identities. More... | |
virtual void | setDefaultIdentity (const Name &identityName) final |
Set an identity with name identityName as the default identity. More... | |
virtual Name | getDefaultIdentity () const final |
Get the default identity. More... | |
virtual bool | hasKey (const Name &identity, const name::Component &keyId) const final |
Check the existence of a key. More... | |
virtual void | addKey (const Name &identity, const name::Component &keyId, const PublicKey &publicKey) final |
Add a key. More... | |
virtual void | removeKey (const Name &identity, const name::Component &keyId) final |
Remove a key. More... | |
virtual PublicKey | getKeyBits (const Name &identity, const name::Component &keyId) const final |
Get the key bits of a key. More... | |
virtual std::set< name::Component > | getKeysOfIdentity (const Name &identity) const final |
Get all the key ids of an identity with name identity . More... | |
virtual void | setDefaultKeyOfIdentity (const Name &identity, const name::Component &keyId) final |
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 final |
Get the id of the default key of an identity with name identity . More... | |
virtual bool | hasCertificate (const Name &certName) const final |
Check the existence of a certificate with name certName . More... | |
virtual void | addCertificate (const IdentityCertificate &certificate) final |
Add a certificate. More... | |
virtual void | removeCertificate (const Name &certName) final |
Remove a certificate with name certName . More... | |
virtual IdentityCertificate | getCertificate (const Name &certName) const final |
Get a certificate with name certName . More... | |
virtual std::set< Name > | getCertificatesOfKey (const Name &identity, const name::Component &keyId) const final |
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) final |
Set a cert with name certName as the default of a key with id of . More... | |
virtual IdentityCertificate | getDefaultCertificateOfKey (const Name &identity, const name::Component &keyId) const final |
Get the default certificate of a key with id of . More... | |
Public Member Functions inherited from ndn::security::PibImpl | |
virtual | ~PibImpl () |
Pib backend implementation based on SQLite3 database.
All the contents in Pib are stored in a SQLite3 database file. This backend provides more persistent storage than PibMemory.
Definition at line 38 of file pib-sqlite3.hpp.
|
explicit |
Constructor of PibSqlite3.
This method will create a SQLite3 database file under the directory dir
. If the directory does not exist, it will be created automatically. It assumes that the directory does not contain a PIB database of an older version, It is user's responsibility to update the older version database or remove the database.
dir | The directory where the database file is located. By default, it points to the $HOME/.ndn directory. |
PibImpl::Error | when initialization fails. |
Definition at line 214 of file pib-sqlite3.cpp.
References ndn::security::INITIALIZATION.
ndn::security::PibSqlite3::~PibSqlite3 | ( | ) |
Destruct and cleanup internal state.
Definition at line 255 of file pib-sqlite3.cpp.
|
finalvirtual |
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.
tmpLocator | The name for the new tmpLocator |
Implements ndn::security::PibImpl.
Definition at line 261 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), and ndn::util::Sqlite3Statement::step().
|
finalvirtual |
Get TPM Locator.
Implements ndn::security::PibImpl.
Definition at line 276 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::getString(), and ndn::util::Sqlite3Statement::step().
|
finalvirtual |
Check the existence of an identity.
identity | The name of the identity. |
Implements ndn::security::PibImpl.
Definition at line 289 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
Referenced by getDefaultKeyOfIdentity().
|
finalvirtual |
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 297 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
Referenced by addKey().
|
finalvirtual |
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 305 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
|
finalvirtual |
Get the name of all the identities.
Implements ndn::security::PibImpl.
Definition at line 313 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::getBlock(), and ndn::util::Sqlite3Statement::step().
|
finalvirtual |
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 325 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
|
finalvirtual |
Get the default identity.
Pib::Error | if no default identity. |
Implements ndn::security::PibImpl.
Definition at line 333 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::getBlock(), ns3::ndn::Name, and ndn::util::Sqlite3Statement::step().
|
finalvirtual |
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 344 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), ndn::security::getKeyName(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
Referenced by addKey(), and setDefaultKeyOfIdentity().
|
finalvirtual |
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 355 of file pib-sqlite3.cpp.
References addIdentity(), ndn::util::Sqlite3Statement::bind(), ndn::Buffer::buf(), ndn::PublicKey::get(), ndn::security::getKeyName(), ndn::PublicKey::getKeyType(), hasKey(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
Referenced by addCertificate().
|
finalvirtual |
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 378 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), ndn::security::getKeyName(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
|
finalvirtual |
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 388 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::getBlob(), ndn::security::getKeyName(), ndn::util::Sqlite3Statement::getSize(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
|
finalvirtual |
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 402 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::getBlock(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
|
finalvirtual |
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 421 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), ndn::security::getKeyName(), hasKey(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
|
finalvirtual |
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 435 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), ndn::Name::get(), ndn::util::Sqlite3Statement::getBlock(), hasIdentity(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
|
finalvirtual |
Check the existence of a certificate with name certName
.
certName | The name of the certificate. |
Implements ndn::security::PibImpl.
Definition at line 456 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
Referenced by setDefaultCertificateOfKey().
|
finalvirtual |
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 464 of file pib-sqlite3.cpp.
References addKey(), ndn::Name::get(), ndn::Data::getName(), ndn::Name::getPrefix(), ndn::Certificate::getPublicKeyInfo(), ndn::IdentityCertificate::getPublicKeyName(), ndn::Data::wireEncode(), and ndn::Name::wireEncode().
|
finalvirtual |
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 486 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
|
finalvirtual |
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 494 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::getBlock(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
|
finalvirtual |
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 507 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::getBlock(), ndn::security::getKeyName(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
|
finalvirtual |
Set a cert with name certName
as the default of a key with id of .
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 526 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), hasCertificate(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().
|
finalvirtual |
Get the default certificate of a key with id of .
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 540 of file pib-sqlite3.cpp.
References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::getBlock(), ndn::security::getKeyName(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().