NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
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_HPP
23 #define NDN_SECURITY_PIB_HPP
24 
25 #include "identity-container.hpp"
26 
27 namespace ndn {
28 namespace security {
29 
30 class KeyChain;
31 class PibImpl;
32 
48 class Pib : noncopyable
49 {
50 public:
51  friend class KeyChain;
52 
53 public:
55  class Error : public std::runtime_error
56  {
57  public:
58  explicit
59  Error(const std::string& what)
60  : std::runtime_error(what)
61  {
62  }
63  };
64 
65 public:
66 
67  ~Pib();
68 
72  std::string
73  getScheme() const
74  {
75  return m_scheme;
76  }
77 
81  std::string
82  getPibLocator() const;
83 
92  void
93  setTpmLocator(const std::string& tpmLocator);
94 
98  std::string
99  getTpmLocator() const;
100 
107  Identity
108  getIdentity(const Name& identityName) const;
109 
111  const IdentityContainer&
112  getIdentities() const;
113 
120  Identity&
121  getDefaultIdentity() const;
122 
123 NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE: // write operations should be private
124 
125  /*
126  * @brief Create an identity with name @p identityName and return a reference to it.
127  *
128  * If there already exists an identity for the name @p identityName, then it is returned.
129  * If no default identity is set, the newly created identity will be set as the default.
130  *
131  * @param identityName The name for the identity to be added
132  */
133  Identity
134  addIdentity(const Name& identityName);
135 
136  /*
137  * @brief Remove an identity with name @p identityName.
138  *
139  * @param identityName The name for the identity to be deleted
140  */
141  void
142  removeIdentity(const Name& identityName);
143 
152  Identity&
153  setDefaultIdentity(const Name& identityName);
154 
156  /*
157  * @brief Create a new Pib with the specified @p location
158  *
159  * @param scheme The scheme for the Pib
160  * @param location The location for the Pib
161  * @param impl The backend implementation
162  */
163  Pib(const std::string scheme, const std::string& location, shared_ptr<PibImpl> impl);
164 
165  shared_ptr<PibImpl>
167  {
168  return m_impl;
169  }
170 
171 protected:
172  std::string m_scheme;
173  std::string m_location;
174 
175  mutable bool m_hasDefaultIdentity;
177 
180 
181  shared_ptr<PibImpl> m_impl;
182 };
183 
184 } // namespace security
185 } // namespace ndn
186 
187 #endif // NDN_SECURITY_PIB_HPP
Identity & getDefaultIdentity() const
Get the default identity.
Definition: pib.cpp:108
bool m_needRefreshIdentities
Definition: pib.hpp:178
Copyright (c) 2011-2015 Regents of the University of California.
Error(const std::string &what)
Definition: pib.hpp:59
represents an identity
Definition: identity.hpp:44
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:43
bool m_hasDefaultIdentity
Definition: pib.hpp:175
void setTpmLocator(const std::string &tpmLocator)
Set the corresponding TPM information to tpmLocator.
Definition: pib.cpp:48
std::string getPibLocator() const
Get PIB Locator.
Definition: pib.cpp:42
The packet signing interface.
Definition: key-chain.hpp:48
IdentityContainer m_identities
Definition: pib.hpp:179
Identity getIdentity(const Name &identityName) const
Get an identity with name identityName.
Definition: pib.cpp:81
STL namespace.
A handler to search or enumerate identities in PIB.
std::string m_scheme
Definition: pib.hpp:172
represents a semantic error
Definition: pib.hpp:55
Identity m_defaultIdentity
Definition: pib.hpp:176
void removeIdentity(const Name &identityName)
Definition: pib.cpp:71
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const std::string & location
Definition: pib.hpp:163
std::string getScheme() const
return the scheme of the PibLocator
Definition: pib.hpp:73
Identity & setDefaultIdentity(const Name &identityName)
Set an identity with name identityName as the default identity.
Definition: pib.cpp:98
shared_ptr< PibImpl > getImpl()
Definition: pib.hpp:166
const IdentityContainer & getIdentities() const
Get all the identities.
Definition: pib.cpp:87
std::string getTpmLocator() const
Get TPM Locator.
Definition: pib.cpp:54
shared_ptr< PibImpl > m_impl
Definition: pib.hpp:181
Name abstraction to represent an absolute name.
Definition: name.hpp:46
represents the PIB
Definition: pib.hpp:48
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE const std::string shared_ptr< PibImpl > impl
Definition: pib.hpp:163
std::string m_location
Definition: pib.hpp:173