All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
pib-memory.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_PIB_MEMORY_HPP
24 #define NDN_PIB_MEMORY_HPP
25 
26 #include <map>
27 #include "pib-impl.hpp"
28 
29 namespace ndn {
30 
36 class PibMemory : public PibImpl {
37 public:
42  : hasDefaultIdentity_(false)
43  {
44  }
45 
46  ~PibMemory();
47 
48  static std::string
49  getScheme();
50 
51  // TpmLocator management.
52 
58  virtual void
59  setTpmLocator(const std::string& tpmLocator);
60 
65  virtual std::string
66  getTpmLocator() const;
67 
68  // Identity management.
69 
75  virtual bool
76  hasIdentity(const Name& identityName) const;
77 
83  virtual void
84  addIdentity(const Name& identityName);
85 
92  virtual void
93  removeIdentity(const Name& identityName);
94 
98  virtual void
100 
105  virtual std::set<Name>
106  getIdentities() const;
107 
113  virtual void
114  setDefaultIdentity(const Name& identityName);
115 
121  virtual Name
122  getDefaultIdentity() const;
123 
124  // Key management.
125 
132  virtual bool
133  hasKey(const Name& keyName) const;
134 
147  virtual void
148  addKey
149  (const Name& identityName, const Name& keyName, const uint8_t* key,
150  size_t keyLength);
151 
157  virtual void
158  removeKey(const Name& keyName);
159 
166  virtual Blob
167  getKeyBits(const Name& keyName) const;
168 
177  virtual std::set<Name>
178  getKeysOfIdentity(const Name& identityName) const;
179 
187  virtual void
188  setDefaultKeyOfIdentity(const Name& identityName, const Name& keyName);
189 
197  virtual Name
198  getDefaultKeyOfIdentity(const Name& identityName) const;
199 
200  // Certificate management.
201 
207  virtual bool
208  hasCertificate(const Name& certificateName) const;
209 
220  virtual void
221  addCertificate(const CertificateV2& certificate);
222 
228  virtual void
229  removeCertificate(const Name& certificateName);
230 
237  virtual ptr_lib::shared_ptr<CertificateV2>
238  getCertificate(const Name& certificateName) const;
239 
249  virtual std::set<Name>
250  getCertificatesOfKey(const Name& keyName) const;
251 
260  virtual void
261  setDefaultCertificateOfKey(const Name& keyName, const Name& certificateName);
262 
269  virtual ptr_lib::shared_ptr<CertificateV2>
270  getDefaultCertificateOfKey(const Name& keyName) const;
271 
272 private:
273  // Disable the copy constructor and assignment operator.
274  PibMemory(const PibMemory& other);
275  PibMemory& operator=(const PibMemory& other);
276 
277  std::string tpmLocator_;
278 
279  bool hasDefaultIdentity_;
280  Name defaultIdentityName_;
281 
282  std::set<Name> identityNames_;
283 
284  // identity => default key Name.
285  std::map<Name, Name> defaultKeyNames_;
286 
287  // keyName => keyBits.
288  std::map<Name, Blob> keys_;
289 
290  // keyName => default certificate Name.
291  std::map<Name, Name> defaultCertificateNames_;
292 
293  // certificate Name => certificate.
294  std::map<Name, ptr_lib::shared_ptr<CertificateV2>> certificates_;
295 };
296 
297 }
298 
299 #endif
virtual void addCertificate(const CertificateV2 &certificate)
Add the certificate.
Definition: pib-memory.cpp:200
virtual ptr_lib::shared_ptr< CertificateV2 > getCertificate(const Name &certificateName) const
Get the certificate with name certificateName.
Definition: pib-memory.cpp:228
virtual void removeIdentity(const Name &identityName)
Remove the identity and its related keys and certificates.
Definition: pib-memory.cpp:60
virtual void setTpmLocator(const std::string &tpmLocator)
Set the corresponding TPM information to tpmLocator.
Definition: pib-memory.cpp:36
PibImpl is an abstract base class for the PIB implementation used by the Pib class.
Definition: pib-impl.hpp:37
virtual bool hasIdentity(const Name &identityName) const
Check for the existence of an identity.
Definition: pib-memory.cpp:42
virtual void setDefaultCertificateOfKey(const Name &keyName, const Name &certificateName)
Set the cert with name certificateName as the default for the key with keyName.
Definition: pib-memory.cpp:253
virtual Name getDefaultKeyOfIdentity(const Name &identityName) const
Get the name of the default key for the identity with name identityName.
Definition: pib-memory.cpp:183
virtual void removeCertificate(const Name &certificateName)
Remove the certificate with name certificateName.
Definition: pib-memory.cpp:217
CertificateV2 represents a certificate following the certificate format naming convention.
Definition: certificate-v2.hpp:81
virtual std::set< Name > getKeysOfIdentity(const Name &identityName) const
Get all the key names of the identity with the name identityName.
Definition: pib-memory.cpp:159
virtual void clearIdentities()
Erase all certificates, keys, and identities.
Definition: pib-memory.cpp:74
virtual Blob getKeyBits(const Name &keyName) const
Get the key bits of a key with name keyName.
Definition: pib-memory.cpp:146
PibMemory extends PibImpl and is used by the Pib class as an in-memory implementation of a PIB...
Definition: pib-memory.hpp:36
virtual Name getDefaultIdentity() const
Get the default identity.
Definition: pib-memory.cpp:102
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
virtual bool hasCertificate(const Name &certificateName) const
Check for the existence of a certificate with name certificateName.
Definition: pib-memory.cpp:194
A Blob holds a pointer to an immutable byte array implemented as const std::vector<uint8_t>.
Definition: blob.hpp:42
virtual ptr_lib::shared_ptr< CertificateV2 > getDefaultCertificateOfKey(const Name &keyName) const
Get the default certificate for the key with eyName.
Definition: pib-memory.cpp:262
virtual void removeKey(const Name &keyName)
Remove the key with keyName and its related certificates.
Definition: pib-memory.cpp:132
virtual std::string getTpmLocator() const
Get the TPM Locator.
Definition: pib-memory.cpp:39
virtual void addIdentity(const Name &identityName)
Add the identity.
Definition: pib-memory.cpp:48
virtual bool hasKey(const Name &keyName) const
Check for the existence of a key with keyName.
Definition: pib-memory.cpp:112
virtual std::set< Name > getCertificatesOfKey(const Name &keyName) const
Get a list of certificate names of the key with id keyName.
Definition: pib-memory.cpp:239
virtual std::set< Name > getIdentities() const
Get the names of all the identities.
Definition: pib-memory.cpp:86
virtual void setDefaultKeyOfIdentity(const Name &identityName, const Name &keyName)
Set the key with keyName as the default key for the identity with name identityName.
Definition: pib-memory.cpp:173
PibMemory()
Create a default PibMemory with no values.
Definition: pib-memory.hpp:41
virtual void setDefaultIdentity(const Name &identityName)
Set the identity with the identityName as the default identity.
Definition: pib-memory.cpp:93
virtual void addKey(const Name &identityName, const Name &keyName, const uint8_t *key, size_t keyLength)
Add the key.
Definition: pib-memory.cpp:119