NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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_MEMORY_HPP
23 #define NDN_SECURITY_PIB_MEMORY_HPP
24 
25 #include "pib-impl.hpp"
26 
27 namespace ndn {
28 namespace security {
29 
36 class PibMemory : public PibImpl
37 {
38 public:
39  class Error : public PibImpl::Error
40  {
41  public:
42  explicit
43  Error(const std::string& what)
44  : PibImpl::Error(what)
45  {
46  }
47  };
48 
49 public:
50  PibMemory();
51 
52 public: // TpmLocator management
53 
54  virtual void
55  setTpmLocator(const std::string& tpmLocator) override;
56 
57  virtual std::string
58  getTpmLocator() const override;
59 
60 public: // Identity management
61 
62  virtual bool
63  hasIdentity(const Name& identity) const override;
64 
65  virtual void
66  addIdentity(const Name& identity) override;
67 
68  virtual void
69  removeIdentity(const Name& identity) override;
70 
71  virtual std::set<Name>
72  getIdentities() const override;
73 
74  virtual void
75  setDefaultIdentity(const Name& identityName) override;
76 
77  virtual Name
78  getDefaultIdentity() const override;
79 
80 public: // Key management
81 
82  virtual bool
83  hasKey(const Name& identity, const name::Component& keyId) const override;
84 
85  virtual void
86  addKey(const Name& identity, const name::Component& keyId, const v1::PublicKey& publicKey) override;
87 
88  virtual void
89  removeKey(const Name& identity, const name::Component& keyId) override;
90 
91  virtual v1::PublicKey
92  getKeyBits(const Name& identity, const name::Component& keyId) const override;
93 
94  virtual std::set<name::Component>
95  getKeysOfIdentity(const Name& identity) const override;
96 
97  virtual void
98  setDefaultKeyOfIdentity(const Name& identity, const name::Component& keyId) override;
99 
100  virtual name::Component
101  getDefaultKeyOfIdentity(const Name& identity) const override;
102 
103 public: // Certificate management
104 
105  virtual bool
106  hasCertificate(const Name& certName) const override;
107 
108  virtual void
109  addCertificate(const v1::IdentityCertificate& certificate) override;
110 
111  virtual void
112  removeCertificate(const Name& certName) override;
113 
115  getCertificate(const Name& certName) const override;
116 
117  virtual std::set<Name>
118  getCertificatesOfKey(const Name& identity, const name::Component& keyId) const override;
119 
120  virtual void
121  setDefaultCertificateOfKey(const Name& identity, const name::Component& keyId, const Name& certName) override;
122 
124  getDefaultCertificateOfKey(const Name& identity, const name::Component& keyId) const override;
125 
126 private: // Key management
127 
128  Name
129  getKeyName(const Name& identity, const name::Component& keyId) const;
130 
131 private:
132 
133  std::set<Name> m_identities;
134  bool m_hasDefaultIdentity;
135  Name m_defaultIdentity;
136 
138  std::map<Name, v1::PublicKey> m_keys;
139 
141  std::map<Name, Name> m_defaultKey;
142 
144  std::map<Name, v1::IdentityCertificate> m_certs;
145 
147  std::map<Name, Name> m_defaultCert;
148 };
149 
150 } // namespace security
151 } // namespace ndn
152 
153 #endif // NDN_SECURITY_PIB_MEMORY_HPP
virtual v1::PublicKey getKeyBits(const Name &identity, const name::Component &keyId) const override
Get the key bits of a key.
Definition: pib-memory.cpp:131
represents a non-semantic error
Definition: pib-impl.hpp:46
Copyright (c) 2011-2015 Regents of the University of California.
virtual Name getDefaultIdentity() const override
Get the default identity.
Definition: pib-memory.cpp:90
virtual void removeIdentity(const Name &identity) override
Remove an identity.
Definition: pib-memory.cpp:63
An in-memory implementation of Pib.
Definition: pib-memory.hpp:36
virtual bool hasCertificate(const Name &certName) const override
Check the existence of a certificate with name certName.
Definition: pib-memory.cpp:181
virtual void addIdentity(const Name &identity) override
Add an identity.
Definition: pib-memory.cpp:52
virtual void setTpmLocator(const std::string &tpmLocator) override
Set the corresponding TPM information to tpmLocator.
Definition: pib-memory.cpp:34
virtual bool hasKey(const Name &identity, const name::Component &keyId) const override
Check the existence of a key.
Definition: pib-memory.cpp:99
virtual bool hasIdentity(const Name &identity) const override
Check the existence of an identity.
Definition: pib-memory.cpp:46
virtual v1::IdentityCertificate getCertificate(const Name &certName) const override
Get a certificate with name certName.
Definition: pib-memory.cpp:208
virtual std::set< name::Component > getKeysOfIdentity(const Name &identity) const override
Get all the key ids of an identity with name identity.
Definition: pib-memory.cpp:141
virtual std::set< Name > getCertificatesOfKey(const Name &identity, const name::Component &keyId) const override
Get a list of certificate names of a key with id keyId of identity.
Definition: pib-memory.cpp:218
virtual std::set< Name > getIdentities() const override
Get the name of all the identities.
Definition: pib-memory.cpp:76
virtual void addKey(const Name &identity, const name::Component &keyId, const v1::PublicKey &publicKey) override
Add a key.
Definition: pib-memory.cpp:105
virtual void setDefaultCertificateOfKey(const Name &identity, const name::Component &keyId, const Name &certName) override
Set a cert with name certName as the default of a key with id keyId of identity.
Definition: pib-memory.cpp:231
virtual void addCertificate(const v1::IdentityCertificate &certificate) override
Add a certificate.
Definition: pib-memory.cpp:187
Name abstraction to represent an absolute name.
Definition: name.hpp:46
Abstract class of PIB implementation.
Definition: pib-impl.hpp:37
virtual void removeKey(const Name &identity, const name::Component &keyId) override
Remove a key.
Definition: pib-memory.cpp:117
virtual void setDefaultIdentity(const Name &identityName) override
Set an identity with name identityName as the default identity.
Definition: pib-memory.cpp:82
virtual v1::IdentityCertificate getDefaultCertificateOfKey(const Name &identity, const name::Component &keyId) const override
Get the default certificate of a key with id keyId of identity.
Definition: pib-memory.cpp:241
Component holds a read-only name component value.
virtual void removeCertificate(const Name &certName) override
Remove a certificate with name certName.
Definition: pib-memory.cpp:201
Error(const std::string &what)
Definition: pib-memory.hpp:43
virtual name::Component getDefaultKeyOfIdentity(const Name &identity) const override
Get the id of the default key of an identity with name identity.
Definition: pib-memory.cpp:163
virtual void setDefaultKeyOfIdentity(const Name &identity, const name::Component &keyId) override
Set an key with id keyId as the default key of an identity with name identity.
Definition: pib-memory.cpp:152
virtual std::string getTpmLocator() const override
Get TPM Locator.
Definition: pib-memory.cpp:40