NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::CommandInterestValidator Class Reference

Helper class to validate CommandInterests. More...

#include <command-interest-validator.hpp>

Inheritance diagram for ndn::CommandInterestValidator:
Collaboration diagram for ndn::CommandInterestValidator:

Public Types

enum  {
  POS_SIG_VALUE = -1, POS_SIG_INFO = -2, POS_RANDOM_VAL = -3, POS_TIMESTAMP = -4,
  MIN_LENGTH = 4, GRACE_INTERVAL = 3000
}
 

Public Member Functions

 CommandInterestValidator (const time::milliseconds &graceInterval=time::milliseconds(static_cast< int >(GRACE_INTERVAL)))
 
virtual ~CommandInterestValidator ()
 
void addInterestRule (const std::string &regex, const IdentityCertificate &certificate)
 add an Interest rule that allows a specific certificate More...
 
void addInterestRule (const std::string &regex, const Name &keyName, const PublicKey &publicKey)
 add an Interest rule that allows a specific public key More...
 
void addInterestBypassRule (const std::string &regex)
 add an Interest rule that allows any signer More...
 
void reset ()
 Remove all installed Interest rules (e.g., when reinitialization needed) More...
 
- Public Member Functions inherited from ndn::Validator
 Validator (Face *face=nullptr)
 Validator constructor. More...
 
 Validator (Face &face)
 
void validate (const Data &data, const OnDataValidated &onValidated, const OnDataValidationFailed &onValidationFailed)
 Validate Data and call either onValidated or onValidationFailed. More...
 
void validate (const Interest &interest, const OnInterestValidated &onValidated, const OnInterestValidationFailed &onValidationFailed)
 Validate Interest and call either onValidated or onValidationFailed. More...
 

Protected Member Functions

virtual void checkPolicy (const Data &data, int stepCount, const OnDataValidated &onValidated, const OnDataValidationFailed &onValidationFailed, std::vector< shared_ptr< ValidationRequest > > &nextSteps)
 Check the Data against policy and return the next validation step if necessary. More...
 
virtual void checkPolicy (const Interest &interest, int stepCount, const OnInterestValidated &onValidated, const OnInterestValidationFailed &onValidationFailed, std::vector< shared_ptr< ValidationRequest > > &nextSteps)
 Check the Interest against validation policy and return the next validation step if necessary. More...
 
- Protected Member Functions inherited from ndn::Validator
void onData (const Interest &interest, const Data &data, const shared_ptr< ValidationRequest > &nextStep)
 Process the received certificate. More...
 
void validate (const Data &data, const OnDataValidated &onValidated, const OnDataValidationFailed &onValidationFailed, int nSteps)
 
void validate (const Interest &interest, const OnInterestValidated &onValidated, const OnInterestValidationFailed &onValidationFailed, int nSteps)
 
virtual shared_ptr< const DatapreCertificateValidation (const Data &data)
 Hooks. More...
 
virtual void onTimeout (const Interest &interest, int nRemainingRetries, const OnFailure &onFailure, const shared_ptr< ValidationRequest > &validationRequest)
 trigger when interest for certificate times out. More...
 
virtual void afterCheckPolicy (const std::vector< shared_ptr< ValidationRequest > > &nextSteps, const OnFailure &onFailure)
 trigger after checkPolicy is done. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ndn::Validator
static bool verifySignature (const Data &data, const PublicKey &publicKey)
 Verify the data using the publicKey. More...
 
static bool verifySignature (const Interest &interest, const PublicKey &publicKey)
 Verify the signed Interest using the publicKey. More...
 
static bool verifySignature (const Buffer &blob, const Signature &sig, const PublicKey &publicKey)
 Verify the blob using the publicKey against the signature. More...
 
static bool verifySignature (const Data &data, const Signature &sig, const PublicKey &publicKey)
 Verify the data using the publicKey against the SHA256-RSA signature. More...
 
static bool verifySignature (const Interest &interest, const Signature &sig, const PublicKey &publicKey)
 Verify the interest using the publicKey against the SHA256-RSA signature. More...
 
static bool verifySignature (const uint8_t *buf, const size_t size, const Signature &sig, const PublicKey &publicKey)
 Verify the blob using the publicKey against the SHA256-RSA signature. More...
 
static bool verifySignature (const Data &data, const DigestSha256 &sig)
 Verify the data against the SHA256 signature. More...
 
static bool verifySignature (const Interest &interest, const DigestSha256 &sig)
 Verify the interest against the SHA256 signature. More...
 
static bool verifySignature (const Buffer &blob, const DigestSha256 &sig)
 Verify the blob against the SHA256 signature. More...
 
static bool verifySignature (const uint8_t *buf, const size_t size, const DigestSha256 &sig)
 Verify the blob against the SHA256 signature. More...
 
- Protected Types inherited from ndn::Validator
typedef function< void(const std::string &)> OnFailure
 
- Protected Attributes inherited from ndn::Validator
Facem_face
 

Detailed Description

Helper class to validate CommandInterests.

