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-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_VALIDATOR_CONFIG_CHECKER_HPP
23
#define NDN_CXX_SECURITY_VALIDATOR_CONFIG_CHECKER_HPP
24
25
#include "
ndn-cxx/name.hpp
"
26
#include "
ndn-cxx/security/validator-config/common.hpp
"
27
#include "
ndn-cxx/security/validator-config/name-relation.hpp
"
28
#include "
ndn-cxx/util/regex.hpp
"
29
30
namespace
ndn
{
31
namespace
security
{
32
inline
namespace
v2 {
33
34
class
ValidationState
;
35
36
namespace
validator_config {
37
38
class
Checker
: noncopyable
39
{
40
public
:
41
class
Result
42
{
43
public
:
49
explicit
operator
bool()
const
50
{
51
return
m_error.empty();
52
}
53
58
const
std::string&
59
getErrorMessage
()
const
60
{
61
return
m_error;
62
}
63
64
private
:
65
explicit
66
Result
(std::string error);
67
68
private
:
69
std::string m_error;
70
71
friend
Checker
;
72
};
73
74
explicit
75
Checker
(
tlv::SignatureTypeValue
sigType);
76
77
virtual
78
~Checker
() =
default
;
79
89
Result
90
check
(uint32_t pktType,
tlv::SignatureTypeValue
sigType,
91
const
Name
& pktName,
const
Name
& klName,
const
ValidationState
& state);
92
100
static
unique_ptr<Checker>
101
create
(
const
ConfigSection
& configSection,
const
std::string& configFilename);
102
103
protected
:
108
virtual
Result
109
checkNames
(
const
Name
& pktName,
const
Name
& klName);
110
111
static
Result
112
accept
()
113
{
114
return
Result
(
""
);
115
}
116
117
class
NegativeResultBuilder
;
118
119
static
NegativeResultBuilder
120
reject
();
121
122
private
:
123
static
unique_ptr<Checker>
124
createCustomizedChecker(
const
ConfigSection
& configSection,
const
std::string& configFilename);
125
126
static
unique_ptr<Checker>
127
createHierarchicalChecker(
const
ConfigSection
& configSection,
const
std::string& configFilename);
128
129
static
unique_ptr<Checker>
130
createKeyLocatorChecker(
tlv::SignatureTypeValue
sigType,
131
const
ConfigSection
& configSection,
const
std::string& configFilename);
132
133
static
unique_ptr<Checker>
134
createKeyLocatorNameChecker(
tlv::SignatureTypeValue
sigType,
135
const
ConfigSection
& configSection,
const
std::string& configFilename);
136
137
protected
:
138
tlv::SignatureTypeValue
m_sigType
=
tlv::SignatureSha256WithEcdsa
;
139
};
140
141
class
NameRelationChecker
:
public
Checker
142
{
143
public
:
144
NameRelationChecker
(
tlv::SignatureTypeValue
sigType,
const
Name
&
name
,
const
NameRelation
& relation);
145
146
protected
:
147
Result
148
checkNames
(
const
Name
& pktName,
const
Name
& klName)
override
;
149
150
private
:
151
Name
m_name;
152
NameRelation
m_relation;
153
};
154
155
class
RegexChecker
:
public
Checker
156
{
157
public
:
158
explicit
159
RegexChecker
(
tlv::SignatureTypeValue
sigType,
const
Regex
& regex);
160
161
protected
:
162
Result
163
checkNames
(
const
Name
& pktName,
const
Name
& klName)
override
;
164
165
private
:
166
Regex
m_regex;
167
};
168
169
class
HyperRelationChecker
:
public
Checker
170
{
171
public
:
172
HyperRelationChecker
(
tlv::SignatureTypeValue
sigType,
173
const
std::string& pktNameExpr,
const
std::string pktNameExpand,
174
const
std::string& klNameExpr,
const
std::string klNameExpand,
175
const
NameRelation
& hyperRelation);
176
177
protected
:
178
Result
179
checkNames
(
const
Name
& pktName,
const
Name
& klName)
override
;
180
181
private
:
182
Regex
m_hyperPRegex;
183
Regex
m_hyperKRegex;
184
NameRelation
m_hyperRelation;
185
};
186
187
}
// namespace validator_config
188
}
// inline namespace v2
189
}
// namespace security
190
}
// namespace ndn
191
192
#endif // NDN_CXX_SECURITY_VALIDATOR_CONFIG_CHECKER_HPP
ndn::security::v2::validator_config::NameRelation
NameRelation
Definition:
name-relation.hpp:33
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-strategy-choice-helper.hpp:34
ndn::security::v2::validator_config::Checker::NegativeResultBuilder
Definition:
checker.cpp:45
ndn::security::v2::validator_config::Checker::Result
Definition:
checker.hpp:41
ndn::security::v2::validator_config::Checker::checkNames
virtual Result checkNames(const Name &pktName, const Name &klName)
Base version of name checking.
Definition:
checker.cpp:108
ndn::security::v2::validator_config::Checker::accept
static Result accept()
Definition:
checker.hpp:112
ndn::security::v2::validator_config::Checker::~Checker
virtual ~Checker()=default
ndn::RegexTopMatcher
Definition:
regex-top-matcher.hpp:34
ndn::security::v2::ValidationState
ndn security ValidationState
Definition:
validation-state.cpp:31
regex.hpp
ndn::security::v2::validator_config::Checker::check
Result check(uint32_t pktType, tlv::SignatureTypeValue sigType, const Name &pktName, const Name &klName, const ValidationState &state)
Check if packet name and KeyLocator satisfy the checker's conditions.
Definition:
checker.cpp:73
ndn::security::v2::validator_config::Checker
Definition:
checker.hpp:38
ndn::security::v2::validator_config::NameRelationChecker
Definition:
checker.hpp:141
ndn::security::v2::validator_config::HyperRelationChecker
Definition:
checker.hpp:169
name-relation.hpp
ndn::security::v2::validator_config::Checker::reject
static NegativeResultBuilder reject()
Definition:
checker.cpp:67
ndn::Name
Represents an absolute name.
Definition:
name.hpp:41
ndn::security::v2::validator_config::RegexChecker
Definition:
checker.hpp:155
ndn::tlv::SignatureSha256WithEcdsa
Definition:
tlv.hpp:135
ndn::tlv::SignatureTypeValue
SignatureTypeValue
SignatureType values.
Definition:
tlv.hpp:132
ndn::security::v2::validator_config::ConfigSection
boost::property_tree::ptree ConfigSection
Definition:
common.hpp:36
ndn::security::v2::validator_config::Checker::m_sigType
tlv::SignatureTypeValue m_sigType
Definition:
checker.hpp:138
ndn::security
Definition:
dummy-keychain.cpp:28
ndn::security::v2::validator_config::Checker::Result::getErrorMessage
const std::string & getErrorMessage() const
Return checker error message.
Definition:
checker.hpp:59
common.hpp
ndn::security::v2::ValidationState
Validation state.
Definition:
validation-state.hpp:59
name.hpp
ndn::security::v2::validator_config::Checker::create
static unique_ptr< Checker > create(const ConfigSection &configSection, const std::string &configFilename)
create a checker from configuration section
Definition:
checker.cpp:182
ndn::name
Definition:
name-component-types.hpp:33
ndnSIM
ndn-cxx
ndn-cxx
security
validator-config
checker.hpp
Generated on Fri May 6 2022 12:34:13 for ndnSIM by
1.8.13