security: Fix a bug of Validator, making checkPolicy methods pure abstract
This commit also includes fixes to unit tests.
Change-Id: If92569fc9dabaa08714d458e5195b6a83acb8701
diff --git a/src/security/validator-null.hpp b/src/security/validator-null.hpp
index 90b5293..27dc63d 100644
--- a/src/security/validator-null.hpp
+++ b/src/security/validator-null.hpp
@@ -14,22 +14,22 @@
namespace ndn {
class ValidatorNull : public Validator {
-protected:
-
+public:
virtual
~ValidatorNull()
{}
-
+
+protected:
virtual void
- checkPolicy (shared_ptr<const Data> data,
+ checkPolicy (const shared_ptr<const Data>& data,
int stepCount,
const OnDataValidated &onValidated,
const OnDataValidationFailed &onValidationFailed,
std::vector<shared_ptr<ValidationRequest> > &nextSteps)
{ onValidated(data); }
-
+
virtual void
- checkPolicy (shared_ptr<const Interest> interest,
+ checkPolicy (const shared_ptr<const Interest>& interest,
int stepCount,
const OnInterestValidated &onValidated,
const OnInterestValidationFailed &onValidationFailed,
diff --git a/src/security/validator-regex.hpp b/src/security/validator-regex.hpp
index e080ddf..a06964c 100644
--- a/src/security/validator-regex.hpp
+++ b/src/security/validator-regex.hpp
@@ -51,12 +51,20 @@
protected:
virtual void
- checkPolicy (const shared_ptr<const Data> &data,
+ checkPolicy (const shared_ptr<const Data>& data,
int stepCount,
const OnDataValidated &onValidated,
const OnDataValidationFailed &onValidationFailed,
std::vector<shared_ptr<ValidationRequest> > &nextSteps);
+ virtual void
+ checkPolicy (const shared_ptr<const Interest>& interest,
+ int stepCount,
+ const OnInterestValidated &onValidated,
+ const OnInterestValidationFailed &onValidationFailed,
+ std::vector<shared_ptr<ValidationRequest> > &nextSteps)
+ { onValidationFailed(interest); }
+
void
onCertificateValidated(const shared_ptr<const Data> &signCertificate,
const shared_ptr<const Data> &data,
diff --git a/src/security/validator.hpp b/src/security/validator.hpp
index 82f8e98..4ba4c43 100644
--- a/src/security/validator.hpp
+++ b/src/security/validator.hpp
@@ -97,8 +97,7 @@
int stepCount,
const OnDataValidated &onValidated,
const OnDataValidationFailed &onValidationFailed,
- std::vector<shared_ptr<ValidationRequest> > &nextSteps)
- { onValidationFailed(data); }
+ std::vector<shared_ptr<ValidationRequest> > &nextSteps) = 0;
/**
* @brief Check the Interest against validation policy and return the next validation step if necessary.
@@ -117,8 +116,7 @@
int stepCount,
const OnInterestValidated &onValidated,
const OnInterestValidationFailed &onValidationFailed,
- std::vector<shared_ptr<ValidationRequest> > &nextSteps)
- { onValidationFailed(interest); }
+ std::vector<shared_ptr<ValidationRequest> > &nextSteps) = 0;
private:
typedef function< void () > OnFailure;