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
ndn::security::pib::CertificateContainer::add
void add(const v2::Certificate &certificate)
Add certificate into the container.
Definition: certificate-container.cpp:116
ndn::security::pib::CertificateContainer::const_iterator::iterator_category
std::forward_iterator_tag iterator_category
Definition: certificate-container.hpp:53
ndn::security::pib::CertificateContainer::const_iterator::operator==
bool operator==(const const_iterator &other) const
Definition: certificate-container.cpp:68
ndn::security::pib::CertificateContainer::const_iterator::difference_type
std::ptrdiff_t difference_type
Definition: certificate-container.hpp:55
certificate.hpp
ndn::security::pib::CertificateContainer::const_iterator::const_iterator
const_iterator()
Definition: certificate-container.cpp:32
ndn::security::pib::CertificateContainer
Container of certificates of a key.
Definition: certificate-container.hpp:48
ndn::security::pib::CertificateContainer::size
size_t size() const
Definition: certificate-container.cpp:110
ndn::security::pib::CertificateContainer::begin
const_iterator begin() const
Definition: certificate-container.cpp:92
ndn::security::pib::CertificateContainer::iterator
const_iterator iterator
Definition: certificate-container.hpp:86
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
ndn::security::v2::Certificate
The certificate following the certificate format naming convention.
Definition: certificate.hpp:82
ndn::security::pib::CertificateContainer::remove
void remove(const Name &certName)
Remove a certificate with certName from the container.
Definition: certificate-container.cpp:129
ndn::security::pib::CertificateContainer::pibImpl
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE shared_ptr< PibImpl > pibImpl
Definition: certificate-container.hpp:135
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:48
ndn::security::pib::detail::KeyImpl
Backend instance of Key.
Definition: key-impl.hpp:45
ndn::security::pib::CertificateContainer::const_iterator::operator++
const_iterator & operator++()
Definition: certificate-container.cpp:52
ndn::security::pib::CertificateContainer::end
const_iterator end() const
Definition: certificate-container.cpp:98
ndn::security::pib::CertificateContainer::getCache
const std::unordered_map< Name, v2::Certificate > & getCache() const
Definition: certificate-container.hpp:144
ndn::security::pib::CertificateContainer::find
const_iterator find(const Name &certName) const
Definition: certificate-container.cpp:104
ndn::security::pib::CertificateContainer::get
v2::Certificate get(const Name &certName) const
Get a certificate with certName from the container.
Definition: certificate-container.cpp:143
ndn::security::pib::CertificateContainer::getCertNames
const std::set< Name > & getCertNames() const
Definition: certificate-container.hpp:138
ndn::security::pib::CertificateContainer::const_iterator
Definition: certificate-container.hpp:51
ndn::security::pib::CertificateContainer::const_iterator::operator*
v2::Certificate operator*()
Definition: certificate-container.cpp:45
ndn::security::pib::CertificateContainer::const_iterator::operator!=
bool operator!=(const const_iterator &other) const
Definition: certificate-container.cpp:78
ndn::security::pib::CertificateContainer::isConsistent
bool isConsistent() const
Check if the container is consistent with the backend storage.
Definition: certificate-container.cpp:161
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34