ndn::security::ValidatorConfig Class Reference

Helper for validator that uses SignedInterest + CommandInterest + Config policy and NetworkFetcher. More...

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

+ Inheritance diagram for ndn::security::ValidatorConfig:
+ Collaboration diagram for ndn::security::ValidatorConfig:

Public Types

using CommandInterestOptions = ValidationPolicyCommandInterest::Options
 
using SignedInterestOptions = ValidationPolicySignedInterest::Options
 

Public Member Functions

 ValidatorConfig (Face &face, const CommandInterestOptions &ciOptions={}, const SignedInterestOptions &siOptions={})
 
 ValidatorConfig (std::unique_ptr< CertificateFetcher > fetcher, const CommandInterestOptions &ciOptions={}, const SignedInterestOptions &siOptions={})
 
void cacheUnverifiedCert (Certificate &&cert)
 Cache unverified certificate for a period of time (5 minutes). More...
 
void cacheVerifiedCertificate (Certificate &&cert)
 Cache verified cert a period of time (1 hour). More...
 
const CertificatefindTrustedCert (const Interest &interestForCert) const
 Find a trusted certificate in trust anchor container or in verified cache. More...
 
CertificateFetchergetFetcher () const noexcept
 
size_t getMaxDepth () const noexcept
 Return the maximum depth of the certificate chain. More...
 
ValidationPolicygetPolicy () const noexcept
 
const TrustAnchorContainergetTrustAnchors () const
 
const CertificateCachegetUnverifiedCertCache () const
 
const CertificateCachegetVerifiedCertCache () const
 
bool isCertKnown (const Name &certPrefix) const
 Check if certificate exists in the verified/unverified cache or in the set of trust anchors. More...
 
void load (const std::string &filename)
 
void load (const std::string &input, const std::string &filename)
 
void load (const validator_config::ConfigSection &configSection, const std::string &filename)
 
void load (std::istream &input, const std::string &filename)
 
void loadAnchor (const std::string &groupId, Certificate &&cert)
 Load static trust anchor. More...
 
void loadAnchor (const std::string &groupId, const std::string &certfilePath, time::nanoseconds refreshPeriod, bool isDir=false)
 Load dynamic trust anchors. More...
 
void resetAnchors ()
 Remove any previously loaded static or dynamic trust anchor. More...
 
void resetVerifiedCertificates ()
 Remove any cached verified certificates. More...
 
void setMaxDepth (size_t depth) noexcept
 Set the maximum depth of the certificate chain. More...
 
void validate (const Data &data, const DataValidationSuccessCallback &successCb, const DataValidationFailureCallback &failureCb)
 Asynchronously validate data. More...
 
void validate (const Interest &interest, const InterestValidationSuccessCallback &successCb, const InterestValidationFailureCallback &failureCb)
 Asynchronously validate interest. More...
 
 Validator (unique_ptr< ValidationPolicy > policy, unique_ptr< CertificateFetcher > certFetcher)
 Validator constructor. More...
 

Protected Member Functions

void cacheVerifiedCert (Certificate &&cert)
 Cache verified certificate a period of time (1 hour). More...
 
void resetVerifiedCerts ()
 Remove any cached verified certificates. More...
 

Protected Attributes

TrustAnchorContainer m_trustAnchors
 
CertificateCache m_unverifiedCertCache
 
CertificateCache m_verifiedCertCache
 

Detailed Description

Helper for validator that uses SignedInterest + CommandInterest + Config policy and NetworkFetcher.

Definition at line 37 of file validator-config.hpp.

Member Typedef Documentation

◆ CommandInterestOptions

◆ SignedInterestOptions

Constructor & Destructor Documentation

◆ ValidatorConfig() [1/2]

ndn::security::ValidatorConfig::ValidatorConfig ( std::unique_ptr< CertificateFetcher fetcher,
const CommandInterestOptions ciOptions = {},
const SignedInterestOptions siOptions = {} 
)
explicit

Definition at line 27 of file validator-config.cpp.

◆ ValidatorConfig() [2/2]

ndn::security::ValidatorConfig::ValidatorConfig ( Face face,
const CommandInterestOptions ciOptions = {},
const SignedInterestOptions siOptions = {} 
)
explicit

Definition at line 40 of file validator-config.cpp.

Member Function Documentation

◆ cacheUnverifiedCert()

void ndn::security::CertificateStorage::cacheUnverifiedCert ( Certificate &&  cert)
inherited

Cache unverified certificate for a period of time (5 minutes).

Parameters
certThe certificate packet
Todo:
Add ability to customize time period

Definition at line 81 of file certificate-storage.cpp.

◆ cacheVerifiedCert()

void ndn::security::CertificateStorage::cacheVerifiedCert ( Certificate &&  cert)
protectedinherited

Cache verified certificate a period of time (1 hour).

Parameters
certThe certificate packet
Todo:
Add ability to customize time period

Definition at line 69 of file certificate-storage.cpp.

◆ cacheVerifiedCertificate()

void ndn::security::Validator::cacheVerifiedCertificate ( Certificate &&  cert)
inherited

Cache verified cert a period of time (1 hour).

Todo:
Add ability to customize time period

Definition at line 188 of file validator.cpp.

◆ findTrustedCert()

const Certificate * ndn::security::CertificateStorage::findTrustedCert ( const Interest interestForCert) const
inherited

Find a trusted certificate in trust anchor container or in verified cache.

Parameters
interestForCertInterest for certificate
Returns
Found certificate, nullptr if not found.
Note
The returned pointer may get invalidated after next findTrustedCert() or findCert() calls.

