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-2019 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_IMPL_PIB_MEMORY_HPP
23 #define NDN_SECURITY_PIB_IMPL_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_IMPL_PIB_MEMORY_HPP
ndn::security::pib::PibMemory::getScheme
static const std::string & getScheme()
Definition: pib-memory.cpp:38
ndn::security::pib::PibMemory::removeCertificate
void removeCertificate(const Name &certName) override
Remove a certificate with name certName.
Definition: pib-memory.cpp:224
ndn::security::pib::PibMemory::setTpmLocator
void setTpmLocator(const std::string &tpmLocator) override
Set the corresponding TPM information to tpmLocator.
Definition: pib-memory.cpp:45
ndn::security::pib::PibMemory::getTpmLocator
std::string getTpmLocator() const override
Get TPM Locator.
Definition: pib-memory.cpp:51
ndn::security::pib::PibMemory::hasCertificate
bool hasCertificate(const Name &certName) const override
Check the existence of a certificate with name certName.
Definition: pib-memory.cpp:203
ndn::security::pib::PibMemory::addIdentity
void addIdentity(const Name &identity) override
Add an identity.
Definition: pib-memory.cpp:63
ndn::Buffer
General-purpose automatically managed/resized buffer.
Definition: buffer.hpp:41
ndn::security::pib::PibMemory::addKey
void addKey(const Name &identity, const Name &keyName, const uint8_t *key, size_t keyLen) override
Add a key.
Definition: pib-memory.cpp:131
ndn::security::pib::PibMemory::getKeyBits
Buffer getKeyBits(const Name &keyName) const override
Get the key bits of a key with name keyName.
Definition: pib-memory.cpp:158
ndn::security::pib::PibMemory::getDefaultIdentity
Name getDefaultIdentity() const override
Get the default identity.
Definition: pib-memory.cpp:115
ndn::security::pib::PibMemory::getDefaultKeyOfIdentity
Name getDefaultKeyOfIdentity(const Name &identity) const override
Definition: pib-memory.cpp:192
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
ndn::security::pib::PibMemory::getDefaultCertificateOfKey
v2::Certificate getDefaultCertificateOfKey(const Name &keyName) const override
Definition: pib-memory.cpp:267
ndn::security::v2::Certificate
The certificate following the certificate format naming convention.
Definition: certificate.hpp:82
ndn::security::pib::PibMemory::setDefaultCertificateOfKey
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
ndn::security::pib::PibMemory::hasKey
bool hasKey(const Name &keyName) const override
Check the existence of a key with keyName.
Definition: pib-memory.cpp:125
ndn::security::pib::PibMemory::getCertificatesOfKey
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
ndn::security::pib::PibMemory::removeIdentity
void removeIdentity(const Name &identity) override
Remove an identity and related keys and certificates.
Definition: pib-memory.cpp:74
ndn::security::pib::PibMemory::hasIdentity
bool hasIdentity(const Name &identity) const override
Check the existence of an identity.
Definition: pib-memory.cpp:57
ndn::security::pib::PibMemory::getKeysOfIdentity
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
ndn::security::pib::PibMemory::removeKey
void removeKey(const Name &keyName) override
Remove a key with keyName and related certificates.
Definition: pib-memory.cpp:144
ndn::security::pib::PibMemory::clearIdentities
void clearIdentities() override
Erasing all certificates, keys, and identities.
Definition: pib-memory.cpp:89
ndn::security::pib::PibMemory::addCertificate
void addCertificate(const v2::Certificate &certificate) override
Add a certificate.
Definition: pib-memory.cpp:209
ndn::security::pib::PibMemory
An in-memory implementation of Pib.
Definition: pib-memory.hpp:38
ndn::security::pib::PibMemory::setDefaultKeyOfIdentity
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
ndn::security::pib::PibMemory::PibMemory
PibMemory(const std::string &location="")
Create memory based PIB backend.
Definition: pib-memory.cpp:32
pib-impl.hpp
ndn::security::pib::PibImpl
Abstract class of PIB implementation.
Definition: pib-impl.hpp:41
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34
ndn::security::pib::PibMemory::getCertificate
v2::Certificate getCertificate(const Name &certName) const override
Get a certificate with name certName.
Definition: pib-memory.cpp:234
ndn::security::pib::PibMemory::getIdentities
std::set< Name > getIdentities() const override
Get the name of all the identities.
Definition: pib-memory.cpp:101
ndn::security::pib::PibMemory::setDefaultIdentity
void setDefaultIdentity(const Name &identityName) override
Set an identity with name identityName as the default identity.
Definition: pib-memory.cpp:107