All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
pib-impl.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_PIB_IMPL_HPP
24 #define NDN_PIB_IMPL_HPP
25 
26 #include <set>
27 #include "pib.hpp"
28 #include "../v2/certificate-v2.hpp"
29 
30 namespace ndn {
31 
37 class PibImpl {
38 public:
45  class Error : public std::runtime_error
46  {
47  public:
48  Error(const std::string& what)
49  : std::runtime_error(what)
50  {
51  }
52  };
53 
54  PibImpl() {}
55 
56  virtual
57  ~PibImpl() {}
58 
59  // TpmLocator management.
60 
66  virtual void
67  setTpmLocator(const std::string& tpmLocator) = 0;
68 
73  virtual std::string
74  getTpmLocator() const = 0;
75 
76  // Identity management.
77 
83  virtual bool
84  hasIdentity(const Name& identityName) const = 0;
85 
91  virtual void
92  addIdentity(const Name& identityName) = 0;
93 
100  virtual void
101  removeIdentity(const Name& identityName) = 0;
102 
106  virtual void
107  clearIdentities() = 0;
108 
113  virtual std::set<Name>
114  getIdentities() const = 0;
115 
121  virtual void
122  setDefaultIdentity(const Name& identityName) = 0;
123 
129  virtual Name
130  getDefaultIdentity() const = 0;
131 
132  // Key management.
133 
140  virtual bool
141  hasKey(const Name& keyName) const = 0;
142 
155  virtual void
156  addKey
157  (const Name& identityName, const Name& keyName, const uint8_t* key,
158  size_t keyLength) = 0;
159 
165  virtual void
166  removeKey(const Name& keyName) = 0;
167 
174  virtual Blob
175  getKeyBits(const Name& keyName) const = 0;
176 
185  virtual std::set<Name>
186  getKeysOfIdentity(const Name& identityName) const = 0;
187 
195  virtual void
196  setDefaultKeyOfIdentity(const Name& identityName, const Name& keyName) = 0;
197 
205  virtual Name
206  getDefaultKeyOfIdentity(const Name& identityName) const = 0;
207 
208  // Certificate management.
209 
215  virtual bool
216  hasCertificate(const Name& certificateName) const = 0;
217 
228  virtual void
229  addCertificate(const CertificateV2& certificate) = 0;
230 
236  virtual void
237  removeCertificate(const Name& certificateName) = 0;
238 
245  virtual ptr_lib::shared_ptr<CertificateV2>
246  getCertificate(const Name& certificateName) const = 0;
247 
257  virtual std::set<Name>
258  getCertificatesOfKey(const Name& keyName) const = 0;
259 
268  virtual void
269  setDefaultCertificateOfKey(const Name& keyName, const Name& certificateName) = 0;
270 
277  virtual ptr_lib::shared_ptr<CertificateV2>
278  getDefaultCertificateOfKey(const Name& keyName) const = 0;
279 
280 private:
281  // Disable the copy constructor and assignment operator.
282  PibImpl(const PibImpl& other);
283  PibImpl& operator=(const PibImpl& other);
284 };
285 
286 }
287 
288 #endif
virtual std::set< Name > getKeysOfIdentity(const Name &identityName) const =0
Get all the key names of the identity with the name identityName.
virtual void setTpmLocator(const std::string &tpmLocator)=0
Set the corresponding TPM information to tpmLocator.
virtual void removeIdentity(const Name &identityName)=0
Remove the identity and its related keys and certificates.
PibImpl is an abstract base class for the PIB implementation used by the Pib class.
Definition: pib-impl.hpp:37
A PibImpl::Error extends runtime_error and represents a non-semantic error in PIB implementation proc...
Definition: pib-impl.hpp:45
virtual void setDefaultCertificateOfKey(const Name &keyName, const Name &certificateName)=0
Set the cert with name certificateName as the default for the key with keyName.
virtual void setDefaultIdentity(const Name &identityName)=0
Set the identity with the identityName as the default identity.
virtual void removeCertificate(const Name &certificateName)=0
Remove the certificate with name certificateName.
virtual void clearIdentities()=0
Erase all certificates, keys, and identities.
virtual void addKey(const Name &identityName, const Name &keyName, const uint8_t *key, size_t keyLength)=0
Add the key.
virtual ptr_lib::shared_ptr< CertificateV2 > getCertificate(const Name &certificateName) const =0
Get the certificate with name certificateName.
virtual void addCertificate(const CertificateV2 &certificate)=0
Add the certificate.
virtual bool hasIdentity(const Name &identityName) const =0
Check for the existence of an identity.
virtual std::set< Name > getCertificatesOfKey(const Name &keyName) const =0
Get a list of certificate names of the key with id keyName.
virtual void addIdentity(const Name &identityName)=0
Add the identity.
virtual Name getDefaultIdentity() const =0
Get the default identity.
virtual Blob getKeyBits(const Name &keyName) const =0
Get the key bits of a key with name keyName.
virtual std::string getTpmLocator() const =0
Get the TPM Locator.
virtual void setDefaultKeyOfIdentity(const Name &identityName, const Name &keyName)=0
Set the key with keyName as the default key for the identity with name identityName.
virtual bool hasKey(const Name &keyName) const =0
Check for the existence of a key with keyName.
virtual void removeKey(const Name &keyName)=0
Remove the key with keyName and its related certificates.
virtual ptr_lib::shared_ptr< CertificateV2 > getDefaultCertificateOfKey(const Name &keyName) const =0
Get the default certificate for the key with eyName.
virtual bool hasCertificate(const Name &certificateName) const =0
Check for the existence of a certificate with name certificateName.
virtual Name getDefaultKeyOfIdentity(const Name &identityName) const =0
Get the name of the default key for the identity with name identityName.
virtual std::set< Name > getIdentities() const =0
Get the names of all the identities.