ndn::security::v1::SecPublicInfoSqlite3 Class Reference

#include <sec-public-info-sqlite3.hpp>

Inheritance diagram for ndn::security::v1::SecPublicInfoSqlite3:
[legend]
Collaboration diagram for ndn::security::v1::SecPublicInfoSqlite3:
[legend]

Data Structures

class  Error
 

Public Member Functions

 SecPublicInfoSqlite3 (const std::string &dir="")
 
virtual ~SecPublicInfoSqlite3 ()
 
virtual void setTpmLocator (const std::string &tpmLocator)
 Set the corresponding TPM information to tpmLocator. More...
 
virtual std::string getTpmLocator ()
 Get TPM Locator. More...
 
virtual std::string getPibLocator ()
 
virtual bool doesIdentityExist (const Name &identityName)
 Check if the specified identity already exists. More...
 
virtual void addIdentity (const Name &identityName)
 Add a new identity. More...
 
virtual bool revokeIdentity ()
 Revoke the identity. More...
 
virtual bool doesPublicKeyExist (const Name &keyName)
 Check if the specified key already exists. More...
 
virtual void addKey (const Name &keyName, const PublicKey &publicKeyDer)
 Add a public key to the identity storage. More...
 
virtual shared_ptr< PublicKeygetPublicKey (const Name &keyName)
 Get shared pointer to PublicKey object from the identity storage. More...
 
virtual KeyType getPublicKeyType (const Name &keyName)
 Get the type of the queried public key. More...
 
virtual bool doesCertificateExist (const Name &certificateName)
 Check if the specified certificate already exists. More...
 
virtual void addCertificate (const IdentityCertificate &certificate)
 Add a certificate to the identity storage. More...
 
virtual shared_ptr< IdentityCertificategetCertificate (const Name &certificateName)
 Get a shared pointer to identity certificate object from the identity storage. More...
 
virtual Name getDefaultIdentity ()
 Get name of the default identity. More...
 
virtual Name getDefaultKeyNameForIdentity (const Name &identityName)
 Get name of the default key name for the specified identity. More...
 
virtual Name getDefaultCertificateNameForKey (const Name &keyName)
 Get name of the default certificate name for the specified key. More...
 
virtual void getAllIdentities (std::vector< Name > &nameList, bool isDefault)
 Get all the identities from public info. More...
 
virtual void getAllKeyNames (std::vector< Name > &nameList, bool isDefault)
 Get all the key names from public info. More...
 
virtual void getAllKeyNamesOfIdentity (const Name &identity, std::vector< Name > &nameList, bool isDefault)
 Get all the key names of a particular identity. More...
 
virtual void getAllCertificateNames (std::vector< Name > &nameList, bool isDefault)
 Get all the certificate name in public info. More...
 
virtual void getAllCertificateNamesOfKey (const Name &keyName, std::vector< Name > &nameList, bool isDefault)
 Get all the certificate name of a particular key name. More...
 
virtual void deleteCertificateInfo (const Name &certificateName)
 Delete a certificate. More...
 
virtual void deletePublicKeyInfo (const Name &keyName)
 Delete a public key and related certificates. More...
 
virtual void deleteIdentityInfo (const Name &identity)
 Delete an identity and related public keys and certificates. More...
 
void addPublicKey (const Name &keyName, KeyType keyType, const PublicKey &publicKey)
 Add a public key to the identity storage. More...
 
void setDefaultIdentity (const Name &identityName)
 Set the default identity. More...
 
void setDefaultKeyNameForIdentity (const Name &keyName)
 Set the default key name for the corresponding identity. More...
 
void setDefaultCertificateNameForKey (const Name &certificateName)
 Set the default certificate name for the corresponding key. More...
 
Name getNewKeyName (const Name &identityName, bool useKsk)
 Generate a key name for the identity. More...
 
Name getDefaultCertificateNameForIdentity (const Name &identityName)
 Get the default certificate name for the specified identity. More...
 
