pib-impl.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_SECURITY_PIB_PIB_IMPL_HPP
23 #define NDN_SECURITY_PIB_PIB_IMPL_HPP
24 
25 #include "pib.hpp"
26 #include <set>
27 #include "../v2/certificate.hpp"
28 
29 namespace ndn {
30 namespace security {
31 namespace pib {
32 
39 class PibImpl : noncopyable
40 {
41 public:
48  class Error : public std::runtime_error
49  {
50  public:
51  explicit
52  Error(const std::string& what)
53  : std::runtime_error(what)
54  {
55  }
56  };
57 
58 public:
59  virtual
60  ~PibImpl() = default;
61 
62 public: // TpmLocator management
68  virtual void
69  setTpmLocator(const std::string& tpmLocator) = 0;
70 
74  virtual std::string
75  getTpmLocator() const = 0;
76 
77 public: // Identity management
84  virtual bool
85  hasIdentity(const Name& identity) const = 0;
86 
95  virtual void
96  addIdentity(const Name& identity) = 0;
97 
106  virtual void
107  removeIdentity(const Name& identity) = 0;
108 
112  virtual void
113  clearIdentities() = 0;
114 
118  virtual std::set<Name>
119  getIdentities() const = 0;
120 
128  virtual void
129  setDefaultIdentity(const Name& identityName) = 0;
130 
137  virtual Name
138  getDefaultIdentity() const = 0;
139 
140 public: // Key management
146  virtual bool
147  hasKey(const Name& keyName) const = 0;
148 
162  virtual void
163  addKey(const Name& identity, const Name& keyName, const uint8_t* key, size_t keyLen) = 0;
164 
170  virtual void
171  removeKey(const Name& keyName) = 0;
172 
179  virtual Buffer
180  getKeyBits(const Name& keyName) const = 0;
181 
190  virtual std::set<Name>
191  getKeysOfIdentity(const Name& identity) const = 0;
192 
198  virtual void
199  setDefaultKeyOfIdentity(const Name& identity, const Name& keyName) = 0;
200 
206  virtual Name
207  getDefaultKeyOfIdentity(const Name& identity) const = 0;
208 
209 public: // Certificate Management
216  virtual bool
217  hasCertificate(const Name& certName) const = 0;
218 
231  virtual void
232  addCertificate(const v2::Certificate& certificate) = 0;
233 
241  virtual void
242  removeCertificate(const Name& certName) = 0;
243 
251  virtual v2::Certificate
252  getCertificate(const Name& certName) const = 0;
253 
262  virtual std::set<Name>
263  getCertificatesOfKey(const Name& keyName) const = 0;
264 
270  virtual void
271  setDefaultCertificateOfKey(const Name& keyName, const Name& certName) = 0;
272 
278  virtual v2::Certificate
279  getDefaultCertificateOfKey(const Name& keyName) const = 0;
280 };
281 
282 } // namespace pib
283 } // namespace security
284 } // namespace ndn
285 
286 #endif // NDN_SECURITY_PIB_PIB_IMPL_HPP
represents a non-semantic error
Definition: pib-impl.hpp:48
virtual void removeIdentity(const Name &identity)=0
Remove an identity and related keys and certificates.
Copyright (c) 2013-2017 Regents of the University of California.
Definition: common.hpp:66
The certificate following the certificate format naming convention.
Definition: certificate.hpp:81
virtual void removeKey(const Name &keyName)=0
Remove a key with keyName and related certificates.
virtual void removeCertificate(const Name &certName)=0
Remove a certificate with name certName.
virtual ~PibImpl()=default
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 bool hasIdentity(const Name &identity) const =0
Check the existence of an identity.
STL namespace.
virtual void setDefaultIdentity(const Name &identityName)=0
Set an identity with name identityName as the default identity.
virtual bool hasKey(const Name &keyName) const =0
Check the existence of a key with keyName.
virtual bool hasCertificate(const Name &certName) const =0
Check the existence of a certificate with name certName.
virtual std::string getTpmLocator() const =0
Get TPM Locator.
virtual void addIdentity(const Name &identity)=0
Add an identity.
virtual std::set< Name > getCertificatesOfKey(const Name &keyName) const =0
Get a list of certificate names of a key with id keyName.
virtual void clearIdentities()=0
Erasing all certificates, keys, and identities.
Error(const std::string &what)
Definition: pib-impl.hpp:52
Represents an absolute name.
Definition: name.hpp:42
virtual Name getDefaultIdentity() const =0
Get the default identity.
virtual void addKey(const Name &identity, const Name &keyName, const uint8_t *key, size_t keyLen)=0
Add a key.
virtual v2::Certificate getCertificate(const Name &certName) const =0
Get a certificate with name certName.
virtual void setTpmLocator(const std::string &tpmLocator)=0
Set the corresponding TPM information to tpmLocator.
virtual std::set< Name > getIdentities() const =0
Get the name of all the identities.
virtual v2::Certificate getDefaultCertificateOfKey(const Name &keyName) const =0
virtual Name getDefaultKeyOfIdentity(const Name &identity) const =0
virtual void addCertificate(const v2::Certificate &certificate)=0
Add a certificate.
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.
General-purpose automatically managed/resized buffer.
Definition: buffer.hpp:40
virtual std::set< Name > getKeysOfIdentity(const Name &identity) const =0
Get all the key names of an identity with name identity.
Abstract class of PIB implementation.
Definition: pib-impl.hpp:39
virtual Buffer getKeyBits(const Name &keyName) const =0
Get the key bits of a key with name keyName.