All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
pib-sqlite3.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_PIB_SQLITE3_HPP
24 #define NDN_PIB_SQLITE3_HPP
25 
26 // Define this even if we don't have NDN_CPP_HAVE_SQLITE3 .
27 #define NDN_PIB_SQLITE3_SCHEME "pib-sqlite3"
28 
29 // Only compile if ndn-cpp-config.h defines NDN_CPP_HAVE_SQLITE3.
30 #include "../../ndn-cpp-config.h"
31 #ifdef NDN_CPP_HAVE_SQLITE3
32 
33 #include "pib-impl.hpp"
34 
35 struct sqlite3;
36 
37 namespace ndn {
38 
45 class PibSqlite3 : public PibImpl {
46 public:
58  (const std::string& databaseDirectoryPath = "",
59  const std::string& databaseFilename = "pib.db");
60 
64  virtual
65  ~PibSqlite3();
66 
67  static std::string
68  getScheme();
69 
70  // TpmLocator management.
71 
77  virtual void
78  setTpmLocator(const std::string& tpmLocator);
79 
84  virtual std::string
85  getTpmLocator() const;
86 
87  // Identity management.
88 
94  virtual bool
95  hasIdentity(const Name& identityName) const;
96 
102  virtual void
103  addIdentity(const Name& identityName);
104 
111  virtual void
112  removeIdentity(const Name& identityName);
113 
117  virtual void
118  clearIdentities();
119 
124  virtual std::set<Name>
125  getIdentities() const;
126 
132  virtual void
133  setDefaultIdentity(const Name& identityName);
134 
140  virtual Name
141  getDefaultIdentity() const;
142 
143  // Key management.
144 
151  virtual bool
152  hasKey(const Name& keyName) const;
153 
166  virtual void
167  addKey
168  (const Name& identityName, const Name& keyName, const uint8_t* key,
169  size_t keyLength);
170 
176  virtual void
177  removeKey(const Name& keyName);
178 
185  virtual Blob
186  getKeyBits(const Name& keyName) const;
187 
196  virtual std::set<Name>
197  getKeysOfIdentity(const Name& identityName) const;
198 
206  virtual void
207  setDefaultKeyOfIdentity(const Name& identityName, const Name& keyName);
208 
216  virtual Name
217  getDefaultKeyOfIdentity(const Name& identityName) const;
218 
219  // Certificate management.
220 
226  virtual bool
227  hasCertificate(const Name& certificateName) const;
228 
239  virtual void
240  addCertificate(const CertificateV2& certificate);
241 
247  virtual void
248  removeCertificate(const Name& certificateName);
249 
256  virtual ptr_lib::shared_ptr<CertificateV2>
257  getCertificate(const Name& certificateName) const;
258 
268  virtual std::set<Name>
269  getCertificatesOfKey(const Name& keyName) const;
270 
279  virtual void
280  setDefaultCertificateOfKey(const Name& keyName, const Name& certificateName);
281 
288  virtual ptr_lib::shared_ptr<CertificateV2>
289  getDefaultCertificateOfKey(const Name& keyName) const;
290 
296  static std::string
298 
304  static std::string
306  {
307  return getDefaultDatabaseDirectoryPath() + '/' + "pib.db";
308  }
309 
310 private:
311  bool
312  hasDefaultIdentity() const;
313 
314  bool
315  hasDefaultKeyOfIdentity(const Name& identityName) const;
316 
317  bool
318  hasDefaultCertificateOfKey(const Name& keyName) const;
319 
320  // Disable the copy constructor and assignment operator.
321  PibSqlite3(const PibSqlite3& other);
322  PibSqlite3& operator=(const PibSqlite3& other);
323 
324  struct sqlite3 *database_;
325 };
326 
327 }
328 
329 #endif // NDN_CPP_HAVE_SQLITE3
330 
331 #endif
virtual void addCertificate(const CertificateV2 &certificate)
Add the certificate.
PibImpl is an abstract base class for the PIB implementation used by the Pib class.
Definition: pib-impl.hpp:37
virtual std::string getTpmLocator() const
Get the TPM Locator.
virtual bool hasIdentity(const Name &identityName) const
Check for the existence of an identity.
virtual ptr_lib::shared_ptr< CertificateV2 > getDefaultCertificateOfKey(const Name &keyName) const
Get the default certificate for the key with eyName.
virtual bool hasCertificate(const Name &certificateName) const
Check for the existence of a certificate with name certificateName.
virtual void addKey(const Name &identityName, const Name &keyName, const uint8_t *key, size_t keyLength)
Add the key.
virtual Name getDefaultKeyOfIdentity(const Name &identityName) const
Get the name of the default key for the identity with name identityName.
CertificateV2 represents a certificate following the certificate format naming convention.
Definition: certificate-v2.hpp:81
virtual ptr_lib::shared_ptr< CertificateV2 > getCertificate(const Name &certificateName) const
Get the certificate with name certificateName.
virtual void addIdentity(const Name &identityName)
Add the identity.
PibSqlite3 extends PibImpl and is used by the Pib class as an implementation of a PIB based on an SQL...
Definition: pib-sqlite3.hpp:45
PibSqlite3(const std::string &databaseDirectoryPath="", const std::string &databaseFilename="pib.db")
Create a new PibSqlite3 to work with an SQLite3 file.
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
A Blob holds a pointer to an immutable byte array implemented as const std::vector<uint8_t>.
Definition: blob.hpp:42
virtual std::set< Name > getCertificatesOfKey(const Name &keyName) const
Get a list of certificate names of the key with id keyName.
virtual std::set< Name > getIdentities() const
Get the names of all the identities.
static std::string getDefaultDatabaseDirectoryPath()
Get the default that the constructor uses if databaseDirectoryPath is omitted.
virtual Blob getKeyBits(const Name &keyName) const
Get the key bits of a key with name keyName.
virtual void setDefaultIdentity(const Name &identityName)
Set the identity with the identityName as the default identity.
static std::string getDefaultDatabaseFilePath()
Get the default database file path that the constructor uses if databaseDirectoryPath and databaseFil...
Definition: pib-sqlite3.hpp:305
virtual void setDefaultKeyOfIdentity(const Name &identityName, const Name &keyName)
Set the key with keyName as the default key for the identity with name identityName.
virtual void removeIdentity(const Name &identityName)
Remove the identity and its related keys and certificates.
virtual bool hasKey(const Name &keyName) const
Check for the existence of a key with keyName.
virtual void removeCertificate(const Name &certificateName)
Remove the certificate with name certificateName.
virtual Name getDefaultIdentity() const
Get the default identity.
virtual void clearIdentities()
Erase all certificates, keys, and identities.
virtual void setTpmLocator(const std::string &tpmLocator)
Set the corresponding TPM information to tpmLocator.
virtual void removeKey(const Name &keyName)
Remove the key with keyName and its related certificates.
virtual ~PibSqlite3()
Destroy and clean up the internal state.
virtual std::set< Name > getKeysOfIdentity(const Name &identityName) const
Get all the key names of the identity with the name identityName.
virtual void setDefaultCertificateOfKey(const Name &keyName, const Name &certificateName)
Set the cert with name certificateName as the default for the key with keyName.