NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
sec-public-info-sqlite3.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
25 #ifndef NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP
26 #define NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP
27 
28 #include "../common.hpp"
29 #include "sec-public-info.hpp"
30 
31 struct sqlite3;
32 
33 namespace ndn {
34 
36 {
37 public:
38  class Error : public SecPublicInfo::Error
39  {
40  public:
41  explicit
42  Error(const std::string& what)
43  : SecPublicInfo::Error(what)
44  {
45  }
46  };
47 
48  explicit
49  SecPublicInfoSqlite3(const std::string& dir = "");
50 
51  virtual
53 
54  /**********************
55  * from SecPublicInfo *
56  **********************/
57 
58  virtual void
59  setTpmLocator(const std::string& tpmLocator);
60 
61  virtual std::string
62  getTpmLocator();
63 
64  virtual std::string
65  getPibLocator();
66 
67  virtual bool
68  doesIdentityExist(const Name& identityName);
69 
70  virtual void
71  addIdentity(const Name& identityName);
72 
73  virtual bool
75 
76  virtual bool
77  doesPublicKeyExist(const Name& keyName);
78 
79  virtual void
80  addKey(const Name& keyName, const PublicKey& publicKeyDer);
81 
82  virtual shared_ptr<PublicKey>
83  getPublicKey(const Name& keyName);
84 
85  virtual KeyType
86  getPublicKeyType(const Name& keyName);
87 
88  virtual bool
89  doesCertificateExist(const Name& certificateName);
90 
91  virtual void
92  addCertificate(const IdentityCertificate& certificate);
93 
94  virtual shared_ptr<IdentityCertificate>
95  getCertificate(const Name& certificateName);
96 
97 
98 
99  virtual Name
101 
102  virtual Name
103  getDefaultKeyNameForIdentity(const Name& identityName);
104 
105  virtual Name
106  getDefaultCertificateNameForKey(const Name& keyName);
107 
108  virtual void
109  getAllIdentities(std::vector<Name>& nameList, bool isDefault);
110 
111  virtual void
112  getAllKeyNames(std::vector<Name>& nameList, bool isDefault);
113 
114  virtual void
115  getAllKeyNamesOfIdentity(const Name& identity, std::vector<Name>& nameList, bool isDefault);
116 
117  virtual void
118  getAllCertificateNames(std::vector<Name>& nameList, bool isDefault);
119 
120  virtual void
121  getAllCertificateNamesOfKey(const Name& keyName, std::vector<Name>& nameList, bool isDefault);
122 
123  virtual void
124  deleteCertificateInfo(const Name& certificateName);
125 
126  virtual void
127  deletePublicKeyInfo(const Name& keyName);
128 
129  virtual void
130  deleteIdentityInfo(const Name& identity);
131 
132 private:
133  bool
134  initializeTable(const std::string& tableName, const std::string& initCommand);
135 
136  void
137  deleteTable(const std::string& tableName);
138 
139  void
140  setTpmLocatorInternal(const std::string& tpmLocator, bool needReset);
141 
142  void
143  setDefaultIdentityInternal(const Name& identityName);
144 
145  void
146  setDefaultKeyNameForIdentityInternal(const Name& keyName);
147 
148  void
149  setDefaultCertificateNameForKeyInternal(const Name& certificateName);
150 
151  std::string
152  getScheme();
153 
155  bool
156  doesTableExist(const std::string& tableName);
157 
158 public:
159  static const std::string SCHEME;
160 
161 private:
162  sqlite3* m_database;
163 };
164 
165 } // namespace ndn
166 
167 #endif // NDN_SECURITY_SEC_PUBLIC_INFO_SQLITE3_HPP
Copyright (c) 2011-2015 Regents of the University of California.
virtual bool doesIdentityExist(const Name &identityName)
Check if the specified identity already exists.
virtual void getAllKeyNames(std::vector< Name > &nameList, bool isDefault)
Get all the key names from public info.
virtual shared_ptr< IdentityCertificate > getCertificate(const Name &certificateName)
Get a shared pointer to identity certificate object from the identity storage.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:43
virtual void getAllCertificateNamesOfKey(const Name &keyName, std::vector< Name > &nameList, bool isDefault)
Get all the certificate name of a particular key name.
virtual bool doesCertificateExist(const Name &certificateName)
Check if the specified certificate already exists.
virtual Name getDefaultKeyNameForIdentity(const Name &identityName)
Get name of the default key name for the specified identity.
virtual std::string getTpmLocator()
Get TPM Locator.
virtual bool doesPublicKeyExist(const Name &keyName)
Check if the specified key already exists.
virtual shared_ptr< PublicKey > getPublicKey(const Name &keyName)
Get shared pointer to PublicKey object from the identity storage.
virtual bool revokeIdentity()
Revoke the identity.
virtual KeyType getPublicKeyType(const Name &keyName)
Get the type of the queried public key.
virtual void deletePublicKeyInfo(const Name &keyName)
Delete a public key and related certificates.
Name abstraction to represent an absolute name.
Definition: name.hpp:46
static const std::string SCHEME
virtual void getAllIdentities(std::vector< Name > &nameList, bool isDefault)
Get all the identities from public info.
virtual Name getDefaultIdentity()
Get name of the default identity.
virtual void addIdentity(const Name &identityName)
Add a new identity.
virtual void addKey(const Name &keyName, const PublicKey &publicKeyDer)
Add a public key to the identity storage.
virtual void deleteCertificateInfo(const Name &certificateName)
Delete a certificate.
SecPublicInfoSqlite3(const std::string &dir="")
virtual void getAllKeyNamesOfIdentity(const Name &identity, std::vector< Name > &nameList, bool isDefault)
Get all the key names of a particular identity.
virtual Name getDefaultCertificateNameForKey(const Name &keyName)
Get name of the default certificate name for the specified key.
virtual void addCertificate(const IdentityCertificate &certificate)
Add a certificate to the identity storage.
virtual void deleteIdentityInfo(const Name &identity)
Delete an identity and related public keys and certificates.
virtual void getAllCertificateNames(std::vector< Name > &nameList, bool isDefault)
Get all the certificate name in public info.
SecPublicInfo is a base class for the storage of public information.
virtual void setTpmLocator(const std::string &tpmLocator)
Set the corresponding TPM information to tpmLocator.