31 #define NDN_LOG_DEBUG_DEPTH(x) NDN_LOG_DEBUG(std::string(this->getDepth() + 1, '>') << " " << x)
32 #define NDN_LOG_TRACE_DEPTH(x) NDN_LOG_TRACE(std::string(this->getDepth() + 1, '>') << " " << x)
37 BOOST_ASSERT(!boost::logic::indeterminate(
m_outcome));
43 return !m_seenCertificateNames.insert(certName).second;
49 m_certificateChain.push_front(cert);
53 ValidationState::verifyCertificateChain(
const Certificate& trustedCert)
56 for (
auto it = m_certificateChain.begin(); it != m_certificateChain.end(); ++it) {
57 const auto& certToValidate = *it;
61 m_certificateChain.erase(it, m_certificateChain.end());
66 validatedCert = &certToValidate;
77 , m_successCb(successCb)
78 , m_failureCb(failureCb)
80 BOOST_ASSERT(m_successCb !=
nullptr);
81 BOOST_ASSERT(m_failureCb !=
nullptr);
86 if (boost::logic::indeterminate(
m_outcome)) {
88 "Validator/policy did not invoke success or failure callback"});
93 DataValidationState::verifyOriginalPacket(
const std::optional<Certificate>& trustedCert)
98 BOOST_ASSERT(boost::logic::indeterminate(
m_outcome));
107 DataValidationState::bypassValidation()
111 BOOST_ASSERT(boost::logic::indeterminate(
m_outcome));
119 m_failureCb(m_data, error);
120 BOOST_ASSERT(boost::logic::indeterminate(
m_outcome));
129 : m_interest(interest)
130 , m_failureCb(failureCb)
133 BOOST_ASSERT(successCb !=
nullptr);
134 BOOST_ASSERT(m_failureCb !=
nullptr);
139 if (boost::logic::indeterminate(
m_outcome)) {
141 "Validator/policy did not invoke success or failure callback"});
146 InterestValidationState::verifyOriginalPacket(
const std::optional<Certificate>& trustedCert)
151 BOOST_ASSERT(boost::logic::indeterminate(
m_outcome));
160 InterestValidationState::bypassValidation()
164 BOOST_ASSERT(boost::logic::indeterminate(
m_outcome));
172 m_failureCb(m_interest, error);
173 BOOST_ASSERT(boost::logic::indeterminate(
m_outcome));
Represents a Data packet.
const Name & getName() const noexcept
Get the Data name.
Represents an Interest packet.
const Name & getName() const noexcept
Get the Interest name.
Represents an absolute name.
Represents an NDN certificate.
DataValidationState(const Data &data, const DataValidationSuccessCallback &successCb, const DataValidationFailureCallback &failureCb)
Create validation state for data.
void fail(const ValidationError &error) final
Call the failure callback.
~DataValidationState() final
Destructor.
~InterestValidationState() final
Destructor.
void fail(const ValidationError &error) final
Call the failure callback.
signal::Signal< InterestValidationState, Interest > afterSuccess
InterestValidationState(const Interest &interest, const InterestValidationSuccessCallback &successCb, const InterestValidationFailureCallback &failureCb)
Create validation state for interest.
Validation error code and optional detailed error message.
@ INVALID_SIGNATURE
Signature verification failed.
@ IMPLEMENTATION_ERROR
Internal implementation error.
virtual ~ValidationState()
bool hasSeenCertificateName(const Name &certName)
Check if certName has been previously seen and record the supplied name.
virtual void fail(const ValidationError &error)=0
Call the failure callback.
void addCertificate(const Certificate &cert)
Add cert to the top of the certificate chain.
boost::logic::tribool m_outcome
#define NDN_LOG_TRACE(expression)
Log at TRACE level.
#define NDN_LOG_INIT(name)
Define a non-member log module.
Contains the ndn-cxx security framework.
std::function< void(const Interest &)> InterestValidationSuccessCallback
Callback to report a successful Interest validation.
bool verifySignature(const InputBuffers &blobs, span< const uint8_t > sig, const transform::PublicKey &key)
Verify blobs using key against sig.
std::function< void(const Interest &, const ValidationError &)> InterestValidationFailureCallback
Callback to report a failed Interest validation.
std::function< void(const Data &)> DataValidationSuccessCallback
Callback to report a successful Data validation.
std::function< void(const Data &, const ValidationError &)> DataValidationFailureCallback
Callback to report a failed Data validation.
#define NDN_LOG_DEBUG_DEPTH(x)
#define NDN_LOG_TRACE_DEPTH(x)