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