NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
certificate-container.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2021 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_CXX_SECURITY_PIB_CERTIFICATE_CONTAINER_HPP
23 #define NDN_CXX_SECURITY_PIB_CERTIFICATE_CONTAINER_HPP
24 
26 
27 #include <iterator>
28 #include <set>
29 #include <unordered_map>
30 
31 namespace ndn {
32 namespace security {
33 namespace pib {
34 
35 class PibImpl;
36 
37 namespace detail {
38 class KeyImpl;
39 } // namespace detail
40 
47 class CertificateContainer : noncopyable
48 {
49 public:
51  {
52  public:
53  using iterator_category = std::forward_iterator_tag;
54  using value_type = const Certificate;
55  using difference_type = std::ptrdiff_t;
56  using pointer = value_type*;
58 
60 
61  Certificate
62  operator*();
63 
65  operator++();
66 
68  operator++(int);
69 
70  bool
71  operator==(const const_iterator& other) const;
72 
73  bool
74  operator!=(const const_iterator& other) const;
75 
76  private:
77  const_iterator(std::set<Name>::const_iterator it, const CertificateContainer& container);
78 
79  private:
80  std::set<Name>::const_iterator m_it;
81  const CertificateContainer* m_container;
82 
83  friend class CertificateContainer;
84  };
85 
87 
88 public:
90  begin() const;
91 
93  end() const;
94 
96  find(const Name& certName) const;
97 
98  size_t
99  size() const;
100 
105  void
106  add(const Certificate& certificate);
107 
112  void
113  remove(const Name& certName);
114 
120  Certificate
121  get(const Name& certName) const;
122 
127  bool
128  isConsistent() const;
129 
135  CertificateContainer(const Name& keyName, shared_ptr<PibImpl> pibImpl);
136 
137  const std::set<Name>&
138  getCertNames() const
139  {
140  return m_certNames;
141  }
142 
143  const std::unordered_map<Name, Certificate>&
144  getCache() const
145  {
146  return m_certs;
147  }
148 
149 private:
150  Name m_keyName;
151  std::set<Name> m_certNames;
153  mutable std::unordered_map<Name, Certificate> m_certs;
154 
155  shared_ptr<PibImpl> m_pib;
156 
157 #ifndef DOXYGEN
158  friend detail::KeyImpl;
159 #endif
160 };
161 
162 } // namespace pib
163 
165 
166 } // namespace security
167 } // namespace ndn
168 
169 #endif // NDN_CXX_SECURITY_PIB_CERTIFICATE_CONTAINER_HPP
Copyright (c) 2011-2015 Regents of the University of California.
bool operator==(const Identity &lhs, const Identity &rhs)
Definition: identity.hpp:167
const std::set< Name > & getCertNames() const
const std::unordered_map< Name, Certificate > & getCache() const
Container of certificates of a key.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:48
Represents an absolute name.
Definition: name.hpp:41
Backend instance of Key.
Definition: key-impl.hpp:44
bool operator!=(const Identity &lhs, const Identity &rhs)
Definition: identity.cpp:101
span_constexpr std::size_t size(span< T, Extent > const &spn)
Definition: span-lite.hpp:1535