blob: 85fd2d9e97bea2dc39a057e9f251656c909c5936 [file] [log] [blame]
Yingdi Yu42f66462013-10-31 17:38:22 -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 PANEL_POLICY_MANAGER_H
12#define PANEL_POLICY_MANAGER_H
13
14#include <ndn.cxx/security/policy/policy-manager.h>
15#include <ndn.cxx/security/policy/identity-policy-rule.h>
16#include <ndn.cxx/security/cache/certificate-cache.h>
17#include <map>
18
19#include "endorse-certificate.h"
20
21class PanelPolicyManager : public ndn::security::PolicyManager
22{
23public:
24 PanelPolicyManager(const int & stepLimit = 10,
25 ndn::Ptr<ndn::security::CertificateCache> certificateCache = NULL);
26
27 ~PanelPolicyManager()
28 {}
29
30 /**
31 * @brief check if the received data packet can escape from verification
32 * @param data the received data packet
33 * @return true if the data does not need to be verified, otherwise false
34 */
35 bool
36 skipVerifyAndTrust (const ndn::Data & data);
37
38 /**
39 * @brief check if PolicyManager has the verification rule for the received data
40 * @param data the received data packet
41 * @return true if the data must be verified, otherwise false
42 */
43 bool
44 requireVerify (const ndn::Data & data);
45
46 /**
47 * @brief check whether received data packet complies with the verification policy, and get the indication of next verification step
48 * @param data the received data packet
49 * @param stepCount the number of verification steps that have been done, used to track the verification progress
50 * @param verifiedCallback the callback function that will be called if the received data packet has been validated
51 * @param unverifiedCallback the callback function that will be called if the received data packet cannot be validated
52 * @return the indication of next verification step, NULL if there is no further step
53 */
54 ndn::Ptr<ndn::security::ValidationRequest>
55 checkVerificationPolicy(ndn::Ptr<ndn::Data> data,
56 const int & stepCount,
57 const ndn::DataCallback& verifiedCallback,
58 const ndn::UnverifiedCallback& unverifiedCallback);
59
60
61 /**
62 * @brief check if the signing certificate name and data name satify the signing policy
63 * @param dataName the name of data to be signed
64 * @param certificateName the name of signing certificate
65 * @return true if the signing certificate can be used to sign the data, otherwise false
66 */
67 bool
68 checkSigningPolicy(const ndn::Name & dataName, const ndn::Name & certificateName);
69
70 /**
71 * @brief Infer signing identity name according to policy, if the signing identity cannot be inferred, it should return empty name
72 * @param dataName, the name of data to be signed
73 * @return the signing identity.
74 */
75 ndn::Name
76 inferSigningIdentity(const ndn::Name & dataName);
77
78
79 void
80 addTrustAnchor(const EndorseCertificate& selfEndorseCertificate);
81
82// private:
83// void
84// onCertificateVerified(ndn::Ptr<ndn::Data> certData,
85// ndn::Ptr<ndn::Data> originalData,
86// const ndn::DataCallback& verifiedCallback,
87// const ndn::UnverifiedCallback& unverifiedCallback);
88
89// void
90// onCertificateUnverified(ndn::Ptr<ndn::Data> certData,
91// ndn::Ptr<ndn::Data> originalData,
92// const ndn::UnverifiedCallback& unverifiedCallback);
93
94private:
95 int m_stepLimit;
96 ndn::Ptr<ndn::security::CertificateCache> m_certificateCache;
97 ndn::Ptr<ndn::Regex> m_localPrefixRegex;
98 ndn::Ptr<ndn::security::IdentityPolicyRule> m_invitationDataSigningRule;
99 ndn::Ptr<ndn::security::IdentityPolicyRule> m_dskRule;
100 ndn::Ptr<ndn::Regex> m_keyNameRegex;
101 ndn::Ptr<ndn::Regex> m_signingCertificateRegex;
102 std::map<ndn::Name, ndn::security::Publickey> m_trustAnchors;
103
104};
105
106#endif