blob: 1277ffe6c74ef4bca31da4819c4a77543bd4818d [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
11#ifndef CHRONOS_VALIDATOR_PANEL_HPP
12#define CHRONOS_VALIDATOR_PANEL_HPP
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
22namespace chronos {
23
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
69} // namespace chronos
70
71#endif // CHRONOS_VALIDATOR_PANEL_HPP