All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
basic-identity-storage.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_BASIC_IDENTITY_STORAGE_HPP
24 #define NDN_BASIC_IDENTITY_STORAGE_HPP
25 
26 // Only compile if ndn-cpp-config.h defines NDN_CPP_HAVE_SQLITE3.
27 #include "../../ndn-cpp-config.h"
28 #ifdef NDN_CPP_HAVE_SQLITE3
29 
30 #include "../../common.hpp"
31 #include "identity-storage.hpp"
32 
33 struct sqlite3;
34 
35 namespace ndn
36 {
37 
43 public:
49  BasicIdentityStorage(const std::string& databaseFilePath = "");
50 
54  virtual
56 
62  virtual bool
63  doesIdentityExist(const Name& identityName);
64 
69  virtual void
70  addIdentity(const Name& identityName);
71 
76  virtual bool
78 
84  virtual bool
85  doesKeyExist(const Name& keyName);
86 
95  virtual void
96  addKey(const Name& keyName, KeyType keyType, const Blob& publicKeyDer);
97 
104  virtual Blob
105  getKey(const Name& keyName);
106 
111  virtual void
112  activateKey(const Name& keyName);
113 
118  virtual void
119  deactivateKey(const Name& keyName);
120 
126  virtual bool
127  doesCertificateExist(const Name& certificateName);
128 
135  virtual void
136  addCertificate(const IdentityCertificate& certificate);
137 
144  virtual ptr_lib::shared_ptr<IdentityCertificate>
145  getCertificate(const Name &certificateName);
146 
152  virtual std::string
153  getTpmLocator();
154 
155  /*****************************************
156  * Get/Set Default *
157  *****************************************/
158 
164  virtual Name
166 
173  virtual Name
174  getDefaultKeyNameForIdentity(const Name& identityName);
175 
183  virtual Name
184  getDefaultCertificateNameForKey(const Name& keyName);
185 
192  virtual void
193  getAllIdentities(std::vector<Name>& nameList, bool isDefault);
194 
202  virtual void
204  (const Name& identityName, std::vector<Name>& nameList, bool isDefault);
205 
213  virtual void
215  (const Name& keyName, std::vector<Name>& nameList, bool isDefault);
216 
222  virtual void
223  setDefaultIdentity(const Name& identityName);
224 
232  virtual void
233  setDefaultKeyNameForIdentity(const Name& keyName, const Name& identityNameCheck = Name());
234 
240  virtual void
241  setDefaultCertificateNameForKey(const Name& keyName, const Name& certificateName);
242 
243  /*****************************************
244  * Delete Methods *
245  *****************************************/
246 
251  virtual void
252  deleteCertificateInfo(const Name& certificateName);
253 
258  virtual void
259  deletePublicKeyInfo(const Name& keyName);
260 
265  virtual void
266  deleteIdentityInfo(const Name& identity);
267 
273  static std::string
275 
281  static std::string
283  {
284  return getDefaultDatabaseDirectoryPath() + '/' + "ndnsec-public-info.db";
285  }
286 
287 private:
288 
289  void
290  updateKeyStatus(const Name& keyName, bool isActive);
291 
292  struct sqlite3 *database_;
293 };
294 
295 }
296 
297 #endif // NDN_CPP_HAVE_SQLITE3
298 
299 #endif
virtual Blob getKey(const Name &keyName)
Get the public key DER blob from the identity storage.
virtual void activateKey(const Name &keyName)
Activate a key.
virtual void deleteIdentityInfo(const Name &identity)
Delete an identity and related public keys and certificates.
virtual void deactivateKey(const Name &keyName)
Deactivate a key.
virtual void addKey(const Name &keyName, KeyType keyType, const Blob &publicKeyDer)
Add a public key to the identity storage.
virtual void getAllKeyNamesOfIdentity(const Name &identityName, std::vector< Name > &nameList, bool isDefault)
Append all the key names of a particular identity to the nameList.
virtual void setDefaultCertificateNameForKey(const Name &keyName, const Name &certificateName)
Set the default key name for the specified identity.
virtual Name getDefaultIdentity()
Get the default identity.
virtual Name getDefaultCertificateNameForKey(const Name &keyName)
Get the default certificate name for the specified key.
Definition: identity-certificate.hpp:30
virtual std::string getTpmLocator()
Get the TPM locator associated with this storage.
BasicIdentityStorage(const std::string &databaseFilePath="")
Create a new BasicIdentityStorage to work with an SQLite file.
KeyType
Definition: security-common.hpp:50
virtual void deleteCertificateInfo(const Name &certificateName)
Delete a certificate.
virtual void deletePublicKeyInfo(const Name &keyName)
Delete a public key and related certificates.
static std::string getDefaultDatabaseFilePath()
Get the default database file path that the constructor uses if databaseDirectoryPath and databaseFil...
Definition: basic-identity-storage.hpp:282
virtual ~BasicIdentityStorage()
The virtual Destructor.
virtual void addIdentity(const Name &identityName)
Add a new identity.
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
virtual ptr_lib::shared_ptr< IdentityCertificate > getCertificate(const Name &certificateName)
Get a certificate from the identity storage.
IdentityStorage is a base class for the storage of identity, public keys and certificates.
Definition: identity-storage.hpp:39
A Blob holds a pointer to an immutable byte array implemented as const std::vector<uint8_t>.
Definition: blob.hpp:42
BasicIdentityStorage extends IdentityStorage to implement a basic storage of identity, public keys and certificates using SQLite.
Definition: basic-identity-storage.hpp:42
virtual bool doesCertificateExist(const Name &certificateName)
Check if the specified certificate already exists.
virtual bool doesKeyExist(const Name &keyName)
Check if the specified key already exists.
virtual void addCertificate(const IdentityCertificate &certificate)
Add a certificate to the identity storage.
virtual bool revokeIdentity()
Revoke the identity.
static std::string getDefaultDatabaseDirectoryPath()
Get the default directory that the constructor uses if databaseFilePath is omitted.
virtual void setDefaultKeyNameForIdentity(const Name &keyName, const Name &identityNameCheck=Name())
Set a key as the default key of an identity.
virtual Name getDefaultKeyNameForIdentity(const Name &identityName)
Get the default key name for the specified identity.
virtual void getAllIdentities(std::vector< Name > &nameList, bool isDefault)
Append all the identity names to the nameList.
virtual void getAllCertificateNamesOfKey(const Name &keyName, std::vector< Name > &nameList, bool isDefault)
Append all the certificate names of a particular key name to the nameList.
virtual bool doesIdentityExist(const Name &identityName)
Check if the specified identity already exists.
virtual void setDefaultIdentity(const Name &identityName)
Set the default identity.