Name getDefaultCertificateName ()
 Get the default certificate name of the default identity. More...
 
void addCertificateAsKeyDefault (const IdentityCertificate &certificate)
 Add a certificate and set the certificate as the default one of its corresponding key. More...
 
void addCertificateAsIdentityDefault (const IdentityCertificate &certificate)
 Add a certificate into the public key identity storage and set the certificate as the default one of its corresponding identity. More...
 
void addCertificateAsSystemDefault (const IdentityCertificate &certificate)
 Add a certificate into the public key identity storage and set the certificate as the default one of the default identity. More...
 
shared_ptr< IdentityCertificatedefaultCertificate ()
 Get cached default certificate of the default identity. More...
 
shared_ptr< IdentityCertificategetDefaultCertificate ()
 Get cached default certificate of the default identity. More...
 
void refreshDefaultCertificate ()
 try to get the default certificate of the default identity from the public info More...
 

Static Public Attributes

static const std::string SCHEME
 

Protected Attributes

shared_ptr< IdentityCertificatem_defaultCertificate
 
std::string m_location
 

Detailed Description

Definition at line 37 of file v1/sec-public-info-sqlite3.hpp.

Constructor & Destructor Documentation

ndn::security::v1::SecPublicInfoSqlite3::SecPublicInfoSqlite3 ( const std::string &  dir = "")
explicit
Todo:
Add define for windows/unix in wscript. The following may completely fail on windows

Definition at line 114 of file sec-public-info-sqlite3.cpp.

ndn::security::v1::SecPublicInfoSqlite3::~SecPublicInfoSqlite3 ( )
virtual

Definition at line 159 of file sec-public-info-sqlite3.cpp.

Member Function Documentation

void ndn::security::v1::SecPublicInfoSqlite3::addCertificate ( const IdentityCertificate certificate)
virtual

Add a certificate to the identity storage.

It will add the corresponding public key and identity if they do not exist

Parameters
certificateThe certificate to be added

Implements ndn::security::v1::SecPublicInfo.

Definition at line 488 of file sec-public-info-sqlite3.cpp.

void ndn::security::v1::SecPublicInfo::addCertificateAsIdentityDefault ( const IdentityCertificate certificate)
inherited

Add a certificate into the public key identity storage and set the certificate as the default one of its corresponding identity.

Parameters
certificateThe certificate to be added
Exceptions
SecPublicInfo::Errorif the certificate cannot be added (though it is really rare)

Definition at line 117 of file sec-public-info.cpp.

void ndn::security::v1::SecPublicInfo::addCertificateAsKeyDefault ( const IdentityCertificate certificate)
inherited

Add a certificate and set the certificate as the default one of its corresponding key.

Parameters
certificateThe certificate to be added
Exceptions
SecPublicInfo::Errorif the certificate cannot be added (though it is really rare)

Definition at line 109 of file sec-public-info.cpp.

void ndn::security::v1::SecPublicInfo::addCertificateAsSystemDefault ( const IdentityCertificate certificate)
inherited

Add a certificate into the public key identity storage and set the certificate as the default one of the default identity.

Parameters
certificateThe certificate to be added
Exceptions
SecPublicInfo::Errorif the certificate cannot be added (though it is really rare)

Definition at line 128 of file sec-public-info.cpp.

void ndn::security::v1::SecPublicInfoSqlite3::addIdentity ( const Name identityName)
virtual

Add a new identity.

if identity already exist, do not add it again

Parameters
identityNameThe identity name to be added

Implements ndn::security::v1::SecPublicInfo.

Definition at line 310 of file sec-public-info-sqlite3.cpp.

void ndn::security::v1::SecPublicInfoSqlite3::addKey ( const Name keyName,
const PublicKey publicKey 
)
virtual

Add a public key to the identity storage.

Parameters
keyNameThe name of the public key to be added
publicKeyReference to the PublicKey object

Implements ndn::security::v1::SecPublicInfo.

Definition at line 367 of file sec-public-info-sqlite3.cpp.

