NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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) NDN_CXX_DECL_OVERRIDE;
56 
57  virtual std::string
59 
60 public: // Identity management
61 
62  virtual bool
63  hasIdentity(const Name& identity) const NDN_CXX_DECL_OVERRIDE;
64 
65  virtual void
66  addIdentity(const Name& identity) NDN_CXX_DECL_OVERRIDE;
67 
68  virtual void
69  removeIdentity(const Name& identity) NDN_CXX_DECL_OVERRIDE;
70 
71  virtual std::set<Name>
73 
74  virtual void
75  setDefaultIdentity(const Name& identityName) NDN_CXX_DECL_OVERRIDE;
76 
77  virtual Name
79 
80 public: // Key management
81 
82  virtual bool
83  hasKey(const Name& identity, const name::Component& keyId) const NDN_CXX_DECL_OVERRIDE;
84 
85  virtual void
86  addKey(const Name& identity, const name::Component& keyId, const PublicKey& publicKey) NDN_CXX_DECL_OVERRIDE;
87 
88  virtual void
89  removeKey(const Name& identity, const name::Component& keyId) NDN_CXX_DECL_OVERRIDE;
90 
91  virtual PublicKey
92  getKeyBits(const Name& identity, const name::Component& keyId) const NDN_CXX_DECL_OVERRIDE;
93 
94  virtual std::set<name::Component>
95  getKeysOfIdentity(const Name& identity) const NDN_CXX_DECL_OVERRIDE;
96 
97  virtual void
99 
100  virtual name::Component
101  getDefaultKeyOfIdentity(const Name& identity) const NDN_CXX_DECL_OVERRIDE;
102 
103 public: // Certificate management
104 
105  virtual bool
106  hasCertificate(const Name& certName) const NDN_CXX_DECL_OVERRIDE;
107 
108  virtual void
110 
111  virtual void
113 
114  virtual IdentityCertificate
115  getCertificate(const Name& certName) const NDN_CXX_DECL_OVERRIDE;
116 
117  virtual std::set<Name>
118  getCertificatesOfKey(const Name& identity, const name::Component& keyId) const NDN_CXX_DECL_OVERRIDE;
119 
120  virtual void
121  setDefaultCertificateOfKey(const Name& identity, const name::Component& keyId, const Name& certName) NDN_CXX_DECL_OVERRIDE;
122 
123  virtual IdentityCertificate
124  getDefaultCertificateOfKey(const Name& identity, const name::Component& keyId) const NDN_CXX_DECL_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, PublicKey> m_keys;
139 
141  std::map<Name, Name> m_defaultKey;
142 
144  std::map<Name, 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 IdentityCertificate getCertificate(const Name &certName) const override
Get a certificate with name certName.
Definition: pib-memory.cpp:208
virtual void addKey(const Name &identity, const name::Component &keyId, const PublicKey &publicKey) override
Add a key.
Definition: pib-memory.cpp:105
represents a non-semantic error
Definition: pib-impl.hpp:46
Copyright (c) 2011-2015 Regents of the University of California.
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 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 void addIdentity(const Name &identity) override
Add an identity.
Definition: pib-memory.cpp:52
#define NDN_CXX_DECL_OVERRIDE
expands to &#39;override&#39; if compiler supports this feature, otherwise expands to nothing ...
Definition: common.hpp:57
virtual void setTpmLocator(const std::string &tpmLocator) override
Set the corresponding TPM information to tpmLocator.
Definition: pib-memory.cpp:34
virtual PublicKey getKeyBits(const Name &identity, const name::Component &keyId) const override
Get the key bits of a key.
Definition: pib-memory.cpp:131
virtual Name getDefaultIdentity() const override
Get the default identity.
Definition: pib-memory.cpp:90
virtual std::set< Name > getIdentities() const override
Get the name of all the identities.
Definition: pib-memory.cpp:76
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 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::string getTpmLocator() const override
Get TPM Locator.
Definition: pib-memory.cpp:40
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 of .
Definition: pib-memory.cpp:231
virtual bool hasCertificate(const Name &certName) const override
Check the existence of a certificate with name certName.
Definition: pib-memory.cpp:181
Name abstraction to represent an absolute name.
Definition: name.hpp:46
Abstract class of PIB implementation.
Definition: pib-impl.hpp:37
virtual bool hasKey(const Name &identity, const name::Component &keyId) const override
Check the existence of a key.
Definition: pib-memory.cpp:99
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
Component holds a read-only name component value.
virtual IdentityCertificate getDefaultCertificateOfKey(const Name &identity, const name::Component &keyId) const override
Get the default certificate of a key with id of .
Definition: pib-memory.cpp:241
virtual void removeCertificate(const Name &certName) override
Remove a certificate with name certName.
Definition: pib-memory.cpp:201
virtual void addCertificate(const IdentityCertificate &certificate) override
Add a certificate.
Definition: pib-memory.cpp:187
Error(const std::string &what)
Definition: pib-memory.hpp:43
virtual bool hasIdentity(const Name &identity) const override
Check the existence of an identity.
Definition: pib-memory.cpp:46
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