NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
validation-policy.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_VALIDATION_POLICY_HPP
23 #define NDN_CXX_SECURITY_VALIDATION_POLICY_HPP
24 
25 #include "ndn-cxx/data.hpp"
26 #include "ndn-cxx/interest.hpp"
29 
30 namespace ndn {
31 namespace security {
32 inline namespace v2 {
33 
37 class ValidationPolicy : noncopyable
38 {
39 public:
40  using ValidationContinuation = std::function<void(const shared_ptr<CertificateRequest>& certRequest,
41  const shared_ptr<ValidationState>& state)>;
42 
43  virtual
44  ~ValidationPolicy() = default;
45 
60  void
61  setInnerPolicy(unique_ptr<ValidationPolicy> innerPolicy);
62 
66  bool
68  {
69  return m_innerPolicy != nullptr;
70  }
71 
79 
83  void
84  setValidator(Validator& validator);
85 
100  virtual void
101  checkPolicy(const Data& data, const shared_ptr<ValidationState>& state,
102  const ValidationContinuation& continueValidation) = 0;
103 
118  virtual void
119  checkPolicy(const Interest& interest, const shared_ptr<ValidationState>& state,
120  const ValidationContinuation& continueValidation) = 0;
121 
138  virtual void
139  checkPolicy(const Certificate& certificate, const shared_ptr<ValidationState>& state,
140  const ValidationContinuation& continueValidation)
141  {
142  checkPolicy(static_cast<const Data&>(certificate), state, continueValidation);
143  }
144 
146  Validator* m_validator = nullptr;
147  unique_ptr<ValidationPolicy> m_innerPolicy;
148 };
149 
155 Name
156 getKeyLocatorName(const Data& data, ValidationState& state);
157 
168 Name
169 getKeyLocatorName(const Interest& interest, ValidationState& state);
170 
176 Name
177 extractIdentityNameFromKeyLocator(const Name& keyLocator);
178 
179 } // inline namespace v2
180 } // namespace security
181 } // namespace ndn
182 
183 #endif // NDN_CXX_SECURITY_VALIDATION_POLICY_HPP
void setInnerPolicy(unique_ptr< ValidationPolicy > innerPolicy)
Set inner policy.
Copyright (c) 2011-2015 Regents of the University of California.
Represents an NDN certificate following the version 2.0 format.
Definition: certificate.hpp:60
void setValidator(Validator &validator)
Set validator to which the policy is associated.
Name extractIdentityNameFromKeyLocator(const Name &keyLocator)
Extract identity name from key, version-less certificate, or certificate name.
Represents an Interest packet.
Definition: interest.hpp:48
ValidationPolicy & getInnerPolicy()
Return the inner policy.
Abstraction that implements validation policy for Data and Interest packets.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED
Definition: common.hpp:47
unique_ptr< ValidationPolicy > m_innerPolicy
std::function< void(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state)> ValidationContinuation
static Name getKeyLocatorName(const SignatureInfo &si, ValidationState &state)
Represents an absolute name.
Definition: name.hpp:41
bool hasInnerPolicy() const
Check if inner policy is set.
virtual void checkPolicy(const Data &data, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)=0
Check data against the policy.
virtual void checkPolicy(const Certificate &certificate, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)
Check certificate against the policy.
Represents a Data packet.
Definition: data.hpp:37
Interface for validating data and interest packets.
Definition: validator.hpp:61