NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
pib-sqlite3.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2021 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_CXX_SECURITTY_PIB_IMPL_PIB_SQLITE3_HPP
23 #define NDN_CXX_SECURITTY_PIB_IMPL_PIB_SQLITE3_HPP
24 
26 
27 struct sqlite3;
28 
29 namespace ndn {
30 namespace security {
31 namespace pib {
32 
39 class PibSqlite3 final : public PibImpl
40 {
41 public:
54  explicit
55  PibSqlite3(const std::string& location = "");
56 
60  ~PibSqlite3() final;
61 
62  static const std::string&
63  getScheme();
64 
65 public: // TpmLocator management
66  void
67  setTpmLocator(const std::string& tpmLocator) final;
68 
69  std::string
70  getTpmLocator() const final;
71 
72 public: // Identity management
73  bool
74  hasIdentity(const Name& identity) const final;
75 
76  void
77  addIdentity(const Name& identity) final;
78 
79  void
80  removeIdentity(const Name& identity) final;
81 
82  void
83  clearIdentities() final;
84 
85  std::set<Name>
86  getIdentities() const final;
87 
88  void
89  setDefaultIdentity(const Name& identityName) final;
90 
91  Name
92  getDefaultIdentity() const final;
93 
94 public: // Key management
95  bool
96  hasKey(const Name& keyName) const final;
97 
98  void
99  addKey(const Name& identity, const Name& keyName, span<const uint8_t> key) final;
100 
101  void
102  removeKey(const Name& keyName) final;
103 
104  Buffer
105  getKeyBits(const Name& keyName) const final;
106 
107  std::set<Name>
108  getKeysOfIdentity(const Name& identity) const final;
109 
110  void
111  setDefaultKeyOfIdentity(const Name& identity, const Name& keyName) final;
112 
113  Name
114  getDefaultKeyOfIdentity(const Name& identity) const final;
115 
116 public: // Certificate Management
117  bool
118  hasCertificate(const Name& certName) const final;
119 
120  void
121  addCertificate(const Certificate& certificate) final;
122 
123  void
124  removeCertificate(const Name& certName) final;
125 
126  Certificate
127  getCertificate(const Name& certName) const final;
128 
129  std::set<Name>
130  getCertificatesOfKey(const Name& keyName) const final;
131 
132  void
133  setDefaultCertificateOfKey(const Name& keyName, const Name& certName) final;
134 
135  Certificate
136  getDefaultCertificateOfKey(const Name& keyName) const final;
137 
138 private:
139  bool
140  hasDefaultIdentity() const;
141 
142  bool
143  hasDefaultKeyOfIdentity(const Name& identity) const;
144 
145  bool
146  hasDefaultCertificateOfKey(const Name& keyName) const;
147 
148 private:
149  sqlite3* m_database;
150 };
151 
152 } // namespace pib
153 } // namespace security
154 } // namespace ndn
155 
156 #endif // NDN_CXX_SECURITTY_PIB_IMPL_PIB_SQLITE3_HPP
void removeCertificate(const Name &certName) final
Remove a certificate with name certName.
Copyright (c) 2011-2015 Regents of the University of California.
Name getDefaultKeyOfIdentity(const Name &identity) const final
std::set< Name > getCertificatesOfKey(const Name &keyName) const final
Get a list of certificate names of a key with id keyName.
void clearIdentities() final
Erasing all certificates, keys, and identities.
Certificate getDefaultCertificateOfKey(const Name &keyName) const final
Certificate getCertificate(const Name &certName) const final
Get a certificate with name certName.
std::set< Name > getIdentities() const final
Get the name of all the identities.
void setTpmLocator(const std::string &tpmLocator) final
Set the corresponding TPM information to tpmLocator.
Pib backend implementation based on SQLite3 database.
Definition: pib-sqlite3.hpp:39
std::string getTpmLocator() const final
Get TPM Locator.
void addKey(const Name &identity, const Name &keyName, span< const uint8_t > key) final
Add a key.
Buffer getKeyBits(const Name &keyName) const final
Get the key bits of a key with name keyName.
static const std::string & getScheme()
void removeIdentity(const Name &identity) final
Remove an identity and related keys and certificates.
void setDefaultIdentity(const Name &identityName) final
Set an identity with name identityName as the default identity.
void setDefaultCertificateOfKey(const Name &keyName, const Name &certName) final
Set a cert with name certName as the default of a key with keyName.
Name getDefaultIdentity() const final
Get the default identity.
Represents an absolute name.
Definition: name.hpp:41
PibSqlite3(const std::string &location="")
Create sqlite3-based PIB backed.
void addIdentity(const Name &identity) final
Add an identity.
bool hasKey(const Name &keyName) const final
Check the existence of a key with keyName.
~PibSqlite3() final
Destruct and cleanup internal state.
void addCertificate(const Certificate &certificate) final
Add a certificate.
void removeKey(const Name &keyName) final
Remove a key with keyName and related certificates.
void setDefaultKeyOfIdentity(const Name &identity, const Name &keyName) final
Set an key with keyName as the default key of an identity with name identity.
std::set< Name > getKeysOfIdentity(const Name &identity) const final
Get all the key names of an identity with name identity.
bool hasIdentity(const Name &identity) const final
Check the existence of an identity.
General-purpose automatically managed/resized buffer.
Definition: buffer.hpp:41
Abstract class of PIB implementation.
Definition: pib-impl.hpp:40
bool hasCertificate(const Name &certName) const final
Check the existence of a certificate with name certName.