blob: ab42fe1554d8d99906814513f4d7d75f13f4cba5 [file] [log] [blame]
Yingdi Yu0b0a7362014-08-05 16:31:30 -07001/* -*- 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 Yueb692ac2015-02-10 18:46:18 -080011#ifndef CHRONOCHAT_VALIDATOR_PANEL_HPP
12#define CHRONOCHAT_VALIDATOR_PANEL_HPP
Yingdi Yu0b0a7362014-08-05 16:31:30 -070013
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 Yueb692ac2015-02-10 18:46:18 -080022namespace chronochat {
Yingdi Yu0b0a7362014-08-05 16:31:30 -070023
24class ValidatorPanel : public ndn::Validator
25{
26public:
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
43protected:
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
62private:
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 Yueb692ac2015-02-10 18:46:18 -080069} // namespace chronochat
Yingdi Yu0b0a7362014-08-05 16:31:30 -070070
Yingdi Yueb692ac2015-02-10 18:46:18 -080071#endif // CHRONOCHAT_VALIDATOR_PANEL_HPP