36 shared_ptr<CertificateCache> certificateCache,
39 , m_stepLimit(stepLimit)
40 , m_certificateCache(certificateCache)
47 shared_ptr<CertificateCache> certificateCache,
53 if (certificateCache ==
nullptr)
66 m_trustAnchors[certificate->getName().getPrefix(-1)] = certificate;
71 const shared_ptr<const Data>& data,
75 shared_ptr<v1::IdentityCertificate> certificate =
76 make_shared<v1::IdentityCertificate>(*signCertificate);
78 if (!certificate->isTooLate() && !certificate->isTooEarly()) {
83 return onValidated(data);
85 return onValidationFailed(data,
86 "Cannot verify signature: " +
87 data->getName().toUri());
90 return onValidationFailed(data,
91 "Signing certificate " +
92 signCertificate->getName().toUri() +
93 " is no longer valid.");
99 const std::string& failureInfo,
100 const shared_ptr<const Data>& data,
103 onValidationFailed(data, failureInfo);
111 std::vector<shared_ptr<ValidationRequest> >& nextSteps)
114 return onValidationFailed(data.shared_from_this(),
115 "Maximum steps of validation reached: " +
121 if ((*it)->satisfy(data))
122 return onValidationFailed(data.shared_from_this(),
123 "Comply with mustFail policy: " +
129 if ((*it)->satisfy(data)) {
132 return onValidationFailed(data.shared_from_this(),
133 "Key Locator is missing in Data packet: " +
138 return onValidationFailed(data.shared_from_this(),
139 "Key Locator is not a name: " +
144 shared_ptr<const v1::Certificate> trustedCert;
151 if (trustedCert !=
nullptr) {
153 return onValidated(data.shared_from_this());
155 return onValidationFailed(data.shared_from_this(),
156 "Cannot verify signature: " +
164 data.shared_from_this(), onValidated, onValidationFailed);
168 data.shared_from_this(), onValidationFailed);
171 shared_ptr<ValidationRequest> nextStep =
172 make_shared<ValidationRequest>(interest,
174 onKeyValidationFailed,
178 nextSteps.push_back(nextStep);
184 return onValidationFailed(data.shared_from_this(),
185 "Key Locator is not a name: " +
189 return onValidationFailed(data.shared_from_this(),
190 "Cannot decode signature");
195 return onValidationFailed(data.shared_from_this(),
Copyright (c) 2011-2015 Regents of the University of California.
std::string toUri() const
Encode this name as a URI.
RuleList m_mustFailVerify
RuleList m_verifyPolicies
void addDataVerificationRule(shared_ptr< SecRuleRelative > rule)
Add a rule for data verification.
const Name & getName() const
Get name of the Data packet.
const Name & getName() const
get Name element
represents an Interest packet
void addTrustAnchor(shared_ptr< v1::IdentityCertificate > certificate)
Add a trust anchor.
indicates KeyLocator contains a Name
function< void(const shared_ptr< const Data > &, const std::string &)> OnDataValidationFailed
Callback to report a failed Data validation.
bool hasKeyLocator() const
Check if SignatureInfo block has a KeyLocator.
function< void(const shared_ptr< const Data > &)> OnDataValidated
Callback to report a successful Data validation.
Table::const_iterator iterator
static const shared_ptr< CertificateCache > DEFAULT_CERTIFICATE_CACHE
virtual void checkPolicy(const Data &data, int nSteps, const OnDataValidated &onValidated, const OnDataValidationFailed &onValidationFailed, std::vector< shared_ptr< ValidationRequest > > &nextSteps)
void onCertificateValidated(const shared_ptr< const Data > &signCertificate, const shared_ptr< const Data > &data, const OnDataValidated &onValidated, const OnDataValidationFailed &onValidationFailed)
provides the interfaces for packet validation.
Provide a communication channel with local or remote NDN forwarder.
std::map< Name, shared_ptr< v1::IdentityCertificate > > m_trustAnchors
Name abstraction to represent an absolute name.
shared_ptr< CertificateCache > m_certificateCache
boost::asio::io_service & getIoService()
Return nullptr (cannot use IoService in simulations), preserved for API compatibility.
void onCertificateValidationFailed(const shared_ptr< const Data > &signCertificate, const std::string &failureInfo, const shared_ptr< const Data > &data, const OnDataValidationFailed &onValidationFailed)
static bool verifySignature(const Data &data, const v1::PublicKey &publicKey)
Verify the data using the publicKey.
const Signature & getSignature() const
const KeyLocator & getKeyLocator() const
Get KeyLocator.
ValidatorRegex(Face *face=nullptr, shared_ptr< CertificateCache > certificateCache=DEFAULT_CERTIFICATE_CACHE, const int stepLimit=3)
represents an error in TLV encoding or decoding