All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
pib.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_PIB_HPP
24 #define NDN_PIB_HPP
25 
26 #include <stdexcept>
27 #include "pib-identity-container.hpp"
28 
29 // Give friend access to the tests.
30 class TestKeyChain_Management_Test;
31 
32 namespace ndn {
33 
34 class PibImpl;
35 
54 class Pib {
55 public:
60  class Error : public std::runtime_error
61  {
62  public:
63  Error(const std::string& what)
64  : std::runtime_error(what)
65  {
66  }
67  };
68 
73  std::string
74  getScheme() const { return scheme_; }
75 
80  std::string
81  getPibLocator() const {return scheme_ + ":" + location_; }
82 
88  void
89  setTpmLocator(const std::string& tpmLocator);
90 
95  std::string
96  getTpmLocator();
97 
104  ptr_lib::shared_ptr<PibIdentity>
105  getIdentity(const Name& identityName);
106 
112  ptr_lib::shared_ptr<PibIdentity>&
114 
119  void
120  getAllIdentityNames(std::vector<Name>& nameList);
121 
122 private:
123  friend class KeyChain;
124  // Give friend access to the tests.
125  friend TestKeyChain_Management_Test;
126 
127  /*
128  * Create a Pib instance. This constructor should only be called by KeyChain.
129  * @param scheme The scheme for the PIB.
130  * @param location The location for the PIB.
131  * @param pibImpl The PIB backend implementation.
132  */
133  Pib(const std::string& scheme, const std::string& location,
134  const ptr_lib::shared_ptr<PibImpl>& pibImpl);
135 
139  void
140  reset();
141 
148  ptr_lib::shared_ptr<PibIdentity>
149  addIdentity(const Name& identityName);
150 
157  void
158  removeIdentity(const Name& identityName);
159 
166  ptr_lib::shared_ptr<PibIdentity>
167  setDefaultIdentity(const Name& identityName);
168 
169  // Disable the copy constructor and assignment operator.
170  Pib(const Pib& other);
171  Pib& operator=(const Pib& other);
172 
173  std::string scheme_;
174  std::string location_;
175 
176  ptr_lib::shared_ptr<PibIdentity> defaultIdentity_;
177 
178  PibIdentityContainer identities_;
179 
180  ptr_lib::shared_ptr<PibImpl> pibImpl_;
181 };
182 
183 }
184 
185 #endif
ptr_lib::shared_ptr< PibIdentity > getIdentity(const Name &identityName)
Get the identity with name identityName.
Definition: pib.cpp:101
void getAllIdentityNames(std::vector< Name > &nameList)
Append all the identity names to the nameList.
Definition: pib.cpp:122
std::string getTpmLocator()
Get the TPM Locator.
Definition: pib.cpp:52
A PibIdentityContainer is used to search/enumerate the identities in a PIB.
Definition: pib-identity-container.hpp:44
KeyChain is the main class of the security library.
Definition: key-chain.hpp:53
std::string getScheme() const
Get the scheme of the PIB locator.
Definition: pib.hpp:74
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
void setTpmLocator(const std::string &tpmLocator)
Set the corresponding TPM information to tpmLocator.
Definition: pib.cpp:42
std::string getPibLocator() const
Get the PIB locator.
Definition: pib.hpp:81
ptr_lib::shared_ptr< PibIdentity > & getDefaultIdentity()
Get the default identity.
Definition: pib.cpp:109
A Pib::Error extends runtime_error and represents a semantic error in PIB processing.
Definition: pib.hpp:60
In general, a PIB (Public Information Base) stores the public portion of a user's cryptography keys...
Definition: pib.hpp:54