void ndn::security::v1::SecPublicInfo::addPublicKey ( const Name keyName,
KeyType  keyType,
const PublicKey publicKey 
)
inherited

Add a public key to the identity storage.

Parameters
keyNameThe name of the public key to be added
keyTypeType of the public key to be added
publicKeyReference to the PublicKey object
Deprecated:
Use addKey instead

Definition at line 44 of file sec-public-info.cpp.

shared_ptr< IdentityCertificate > ndn::security::v1::SecPublicInfo::defaultCertificate ( )
inherited

Get cached default certificate of the default identity.

Returns
The certificate which might be empty shared_ptr<IdentityCertificate>()
Deprecated:
Use getDefaultCertificate instead

Definition at line 140 of file sec-public-info.cpp.

void ndn::security::v1::SecPublicInfoSqlite3::deleteCertificateInfo ( const Name certificateName)
virtual

Delete a certificate.

Parameters
certificateNameThe certificate name

Implements ndn::security::v1::SecPublicInfo.

Definition at line 889 of file sec-public-info-sqlite3.cpp.

void ndn::security::v1::SecPublicInfoSqlite3::deleteIdentityInfo ( const Name identity)
virtual

Delete an identity and related public keys and certificates.

Parameters
identityThe identity name

Implements ndn::security::v1::SecPublicInfo.

Definition at line 929 of file sec-public-info-sqlite3.cpp.

void ndn::security::v1::SecPublicInfoSqlite3::deletePublicKeyInfo ( const Name keyName)
virtual

Delete a public key and related certificates.

Parameters
keyNameThe key name

Implements ndn::security::v1::SecPublicInfo.

Definition at line 902 of file sec-public-info-sqlite3.cpp.

bool ndn::security::v1::SecPublicInfoSqlite3::doesCertificateExist ( const Name certificateName)
virtual

Check if the specified certificate already exists.

Parameters
certificateNameThe name of the certificate

Implements ndn::security::v1::SecPublicInfo.

Definition at line 464 of file sec-public-info-sqlite3.cpp.

bool ndn::security::v1::SecPublicInfoSqlite3::doesIdentityExist ( const Name identityName)
virtual

Check if the specified identity already exists.

Parameters
identityNameThe identity name
Returns
true if the identity exists, otherwise false

Implements ndn::security::v1::SecPublicInfo.

Definition at line 286 of file sec-public-info-sqlite3.cpp.

bool ndn::security::v1::SecPublicInfoSqlite3::doesPublicKeyExist ( const Name keyName)
virtual

Check if the specified key already exists.

Parameters
keyNameThe name of the key
Returns
true if the key exists, otherwise false

Implements ndn::security::v1::SecPublicInfo.

Definition at line 336 of file sec-public-info-sqlite3.cpp.

void ndn::security::v1::SecPublicInfoSqlite3::getAllCertificateNames ( std::vector< Name > &  nameList,
bool  isDefault 
)
virtual

Get all the certificate name in public info.

Parameters
[out]nameListOn return, the certificate name list
isDefaultIf specified, only the default certificates are returned

Implements ndn::security::v1::SecPublicInfo.

Definition at line 835 of file sec-public-info-sqlite3.cpp.

void ndn::security::v1::SecPublicInfoSqlite3::getAllCertificateNamesOfKey ( const Name keyName,
std::vector< Name > &  nameList,
bool  isDefault 
)
virtual

Get all the certificate name of a particular key name.

Parameters
keyNameThe specified key name
[out]nameListOn return, the certificate name list
isDefaultIf specified, only the default certificate is returned

Implements ndn::security::v1::SecPublicInfo.

Definition at line 856 of file sec-public-info-sqlite3.cpp.

void ndn::security::v1::SecPublicInfoSqlite3::getAllIdentities ( std::vector< Name > &  nameList,
bool  isDefault 
)
virtual

Get all the identities from public info.

Parameters
[out]nameListOn return, the identity list
isDefaultIf specified, only the default identity is returned