Deprecated:
Use ValidatorConfig instead. See http://redmine.named-data.net/projects/ndn-cxx/wiki/CommandValidatorConf for more details about the configuration format of ValidatorConfig.
See also
http://redmine.named-data.net/projects/nfd/wiki/Command_Interests

Definition at line 42 of file command-interest-validator.hpp.

Member Enumeration Documentation

§ anonymous enum

anonymous enum
Enumerator
POS_SIG_VALUE 
POS_SIG_INFO 
POS_RANDOM_VAL 
POS_TIMESTAMP 
MIN_LENGTH 
GRACE_INTERVAL 

Definition at line 45 of file command-interest-validator.hpp.

Constructor & Destructor Documentation

§ CommandInterestValidator()

ndn::CommandInterestValidator::CommandInterestValidator ( const time::milliseconds &  graceInterval = time::milliseconds(static_cast<int>(GRACE_INTERVAL)))
inline

Definition at line 56 of file command-interest-validator.hpp.

§ ~CommandInterestValidator()

virtual ndn::CommandInterestValidator::~CommandInterestValidator ( )
inlinevirtual

Member Function Documentation

§ addInterestRule() [1/2]

void ndn::CommandInterestValidator::addInterestRule ( const std::string &  regex,
const IdentityCertificate certificate 
)
inline

add an Interest rule that allows a specific certificate

Parameters
regexNDN Regex to match Interest Name
certificatetrusted certificate

Definition at line 129 of file command-interest-validator.hpp.

References ndn::IdentityCertificate::certificateNameToPublicKeyName(), ndn::Data::getName(), and ndn::Certificate::getPublicKeyInfo().

Referenced by ~CommandInterestValidator().

§ addInterestRule() [2/2]

void ndn::CommandInterestValidator::addInterestRule ( const std::string &  regex,
const Name keyName,
const PublicKey publicKey 
)
inline

add an Interest rule that allows a specific public key

Parameters
regexNDN Regex to match Interest Name
keyNameKeyLocator.Name
publicKeypublic key

Definition at line 137 of file command-interest-validator.hpp.

References ndn::RegexTopMatcher::fromName().

§ addInterestBypassRule()

void ndn::CommandInterestValidator::addInterestBypassRule ( const std::string &  regex)
inline

add an Interest rule that allows any signer

Parameters
regexNDN Regex to match Interest Name
Note
Command Interest matched by regex that is signed by any key will be accepted.

Definition at line 148 of file command-interest-validator.hpp.

Referenced by ~CommandInterestValidator().

§ reset()

void ndn::CommandInterestValidator::reset ( )
inline

Remove all installed Interest rules (e.g., when reinitialization needed)

Definition at line 155 of file command-interest-validator.hpp.

Referenced by ~CommandInterestValidator().

§ checkPolicy() [1/2]

virtual void ndn::CommandInterestValidator::checkPolicy ( const Data data,
int  nSteps,
const OnDataValidated onValidated,
const OnDataValidationFailed onValidationFailed,
std::vector< shared_ptr< ValidationRequest > > &  nextSteps 
)
inlineprotectedvirtual

Check the Data against policy and return the next validation step if necessary.

If there is no next validation step, that validation MUST have been done. i.e., either onValidated or onValidationFailed callback is invoked.

Parameters
dataThe Data to check.
nStepsThe number of validation steps that have been done.
onValidatedIf the Data is validated, this calls onValidated(data)
onValidationFailedIf validation fails, this calls onValidationFailed(data)
nextStepsOn return, contains the next validation step

Implements ndn::Validator.

Definition at line 104 of file command-interest-validator.hpp.

§ checkPolicy() [2/2]

void ndn::CommandInterestValidator::checkPolicy ( const Interest interest,
int  nSteps,
const OnInterestValidated onValidated,
const OnInterestValidationFailed onValidationFailed,
std::vector< shared_ptr< ValidationRequest > > &  nextSteps 
)
inlineprotectedvirtual

Check the Interest against validation policy and return the next validation step if necessary.

If there is no next validation step, that validation MUST have been done. i.e., either onValidated or onValidationFailed callback is invoked.

Parameters
interestThe Interest to check.
nStepsThe number of validation steps that have been done.
onValidatedIf the Interest is validated, this calls onValidated(data)
onValidationFailedIf validation fails, this calls onValidationFailed(data)
nextStepsOn return, contains the next validation step

Implements ndn::Validator.

Definition at line 162 of file command-interest-validator.hpp.

References ndn::IdentityCertificate::certificateNameToPublicKeyName(), ndn::time::fromUnixTimestamp(), ndn::Name::get(), ndn::Signature::getKeyLocator(), ndn::KeyLocator::getName(), ndn::Interest::getName(), ndn::KeyLocator::getType(), ndn::Signature::getType(), ndn::KeyLocator::KeyLocator_Name, MIN_LENGTH, ndn::time::system_clock::now(), POS_SIG_INFO, POS_SIG_VALUE, POS_TIMESTAMP, ndn::tlv::SignatureSha256WithRsa, ndn::Name::size(), ndn::name::Component::toNumber(), ndn::Name::toUri(), ndn::Validator::verifySignature(), and ndn::Name::wireEncode().


The documentation for this class was generated from the following file: