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 
146 
147  /*****************************************
148  * Get/Set Default *
149  *****************************************/
150 
156  virtual Name
158 
165  virtual Name
166  getDefaultKeyNameForIdentity(const Name& identityName);
167 
175  virtual Name
176  getDefaultCertificateNameForKey(const Name& keyName);
177 
184  virtual void
185  getAllIdentities(std::vector<Name>& nameList, bool isDefault);
186 
194  virtual void
196  (const Name& identityName, std::vector<Name>& nameList, bool isDefault);
197 
205  virtual void
207  (const Name& keyName, std::vector<Name>& nameList, bool isDefault);
208 
214  virtual void
215  setDefaultIdentity(const Name& identityName);
216 
224  virtual void
225  setDefaultKeyNameForIdentity(const Name& keyName, const Name& identityNameCheck = Name());
226 
232  virtual void
233  setDefaultCertificateNameForKey(const Name& keyName, const Name& certificateName);
234 
235  /*****************************************
236  * Delete Methods *
237  *****************************************/
238 
243  virtual void
244  deleteCertificateInfo(const Name& certificateName);
245 
250  virtual void
251  deletePublicKeyInfo(const Name& keyName);
252 
257  virtual void
258  deleteIdentityInfo(const Name& identity);
259 
260 private:
261 
262  void
263  updateKeyStatus(const Name& keyName, bool isActive);
264 
265  sqlite3 *database_;
266 };
267 
268 }
269 
270 #endif // NDN_CPP_HAVE_SQLITE3
271 
272 #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:35
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
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.