Implements ndn::security::v1::SecPublicInfo.

Definition at line 764 of file sec-public-info-sqlite3.cpp.

void ndn::security::v1::SecPublicInfoSqlite3::getAllKeyNames ( std::vector< Name > &  nameList,
bool  isDefault 
)
virtual

Get all the key names from public info.

Parameters
[out]nameListOn return, the key name list.
isDefaultIf specified, only the default keys are returned

Implements ndn::security::v1::SecPublicInfo.

Definition at line 784 of file sec-public-info-sqlite3.cpp.

void ndn::security::v1::SecPublicInfoSqlite3::getAllKeyNamesOfIdentity ( const Name identity,
std::vector< Name > &  nameList,
bool  isDefault 
)
virtual

Get all the key names of a particular identity.

Parameters
identityThe specified identity name
[out]nameListOn return, the key name list
isDefaultIf specified, only the default key is returned

Implements ndn::security::v1::SecPublicInfo.

Definition at line 808 of file sec-public-info-sqlite3.cpp.

shared_ptr< IdentityCertificate > ndn::security::v1::SecPublicInfoSqlite3::getCertificate ( const Name certificateName)
virtual

Get a shared pointer to identity certificate object from the identity storage.

Parameters
certificateNameThe name of the requested certificate
Exceptions
SecPublicInfo::Errorif the certificate does not exist

Implements ndn::security::v1::SecPublicInfo.

Definition at line 543 of file sec-public-info-sqlite3.cpp.

shared_ptr< IdentityCertificate > ndn::security::v1::SecPublicInfo::getDefaultCertificate ( )
inherited

Get cached default certificate of the default identity.

Returns
The certificate which might be empty shared_ptr<IdentityCertificate>()

Definition at line 146 of file sec-public-info.cpp.

Name ndn::security::v1::SecPublicInfo::getDefaultCertificateName ( )
inherited

Get the default certificate name of the default identity.

Returns
The requested certificate name
Exceptions
SecPublicInfo::Errorif no certificate is found

Definition at line 77 of file sec-public-info.cpp.

Name ndn::security::v1::SecPublicInfo::getDefaultCertificateNameForIdentity ( const Name identityName)
inherited

Get the default certificate name for the specified identity.

Parameters
identityNameThe identity name
Returns
The default certificate name
Exceptions
SecPublicInfo::Errorif no certificate is found

Definition at line 71 of file sec-public-info.cpp.

Name ndn::security::v1::SecPublicInfoSqlite3::getDefaultCertificateNameForKey ( const Name keyName)
virtual

Get name of the default certificate name for the specified key.

Parameters
keyNameThe key name.
Exceptions
SecPublicInfo::Errorif there is no default.

Implements ndn::security::v1::SecPublicInfo.

Definition at line 691 of file sec-public-info-sqlite3.cpp.

Name ndn::security::v1::SecPublicInfoSqlite3::getDefaultIdentity ( )
virtual

Get name of the default identity.

Exceptions
SecPublicInfo::Errorif there is no default.

Implements ndn::security::v1::SecPublicInfo.

Definition at line 579 of file sec-public-info-sqlite3.cpp.

Name ndn::security::v1::SecPublicInfoSqlite3::getDefaultKeyNameForIdentity ( const Name identityName)
virtual

Get name of the default key name for the specified identity.

Parameters
identityNameThe identity name
Exceptions
SecPublicInfo::Errorif there is no default

Implements ndn::security::v1::SecPublicInfo.

Definition at line 629 of file sec-public-info-sqlite3.cpp.

Name ndn::security::v1::SecPublicInfo::getNewKeyName ( const Name identityName,
bool  useKsk 
)
inherited

Generate a key name for the identity.

Parameters
identityNameThe identity name
useKskIf true, generate a KSK name, otherwise a DSK name
Returns
The generated key name

Definition at line 89 of file sec-public-info.cpp.

std::string ndn::security::v1::SecPublicInfoSqlite3::getPibLocator ( )
virtual

