certificate-bundle-fetcher.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2024 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_CERTIFICATE_BUNDLE_FETCHER_HPP
23 #define NDN_CXX_SECURITY_CERTIFICATE_BUNDLE_FETCHER_HPP
24 
25 #include "ndn-cxx/face.hpp"
27 
28 namespace ndn::security {
29 
41 {
42 public:
43  explicit
44  CertificateBundleFetcher(unique_ptr<CertificateFetcher> inner, Face& face);
45 
51  {
52  return m_bundleInterestLifetime;
53  }
54 
58  void
60  {
61  m_bundleInterestLifetime = time;
62  }
63 
67  void
68  setCertificateStorage(CertificateStorage& certStorage) override;
69 
70 protected:
71  void
72  doFetch(const shared_ptr<CertificateRequest>& certRequest,
73  const shared_ptr<ValidationState>& state,
74  const ValidationContinuation& continueValidation) override;
75 
76 private:
85  void
86  fetchFirstBundleSegment(const Name& bundleNamePrefix,
87  const shared_ptr<CertificateRequest>& certRequest,
88  const shared_ptr<ValidationState>& state,
89  const ValidationContinuation& continueValidation);
90 
94  void
95  fetchNextBundleSegment(const Name& fullBundleName, const name::Component& segmentNo,
96  const shared_ptr<CertificateRequest>& certRequest,
97  const shared_ptr<ValidationState>& state,
98  const ValidationContinuation& continueValidation);
99 
116  static Name
117  deriveBundleName(const Name& name);
118 
122  void
123  dataCallback(const Data& data, bool isSegmentZeroExpected,
124  const shared_ptr<CertificateRequest>& certRequest, const shared_ptr<ValidationState>& state,
125  const ValidationContinuation& continueValidation);
126 
130  void
131  nackCallback(const lp::Nack& nack,
132  const shared_ptr<CertificateRequest>& certRequest, const shared_ptr<ValidationState>& state,
133  const ValidationContinuation& continueValidation, const Name& bundleName);
134 
138  void
139  timeoutCallback(const shared_ptr<CertificateRequest>& certRequest, const shared_ptr<ValidationState>& state,
140  const ValidationContinuation& continueValidation, const Name& bundleName);
141 
142 private:
143  unique_ptr<CertificateFetcher> m_inner;
144  Face& m_face;
145  time::milliseconds m_bundleInterestLifetime = 1_s;
146 };
147 
148 } // namespace ndn::security
149 
150 #endif // NDN_CXX_SECURITY_CERTIFICATE_BUNDLE_FETCHER_HPP
Represents a Data packet.
Definition: data.hpp:39
Provide a communication channel with local or remote NDN forwarder.
Definition: face.hpp:91
Represents an absolute name.
Definition: name.hpp:45
Represents a Network Nack.
Definition: nack.hpp:39
Represents a name component.
Fetch certificate bundle from the network.
CertificateBundleFetcher(unique_ptr< CertificateFetcher > inner, Face &face)
void setBundleInterestLifetime(time::milliseconds time)
Set the lifetime of certificate bundle Interest.
void doFetch(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation) override
Asynchronous certificate fetching implementation.
void setCertificateStorage(CertificateStorage &certStorage) override
Set the storage for this and inner certificate fetcher.
Interface used by the validator to fetch missing certificates.
std::function< void(const Certificate &cert, const shared_ptr< ValidationState > &state)> ValidationContinuation
Storage for trusted anchors, verified certificate cache, and unverified certificate cache.
Contains the ndn-cxx security framework.
::boost::chrono::milliseconds milliseconds
Definition: time.hpp:52