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