All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Public Member Functions | List of all members
ndn::Validator Class Reference

The Validator class provides an interface for validating data and interest packets. More...

#include <validator.hpp>

Inheritance diagram for ndn::Validator:
ndn::CertificateStorage ndn::ValidatorConfig ndn::ValidatorNull

Public Member Functions

 Validator (const ptr_lib::shared_ptr< ValidationPolicy > &policy, const ptr_lib::shared_ptr< CertificateFetcher > &certificateFetcher=ptr_lib::make_shared< CertificateFetcherOffline >())
 Create a Validator with the policy and fetcher. More...
 
ValidationPolicygetPolicy ()
 Get the ValidationPolicy given to the constructor. More...
 
CertificateFetchergetFetcher ()
 Get the CertificateFetcher given to (or created in) the constructor. More...
 
void setMaxDepth (size_t maxDepth)
 Set the maximum depth of the certificate chain. More...
 
size_t getMaxDepth () const
 Get the maximum depth of the certificate chain. More...
 
void validate (const Data &data, const DataValidationSuccessCallback &successCallback, const DataValidationFailureCallback &failureCallback)
 Asynchronously validate the Data packet. More...
 
void validate (const Interest &interest, const InterestValidationSuccessCallback &successCallback, const InterestValidationFailureCallback &failureCallback)
 Asynchronously validate the Interest. More...
 
- Public Member Functions inherited from ndn::CertificateStorage
ptr_lib::shared_ptr
< CertificateV2
findTrustedCertificate (const Interest &interestForCertificate)
 Find a trusted certificate in the trust anchor container or in the verified cache. More...
 
bool isCertificateKnown (const Name &certificatePrefix)
 Check if the certificate with the given name prefix exists in the verified cache, the unverified cache, or in the set of trust anchors. More...
 
void cacheUnverifiedCertificate (const CertificateV2 &certificate)
 Cache the unverified certificate for a period of time (5 minutes). More...
 
const TrustAnchorContainergetTrustAnchors () const
 Get the trust anchor container. More...
 
const CertificateCacheV2getVerifiedCertificateCache () const
 Get the verified certificate cache. More...
 
const CertificateCacheV2getUnverifiedCertificateCache () const
 Get the unverified certificate cache. More...
 
void loadAnchor (const std::string &groupId, const CertificateV2 &certificate)
 Load a static trust anchor. More...
 
void loadAnchor (const std::string &groupId, const std::string &path, Milliseconds refreshPeriod, bool isDirectory=false)
 Load dynamic trust anchors. More...
 
void resetAnchors ()
 Remove any previously loaded static or dynamic trust anchors.
 
void cacheVerifiedCertificate (const CertificateV2 &certificate)
 Cache the verified certificate a period of time (1 hour). More...
 
void resetVerifiedCertificates ()
 Remove any cached verified certificates.
 
void setCacheNowOffsetMilliseconds_ (Milliseconds nowOffsetMilliseconds)
 Set the offset when the cache insert() and refresh() get the current time, which should only be used for testing. More...
 

Additional Inherited Members

- Protected Attributes inherited from ndn::CertificateStorage
TrustAnchorContainer trustAnchors_
 
CertificateCacheV2 verifiedCertificateCache_
 
CertificateCacheV2 unverifiedCertificateCache_
 

Detailed Description

The Validator class provides an interface for validating data and interest packets.

Every time a validation process is initiated, it creates a ValidationState that exists until the validation finishes with either success or failure. This state serves several purposes: to record the Interest or Data packet being validated, to record the failure callback, to record certificates in the certification chain for the Interest or Data packet being validated, to record the names of the requested certificates in order to detect loops in the certificate chain, and to keep track of the validation chain size (also known as the validation "depth").

During validation, the policy and/or key fetcher can augment the validation state with policy- and fetcher-specific information using tags.

A Validator has a trust anchor cache to save static and dynamic trust anchors, a verified certificate cache for saving certificates that are already verified, and an unverified certificate cache for saving pre-fetched but not yet verified certificates.

Constructor & Destructor Documentation

ndn::Validator::Validator ( const ptr_lib::shared_ptr< ValidationPolicy > &  policy,
const ptr_lib::shared_ptr< CertificateFetcher > &  certificateFetcher = ptr_lib::make_shared<CertificateFetcherOffline>() 
)

Create a Validator with the policy and fetcher.

Parameters
policyThe validation policy to be associated with this validator.
certificateFetcher(optional) The certificate fetcher implementation. If omitted, use a CertificateFetcherOffline (assuming that the validation policy doesn't need to fetch certificates).

Member Function Documentation

CertificateFetcher& ndn::Validator::getFetcher ( )
inline

Get the CertificateFetcher given to (or created in) the constructor.

Returns
The CertificateFetcher.
size_t ndn::Validator::getMaxDepth ( ) const
inline

Get the maximum depth of the certificate chain.

Returns
The maximum depth.
ValidationPolicy& ndn::Validator::getPolicy ( )
inline

Get the ValidationPolicy given to the constructor.

Returns
The ValidationPolicy.
void ndn::Validator::setMaxDepth ( size_t  maxDepth)
inline

Set the maximum depth of the certificate chain.

Parameters
maxDepthThe maximum depth.
void ndn::Validator::validate ( const Data data,
const DataValidationSuccessCallback successCallback,
const DataValidationFailureCallback failureCallback 
)

Asynchronously validate the Data packet.

Parameters
dataThe Data packet to validate, which is copied.
successCallbackOn validation success, this calls successCallback(data).
failureCallbackOn validation failure, this calls failureCallback(data, error) where error is a ValidationError.
void ndn::Validator::validate ( const Interest interest,
const InterestValidationSuccessCallback successCallback,
const InterestValidationFailureCallback failureCallback 
)

Asynchronously validate the Interest.

Parameters
interestThe Interest to validate, which is copied.
successCallbackOn validation success, this calls successCallback(interest).
failureCallbackOn validation failure, this calls failureCallback(interest, error) where error is a ValidationError.

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