NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
validator.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_V2_VALIDATOR_HPP
23 #define NDN_SECURITY_V2_VALIDATOR_HPP
24 
31 
32 namespace ndn {
33 
34 class Face;
35 
36 namespace security {
37 namespace v2 {
38 
62 {
63 public:
70  Validator(unique_ptr<ValidationPolicy> policy, unique_ptr<CertificateFetcher> certFetcher);
71 
73 
75  getPolicy();
76 
78  getFetcher();
79 
83  void
84  setMaxDepth(size_t depth);
85 
89  size_t
90  getMaxDepth() const;
91 
97  void
98  validate(const Data& data,
99  const DataValidationSuccessCallback& successCb,
100  const DataValidationFailureCallback& failureCb);
101 
107  void
108  validate(const Interest& interest,
109  const InterestValidationSuccessCallback& successCb,
110  const InterestValidationFailureCallback& failureCb);
111 
112 public: // anchor management
121  void
122  loadAnchor(const std::string& groupId, Certificate&& cert);
123 
135  void
136  loadAnchor(const std::string& groupId, const std::string& certfilePath,
137  time::nanoseconds refreshPeriod, bool isDir = false);
138 
142  void
143  resetAnchors();
144 
150  void
152 
156  void
158 
159 private: // Common validator operations
166  void
167  validate(const Certificate& cert, const shared_ptr<ValidationState>& state);
168 
175  void
176  requestCertificate(const shared_ptr<CertificateRequest>& certRequest,
177  const shared_ptr<ValidationState>& state);
178 
179 private:
180  unique_ptr<ValidationPolicy> m_policy;
181  unique_ptr<CertificateFetcher> m_certFetcher;
182  size_t m_maxDepth;
183 };
184 
185 } // namespace v2
186 } // namespace security
187 } // namespace ndn
188 
189 #endif // NDN_SECURITY_V2_VALIDATOR_HPP
ndn::security::v2::Validator
Interface for validating data and interest packets.
Definition: validator.hpp:62
certificate-storage.hpp
ndn::security::v2::DataValidationFailureCallback
function< void(const Data &data, const ValidationError &error)> DataValidationFailureCallback
Callback to report a failed Data validation.
Definition: validation-callback.hpp:42
ndn::security::v2::Validator::setMaxDepth
void setMaxDepth(size_t depth)
Set the maximum depth of the certificate chain.
Definition: validator.cpp:63
certificate-request.hpp
ndn::security::v2::InterestValidationSuccessCallback
function< void(const Interest &interest)> InterestValidationSuccessCallback
Callback to report a successful Interest validation.
Definition: validation-callback.hpp:47
validation-callback.hpp
validation-policy.hpp
ndn::security::v2::ValidationPolicy
Abstraction that implements validation policy for Data and Interest packets.
Definition: validation-policy.hpp:38
ndn::security::v2::CertificateFetcher
Interface used by the validator to fetch missing certificates.
Definition: certificate-fetcher.hpp:40
ndn::security::v2::CertificateStorage
Storage for trusted anchors, verified certificate cache, and unverified certificate cache.
Definition: certificate-storage.hpp:37
ndn::security::v2::Certificate
The certificate following the certificate format naming convention.
Definition: certificate.hpp:82
validation-state.hpp
ndn::security::v2::Validator::getMaxDepth
size_t getMaxDepth() const
Definition: validator.cpp:69
ndn::security::v2::Validator::~Validator
~Validator()
ndn::security::v2::Validator::resetAnchors
void resetAnchors()
remove any previously loaded static or dynamic trust anchor
Definition: validator.cpp:198
ndn::security::v2::InterestValidationFailureCallback
function< void(const Interest &interest, const ValidationError &error)> InterestValidationFailureCallback
Callback to report a failed Interest validation.
Definition: validation-callback.hpp:52
ndn::security::v2::Validator::validate
void validate(const Data &data, const DataValidationSuccessCallback &successCb, const DataValidationFailureCallback &failureCb)
Asynchronously validate data.
Definition: validator.cpp:75
ndn::Interest
Represents an Interest packet.
Definition: interest.hpp:44
ndn::security::v2::Validator::cacheVerifiedCertificate
void cacheVerifiedCertificate(Certificate &&cert)
Cache verified cert a period of time (1 hour)
Definition: validator.cpp:204
ndn::Data
Represents a Data packet.
Definition: data.hpp:36
ndn::security::v2::Validator::getPolicy
ValidationPolicy & getPolicy()
Definition: validator.cpp:51
ndn::security::v2::DataValidationSuccessCallback
function< void(const Data &data)> DataValidationSuccessCallback
Callback to report a successful Data validation.
Definition: validation-callback.hpp:37
Face
ndn Face
Definition: face-impl.hpp:41
ndn::security::v2::Validator::getFetcher
CertificateFetcher & getFetcher()
Definition: validator.cpp:57
ndn::security::v2::Validator::loadAnchor
void loadAnchor(const std::string &groupId, Certificate &&cert)
load static trust anchor.
Definition: validator.cpp:185
ndn::security::v2::Validator::Validator
Validator(unique_ptr< ValidationPolicy > policy, unique_ptr< CertificateFetcher > certFetcher)
Validator constructor.
Definition: validator.cpp:37
certificate-fetcher.hpp
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34
ndn::security::v2::Validator::resetVerifiedCertificates
void resetVerifiedCertificates()
Remove any cached verified certificates.
Definition: validator.cpp:210