NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
checker.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_CONFIG_CHECKER_HPP
23 #define NDN_SECURITY_V2_VALIDATOR_CONFIG_CHECKER_HPP
24 
25 #include "ndn-cxx/name.hpp"
28 #include "ndn-cxx/util/regex.hpp"
29 
30 namespace ndn {
31 namespace security {
32 namespace v2 {
33 
34 class ValidationState;
35 
36 namespace validator_config {
37 
38 class Checker : noncopyable
39 {
40 public:
41  virtual
42  ~Checker() = default;
43 
55  bool
56  check(uint32_t pktType, const Name& pktName, const Name& klName, const shared_ptr<ValidationState>& state);
57 
65  static unique_ptr<Checker>
66  create(const ConfigSection& configSection, const std::string& configFilename);
67 
68 private:
69  static unique_ptr<Checker>
70  createCustomizedChecker(const ConfigSection& configSection, const std::string& configFilename);
71 
72  static unique_ptr<Checker>
73  createHierarchicalChecker(const ConfigSection& configSection, const std::string& configFilename);
74 
75  static unique_ptr<Checker>
76  createKeyLocatorChecker(const ConfigSection& configSection, const std::string& configFilename);
77 
78  static unique_ptr<Checker>
79  createKeyLocatorNameChecker(const ConfigSection& configSection, const std::string& configFilename);
80 
81 protected:
82  virtual bool
83  checkNames(const Name& pktName, const Name& klName, const shared_ptr<ValidationState>& state) = 0;
84 };
85 
87 {
88 public:
89  NameRelationChecker(const Name& name, const NameRelation& relation);
90 
91 protected:
92  bool
93  checkNames(const Name& pktName, const Name& klName, const shared_ptr<ValidationState>& state) override;
94 
95 private:
96  Name m_name;
97  NameRelation m_relation;
98 };
99 
100 class RegexChecker : public Checker
101 {
102 public:
103  explicit
104  RegexChecker(const Regex& regex);
105 
106 protected:
107  bool
108  checkNames(const Name& pktName, const Name& klName, const shared_ptr<ValidationState>& state) override;
109 
110 private:
111  Regex m_regex;
112 };
113 
115 {
116 public:
117  HyperRelationChecker(const std::string& pktNameExpr, const std::string pktNameExpand,
118  const std::string& klNameExpr, const std::string klNameExpand,
119  const NameRelation& hyperRelation);
120 
121 protected:
122  bool
123  checkNames(const Name& pktName, const Name& klName, const shared_ptr<ValidationState>& state) override;
124 
125 private:
126  Regex m_hyperPRegex;
127  Regex m_hyperKRegex;
128  NameRelation m_hyperRelation;
129 };
130 
131 } // namespace validator_config
132 } // namespace v2
133 } // namespace security
134 } // namespace ndn
135 
136 #endif // NDN_SECURITY_V2_VALIDATOR_CONFIG_CHECKER_HPP
Copyright (c) 2011-2015 Regents of the University of California.
NameRelationChecker(const Name &name, const NameRelation &relation)
Definition: checker.cpp:51
bool checkNames(const Name &pktName, const Name &klName, const shared_ptr< ValidationState > &state) override
Definition: checker.cpp:102
bool checkNames(const Name &pktName, const Name &klName, const shared_ptr< ValidationState > &state) override
Definition: checker.cpp:80
Represents an absolute name.
Definition: name.hpp:43
ndn security v2 ValidationState
boost::property_tree::ptree ConfigSection
Definition: common.hpp:36
bool checkNames(const Name &pktName, const Name &klName, const shared_ptr< ValidationState > &state) override
Definition: checker.cpp:58
HyperRelationChecker(const std::string &pktNameExpr, const std::string pktNameExpand, const std::string &klNameExpr, const std::string klNameExpand, const NameRelation &hyperRelation)
Definition: checker.cpp:92
bool check(uint32_t pktType, const Name &pktName, const Name &klName, const shared_ptr< ValidationState > &state)
Check if packet name ane KeyLocator satisfy the checker's conditions.
Definition: checker.cpp:35
virtual bool checkNames(const Name &pktName, const Name &klName, const shared_ptr< ValidationState > &state)=0
static unique_ptr< Checker > create(const ConfigSection &configSection, const std::string &configFilename)
create a checker from configuration section
Definition: checker.cpp:125