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-2017 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_VALIDATION_POLICY_HPP
23 #define NDN_SECURITY_V2_VALIDATION_POLICY_HPP
24 
25 #include "validation-state.hpp"
26 #include "certificate-request.hpp"
27 #include "../../data.hpp"
28 #include "../../interest.hpp"
29 
30 namespace ndn {
31 namespace security {
32 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 
44  : m_validator(nullptr)
45  {
46  }
47 
48  virtual
49  ~ValidationPolicy() = default;
50 
65  void
66  setInnerPolicy(unique_ptr<ValidationPolicy> innerPolicy);
67 
71  bool
73  {
74  return m_innerPolicy != nullptr;
75  }
76 
84 
88  void
89  setValidator(Validator& validator);
90 
105  virtual void
106  checkPolicy(const Data& data, const shared_ptr<ValidationState>& state,
107  const ValidationContinuation& continueValidation) = 0;
108 
123  virtual void
124  checkPolicy(const Interest& interest, const shared_ptr<ValidationState>& state,
125  const ValidationContinuation& continueValidation) = 0;
126 
143  virtual void
144  checkPolicy(const Certificate& certificate, const shared_ptr<ValidationState>& state,
145  const ValidationContinuation& continueValidation)
146  {
147  checkPolicy(static_cast<const Data&>(certificate), state, continueValidation);
148  }
149 
151  Validator* m_validator;
152  unique_ptr<ValidationPolicy> m_innerPolicy;
153 };
154 
160 Name
161 getKeyLocatorName(const Data& data, ValidationState& state);
162 
168 Name
169 getKeyLocatorName(const Interest& interest, ValidationState& state);
170 
171 } // namespace v2
172 } // namespace security
173 } // namespace ndn
174 
175 #endif // NDN_SECURITY_V2_VALIDATION_POLICY_HPP
void setInnerPolicy(unique_ptr< ValidationPolicy > innerPolicy)
Set inner policy.
Copyright (c) 2011-2015 Regents of the University of California.
The certificate following the certificate format naming convention.
Definition: certificate.hpp:81
void setValidator(Validator &validator)
Set validator to which the policy is associated.
Represents an Interest packet.
Definition: interest.hpp:42
ValidationPolicy & getInnerPolicy()
Return the inner policy.
Abstraction that implements validation policy for Data and Interest packets.
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:42
bool hasInnerPolicy() const
Check if inner policy is set.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED
Definition: common.hpp:42
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:35
Interface for validating data and interest packets.
Definition: validator.hpp:61