NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
validation-state.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_SECURITY_V2_VALIDATION_STATE_HPP
23 #define NDN_SECURITY_V2_VALIDATION_STATE_HPP
24 
25 #include "../../tag-host.hpp"
26 #include "validation-callback.hpp"
27 #include "certificate.hpp"
28 #include "../../util/signal.hpp"
29 
30 #include <list>
31 #include <unordered_set>
32 #include <boost/logic/tribool.hpp>
33 
34 namespace ndn {
35 namespace security {
36 namespace v2 {
37 
38 class Validator;
39 
58 class ValidationState : public TagHost, noncopyable
59 {
60 public:
65 
66  virtual
68 
69  boost::logic::tribool
70  getOutcome() const
71  {
72  return m_outcome;
73  }
74 
78  virtual void
79  fail(const ValidationError& error) = 0;
80 
84  size_t
85  getDepth() const;
86 
90  bool
91  hasSeenCertificateName(const Name& certName);
92 
103  void
104  addCertificate(const Certificate& cert);
105 
106 private: // Interface intended to be used only by Validator class
112  virtual void
113  verifyOriginalPacket(const Certificate& trustedCert) = 0;
114 
118  virtual void
119  bypassValidation() = 0;
120 
135  const Certificate*
136  verifyCertificateChain(const Certificate& trustedCert);
137 
138 protected:
139  boost::logic::tribool m_outcome;
140 
141 private:
142  std::unordered_set<Name> m_seenCertificateNames;
143 
150  std::list<v2::Certificate> m_certificateChain;
151 
152  friend class Validator;
153 };
154 
159 {
160 public:
167  DataValidationState(const Data& data,
168  const DataValidationSuccessCallback& successCb,
169  const DataValidationFailureCallback& failureCb);
170 
177  ~DataValidationState() final;
178 
179  void
180  fail(const ValidationError& error) final;
181 
185  const Data&
186  getOriginalData() const;
187 
188 private:
189  void
190  verifyOriginalPacket(const Certificate& trustedCert) final;
191 
192  void
193  bypassValidation() final;
194 
195 private:
196  Data m_data;
197  DataValidationSuccessCallback m_successCb;
198  DataValidationFailureCallback m_failureCb;
199 };
200 
205 {
206 public:
213  InterestValidationState(const Interest& interest,
214  const InterestValidationSuccessCallback& successCb,
215  const InterestValidationFailureCallback& failureCb);
216 
223  ~InterestValidationState() final;
224 
225  void
226  fail(const ValidationError& error) final;
227 
231  const Interest&
232  getOriginalInterest() const;
233 
234 public:
236 
237 private:
238  void
239  verifyOriginalPacket(const Certificate& trustedCert) final;
240 
241  void
242  bypassValidation() final;
243 
244 private:
245  Interest m_interest;
248 };
249 
250 } // namespace v2
251 } // namespace security
252 } // namespace ndn
253 
254 #endif // NDN_SECURITY_V2_VALIDATION_STATE_HPP
ValidationState()
Create validation state.
DataValidationState(const Data &data, const DataValidationSuccessCallback &successCb, const DataValidationFailureCallback &failureCb)
Create validation state for data.
Copyright (c) 2011-2015 Regents of the University of California.
The certificate following the certificate format naming convention.
Definition: certificate.hpp:81
void fail(const ValidationError &error) final
Call the failure callback.
function< void(const Data &data)> DataValidationSuccessCallback
Callback to report a successful Data validation.
bool hasSeenCertificateName(const Name &certName)
Check if certName has been previously seen and record the supplied name.
ndn security v2 Validator
Definition: validator.cpp:32
Base class to store tag information (e.g., inside Interest and Data packets)
Definition: tag-host.hpp:34
void addCertificate(const Certificate &cert)
Add cert to the top of the certificate chain.
Represents an Interest packet.
Definition: interest.hpp:42
function< void(const Data &data, const ValidationError &error)> DataValidationFailureCallback
Callback to report a failed Data validation.
provides a lightweight signal / event system
Definition: signal.hpp:50
Validation state for a data packet.
boost::logic::tribool getOutcome() const
Validation state for an interest packet.
util::Signal< InterestValidationState, Interest > afterSuccess
Represents an absolute name.
Definition: name.hpp:42
void fail(const ValidationError &error) final
Call the failure callback.
function< void(const Interest &interest, const ValidationError &error)> InterestValidationFailureCallback
Callback to report a failed Interest validation.
InterestValidationState(const Interest &interest, const InterestValidationSuccessCallback &successCb, const InterestValidationFailureCallback &failureCb)
Create validation state for interest.
Validation error code and optional detailed error message.
virtual void fail(const ValidationError &error)=0
Call the failure callback.
Represents a Data packet.
Definition: data.hpp:35
function< void(const Interest &interest)> InterestValidationSuccessCallback
Callback to report a successful Interest validation.
Interface for validating data and interest packets.
Definition: validator.hpp:61