certificate-container.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_SECURITY_PIB_CERTIFICATE_CONTAINER_HPP
23 #define NDN_SECURITY_PIB_CERTIFICATE_CONTAINER_HPP
24 
25 #include "../v2/certificate.hpp"
26 
27 #include <set>
28 #include <unordered_map>
29 
30 namespace ndn {
31 namespace security {
32 namespace pib {
33 
34 class PibImpl;
35 
36 namespace detail {
37 class KeyImpl;
38 } // namespace detail
39 
46 class CertificateContainer : noncopyable
47 {
48 public:
49  class const_iterator : public std::iterator<std::forward_iterator_tag, const v2::Certificate>
50  {
51  public:
53 
55  operator*();
56 
58  operator++();
59 
61  operator++(int);
62 
63  bool
64  operator==(const const_iterator& other) const;
65 
66  bool
67  operator!=(const const_iterator& other) const;
68 
69  private:
70  const_iterator(std::set<Name>::const_iterator it, const CertificateContainer& container);
71 
72  private:
73  std::set<Name>::const_iterator m_it;
74  const CertificateContainer* m_container;
75 
76  friend class CertificateContainer;
77  };
78 
80 
81 public:
83  begin() const;
84 
86  end() const;
87 
89  find(const Name& certName) const;
90 
91  size_t
92  size() const;
93 
98  void
99  add(const v2::Certificate& certificate);
100 
105  void
106  remove(const Name& certName);
107 
114  get(const Name& certName) const;
115 
120  bool
121  isConsistent() const;
122 
128  CertificateContainer(const Name& keyName, shared_ptr<PibImpl> pibImpl);
129 
130  const std::set<Name>&
131  getCertNames() const
132  {
133  return m_certNames;
134  }
135 
136  const std::unordered_map<Name, v2::Certificate>&
137  getCache() const
138  {
139  return m_certs;
140  }
141 
142 private:
143  Name m_keyName;
144  std::set<Name> m_certNames;
146  mutable std::unordered_map<Name, v2::Certificate> m_certs;
147 
148  shared_ptr<PibImpl> m_pib;
149 
150  friend class detail::KeyImpl;
151 };
152 
153 } // namespace pib
154 
156 
157 } // namespace security
158 } // namespace ndn
159 
160 #endif // NDN_SECURITY_PIB_CERTIFICATE_CONTAINER_HPP
Copyright (c) 2013-2017 Regents of the University of California.
Definition: common.hpp:66
The certificate following the certificate format naming convention.
Definition: certificate.hpp:81
bool operator==(const Identity &lhs, const Identity &rhs)
Definition: identity.hpp:162
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:43
Container of certificates of a key.
Represents an absolute name.
Definition: name.hpp:42
bool operator!=(const Identity &lhs, const Identity &rhs)
Definition: identity.cpp:101