pib.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2022 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_CXX_SECURITY_PIB_PIB_HPP
23 #define NDN_CXX_SECURITY_PIB_PIB_HPP
24 
26 
27 namespace ndn {
28 namespace security {
29 namespace pib {
30 
31 class PibImpl;
32 
52 class Pib : noncopyable
53 {
54 public:
56  class Error : public std::runtime_error
57  {
58  public:
59  using std::runtime_error::runtime_error;
60  };
61 
62  ~Pib();
63 
67  const std::string&
68  getPibLocator() const
69  {
70  return m_locator;
71  }
72 
76  std::string
77  getTpmLocator() const;
78 
83  void
84  setTpmLocator(const std::string& tpmLocator);
85 
89  void
90  reset();
91 
96  Identity
97  getIdentity(const Name& identityName) const;
98 
102  const IdentityContainer&
103  getIdentities() const;
104 
109  Identity
110  getDefaultIdentity() const;
111 
112 NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE: // write operations are accessible only by KeyChain
119  Pib(const std::string& locator, shared_ptr<PibImpl> impl);
120 
128  Identity
129  addIdentity(const Name& identity);
130 
136  void
137  removeIdentity(const Name& identity);
138 
146  Identity
147  setDefaultIdentity(const Name& identity);
148 
149 private:
150  const std::string m_locator;
151  const shared_ptr<PibImpl> m_impl;
152 
153  IdentityContainer m_identities;
154  mutable Identity m_defaultIdentity;
155 
156  friend KeyChain;
157 };
158 
159 } // namespace pib
160 
161 using pib::Pib;
162 
163 } // namespace security
164 } // namespace ndn
165 
166 #endif // NDN_CXX_SECURITY_PIB_PIB_HPP
Represents an absolute name.
Definition: name.hpp:44
Container of identities of a PIB.
Frontend handle for an identity in the PIB.
Definition: identity.hpp:50
Represents a semantic error.
Definition: pib.hpp:57
Frontend to the Public Information Base.
Definition: pib.hpp:53
Identity getIdentity(const Name &identityName) const
Return an identity with name identityName.
Definition: pib.cpp:89
const std::string & getPibLocator() const
Return the PIB Locator.
Definition: pib.hpp:68
void reset()
Reset the contents of the PIB, including reset of the TPM Locator.
Definition: pib.cpp:61
Identity getDefaultIdentity() const
Return the default identity.
Definition: pib.cpp:116
void setTpmLocator(const std::string &tpmLocator)
Set the associated TPM information to tpmLocator.
Definition: pib.cpp:49
std::string getTpmLocator() const
Return the associated TPM Locator or an empty string if unset.
Definition: pib.cpp:43
const IdentityContainer & getIdentities() const
Return all the identities.
Definition: pib.cpp:96
The main interface for signing key management.
Definition: key-chain.hpp:87
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:48
Definition: data.cpp:25