Helper class to validate CommandInterests. More...
#include <command-interest-validator.hpp>
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 ®ex, const IdentityCertificate &certificate) |
add an Interest rule that allows a specific certificate More... | |
void | addInterestRule (const std::string ®ex, const Name &keyName, const PublicKey &publicKey) |
add an Interest rule that allows a specific public key More... | |
void | addInterestBypassRule (const std::string ®ex) |
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 Data > | preCertificateValidation (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 | |
Face * | m_face |
Helper class to validate CommandInterests.
Definition at line 42 of file command-interest-validator.hpp.
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.
|
inline |
Definition at line 56 of file command-interest-validator.hpp.
|
inlinevirtual |
Definition at line 64 of file command-interest-validator.hpp.
|
inline |
add an Interest rule that allows a specific certificate
Definition at line 129 of file command-interest-validator.hpp.
References ndn::IdentityCertificate::certificateNameToPublicKeyName(), ndn::Data::getName(), and ndn::Certificate::getPublicKeyInfo().
Referenced by nfd::CommandValidator::addInterestRule().
|
inline |
add an Interest rule that allows a specific public key
Definition at line 137 of file command-interest-validator.hpp.
References ndn::RegexTopMatcher::fromName().
|
inline |
|
inline |
Remove all installed Interest rules (e.g., when reinitialization needed)
Definition at line 155 of file command-interest-validator.hpp.
|
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.
data | The Data to check. |
nSteps | The number of validation steps that have been done. |
onValidated | If the Data is validated, this calls onValidated(data) |
onValidationFailed | If validation fails, this calls onValidationFailed(data) |
nextSteps | On return, contains the next validation step |
Implements ndn::Validator.
Definition at line 104 of file command-interest-validator.hpp.
|
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.
interest | The Interest to check. |
nSteps | The number of validation steps that have been done. |
onValidated | If the Interest is validated, this calls onValidated(data) |
onValidationFailed | If validation fails, this calls onValidationFailed(data) |
nextSteps | On 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().