pib.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_SECURITY_PIB_PIB_HPP
23 #define NDN_SECURITY_PIB_PIB_HPP
24 
25 #include "identity-container.hpp"
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  explicit
60  Error(const std::string& what)
61  : std::runtime_error(what)
62  {
63  }
64  };
65 
66 public:
67  ~Pib();
68 
72  std::string
73  getScheme() const
74  {
75  return m_scheme;
76  }
77 
81  std::string
82  getPibLocator() const;
83 
90  void
91  setTpmLocator(const std::string& tpmLocator);
92 
97  std::string
98  getTpmLocator() const;
99 
103  void
104  reset();
105 
110  Identity
111  getIdentity(const Name& identityName) const;
112 
114  const IdentityContainer&
115  getIdentities() const;
116 
121  const Identity&
122  getDefaultIdentity() const;
123 
124 NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE: // write operations should be private
125  /*
126  * @brief Create a Pib instance
127  *
128  * @param scheme The scheme for the Pib
129  * @param location The location for the Pib
130  * @param impl The backend implementation
131  */
132  Pib(const std::string& scheme, const std::string& location, shared_ptr<PibImpl> impl);
133 
134  /*
135  * @brief Create an identity with name @p identityName and return a reference to it.
136  *
137  * If there already exists an identity for the name @p identityName, then it is returned.
138  * If no default identity is set, the newly created identity will be set as the default.
139  *
140  * @param identityName The name for the identity to be added
141  */
142 
150  Identity
151  addIdentity(const Name& identity);
152 
153  /*
154  * @brief Remove an @p identity.
155  *
156  * If the default identity is being removed, no default identity will be selected.
157  */
158  void
159  removeIdentity(const Name& identity);
160 
168  const Identity&
169  setDefaultIdentity(const Name& identity);
170 
171  shared_ptr<PibImpl>
172  getImpl()
173  {
174  return m_impl;
175  }
176 
177 protected:
178  std::string m_scheme;
179  std::string m_location;
180 
183 
185 
186  shared_ptr<PibImpl> m_impl;
187 
188  friend class v2::KeyChain;
189 };
190 
191 } // namespace pib
192 
193 using pib::Pib;
194 
195 } // namespace security
196 } // namespace ndn
197 
198 #endif // NDN_SECURITY_PIB_PIB_HPP
Copyright (c) 2013-2017 Regents of the University of California.
Definition: common.hpp:66
represents a semantic error
Definition: pib.hpp:56
std::string getTpmLocator() const
Get TPM Locator.
Definition: pib.cpp:61
The interface of signing key management.
bool m_isDefaultIdentityLoaded
Definition: pib.hpp:181
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:43
std::string m_location
Definition: pib.hpp:179
std::string getPibLocator() const
Get PIB Locator.
Definition: pib.cpp:45
STL namespace.
void reset()
Reset content in PIB, including reset of the TPM locator.
Definition: pib.cpp:71
shared_ptr< PibImpl > m_impl
Definition: pib.hpp:186
void setTpmLocator(const std::string &tpmLocator)
Set the corresponding TPM information to tpmLocator.
Definition: pib.cpp:51
IdentityContainer m_identities
Definition: pib.hpp:184
Error(const std::string &what)
Definition: pib.hpp:60
std::string getScheme() const
return the scheme of the PibLocator
Definition: pib.hpp:73
const IdentityContainer & getIdentities() const
Get all the identities.
Definition: pib.cpp:108
Represents an absolute name.
Definition: name.hpp:42
const Identity & getDefaultIdentity() const
Get the default identity.
Definition: pib.cpp:129
Container of identities of a Pib.
std::string m_scheme
Definition: pib.hpp:178
A frontend handle of an Identity.
Definition: identity.hpp:42
Identity getIdentity(const Name &identityName) const
Get an identity with name identityName.
Definition: pib.cpp:100
Identity m_defaultIdentity
Definition: pib.hpp:182
represents the PIB
Definition: pib.hpp:52