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; -*- */
2 /*
3  * Copyright (c) 2013-2018 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_SECURITY_PIB_PIB_MEMORY_HPP
23 #define NDN_SECURITY_PIB_PIB_MEMORY_HPP
24 
26 
27 namespace ndn {
28 namespace security {
29 namespace pib {
30 
37 class PibMemory : public PibImpl
38 {
39 public:
44  explicit
45  PibMemory(const std::string& location = "");
46 
47  static const std::string&
48  getScheme();
49 
50 public: // TpmLocator management
51  void
52  setTpmLocator(const std::string& tpmLocator) override;
53 
54  std::string
55  getTpmLocator() const override;
56 
57 public: // Identity management
58  bool
59  hasIdentity(const Name& identity) const override;
60 
61  void
62  addIdentity(const Name& identity) override;
63 
64  void
65  removeIdentity(const Name& identity) override;
66 
67  void
68  clearIdentities() override;
69 
70  std::set<Name>
71  getIdentities() const override;
72 
73  void
74  setDefaultIdentity(const Name& identityName) override;
75 
76  Name
77  getDefaultIdentity() const override;
78 
79 public: // Key management
80  bool
81  hasKey(const Name& keyName) const override;
82 
83  void
84  addKey(const Name& identity, const Name& keyName, const uint8_t* key, size_t keyLen) override;
85 
86  void
87  removeKey(const Name& keyName) override;
88 
89  Buffer
90  getKeyBits(const Name& keyName) const override;
91 
92  std::set<Name>
93  getKeysOfIdentity(const Name& identity) const override;
94 
95  void
96  setDefaultKeyOfIdentity(const Name& identity, const Name& keyName) override;
97 
98  Name
99  getDefaultKeyOfIdentity(const Name& identity) const override;
100 
101 public: // Certificate management
102  bool
103  hasCertificate(const Name& certName) const override;
104 
105  void
106  addCertificate(const v2::Certificate& certificate) override;
107 
108  void
109  removeCertificate(const Name& certName) override;
110 
112  getCertificate(const Name& certName) const override;
113 
114  std::set<Name>
115  getCertificatesOfKey(const Name& keyName) const override;
116 
117  void
118  setDefaultCertificateOfKey(const Name& keyName, const Name& certName) override;
119 
121  getDefaultCertificateOfKey(const Name& keyName) const override;
122 
123 private:
124  std::string m_tpmLocator;
125 
126  bool m_hasDefaultIdentity;
127  Name m_defaultIdentity;
128 
129  std::set<Name> m_identities;
130 
132  std::map<Name, Name> m_defaultKeys;
133 
135  std::map<Name, Buffer> m_keys;
136 
138  std::map<Name, Name> m_defaultCerts;
139 
141  std::map<Name, v2::Certificate> m_certs;
142 };
143 
144 } // namespace pib
145 } // namespace security
146 } // namespace ndn
147 
148 #endif // NDN_SECURITY_PIB_PIB_MEMORY_HPP
bool hasIdentity(const Name &identity) const override
Check the existence of an identity.
Definition: pib-memory.cpp:57
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:192
void clearIdentities() override
Erasing all certificates, keys, and identities.
Definition: pib-memory.cpp:89
static const std::string & getScheme()
Definition: pib-memory.cpp:38
void removeKey(const Name &keyName) override
Remove a key with keyName and related certificates.
Definition: pib-memory.cpp:144
void removeIdentity(const Name &identity) override
Remove an identity and related keys and certificates.
Definition: pib-memory.cpp:74
void addCertificate(const v2::Certificate &certificate) override
Add a certificate.
Definition: pib-memory.cpp:209
std::string getTpmLocator() const override
Get TPM Locator.
Definition: pib-memory.cpp:51
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:257
std::set< Name > getIdentities() const override
Get the name of all the identities.
Definition: pib-memory.cpp:101
bool hasKey(const Name &keyName) const override
Check the existence of a key with keyName.
Definition: pib-memory.cpp:125
PibMemory(const std::string &location="")
Create memory based PIB backend.
Definition: pib-memory.cpp:32
void setTpmLocator(const std::string &tpmLocator) override
Set the corresponding TPM information to tpmLocator.
Definition: pib-memory.cpp:45
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:182
void removeCertificate(const Name &certName) override
Remove a certificate with name certName.
Definition: pib-memory.cpp:224
Name getDefaultIdentity() const override
Get the default identity.
Definition: pib-memory.cpp:115
void addKey(const Name &identity, const Name &keyName, const uint8_t *key, size_t keyLen) override
Add a key.
Definition: pib-memory.cpp:131
Represents an absolute name.
Definition: name.hpp:43
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:234
void setDefaultIdentity(const Name &identityName) override
Set an identity with name identityName as the default identity.
Definition: pib-memory.cpp:107
bool hasCertificate(const Name &certName) const override
Check the existence of a certificate with name certName.
Definition: pib-memory.cpp:203
void addIdentity(const Name &identity) override
Add an identity.
Definition: pib-memory.cpp:63
v2::Certificate getDefaultCertificateOfKey(const Name &keyName) const override
Definition: pib-memory.cpp:267
Buffer getKeyBits(const Name &keyName) const override
Get the key bits of a key with name keyName.
Definition: pib-memory.cpp:158
General-purpose automatically managed/resized buffer.
Definition: buffer.hpp:40
Abstract class of PIB implementation.
Definition: pib-impl.hpp:40
std::set< Name > getKeysOfIdentity(const Name &identity) const override
Get all the key names of an identity with name identity.
Definition: pib-memory.cpp:170
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:245