Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2013, Regents of the University of California |
| 4 | * Yingdi Yu |
| 5 | * |
| 6 | * BSD license, See the LICENSE file for more information |
| 7 | * |
| 8 | * Author: Yingdi Yu <yingdi@cs.ucla.edu> |
| 9 | */ |
| 10 | |
Yingdi Yu | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame^] | 11 | #ifndef CHRONOCHAT_VALIDATOR_PANEL_HPP |
| 12 | #define CHRONOCHAT_VALIDATOR_PANEL_HPP |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 13 | |
| 14 | #include "common.hpp" |
| 15 | |
| 16 | #include <ndn-cxx/security/validator.hpp> |
| 17 | #include <ndn-cxx/security/sec-rule-relative.hpp> |
| 18 | #include <ndn-cxx/security/certificate-cache.hpp> |
| 19 | |
| 20 | #include "endorse-certificate.hpp" |
| 21 | |
Yingdi Yu | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame^] | 22 | namespace chronochat { |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 23 | |
| 24 | class ValidatorPanel : public ndn::Validator |
| 25 | { |
| 26 | public: |
| 27 | |
| 28 | static const shared_ptr<ndn::CertificateCache> DEFAULT_CERT_CACHE; |
| 29 | |
| 30 | ValidatorPanel(int stepLimit = 10, |
| 31 | const shared_ptr<ndn::CertificateCache> cache = DEFAULT_CERT_CACHE); |
| 32 | |
| 33 | ~ValidatorPanel() |
| 34 | { |
| 35 | } |
| 36 | |
| 37 | void |
| 38 | addTrustAnchor(const EndorseCertificate& selfEndorseCertificate); |
| 39 | |
| 40 | void |
| 41 | removeTrustAnchor(const Name& keyName); |
| 42 | |
| 43 | protected: |
| 44 | virtual void |
| 45 | checkPolicy(const Data& data, |
| 46 | int stepCount, |
| 47 | const ndn::OnDataValidated& onValidated, |
| 48 | const ndn::OnDataValidationFailed& onValidationFailed, |
| 49 | std::vector<shared_ptr<ndn::ValidationRequest> >& nextSteps); |
| 50 | |
| 51 | virtual void |
| 52 | checkPolicy(const Interest& interest, |
| 53 | int stepCount, |
| 54 | const ndn::OnInterestValidated& onValidated, |
| 55 | const ndn::OnInterestValidationFailed& onValidationFailed, |
| 56 | std::vector<shared_ptr<ndn::ValidationRequest> >& nextSteps) |
| 57 | { |
| 58 | onValidationFailed(interest.shared_from_this(), |
| 59 | "No rules for interest."); |
| 60 | } |
| 61 | |
| 62 | private: |
| 63 | int m_stepLimit; |
| 64 | shared_ptr<ndn::CertificateCache> m_certificateCache; |
| 65 | shared_ptr<ndn::SecRuleRelative> m_endorseeRule; |
| 66 | std::map<Name, ndn::PublicKey> m_trustAnchors; |
| 67 | }; |
| 68 | |
Yingdi Yu | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame^] | 69 | } // namespace chronochat |
Yingdi Yu | 0b0a736 | 2014-08-05 16:31:30 -0700 | [diff] [blame] | 70 | |
Yingdi Yu | eb692ac | 2015-02-10 18:46:18 -0800 | [diff] [blame^] | 71 | #endif // CHRONOCHAT_VALIDATOR_PANEL_HPP |