Definition at line 33 of file certificate-storage.cpp.

◆ getFetcher()

CertificateFetcher& ndn::security::Validator::getFetcher ( ) const
inlinenoexceptinherited

Definition at line 80 of file validator.hpp.

◆ getMaxDepth()

size_t ndn::security::Validator::getMaxDepth ( ) const
inlinenoexceptinherited

Return the maximum depth of the certificate chain.

Definition at line 89 of file validator.hpp.

◆ getPolicy()

ValidationPolicy& ndn::security::Validator::getPolicy ( ) const
inlinenoexceptinherited

Definition at line 74 of file validator.hpp.

◆ getTrustAnchors()

const TrustAnchorContainer & ndn::security::CertificateStorage::getTrustAnchors ( ) const
inherited
Returns
Trust anchor container

Definition at line 87 of file certificate-storage.cpp.

◆ getUnverifiedCertCache()

const CertificateCache & ndn::security::CertificateStorage::getUnverifiedCertCache ( ) const
inherited
Returns
Unverified certificate cache

Definition at line 99 of file certificate-storage.cpp.

◆ getVerifiedCertCache()

const CertificateCache & ndn::security::CertificateStorage::getVerifiedCertCache ( ) const
inherited
Returns
Verified certificate cache

Definition at line 93 of file certificate-storage.cpp.

◆ isCertKnown()

bool ndn::security::CertificateStorage::isCertKnown ( const Name certPrefix) const
inherited

Check if certificate exists in the verified/unverified cache or in the set of trust anchors.

Definition at line 42 of file certificate-storage.cpp.

◆ load() [1/4]

void ndn::security::ValidatorConfig::load ( const std::string &  filename)

Definition at line 48 of file validator-config.cpp.

◆ load() [2/4]

void ndn::security::ValidatorConfig::load ( const std::string &  input,
const std::string &  filename 
)

Definition at line 54 of file validator-config.cpp.

◆ load() [3/4]

void ndn::security::ValidatorConfig::load ( const validator_config::ConfigSection configSection,
const std::string &  filename 
)

Definition at line 66 of file validator-config.cpp.

◆ load() [4/4]

void ndn::security::ValidatorConfig::load ( std::istream &  input,
const std::string &  filename 
)

Definition at line 60 of file validator-config.cpp.

◆ loadAnchor() [1/2]

void ndn::security::Validator::loadAnchor ( const std::string &  groupId,
Certificate &&  cert 
)
inherited

Load static trust anchor.

Static trust anchors are permanently associated with the validator and never expire.

Parameters
groupIdCertificate group id.
certCertificate to load as a trust anchor.

Definition at line 169 of file validator.cpp.

◆ loadAnchor() [2/2]

void ndn::security::Validator::loadAnchor ( const std::string &  groupId,
const std::string &  certfilePath,
time::nanoseconds  refreshPeriod,
bool  isDir = false 
)
inherited

Load dynamic trust anchors.

Dynamic trust anchors are associated with the validator for as long as the underlying trust anchor file (set of files) exist(s).

Parameters
groupIdCertificate group id, must not be empty.
certfilePathSpecifies the path to load the trust anchors.
refreshPeriodRefresh period for the trust anchors, must be positive.
isDirTells whether the path is a directory or a single file.

Definition at line 175 of file validator.cpp.

◆ resetAnchors()

void ndn::security::Validator::resetAnchors ( )
inherited

Remove any previously loaded static or dynamic trust anchor.

Definition at line 182 of file validator.cpp.

◆ resetVerifiedCertificates()

void ndn::security::Validator::resetVerifiedCertificates ( )
inherited

Remove any cached verified certificates.

Definition at line 194 of file validator.cpp.

◆ resetVerifiedCerts()

void ndn::security::CertificateStorage::resetVerifiedCerts ( )
protectedinherited

Remove any cached verified certificates.

Definition at line 75 of file certificate-storage.cpp.

◆ setMaxDepth()

void ndn::security::Validator::setMaxDepth ( size_t  depth)
inlinenoexceptinherited

Set the maximum depth of the certificate chain.

Definition at line 98 of file validator.hpp.

◆ validate() [1/2]

void ndn::security::Validator::validate ( const Data data,
const DataValidationSuccessCallback successCb,
const DataValidationFailureCallback failureCb 
)
inherited

Asynchronously validate data.

Note
successCb and failureCb must not be nullptr

Definition at line 47 of file validator.cpp.

◆ validate() [2/2]

void ndn::security::Validator::validate ( const Interest interest,
const InterestValidationSuccessCallback successCb,
const InterestValidationFailureCallback failureCb 
)
inherited

Asynchronously validate interest.

Note
successCb and failureCb must not be nullptr

Definition at line 60 of file validator.cpp.

◆ Validator()

ndn::security::Validator::Validator

Validator constructor.

Parameters
policyValidation policy to be associated with the validator.
certFetcherCertificate fetcher implementation.

Definition at line 69 of file validator.cpp.

Member Data Documentation

◆ m_trustAnchors

TrustAnchorContainer ndn::security::CertificateStorage::m_trustAnchors
protectedinherited

Definition at line 131 of file certificate-storage.hpp.

◆ m_unverifiedCertCache

CertificateCache ndn::security::CertificateStorage::m_unverifiedCertCache
protectedinherited

Definition at line 133 of file certificate-storage.hpp.

◆ m_verifiedCertCache

CertificateCache ndn::security::CertificateStorage::m_verifiedCertCache
protectedinherited

Definition at line 132 of file certificate-storage.hpp.