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 <set>
26 #include <unordered_map>
27 #include "../v2/certificate.hpp"
28 
29 namespace ndn {
30 namespace security {
31 namespace pib {
32 
33 class PibImpl;
34 
35 namespace detail {
36 class KeyImpl;
37 } // namespace detail
38 
45 class CertificateContainer : noncopyable
46 {
47 public:
48  class const_iterator : public std::iterator<std::forward_iterator_tag, const v2::Certificate>
49  {
50  public:
52 
54  operator*();
55 
57  operator++();
58 
60  operator++(int);
61 
62  bool
63  operator==(const const_iterator& other) const;
64 
65  bool
66  operator!=(const const_iterator& other) const;
67 
68  private:
69  const_iterator(std::set<Name>::const_iterator it, const CertificateContainer& container);
70 
71  private:
72  std::set<Name>::const_iterator m_it;
73  const CertificateContainer* m_container;
74 
75  friend class CertificateContainer;
76  };
77 
79 
80 public:
82  begin() const;
83 
85  end() const;
86 
88  find(const Name& certName) const;
89 
90  size_t
91  size() const;
92 
97  void
98  add(const v2::Certificate& certificate);
99 
104  void
105  remove(const Name& certName);
106 
113  get(const Name& certName) const;
114 
120  bool
121  isConsistent() const;
122 
128  CertificateContainer(const Name& keyName, shared_ptr<PibImpl> impl);
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_impl;
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-2016 Regents of the University of California.
Definition: common.hpp:74
The certificate following the certificate format naming convention.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:43
Container of certificates of a key.
const_iterator find(const Name &certName) const
bool isConsistent() const
Check if the container is consistent with the backend storage.
Name abstraction to represent an absolute name.
Definition: name.hpp:46
void add(const v2::Certificate &certificate)
Add certificate into the container.
Backend instance of Key.
Definition: key-impl.hpp:45