All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
trust-anchor-container.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
23 #ifndef NDN_TRUST_ANCHOR_CONTAINER_HPP
24 #define NDN_TRUST_ANCHOR_CONTAINER_HPP
25 
26 #include <map>
27 #include "trust-anchor-group.hpp"
28 
29 namespace ndn {
30 
50 public:
51  class Error : public std::runtime_error
52  {
53  public:
54  Error(const std::string& what)
55  : std::runtime_error(what)
56  {
57  }
58  };
59 
61 
70  void
71  insert(const std::string& groupId, const CertificateV2& certificate);
72 
85  void
86  insert
87  (const std::string& groupId, const std::string& path,
88  Milliseconds refreshPeriod, bool isDirectory = false);
89 
93  void
95  {
96  groups_.clear();
97  anchors_.clear();
98  }
99 
105  ptr_lib::shared_ptr<CertificateV2>
106  find(const Name& keyName) const;
107 
115  ptr_lib::shared_ptr<CertificateV2>
116  find(const Interest& interest) const;
117 
125  getGroup(const std::string& groupId);
126 
131  size_t
132  size() const { return anchors_.size(); }
133 
134 private:
135  class AnchorContainer : public CertificateContainerInterface {
136  public:
137  virtual
138  ~AnchorContainer();
139 
144  virtual void
145  add(const CertificateV2& certificate);
146 
152  virtual void
153  remove(const Name& certificateName);
154 
158  void
159  clear() { anchorsByName_.clear(); }
160 
165  size_t
166  size() const { return anchorsByName_.size(); }
167 
168  private:
169  friend class TrustAnchorContainer;
170 
171  std::map<Name, ptr_lib::shared_ptr<CertificateV2> > anchorsByName_;
172  };
173 
174  void
175  refresh();
176 
177  // Disable the copy constructor and assignment operator.
178  TrustAnchorContainer(const TrustAnchorContainer& other);
179  TrustAnchorContainer& operator=(const TrustAnchorContainer& other);
180 
181  std::map<std::string, ptr_lib::shared_ptr<TrustAnchorGroup> > groups_;
182  AnchorContainer anchors_;
183 };
184 
185 }
186 
187 #endif
double Milliseconds
A time interval represented as the number of milliseconds.
Definition: common.hpp:114
ptr_lib::shared_ptr< CertificateV2 > find(const Name &keyName) const
Search for a certificate across all groups (longest prefix match).
Definition: trust-anchor-container.cpp:67
void insert(const std::string &groupId, const CertificateV2 &certificate)
Insert a static trust anchor.
CertificateV2 represents a certificate following the certificate format naming convention.
Definition: certificate-v2.hpp:81
A Name holds an array of Name::Component and represents an NDN name.
Definition: name.hpp:40
An Interest holds a Name and other fields for an interest.
Definition: interest.hpp:43
TrustAnchorGroup & getGroup(const std::string &groupId)
Get the trust anchor group for the groupId.
Definition: trust-anchor-container.cpp:97
size_t size() const
Get the number of trust anchors across all groups.
Definition: trust-anchor-container.hpp:132
void clear()
Remove all static and dynamic anchors.
Definition: trust-anchor-container.hpp:94
Definition: trust-anchor-container.hpp:51
Definition: trust-anchor-group.hpp:31
A TrustAnchorContainer represents a container for trust anchors.
Definition: trust-anchor-container.hpp:49
TrustAnchorGroup represents a group of trust anchors which implement the CertificateContainerInterfac...
Definition: trust-anchor-group.hpp:57