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

Pib backend implementation based on SQLite3 database. More...

#include <pib-sqlite3.hpp>

Inheritance diagram for ndn::security::PibSqlite3:
Collaboration diagram for ndn::security::PibSqlite3:

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< NamegetIdentities () 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::ComponentgetKeysOfIdentity (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< NamegetCertificatesOfKey (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 keyId of identity. More...
 
virtual IdentityCertificate getDefaultCertificateOfKey (const Name &identity, const name::Component &keyId) const final
 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

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.

Constructor & Destructor Documentation

§ PibSqlite3()

ndn::security::PibSqlite3::PibSqlite3 ( const std::string &  dir = "")
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.

Parameters
dirThe directory where the database file is located. By default, it points to the $HOME/.ndn directory.
Exceptions
PibImpl::Errorwhen initialization fails.

Definition at line 214 of file pib-sqlite3.cpp.

§ ~PibSqlite3()

ndn::security::PibSqlite3::~PibSqlite3 ( )

Destruct and cleanup internal state.

Definition at line 255 of file pib-sqlite3.cpp.

Member Function Documentation

§ setTpmLocator()

void ndn::security::PibSqlite3::setTpmLocator ( const std::string &  tpmLocator)
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.

Parameters
tpmLocatorThe name for the new TPM locator

Implements ndn::security::PibImpl.

Definition at line 261 of file pib-sqlite3.cpp.

References ndn::util::Sqlite3Statement::bind(), and ndn::util::Sqlite3Statement::step().

§ getTpmLocator()

std::string ndn::security::PibSqlite3::getTpmLocator ( ) const
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().

§ hasIdentity()

bool ndn::security::PibSqlite3::hasIdentity ( const Name identity) const
finalvirtual

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 289 of file pib-sqlite3.cpp.

References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().

Referenced by getDefaultKeyOfIdentity().

§ addIdentity()

void ndn::security::PibSqlite3::addIdentity ( const Name identity)
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.

Parameters
identityThe 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(), and ndn::security::Pib::setDefaultIdentity().

§ removeIdentity()

void ndn::security::PibSqlite3::removeIdentity ( const Name identity)
finalvirtual

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 305 of file pib-sqlite3.cpp.

References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().

§ getIdentities()

std::set< Name > ndn::security::PibSqlite3::getIdentities ( ) const
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().

§ setDefaultIdentity()

void ndn::security::PibSqlite3::setDefaultIdentity ( const Name identityName)
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.

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

§ getDefaultIdentity()

Name ndn::security::PibSqlite3::getDefaultIdentity ( ) const
finalvirtual

Get the default identity.

Returns
The name for the default identity.
Exceptions
Pib::Errorif 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().

§ hasKey()

bool ndn::security::PibSqlite3::hasKey ( const Name identity,
const name::Component keyId 
) const
finalvirtual

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

§ addKey()

void ndn::security::PibSqlite3::addKey ( const Name identity,
const name::Component keyId,
const PublicKey publicKey 
)
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.

Parameters
identityThe name of the belonged identity.
keyIdThe key id component.
publicKeyThe 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().

§ removeKey()

void ndn::security::PibSqlite3::removeKey ( const Name identity,
const name::Component keyId 
)
finalvirtual

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 378 of file pib-sqlite3.cpp.

References ndn::util::Sqlite3Statement::bind(), ndn::security::getKeyName(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().

§ getKeyBits()

PublicKey ndn::security::PibSqlite3::getKeyBits ( const Name identity,
const name::Component keyId 
) const
finalvirtual

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

§ getKeysOfIdentity()

std::set< name::Component > ndn::security::PibSqlite3::getKeysOfIdentity ( const Name identity) const
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.

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

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

§ setDefaultKeyOfIdentity()

void ndn::security::PibSqlite3::setDefaultKeyOfIdentity ( const Name identity,
const name::Component keyId 
)
finalvirtual

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 421 of file pib-sqlite3.cpp.

References ndn::util::Sqlite3Statement::bind(), ndn::security::getKeyName(), hasKey(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().

§ getDefaultKeyOfIdentity()

name::Component ndn::security::PibSqlite3::getDefaultKeyOfIdentity ( const Name identity) const
finalvirtual

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

§ hasCertificate()

bool ndn::security::PibSqlite3::hasCertificate ( const Name certName) const
finalvirtual

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 456 of file pib-sqlite3.cpp.

References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().

Referenced by setDefaultCertificateOfKey().

§ addCertificate()

void ndn::security::PibSqlite3::addCertificate ( const IdentityCertificate certificate)
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.

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

§ removeCertificate()

void ndn::security::PibSqlite3::removeCertificate ( const Name certName)
finalvirtual

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 486 of file pib-sqlite3.cpp.

References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().

§ getCertificate()

IdentityCertificate ndn::security::PibSqlite3::getCertificate ( const Name certName) const
finalvirtual

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 494 of file pib-sqlite3.cpp.

References ndn::util::Sqlite3Statement::bind(), ndn::util::Sqlite3Statement::getBlock(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().

§ getCertificatesOfKey()

std::set< Name > ndn::security::PibSqlite3::getCertificatesOfKey ( const Name identity,
const name::Component keyId 
) const
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.

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

§ setDefaultCertificateOfKey()

void ndn::security::PibSqlite3::setDefaultCertificateOfKey ( const Name identity,
const name::Component keyId,
const Name certName 
)
finalvirtual

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 526 of file pib-sqlite3.cpp.

References ndn::util::Sqlite3Statement::bind(), hasCertificate(), ndn::util::Sqlite3Statement::step(), and ndn::Name::wireEncode().

§ getDefaultCertificateOfKey()

IdentityCertificate ndn::security::PibSqlite3::getDefaultCertificateOfKey ( const Name identity,
const name::Component keyId 
) const
finalvirtual

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


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