Definition at line 280 of file sec-public-info-sqlite3.cpp.

shared_ptr< PublicKey > ndn::security::v1::SecPublicInfoSqlite3::getPublicKey ( const Name keyName)
virtual

Get shared pointer to PublicKey object from the identity storage.

Parameters
keyNameThe name of the requested public key
Exceptions
SecPublicInfo::Errorif public key does not exist

Implements ndn::security::v1::SecPublicInfo.

Definition at line 402 of file sec-public-info-sqlite3.cpp.

KeyType ndn::security::v1::SecPublicInfoSqlite3::getPublicKeyType ( const Name keyName)
virtual

Get the type of the queried public key.

Note
KeyType is also available from PublicKey instance. This method is more efficient if only KeyType is needed.
Parameters
keyNameThe name of the requested public key
Returns
the type of the key. If the queried key does not exist, KeyType::NONE will be returned

Implements ndn::security::v1::SecPublicInfo.

Definition at line 434 of file sec-public-info-sqlite3.cpp.

string ndn::security::v1::SecPublicInfoSqlite3::getTpmLocator ( )
virtual

Get TPM Locator.

Exceptions
SecPublicInfo::Errorif the TPM info does not exist

Implements ndn::security::v1::SecPublicInfo.

Definition at line 232 of file sec-public-info-sqlite3.cpp.

void ndn::security::v1::SecPublicInfo::refreshDefaultCertificate ( )
inherited

try to get the default certificate of the default identity from the public info

Definition at line 152 of file sec-public-info.cpp.

bool ndn::security::v1::SecPublicInfoSqlite3::revokeIdentity ( )
virtual

Revoke the identity.

Returns
true if the identity was revoked, otherwise false

Implements ndn::security::v1::SecPublicInfo.

Definition at line 329 of file sec-public-info-sqlite3.cpp.

void ndn::security::v1::SecPublicInfo::setDefaultCertificateNameForKey ( const Name certificateName)
inherited

Set the default certificate name for the corresponding key.

Parameters
certificateNameThe certificate name
Exceptions
SecPublicInfo::Errorif either the certificate or key does not exist

Definition at line 64 of file sec-public-info.cpp.

void ndn::security::v1::SecPublicInfo::setDefaultIdentity ( const Name identityName)
inherited

Set the default identity.

Parameters
identityNameThe default identity name
Exceptions
SecPublicInfo::Errorif the identity does not exist

Definition at line 50 of file sec-public-info.cpp.

void ndn::security::v1::SecPublicInfo::setDefaultKeyNameForIdentity ( const Name keyName)
inherited

Set the default key name for the corresponding identity.

Parameters
keyNameThe key name
Exceptions
SecPublicInfo::Errorif either the identity or key does not exist

Definition at line 57 of file sec-public-info.cpp.

void ndn::security::v1::SecPublicInfoSqlite3::setTpmLocator ( const std::string &  tpmLocator)
virtual

Set the corresponding TPM information to tpmLocator.

If the provided tpmLocator is different from the existing one, the PIB will be reset, otherwise nothing will be changed.

For legacy issue, the TPM info may not exist (some old PIB content may not have this info), this method will simply set the TPM info as provided without changing anything else. Thus an ideal process of handling old PIB is to check if TPM info exists. If it does not exist, then set it to the default value according to configuration.

Implements ndn::security::v1::SecPublicInfo.

Definition at line 214 of file sec-public-info-sqlite3.cpp.

Field Documentation

shared_ptr<IdentityCertificate> ndn::security::v1::SecPublicInfo::m_defaultCertificate
protectedinherited

Definition at line 455 of file v1/sec-public-info.hpp.

std::string ndn::security::v1::SecPublicInfo::m_location
protectedinherited

Definition at line 456 of file v1/sec-public-info.hpp.

const std::string ndn::security::v1::SecPublicInfoSqlite3::SCHEME
static

Definition at line 161 of file v1/sec-public-info-sqlite3.hpp.