basic-identity-storage.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_BASIC_IDENTITY_STORAGE_H
24 #define NDN_BASIC_IDENTITY_STORAGE_H
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 <sqlite3.h>
31 #include "../../common.hpp"
32 #include "identity-storage.hpp"
33 
34 namespace ndn
35 {
36 
42 public:
48  BasicIdentityStorage(const std::string& databaseFilePath = "");
49 
53  virtual
55 
61  virtual bool
62  doesIdentityExist(const Name& identityName);
63 
68  virtual void
69  addIdentity(const Name& identityName);
70 
75  virtual bool
77 
83  virtual bool
84  doesKeyExist(const Name& keyName);
85 
94  virtual void
95  addKey(const Name& keyName, KeyType keyType, const Blob& publicKeyDer);
96 
103  virtual Blob
104  getKey(const Name& keyName);
105 
110  virtual void
111  activateKey(const Name& keyName);
112 
117  virtual void
118  deactivateKey(const Name& keyName);
119 
125  virtual bool
126  doesCertificateExist(const Name& certificateName);
127 
134  virtual void
135  addCertificate(const IdentityCertificate& certificate);
136 
143  virtual ptr_lib::shared_ptr<IdentityCertificate>
144  getCertificate(const Name &certificateName);
145 
151  virtual std::string
152  getTpmLocator();
153 
154  /*****************************************
155  * Get/Set Default *
156  *****************************************/
157 
163  virtual Name
165 
172  virtual Name
173  getDefaultKeyNameForIdentity(const Name& identityName);
174 
182  virtual Name
183  getDefaultCertificateNameForKey(const Name& keyName);
184 
191  virtual void
192  getAllIdentities(std::vector<Name>& nameList, bool isDefault);
193 
201  virtual void
203  (const Name& identityName, std::vector<Name>& nameList, bool isDefault);
204 
212  virtual void
214  (const Name& keyName, std::vector<Name>& nameList, bool isDefault);
215 
221  virtual void
222  setDefaultIdentity(const Name& identityName);
223 
231  virtual void
232  setDefaultKeyNameForIdentity(const Name& keyName, const Name& identityNameCheck = Name());
233 
239  virtual void
240  setDefaultCertificateNameForKey(const Name& keyName, const Name& certificateName);
241 
242  /*****************************************
243  * Delete Methods *
244  *****************************************/
245 
250  virtual void
251  deleteCertificateInfo(const Name& certificateName);
252 
257  virtual void
258  deletePublicKeyInfo(const Name& keyName);
259 
264  virtual void
265  deleteIdentityInfo(const Name& identity);
266 
267 private:
268 
269  void
270  updateKeyStatus(const Name& keyName, bool isActive);
271 
272  sqlite3 *database_;
273 };
274 
275 }
276 
277 #endif // NDN_CPP_HAVE_SQLITE3
278 
279 #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.
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:36
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.
virtual void deleteCertificateInfo(const Name &certificateName)
Delete a certificate.
virtual void deletePublicKeyInfo(const Name &keyName)
Delete a public key and related certificates.
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.
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:41
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.
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.