blob: 03890a0c18b05cf9ec2af3cb505a9901a071073c [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_INVITATION_HPP
12#define CHRONOCHAT_VALIDATOR_INVITATION_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/certificate-cache.hpp>
18#include <ndn-cxx/security/sec-rule-relative.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 ValidatorInvitation : public ndn::Validator
25{
26 typedef function<void(const std::string&)> OnValidationFailed;
27 typedef function<void()> OnValidated;
28
29public:
30 class Error : public ndn::Validator::Error
31 {
32 public:
33 Error(const std::string& what)
34 : ndn::Validator::Error(what)
35 {
36 }
37 };
38
39 static const shared_ptr<ndn::CertificateCache> DefaultCertificateCache;
40
41 ValidatorInvitation();
42
43 virtual
44 ~ValidatorInvitation()
45 {
46 }
47
48 void
49 addTrustAnchor(const Name& keyName, const ndn::PublicKey& key);
50
51 void
52 removeTrustAnchor(const Name& keyName);
53
54 void
55 cleanTrustAnchor();
56
57protected:
58 void
59 checkPolicy(const Data& data,
60 int stepCount,
61 const ndn::OnDataValidated& onValidated,
62 const ndn::OnDataValidationFailed& onValidationFailed,
63 std::vector<shared_ptr<ndn::ValidationRequest> >& nextSteps);
64
65 void
66 checkPolicy(const Interest& interest,
67 int stepCount,
68 const ndn::OnInterestValidated& onValidated,
69 const ndn::OnInterestValidationFailed& onValidationFailed,
70 std::vector<shared_ptr<ndn::ValidationRequest> >& nextSteps);
71
72private:
73 void
74 internalCheck(const uint8_t* buf, size_t size,
75 const Signature& sig,
76 const Name& keyLocatorName,
77 const Data& innerData,
78 const OnValidated& onValidated,
79 const OnValidationFailed& onValidationFailed);
80
81private:
82 typedef std::map<Name, ndn::PublicKey> TrustAnchors;
83
84 ndn::SecRuleRelative m_invitationReplyRule;
85 ndn::Regex m_invitationInterestRule;
86 ndn::Regex m_innerKeyRegex;
87 TrustAnchors m_trustAnchors;
88};
89
Yingdi Yueb692ac2015-02-10 18:46:18 -080090} // namespace chronochat
Yingdi Yu0b0a7362014-08-05 16:31:30 -070091
Yingdi Yueb692ac2015-02-10 18:46:18 -080092#endif // CHRONOCHAT_VALIDATOR_INVITATION_HPP