Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -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 | |
| 11 | #ifndef INVITATION_POLICY_MANAGER_H |
| 12 | #define INVITATION_POLICY_MANAGER_H |
| 13 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 14 | #include <ndn-cpp/security/policy/policy-manager.hpp> |
| 15 | #include <ndn-cpp-et/policy-manager/identity-policy-rule.hpp> |
| 16 | #include <ndn-cpp-et/cache/ttl-certificate-cache.hpp> |
| 17 | #include <ndn-cpp-et/regex/regex.hpp> |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 18 | #include <map> |
| 19 | |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 20 | #include "endorse-certificate.h" |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 21 | #include "chat-policy-rule.h" |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 22 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 23 | class InvitationPolicyManager : public ndn::PolicyManager |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 24 | { |
| 25 | public: |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 26 | InvitationPolicyManager(const std::string& chatroomName, |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 27 | const ndn::Name& signingIdentity, |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 28 | int stepLimit = 10); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 29 | |
| 30 | virtual |
| 31 | ~InvitationPolicyManager(); |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 32 | |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 33 | bool |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 34 | skipVerifyAndTrust (const ndn::Data& data); |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 35 | |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 36 | bool |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 37 | requireVerify (const ndn::Data& data); |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 38 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 39 | ndn::ptr_lib::shared_ptr<ndn::ValidationRequest> |
| 40 | checkVerificationPolicy(const ndn::ptr_lib::shared_ptr<ndn::Data>& data, |
| 41 | int stepCount, |
| 42 | const ndn::OnVerified& onVerified, |
| 43 | const ndn::OnVerifyFailed& onVerifyFailed); |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 44 | |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 45 | bool |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 46 | checkSigningPolicy(const ndn::Name& dataName, |
| 47 | const ndn::Name& certificateName); |
| 48 | |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 49 | ndn::Name |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 50 | inferSigningIdentity(const ndn::Name& dataName); |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 51 | |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 52 | void |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 53 | addTrustAnchor(const EndorseCertificate& selfEndorseCertificate); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 54 | |
| 55 | // void |
| 56 | // addChatDataRule(const ndn::Name& prefix, |
| 57 | // const ndn::security::IdentityCertificate identityCertificate); |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 58 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 59 | ndn::ptr_lib::shared_ptr<ndn::IdentityCertificate> |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 60 | getValidatedDskCertificate(const ndn::Name& certName); |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 61 | |
| 62 | private: |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 63 | void |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 64 | onDskCertificateVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& certData, |
| 65 | ndn::ptr_lib::shared_ptr<ndn::Data> originalData, |
| 66 | const ndn::OnVerified& onVerified, |
| 67 | const ndn::OnVerifyFailed& onVerifyFailed); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 68 | |
| 69 | void |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 70 | onDskCertificateVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& certData, |
| 71 | ndn::ptr_lib::shared_ptr<ndn::Data> originalData, |
| 72 | const ndn::OnVerifyFailed& onVerifyFailed); |
| 73 | |
| 74 | static bool |
| 75 | isSameKey(const ndn::Blob& keyA, const ndn::Blob& keyB); |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 76 | |
| 77 | private: |
| 78 | std::string m_chatroomName; |
Yingdi Yu | e35bdb8 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 79 | ndn::Name m_signingIdentity; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 80 | |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 81 | int m_stepLimit; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 82 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 83 | ndn::TTLCertificateCache m_certificateCache; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 84 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 85 | ndn::ptr_lib::shared_ptr<ndn::IdentityPolicyRule> m_invitationPolicyRule; |
| 86 | ndn::ptr_lib::shared_ptr<ndn::IdentityPolicyRule> m_dskRule; |
| 87 | std::map<ndn::Name, ChatPolicyRule, ndn::Name::BreadthFirstLess> m_chatDataRules; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 88 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 89 | ndn::ptr_lib::shared_ptr<ndn::Regex> m_kskRegex; |
| 90 | ndn::ptr_lib::shared_ptr<ndn::Regex> m_keyNameRegex; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 91 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 92 | std::map<ndn::Name, ndn::PublicKey, ndn::Name::BreadthFirstLess> m_trustAnchors; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 93 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 94 | std::map<ndn::Name, ndn::ptr_lib::shared_ptr<ndn::IdentityCertificate>, ndn::Name::BreadthFirstLess> m_dskCertificates; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 95 | |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 96 | }; |
| 97 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 98 | #endif //CHATROOM_POLICY_MANAGER_H |