NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
pib-memory.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_MEMORY_HPP
23 #define NDN_SECURITY_PIB_PIB_MEMORY_HPP
24 
25 #include "pib-impl.hpp"
26 
27 namespace ndn {
28 namespace security {
29 namespace pib {
30 
37 class PibMemory : public PibImpl
38 {
39 public:
40  class Error : public PibImpl::Error
41  {
42  public:
43  explicit
44  Error(const std::string& what)
45  : PibImpl::Error(what)
46  {
47  }
48  };
49 
50 public:
55  explicit
56  PibMemory(const std::string& location = "");
57 
58  static const std::string&
59  getScheme();
60 
61 public: // TpmLocator management
62  void
63  setTpmLocator(const std::string& tpmLocator) override;
64 
65  std::string
66  getTpmLocator() const override;
67 
68 public: // Identity management
69  bool
70  hasIdentity(const Name& identity) const override;
71 
72  void
73  addIdentity(const Name& identity) override;
74 
75  void
76  removeIdentity(const Name& identity) override;
77 
78  void
79  clearIdentities() override;
80 
81  std::set<Name>
82  getIdentities() const override;
83 
84  void
85  setDefaultIdentity(const Name& identityName) override;
86 
87  Name
88  getDefaultIdentity() const override;
89 
90 public: // Key management
91  bool
92  hasKey(const Name& keyName) const override;
93 
94  void
95  addKey(const Name& identity, const Name& keyName, const uint8_t* key, size_t keyLen) override;
96 
97  void
98  removeKey(const Name& keyName) override;
99 
100  Buffer
101  getKeyBits(const Name& keyName) const override;
102 
103  std::set<Name>
104  getKeysOfIdentity(const Name& identity) const override;
105 
106  void
107  setDefaultKeyOfIdentity(const Name& identity, const Name& keyName) override;
108 
109  Name
110  getDefaultKeyOfIdentity(const Name& identity) const override;
111 
112 public: // Certificate management
113  bool
114  hasCertificate(const Name& certName) const override;
115 
116  void
117  addCertificate(const v2::Certificate& certificate) override;
118 
119  void
120  removeCertificate(const Name& certName) override;
121 
123  getCertificate(const Name& certName) const override;
124 
125  std::set<Name>
126  getCertificatesOfKey(const Name& keyName) const override;
127 
128  void
129  setDefaultCertificateOfKey(const Name& keyName, const Name& certName) override;
130 
132  getDefaultCertificateOfKey(const Name& keyName) const override;
133 
134 private:
135  std::string m_tpmLocator;
136 
137  bool m_hasDefaultIdentity;
138  Name m_defaultIdentity;
139 
140  std::set<Name> m_identities;
141 
143  std::map<Name, Name> m_defaultKeys;
144 
146  std::map<Name, Buffer> m_keys;
147 
149  std::map<Name, Name> m_defaultCerts;
150 
152  std::map<Name, v2::Certificate> m_certs;
153 };
154 
155 } // namespace pib
156 } // namespace security
157 } // namespace ndn
158 
159 #endif // NDN_SECURITY_PIB_PIB_MEMORY_HPP
bool hasIdentity(const Name &identity) const override
Check the existence of an identity.
Definition: pib-memory.cpp:55
represents a non-semantic error
Definition: pib-impl.hpp:48
Copyright (c) 2011-2015 Regents of the University of California.
The certificate following the certificate format naming convention.
Definition: certificate.hpp:81
Name getDefaultKeyOfIdentity(const Name &identity) const override
Definition: pib-memory.cpp:190
void clearIdentities() override
Erasing all certificates, keys, and identities.
Definition: pib-memory.cpp:87
static const std::string & getScheme()
Definition: pib-memory.cpp:36
void removeKey(const Name &keyName) override
Remove a key with keyName and related certificates.
Definition: pib-memory.cpp:142
void removeIdentity(const Name &identity) override
Remove an identity and related keys and certificates.
Definition: pib-memory.cpp:72
void addCertificate(const v2::Certificate &certificate) override
Add a certificate.
Definition: pib-memory.cpp:207
std::string getTpmLocator() const override
Get TPM Locator.
Definition: pib-memory.cpp:49
void setDefaultCertificateOfKey(const Name &keyName, const Name &certName) override
Set a cert with name certName as the default of a key with keyName.
Definition: pib-memory.cpp:255
std::set< Name > getIdentities() const override
Get the name of all the identities.
Definition: pib-memory.cpp:99
bool hasKey(const Name &keyName) const override
Check the existence of a key with keyName.
Definition: pib-memory.cpp:123
PibMemory(const std::string &location="")
Create memory based PIB backend.
Definition: pib-memory.cpp:30
void setTpmLocator(const std::string &tpmLocator) override
Set the corresponding TPM information to tpmLocator.
Definition: pib-memory.cpp:43
void setDefaultKeyOfIdentity(const Name &identity, const Name &keyName) override
Set an key with keyName as the default key of an identity with name identity.
Definition: pib-memory.cpp:180
void removeCertificate(const Name &certName) override
Remove a certificate with name certName.
Definition: pib-memory.cpp:222
Name getDefaultIdentity() const override
Get the default identity.
Definition: pib-memory.cpp:113
void addKey(const Name &identity, const Name &keyName, const uint8_t *key, size_t keyLen) override
Add a key.
Definition: pib-memory.cpp:129
Represents an absolute name.
Definition: name.hpp:42
An in-memory implementation of Pib.
Definition: pib-memory.hpp:37
v2::Certificate getCertificate(const Name &certName) const override
Get a certificate with name certName.
Definition: pib-memory.cpp:232
void setDefaultIdentity(const Name &identityName) override
Set an identity with name identityName as the default identity.
Definition: pib-memory.cpp:105
bool hasCertificate(const Name &certName) const override
Check the existence of a certificate with name certName.
Definition: pib-memory.cpp:201
void addIdentity(const Name &identity) override
Add an identity.
Definition: pib-memory.cpp:61
Error(const std::string &what)
Definition: pib-memory.hpp:44
v2::Certificate getDefaultCertificateOfKey(const Name &keyName) const override
Definition: pib-memory.cpp:265
Buffer getKeyBits(const Name &keyName) const override
Get the key bits of a key with name keyName.
Definition: pib-memory.cpp:156
General-purpose automatically managed/resized buffer.
Definition: buffer.hpp:40
Abstract class of PIB implementation.
Definition: pib-impl.hpp:39
std::set< Name > getKeysOfIdentity(const Name &identity) const override
Get all the key names of an identity with name identity.
Definition: pib-memory.cpp:168
std::set< Name > getCertificatesOfKey(const Name &keyName) const override
Get a list of certificate names of a key with id keyName.
Definition: pib-memory.cpp:243