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-2018 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_SECURITY_PIB_CERTIFICATE_CONTAINER_HPP
23 #define NDN_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 v2::Certificate;
55  using difference_type = std::ptrdiff_t;
56  using pointer = value_type*;
58 
60 
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 v2::Certificate& certificate);
107 
112  void
113  remove(const Name& certName);
114 
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, v2::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, v2::Certificate> m_certs;
154 
155  shared_ptr<PibImpl> m_pib;
156 
157  friend class detail::KeyImpl;
158 };
159 
160 } // namespace pib
161 
163 
164 } // namespace security
165 } // namespace ndn
166 
167 #endif // NDN_SECURITY_PIB_CERTIFICATE_CONTAINER_HPP
Copyright (c) 2011-2015 Regents of the University of California.
The certificate following the certificate format naming convention.
Definition: certificate.hpp:81
void remove(const Name &certName)
Remove a certificate with certName from the container.
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE shared_ptr< PibImpl > pibImpl
bool isConsistent() const
Check if the container is consistent with the backend storage.
v2::Certificate get(const Name &certName) const
Get a certificate with certName from the container.
const std::set< Name > & getCertNames() const
const std::unordered_map< Name, v2::Certificate > & getCache() const
Container of certificates of a key.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:43
Represents an absolute name.
Definition: name.hpp:43
void add(const v2::Certificate &certificate)
Add certificate into the container.
Backend instance of Key.
Definition: key-impl.hpp:44
const_iterator find(const Name &certName) const