NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
validator-regex.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
24 #ifndef NDN_SECURITY_VALIDATOR_REGEX_HPP
25 #define NDN_SECURITY_VALIDATOR_REGEX_HPP
26 
27 #include "validator.hpp"
29 #include "sec-rule-relative.hpp"
30 #include "certificate-cache.hpp"
31 #include "../util/regex.hpp"
32 
33 namespace ndn {
34 namespace security {
35 
36 class ValidatorRegex : public Validator
37 {
38 public:
39  class Error : public Validator::Error
40  {
41  public:
42  explicit
43  Error(const std::string& what)
44  : Validator::Error(what)
45  {
46  }
47  };
48 
53  explicit
54  ValidatorRegex(Face* face = nullptr,
55  shared_ptr<CertificateCache> certificateCache = DEFAULT_CERTIFICATE_CACHE,
56  const int stepLimit = 3);
57 
59  explicit
61  shared_ptr<CertificateCache> certificateCache = DEFAULT_CERTIFICATE_CACHE,
62  const int stepLimit = 3);
63 
64  virtual
66  {
67  }
68 
74  void
75  addDataVerificationRule(shared_ptr<SecRuleRelative> rule);
76 
82  void
83  addTrustAnchor(shared_ptr<v1::IdentityCertificate> certificate);
84 
85 protected:
86  virtual void
87  checkPolicy(const Data& data,
88  int nSteps,
89  const OnDataValidated& onValidated,
90  const OnDataValidationFailed& onValidationFailed,
91  std::vector<shared_ptr<ValidationRequest> >& nextSteps);
92 
93  virtual void
94  checkPolicy(const Interest& interest,
95  int nSteps,
96  const OnInterestValidated& onValidated,
97  const OnInterestValidationFailed& onValidationFailed,
98  std::vector<shared_ptr<ValidationRequest> >& nextSteps)
99  {
100  onValidationFailed(interest.shared_from_this(), "No policy for signed interest checking");
101  }
102 
103  void
104  onCertificateValidated(const shared_ptr<const Data>& signCertificate,
105  const shared_ptr<const Data>& data,
106  const OnDataValidated& onValidated,
107  const OnDataValidationFailed& onValidationFailed);
108 
109  void
110  onCertificateValidationFailed(const shared_ptr<const Data>& signCertificate,
111  const std::string& failureInfo,
112  const shared_ptr<const Data>& data,
113  const OnDataValidationFailed& onValidationFailed);
114 
115 public:
116  static const shared_ptr<CertificateCache> DEFAULT_CERTIFICATE_CACHE;
117 
118 protected:
119  typedef std::vector< shared_ptr<SecRuleRelative> > RuleList;
120  typedef std::vector< shared_ptr<Regex> > RegexList;
121 
123  shared_ptr<CertificateCache> m_certificateCache;
126  std::map<Name, shared_ptr<v1::IdentityCertificate> > m_trustAnchors;
127 };
128 
129 } // namespace security
130 
132 
133 } // namespace ndn
134 
135 #endif // NDN_SECURITY_VALIDATOR_REGEX_HPP
function< void(const shared_ptr< const Interest > &, const std::string &)> OnInterestValidationFailed
Callback to report a failed Interest validation.
Copyright (c) 2011-2015 Regents of the University of California.
void addDataVerificationRule(shared_ptr< SecRuleRelative > rule)
Add a rule for data verification.
represents an Interest packet
Definition: interest.hpp:42
std::vector< shared_ptr< Regex > > RegexList
void addTrustAnchor(shared_ptr< v1::IdentityCertificate > certificate)
Add a trust anchor.
function< void(const shared_ptr< const Data > &, const std::string &)> OnDataValidationFailed
Callback to report a failed Data validation.
function< void(const shared_ptr< const Data > &)> OnDataValidated
Callback to report a successful Data validation.
function< void(const shared_ptr< const Interest > &)> OnInterestValidated
Callback to report a successful Interest validation.
static const shared_ptr< CertificateCache > DEFAULT_CERTIFICATE_CACHE
virtual void checkPolicy(const Interest &interest, int nSteps, const OnInterestValidated &onValidated, const OnInterestValidationFailed &onValidationFailed, std::vector< shared_ptr< ValidationRequest > > &nextSteps)
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)
std::vector< shared_ptr< SecRuleRelative > > RuleList
provides the interfaces for packet validation.
Definition: validator.hpp:42
Provide a communication channel with local or remote NDN forwarder.
Definition: face.hpp:125
std::map< Name, shared_ptr< v1::IdentityCertificate > > m_trustAnchors
shared_ptr< CertificateCache > m_certificateCache
void onCertificateValidationFailed(const shared_ptr< const Data > &signCertificate, const std::string &failureInfo, const shared_ptr< const Data > &data, const OnDataValidationFailed &onValidationFailed)
represents a Data packet
Definition: data.hpp:37
ValidatorRegex(Face *face=nullptr, shared_ptr< CertificateCache > certificateCache=DEFAULT_CERTIFICATE_CACHE, const int stepLimit=3)