NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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"
28 #include "identity-certificate.hpp"
29 #include "sec-rule-relative.hpp"
30 #include "certificate-cache.hpp"
31 #include "../util/regex.hpp"
32 
33 namespace ndn {
34 
35 class ValidatorRegex : public Validator
36 {
37 public:
38  class Error : public Validator::Error
39  {
40  public:
41  explicit
42  Error(const std::string& what)
43  : Validator::Error(what)
44  {
45  }
46  };
47 
52  explicit
53  ValidatorRegex(Face* face = nullptr,
54  shared_ptr<CertificateCache> certificateCache = DEFAULT_CERTIFICATE_CACHE,
55  const int stepLimit = 3);
56 
58  explicit
60  shared_ptr<CertificateCache> certificateCache = DEFAULT_CERTIFICATE_CACHE,
61  const int stepLimit = 3);
62 
63  virtual
65  {
66  }
67 
73  void
74  addDataVerificationRule(shared_ptr<SecRuleRelative> rule);
75 
81  void
82  addTrustAnchor(shared_ptr<IdentityCertificate> certificate);
83 
84 protected:
85  virtual void
86  checkPolicy(const Data& data,
87  int nSteps,
88  const OnDataValidated& onValidated,
89  const OnDataValidationFailed& onValidationFailed,
90  std::vector<shared_ptr<ValidationRequest> >& nextSteps);
91 
92  virtual void
93  checkPolicy(const Interest& interest,
94  int nSteps,
95  const OnInterestValidated& onValidated,
96  const OnInterestValidationFailed& onValidationFailed,
97  std::vector<shared_ptr<ValidationRequest> >& nextSteps)
98  {
99  onValidationFailed(interest.shared_from_this(), "No policy for signed interest checking");
100  }
101 
102  void
103  onCertificateValidated(const shared_ptr<const Data>& signCertificate,
104  const shared_ptr<const Data>& data,
105  const OnDataValidated& onValidated,
106  const OnDataValidationFailed& onValidationFailed);
107 
108  void
109  onCertificateValidationFailed(const shared_ptr<const Data>& signCertificate,
110  const std::string& failureInfo,
111  const shared_ptr<const Data>& data,
112  const OnDataValidationFailed& onValidationFailed);
113 
114 public:
115  static const shared_ptr<CertificateCache> DEFAULT_CERTIFICATE_CACHE;
116 
117 protected:
118  typedef std::vector< shared_ptr<SecRuleRelative> > RuleList;
119  typedef std::vector< shared_ptr<Regex> > RegexList;
120 
122  shared_ptr<CertificateCache> m_certificateCache;
125  std::map<Name, shared_ptr<IdentityCertificate> > m_trustAnchors;
126 };
127 
128 } // namespace ndn
129 
130 #endif // NDN_SECURITY_VALIDATOR_REGEX_HPP
Copyright (c) 2011-2015 Regents of the University of California.
std::vector< shared_ptr< SecRuleRelative > > RuleList
void onCertificateValidationFailed(const shared_ptr< const Data > &signCertificate, const std::string &failureInfo, const shared_ptr< const Data > &data, const OnDataValidationFailed &onValidationFailed)
void onCertificateValidated(const shared_ptr< const Data > &signCertificate, const shared_ptr< const Data > &data, const OnDataValidated &onValidated, const OnDataValidationFailed &onValidationFailed)
shared_ptr< CertificateCache > m_certificateCache
virtual void checkPolicy(const Data &data, int nSteps, const OnDataValidated &onValidated, const OnDataValidationFailed &onValidationFailed, std::vector< shared_ptr< ValidationRequest > > &nextSteps)
Check the Data against policy and return the next validation step if necessary.
Error(const std::string &what)
represents an Interest packet
Definition: interest.hpp:45
function< void(const shared_ptr< const Data > &)> OnDataValidated
Callback to report a successful Data validation.
ValidatorRegex(Face *face=nullptr, shared_ptr< CertificateCache > certificateCache=DEFAULT_CERTIFICATE_CACHE, const int stepLimit=3)
std::vector< shared_ptr< Regex > > RegexList
static const shared_ptr< CertificateCache > DEFAULT_CERTIFICATE_CACHE
std::map< Name, shared_ptr< IdentityCertificate > > m_trustAnchors
function< void(const shared_ptr< const Data > &, const std::string &)> OnDataValidationFailed
Callback to report a failed Data validation.
Abstraction to communicate with local or remote NDN forwarder.
Definition: face.hpp:119
void addDataVerificationRule(shared_ptr< SecRuleRelative > rule)
Add a rule for data verification.
function< void(const shared_ptr< const Interest > &, const std::string &)> OnInterestValidationFailed
Callback to report a failed Interest validation.
void addTrustAnchor(shared_ptr< IdentityCertificate > certificate)
Add a trust anchor.
virtual void checkPolicy(const Interest &interest, int nSteps, const OnInterestValidated &onValidated, const OnInterestValidationFailed &onValidationFailed, std::vector< shared_ptr< ValidationRequest > > &nextSteps)
Check the Interest against validation policy and return the next validation step if necessary...
represents a Data packet
Definition: data.hpp:39
Validator is one of the main classes of the security library.
Definition: validator.hpp:46
function< void(const shared_ptr< const Interest > &)> OnInterestValidated
Callback to report a successful Interest validation.