All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | Static Public Member Functions | List of all members
ndn::PibSqlite3 Class Reference

PibSqlite3 extends PibImpl and is used by the Pib class as an implementation of a PIB based on an SQLite3 database. More...

#include <pib-sqlite3.hpp>

Inheritance diagram for ndn::PibSqlite3:
ndn::PibImpl

Public Member Functions

 PibSqlite3 (const std::string &databaseDirectoryPath="", const std::string &databaseFilename="pib.db")
 Create a new PibSqlite3 to work with an SQLite3 file. More...
 
virtual ~PibSqlite3 ()
 Destroy and clean up the internal state.
 
virtual void setTpmLocator (const std::string &tpmLocator)
 Set the corresponding TPM information to tpmLocator. More...
 
virtual std::string getTpmLocator () const
 Get the TPM Locator. More...
 
virtual bool hasIdentity (const Name &identityName) const
 Check for the existence of an identity. More...
 
virtual void addIdentity (const Name &identityName)
 Add the identity. More...
 
virtual void removeIdentity (const Name &identityName)
 Remove the identity and its related keys and certificates. More...
 
virtual void clearIdentities ()
 Erase all certificates, keys, and identities.
 
virtual std::set< NamegetIdentities () const
 Get the names of all the identities. More...
 
virtual void setDefaultIdentity (const Name &identityName)
 Set the identity with the identityName as the default identity. More...
 
virtual Name getDefaultIdentity () const
 Get the default identity. More...
 
virtual bool hasKey (const Name &keyName) const
 Check for the existence of a key with keyName. More...
 
virtual void addKey (const Name &identityName, const Name &keyName, const uint8_t *key, size_t keyLength)
 Add the key. More...
 
virtual void removeKey (const Name &keyName)
 Remove the key with keyName and its related certificates. More...
 
virtual Blob getKeyBits (const Name &keyName) const
 Get the key bits of a key with name keyName. More...
 
virtual std::set< NamegetKeysOfIdentity (const Name &identityName) const
 Get all the key names of the identity with the name identityName. More...
 
virtual void setDefaultKeyOfIdentity (const Name &identityName, const Name &keyName)
 Set the key with keyName as the default key for the identity with name identityName. More...
 
virtual Name getDefaultKeyOfIdentity (const Name &identityName) const
 Get the name of the default key for the identity with name identityName. More...
 
virtual bool hasCertificate (const Name &certificateName) const
 Check for the existence of a certificate with name certificateName. More...
 
virtual void addCertificate (const CertificateV2 &certificate)
 Add the certificate. More...
 
virtual void removeCertificate (const Name &certificateName)
 Remove the certificate with name certificateName. More...
 
virtual ptr_lib::shared_ptr
< CertificateV2
getCertificate (const Name &certificateName) const
 Get the certificate with name certificateName. More...
 
virtual std::set< NamegetCertificatesOfKey (const Name &keyName) const
 Get a list of certificate names of the key with id keyName. More...
 
virtual void setDefaultCertificateOfKey (const Name &keyName, const Name &certificateName)
 Set the cert with name certificateName as the default for the key with keyName. More...
 
virtual ptr_lib::shared_ptr
< CertificateV2
getDefaultCertificateOfKey (const Name &keyName) const
 Get the default certificate for the key with eyName. More...
 

Static Public Member Functions

static std::string getScheme ()
 
static std::string getDefaultDatabaseDirectoryPath ()
 Get the default that the constructor uses if databaseDirectoryPath is omitted. More...
 
static std::string getDefaultDatabaseFilePath ()
 Get the default database file path that the constructor uses if databaseDirectoryPath and databaseFilename are omitted. More...
 

Detailed Description

PibSqlite3 extends PibImpl and is used by the Pib class as an implementation of a PIB based on an SQLite3 database.

All the contents in the PIB are stored in an SQLite3 database file. This provides more persistent storage than PibMemory.

Constructor & Destructor Documentation

ndn::PibSqlite3::PibSqlite3 ( const std::string &  databaseDirectoryPath = "",
const std::string &  databaseFilename = "pib.db" 
)

Create a new PibSqlite3 to work with an SQLite3 file.

This assumes that the database directory does not contain a PIB database of an older version.

Parameters
databaseDirectoryPath(optional) The directory where the database file is located. If omitted, use $HOME/.ndn . If the directory does not exist, create it.
databaseFilename(optional) The name if the database file in the databaseDirectoryPath. If omitted, use "pib.db".
Exceptions
PibImpl::Errorif initialization fails.

Member Function Documentation

virtual void ndn::PibSqlite3::addCertificate ( const CertificateV2 certificate)
virtual

Add the certificate.

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

Parameters
certificateThe certificate to add. This copies the object.

Implements ndn::PibImpl.

virtual void ndn::PibSqlite3::addIdentity ( const Name identityName)
virtual

Add the identity.

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

Parameters
identityNameThe name of the identity to add. This copies the name.

Implements ndn::PibImpl.

virtual void ndn::PibSqlite3::addKey ( const Name identityName,
const Name keyName,
const uint8_t *  key,
size_t  keyLength 
)
virtual

Add the 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 for the identity has been set, then set the added key as the default for the identity. If no default identity has been set, identity becomes the default.

Parameters
identityNameThe name of the identity that the key belongs to. This copies the name.
keyNameThe name of the key. This copies the name.
keyThe public key bits. This copies the array.
keyLengthThe length of the public key bits array.

Implements ndn::PibImpl.

virtual ptr_lib::shared_ptr<CertificateV2> ndn::PibSqlite3::getCertificate ( const Name certificateName) const
virtual

Get the certificate with name certificateName.

