All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
ndn::ValidationPolicy Class Referenceabstract

ValidationPolicy is an abstract base class that implements a validation policy for Data and Interest packets. More...

#include <validation-policy.hpp>

Inheritance diagram for ndn::ValidationPolicy:
ndn::ValidationPolicyAcceptAll ndn::ValidationPolicyCommandInterest ndn::ValidationPolicyConfig ndn::ValidationPolicyFromPib ndn::ValidationPolicySimpleHierarchy ValidationPolicySimpleHierarchyForInterestOnly

Public Types

typedef func_lib::function
< void(const
ptr_lib::shared_ptr
< CertificateRequest >
&certificateRequest, const
ptr_lib::shared_ptr
< ValidationState > &state)> 
ValidationContinuation
 

Public Member Functions

void setInnerPolicy (const ptr_lib::shared_ptr< ValidationPolicy > &innerPolicy)
 Set the inner policy. More...
 
bool hasInnerPolicy () const
 Check if the inner policy is set. More...
 
ValidationPolicygetInnerPolicy ()
 Get the inner policy. More...
 
void setValidator (Validator &validator)
 Set the validator to which this policy is associated. More...
 
virtual void checkPolicy (const Data &data, const ptr_lib::shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)=0
 Check the Data packet against the policy. More...
 
virtual void checkPolicy (const Interest &interest, const ptr_lib::shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)=0
 Check the Interest against the policy. More...
 
virtual void checkCertificatePolicy (const CertificateV2 &certificate, const ptr_lib::shared_ptr< ValidationState > &state, const ValidationContinuation &continueValidation)
 Check the certificate against the policy. More...
 

Static Public Member Functions

static Name getKeyLocatorName (const Data &data, ValidationState &state)
 Extract the KeyLocator Name from a Data packet. More...
 
static Name getKeyLocatorName (const Interest &interest, ValidationState &state)
 Extract the KeyLocator Name from a signed Interest. More...
 

Protected Attributes

friend TestValidator_ConstructorSetValidator_Test
 
Validatorvalidator_
 
ptr_lib::shared_ptr
< ValidationPolicy
innerPolicy_
 

Detailed Description

ValidationPolicy is an abstract base class that implements a validation policy for Data and Interest packets.

Member Function Documentation

void ndn::ValidationPolicy::checkCertificatePolicy ( const CertificateV2 certificate,
const ptr_lib::shared_ptr< ValidationState > &  state,
const ValidationContinuation &  continueValidation 
)
virtual

Check the certificate against the policy.

This base class implementation just calls checkPolicy(Data, ...). Your derived class may override. Depending on implementation of the policy, this check can be done synchronously or asynchronously. See the checkPolicy(Data) documentation for the semantics.

Parameters
certificateThe certificate to check.
stateThe ValidationState of this validation.
continueValidationThe policy should call continueValidation() as described above.
virtual void ndn::ValidationPolicy::checkPolicy ( const Data data,
const ptr_lib::shared_ptr< ValidationState > &  state,
const ValidationContinuation &  continueValidation 
)
pure virtual

Check the Data packet against the policy.

Your derived class must implement this. Depending on the implementation of the policy, this check can be done synchronously or asynchronously. The semantics of checkPolicy are as follows: If the packet violates the policy, then the policy should call state.fail() with an appropriate error code and error description. If the packet conforms to the policy and no further key retrievals are necessary, then the policy should call continueValidation(null, state). If the packet conforms to the policy and a key needs to be fetched, then the policy should call continueValidation(<appropriate-key-request-instance>, state).

Parameters
dataThe Data packet to check.
stateThe ValidationState of this validation.
continueValidationThe policy should call continueValidation() as described above.

Implemented in ValidationPolicySimpleHierarchyForInterestOnly, ndn::ValidationPolicyCommandInterest, ndn::ValidationPolicyConfig, ndn::ValidationPolicyFromPib, ndn::ValidationPolicyAcceptAll, and ndn::ValidationPolicySimpleHierarchy.

virtual void ndn::ValidationPolicy::checkPolicy ( const Interest interest,
const ptr_lib::shared_ptr< ValidationState > &  state,
const ValidationContinuation &  continueValidation 
)
pure virtual

Check the Interest against the policy.

Your derived class must implement this. Depending on implementation of the policy, this check can be done synchronously or asynchronously. See the checkPolicy(Data) documentation for the semantics.

Parameters
interestThe Interest packet to check.
stateThe ValidationState of this validation.
continueValidationThe policy should call continueValidation() as described above.

Implemented in ndn::ValidationPolicyCommandInterest, ndn::ValidationPolicyConfig, ndn::ValidationPolicyFromPib, ndn::ValidationPolicyAcceptAll, and ndn::ValidationPolicySimpleHierarchy.

ValidationPolicy& ndn::ValidationPolicy::getInnerPolicy ( )
inline

Get the inner policy.

If the inner policy was not set, the behavior is undefined.

Returns
The inner policy.
static Name ndn::ValidationPolicy::getKeyLocatorName ( const Data data,
ValidationState state 
)
inlinestatic

Extract the KeyLocator Name from a Data packet.

The Data packet must contain a KeyLocator of type KEYNAME. Otherwise, state.fail is invoked with INVALID_KEY_LOCATOR.

Parameters
dataThe Data packet with the KeyLocator.
stateOn error, this calls state.fail and returns an empty Name.
Returns
The KeyLocator name, or an empty Name for failure.
Name ndn::ValidationPolicy::getKeyLocatorName ( const Interest interest,
ValidationState state 
)
static

Extract the KeyLocator Name from a signed Interest.

The Interest must have SignatureInfo and contain a KeyLocator of type KEYNAME. Otherwise, state.fail is invoked with INVALID_KEY_LOCATOR.

Parameters
interestThe signed Interest with the KeyLocator.
stateOn error, this calls state.fail and returns an empty Name.
Returns
The KeyLocator name, or an empty Name for failure.
bool ndn::ValidationPolicy::hasInnerPolicy ( ) const
inline

Check if the inner policy is set.

Returns
True if the inner policy is set.
void ndn::ValidationPolicy::setInnerPolicy ( const ptr_lib::shared_ptr< ValidationPolicy > &  innerPolicy)

Set the inner policy.

Multiple assignments of the inner policy will create a "chain" of linked policies. The inner policy from the latest invocation of setInnerPolicy will be at the bottom of the policy list. For example, the sequence this->setInnerPolicy(policy1) and this->setInnerPolicy(policy2), will result in this->innerPolicy_ == policy1, this->innerPolicy_->innerPolicy_ == policy2', and this->innerPolicy_->innerPolicy_->innerPolicy_ == null.

Exceptions
invalid_argumentif the innerPolicy is null.
void ndn::ValidationPolicy::setValidator ( Validator validator)
inline

Set the validator to which this policy is associated.

This replaces any previous validator.

Parameters
validatorThe validator.

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