ndn::security::validator_config::Rule Class Reference

#include <ndn-cxx/security/validator-config/rule.hpp>

+ Inheritance diagram for ndn::security::validator_config::Rule:
+ Collaboration diagram for ndn::security::validator_config::Rule:

Public Member Functions

 Rule (const std::string &id, uint32_t pktType)
 
void addChecker (unique_ptr< Checker > checker)
 
void addFilter (unique_ptr< Filter > filter)
 
bool check (uint32_t pktType, tlv::SignatureTypeValue sigType, const Name &pktName, const Name &klName, const shared_ptr< ValidationState > &state) const
 Check if packet satisfies rule's condition. More...
 
const std::string & getId () const
 
uint32_t getPktType () const
 
bool match (uint32_t pktType, const Name &pktName, const shared_ptr< ValidationState > &state) const
 Check if the packet name matches rule's filter. More...
 

Static Public Member Functions

static unique_ptr< Rulecreate (const ConfigSection &configSection, const std::string &configFilename)
 Create a rule from configuration section. More...
 

Detailed Description

Definition at line 34 of file rule.hpp.

Constructor & Destructor Documentation

◆ Rule()

ndn::security::validator_config::Rule::Rule ( const std::string &  id,
uint32_t  pktType 
)

Definition at line 32 of file rule.cpp.

Member Function Documentation

◆ addChecker()

void ndn::security::validator_config::Rule::addChecker ( unique_ptr< Checker checker)

Definition at line 45 of file rule.cpp.

◆ addFilter()

void ndn::security::validator_config::Rule::addFilter ( unique_ptr< Filter filter)

Definition at line 39 of file rule.cpp.

◆ check()

bool ndn::security::validator_config::Rule::check ( uint32_t  pktType,
tlv::SignatureTypeValue  sigType,
const Name pktName,
const Name klName,
const shared_ptr< ValidationState > &  state 
) const

Check if packet satisfies rule's condition.

Parameters
pktTypetlv::Interest or tlv::Data
sigTypeSignature type
pktNamepacket name, for signed Interests the last two components are not removed
klNameKeyLocator name
stateValidation state
Return values
falsepacket violates all checkers. fail() will have been called on state with proper code and message.
truepacket satisfies at least one checker, further validation is needed.
Exceptions
Errorthe supplied pktType doesn't match one for which the rule is designed.

Definition at line 74 of file rule.cpp.

◆ create()

unique_ptr< Rule > ndn::security::validator_config::Rule::create ( const ConfigSection configSection,
const std::string &  configFilename 
)
static

Create a rule from configuration section.

Parameters
configSectionThe section containing the definition of checker.
configFilenameThe configuration file name.
Returns
a rule created from configuration

Definition at line 104 of file rule.cpp.

◆ getId()

const std::string& ndn::security::validator_config::Rule::getId ( ) const
inline

Definition at line 40 of file rule.hpp.

◆ getPktType()

uint32_t ndn::security::validator_config::Rule::getPktType ( ) const
inline

Definition at line 46 of file rule.hpp.

◆ match()

bool ndn::security::validator_config::Rule::match ( uint32_t  pktType,
const Name pktName,
const shared_ptr< ValidationState > &  state 
) const

Check if the packet name matches rule's filter.

If no filters were added, the rule matches everything.

Parameters
pktTypetlv::Interest or tlv::Data
pktNamepacket name, for signed Interests the last two components are not removed
stateThe associated validation state
Return values
trueIf at least one filter matches pktName
falseIf none of the filters match pktName
Exceptions
Errorthe supplied pktType doesn't match one for which the rule is designed

Definition at line 51 of file rule.cpp.