Parameters
certificateNameThe name of the certificate.
Returns
A copy of the certificate.
Exceptions
Pib::Errorif the certificate does not exist.

Implements ndn::PibImpl.

virtual std::set<Name> ndn::PibSqlite3::getCertificatesOfKey ( const Name keyName) const
virtual

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

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

Parameters
keyNameThe name of the key.
Returns
The set of certificate names. The Name objects are fresh copies. If the key does not exist, return an empty set.

Implements ndn::PibImpl.

virtual ptr_lib::shared_ptr<CertificateV2> ndn::PibSqlite3::getDefaultCertificateOfKey ( const Name keyName) const
virtual

Get the default certificate for the key with eyName.

Parameters
keyNameThe name of the key.
Returns
A copy of the default certificate.
Exceptions
Pib::Errorif the default certificate does not exist.

Implements ndn::PibImpl.

static std::string ndn::PibSqlite3::getDefaultDatabaseDirectoryPath ( )
static

Get the default that the constructor uses if databaseDirectoryPath is omitted.

This does not try to create the directory.

Returns
The default database directory path.
static std::string ndn::PibSqlite3::getDefaultDatabaseFilePath ( )
inlinestatic

Get the default database file path that the constructor uses if databaseDirectoryPath and databaseFilename are omitted.

Returns
The default database file path.
virtual Name ndn::PibSqlite3::getDefaultIdentity ( ) const
virtual

Get the default identity.

Returns
The name of the default identity, as a fresh copy.
Exceptions
Pib::Errorfor no default identity.

Implements ndn::PibImpl.

virtual Name ndn::PibSqlite3::getDefaultKeyOfIdentity ( const Name identityName) const
virtual

Get the name of the default key for the identity with name identityName.

Parameters
identityNameThe name of the identity.
Returns
The name of the default key, as a fresh copy.
Exceptions
Pib::Errorif there is no default key or if the identity does not exist.

Implements ndn::PibImpl.

virtual std::set<Name> ndn::PibSqlite3::getIdentities ( ) const
virtual

Get the names of all the identities.

Returns
The set of identity names. The Name objects are fresh copies.

Implements ndn::PibImpl.

virtual Blob ndn::PibSqlite3::getKeyBits ( const Name keyName) const
virtual

Get the key bits of a key with name keyName.

Parameters
keyNameThe name of the key.
Returns
The key bits.
Exceptions
Pib::Errorif the key does not exist.

Implements ndn::PibImpl.

virtual std::set<Name> ndn::PibSqlite3::getKeysOfIdentity ( const Name identityName) const
virtual

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

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

Parameters
identityNameThe name of the identity.
Returns
The set of key names. The Name objects are fresh copies. If the identity does not exist, return an empty set.

Implements ndn::PibImpl.

virtual std::string ndn::PibSqlite3::getTpmLocator ( ) const
virtual

Get the TPM Locator.

Returns
The TPM locator string.

Implements ndn::PibImpl.

virtual bool ndn::PibSqlite3::hasCertificate ( const Name certificateName) const
virtual

Check for the existence of a certificate with name certificateName.

Parameters
certificateNameThe name of the certificate.
Returns
True if the certificate exists, otherwise false.

Implements ndn::PibImpl.

virtual bool ndn::PibSqlite3::hasIdentity ( const Name identityName) const
virtual

Check for the existence of an identity.

Parameters
identityNameThe name of the identity.
Returns
True if the identity exists, otherwise false.

Implements ndn::PibImpl.

virtual bool ndn::PibSqlite3::hasKey ( const Name keyName) const
virtual

Check for the existence of a key with keyName.

Parameters
keyNameThe name of the key.
Returns
True if the key exists, otherwise false. Return false if the identity does not exist.

Implements ndn::PibImpl.

virtual void ndn::PibSqlite3::removeCertificate ( const Name certificateName)
virtual

Remove the certificate with name certificateName.

If the certificate does not exist, do nothing.

Parameters
certificateNameThe name of the certificate.

Implements ndn::PibImpl.

virtual void ndn::PibSqlite3::removeIdentity ( const Name identityName)
virtual

Remove the identity and its 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
identityNameThe name of the identity to remove.

Implements ndn::PibImpl.

virtual void ndn::PibSqlite3::removeKey ( const Name keyName)
virtual

Remove the key with keyName and its related certificates.

If the key does not exist, do nothing.

Parameters
keyNameThe name of the key.

Implements ndn::PibImpl.

virtual void ndn::PibSqlite3::setDefaultCertificateOfKey ( const Name keyName,
const Name certificateName 
)
virtual

Set the cert with name certificateName as the default for the key with keyName.

Parameters
keyNameThe name of the key.
certificateNameThe name of the certificate. This copies the name.
Exceptions
Pib::Errorif the certificate with name certificateName does not exist.

Implements ndn::PibImpl.

virtual void ndn::PibSqlite3::setDefaultIdentity ( const Name identityName)
virtual

Set the identity with the identityName as the default identity.

If the identity with identityName does not exist, then it will be created.

Parameters
identityNameThe name for the default identity. This copies the name.

Implements ndn::PibImpl.

virtual void ndn::PibSqlite3::setDefaultKeyOfIdentity ( const Name identityName,
const Name keyName 
)
virtual

Set the key with keyName as the default key for the identity with name identityName.

Parameters
identityNameThe name of the identity.
keyNameThe name of the key. This copies the name.
Exceptions
Pib::Errorif the key does not exist.

Implements ndn::PibImpl.

virtual void ndn::PibSqlite3::setTpmLocator ( const std::string &  tpmLocator)
virtual

Set the corresponding TPM information to tpmLocator.

This method does not reset the contents of the PIB.

Parameters
tpmLocatorThe TPM locator string.

Implements ndn::PibImpl.


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