pib-impl.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2022 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_SECURITY_PIB_PIB_IMPL_HPP
23 #define NDN_CXX_SECURITY_PIB_PIB_IMPL_HPP
24 
27 
28 #include <set>
29 
30 namespace ndn {
31 namespace security {
32 namespace pib {
33 
42 class PibImpl : noncopyable
43 {
44 public:
51  class Error : public std::runtime_error
52  {
53  public:
54  using std::runtime_error::runtime_error;
55  };
56 
57  virtual
58  ~PibImpl() = default;
59 
60 public: // TPM Locator management
64  virtual std::string
65  getTpmLocator() const = 0;
66 
72  virtual void
73  setTpmLocator(const std::string& tpmLocator) = 0;
74 
75 public: // Identity management
82  virtual bool
83  hasIdentity(const Name& identity) const = 0;
84 
93  virtual void
94  addIdentity(const Name& identity) = 0;
95 
104  virtual void
105  removeIdentity(const Name& identity) = 0;
106 
110  virtual void
112 
116  virtual std::set<Name>
117  getIdentities() const = 0;
118 
126  virtual void
127  setDefaultIdentity(const Name& identityName) = 0;
128 
135  virtual Name
136  getDefaultIdentity() const = 0;
137 
138 public: // Key management
144  virtual bool
145  hasKey(const Name& keyName) const = 0;
146 
159  virtual void
160  addKey(const Name& identity, const Name& keyName, span<const uint8_t> key) = 0;
161 
167  virtual void
168  removeKey(const Name& keyName) = 0;
169 
176  virtual Buffer
177  getKeyBits(const Name& keyName) const = 0;
178 
187  virtual std::set<Name>
188  getKeysOfIdentity(const Name& identity) const = 0;
189 
195  virtual void
196  setDefaultKeyOfIdentity(const Name& identity, const Name& keyName) = 0;
197 
203  virtual Name
204  getDefaultKeyOfIdentity(const Name& identity) const = 0;
205 
206 public: // Certificate Management
213  virtual bool
214  hasCertificate(const Name& certName) const = 0;
215 
228  virtual void
229  addCertificate(const Certificate& certificate) = 0;
230 
238  virtual void
239  removeCertificate(const Name& certName) = 0;
240 
248  virtual Certificate
249  getCertificate(const Name& certName) const = 0;
250 
259  virtual std::set<Name>
260  getCertificatesOfKey(const Name& keyName) const = 0;
261 
267  virtual void
268  setDefaultCertificateOfKey(const Name& keyName, const Name& certName) = 0;
269 
275  virtual Certificate
276  getDefaultCertificateOfKey(const Name& keyName) const = 0;
277 };
278 
279 } // namespace pib
280 } // namespace security
281 } // namespace ndn
282 
283 #endif // NDN_CXX_SECURITY_PIB_PIB_IMPL_HPP
General-purpose automatically managed/resized buffer.
Definition: buffer.hpp:42
Represents an absolute name.
Definition: name.hpp:44
Represents a non-semantic error.
Definition: pib-impl.hpp:52
PIB backend interface.
Definition: pib-impl.hpp:43
virtual void addCertificate(const Certificate &certificate)=0
Add a certificate.
virtual void setDefaultIdentity(const Name &identityName)=0
Set an identity with name identityName as the default identity.
virtual void setTpmLocator(const std::string &tpmLocator)=0
Set the associated TPM information to tpmLocator.
virtual Certificate getCertificate(const Name &certName) const =0
Get a certificate with name certName.
virtual void setDefaultKeyOfIdentity(const Name &identity, const Name &keyName)=0
Set an key with keyName as the default key of an identity with name identity.
virtual bool hasKey(const Name &keyName) const =0
Check the existence of a key with keyName.
virtual Certificate getDefaultCertificateOfKey(const Name &keyName) const =0
virtual Name getDefaultKeyOfIdentity(const Name &identity) const =0
virtual std::set< Name > getCertificatesOfKey(const Name &keyName) const =0
Get a list of certificate names of a key with id keyName.
virtual Name getDefaultIdentity() const =0
Get the default identity.
virtual bool hasCertificate(const Name &certName) const =0
Check the existence of a certificate with name certName.
virtual void removeCertificate(const Name &certName)=0
Remove a certificate with name certName.
virtual Buffer getKeyBits(const Name &keyName) const =0
Get the key bits of a key with name keyName.
virtual void clearIdentities()=0
Erasing all certificates, keys, and identities.
virtual std::set< Name > getKeysOfIdentity(const Name &identity) const =0
Get all the key names of an identity with name identity.
virtual void removeIdentity(const Name &identity)=0
Remove an identity and related keys and certificates.
virtual void setDefaultCertificateOfKey(const Name &keyName, const Name &certName)=0
Set a cert with name certName as the default of a key with keyName.
virtual ~PibImpl()=default
virtual std::string getTpmLocator() const =0
Return the associated TPM Locator or an empty string if unset.
virtual void addKey(const Name &identity, const Name &keyName, span< const uint8_t > key)=0
Add a key.
virtual std::set< Name > getIdentities() const =0
Get the name of all the identities.
virtual void removeKey(const Name &keyName)=0
Remove a key with keyName and related certificates.
virtual void addIdentity(const Name &identity)=0
Add an identity.
virtual bool hasIdentity(const Name &identity) const =0
Check the existence of an identity.
Represents an NDN certificate.
Definition: certificate.hpp:60
Definition: data.cpp:25