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-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_VALIDATION_POLICY_HPP
23 #define NDN_SECURITY_V2_VALIDATION_POLICY_HPP
24 
25 #include "ndn-cxx/data.hpp"
26 #include "ndn-cxx/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 
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 
163 Name
164 getKeyLocatorName(const Interest& interest, ValidationState& state);
165 
166 } // namespace v2
167 } // namespace security
168 } // namespace ndn
169 
170 #endif // NDN_SECURITY_V2_VALIDATION_POLICY_HPP
ndn::security::v2::Validator
Interface for validating data and interest packets.
Definition: validator.hpp:62
certificate-request.hpp
ndn::security::v2::ValidationPolicy::checkPolicy
virtual void checkPolicy(const Certificate &certificate, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)
Check certificate against the policy.
Definition: validation-policy.hpp:139
NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PROTECTED
Definition: common.hpp:47
ndn::security::v2::ValidationPolicy::setValidator
void setValidator(Validator &validator)
Set validator to which the policy is associated.
Definition: validation-policy.cpp:55
ndn::security::v2::ValidationPolicy::hasInnerPolicy
bool hasInnerPolicy() const
Check if inner policy is set.
Definition: validation-policy.hpp:67
ndn::security::v2::ValidationPolicy::~ValidationPolicy
virtual ~ValidationPolicy()=default
ndn::security::v2::ValidationPolicy::ValidationContinuation
std::function< void(const shared_ptr< CertificateRequest > &certRequest, const shared_ptr< ValidationState > &state)> ValidationContinuation
Definition: validation-policy.hpp:41
ndn::security::v2::ValidationPolicy
Abstraction that implements validation policy for Data and Interest packets.
Definition: validation-policy.hpp:38
ndn::Name
Represents an absolute name.
Definition: name.hpp:44
ndn::security::v2::ValidationPolicy::setInnerPolicy
void setInnerPolicy(unique_ptr< ValidationPolicy > innerPolicy)
Set inner policy.
Definition: validation-policy.cpp:30
ndn::security::v2::Certificate
The certificate following the certificate format naming convention.
Definition: certificate.hpp:82
validation-state.hpp
ndn::security::v2::ValidationPolicy::checkPolicy
virtual void checkPolicy(const Data &data, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)=0
Check data against the policy.
ndn::security::v2::ValidationState
Validation state.
Definition: validation-state.hpp:59
ndn::security::v2::ValidationPolicy::checkPolicy
virtual void checkPolicy(const Interest &interest, const shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)=0
Check interest against the policy.
ndn::Interest
Represents an Interest packet.
Definition: interest.hpp:44
ndn::Data
Represents a Data packet.
Definition: data.hpp:36
interest.hpp
data.hpp
ndn::security::v2::getKeyLocatorName
static Name getKeyLocatorName(const SignatureInfo &si, ValidationState &state)
Definition: validation-policy.cpp:64
ndn::security::v2::ValidationPolicy::getInnerPolicy
ValidationPolicy & getInnerPolicy()
Return the inner policy.
Definition: validation-policy.cpp:49
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34
ndn::security::v2::ValidationPolicy::m_innerPolicy
unique_ptr< ValidationPolicy > m_innerPolicy
Definition: validation-policy.hpp:147