Yingdi Yu | ea5f1c6 | 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 | |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame^] | 11 | #ifndef SEC_POLICY_CHRONO_CHAT_INVITATION_H |
| 12 | #define SEC_POLICY_CHRONO_CHAT_INVITATION_H |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 13 | |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame^] | 14 | #include <ndn-cpp/security/sec-policy.hpp> |
| 15 | #include <ndn-cpp-et/policy/sec-rule-identity.hpp> |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 16 | #include <ndn-cpp-et/cache/ttl-certificate-cache.hpp> |
| 17 | #include <ndn-cpp-et/regex/regex.hpp> |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 18 | #include <map> |
| 19 | |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 20 | #include "endorse-certificate.h" |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame^] | 21 | #include "sec-rule-chrono-chat.h" |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 22 | |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame^] | 23 | class SecPolicyChronoChatInvitation : public ndn::SecPolicy |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 24 | { |
| 25 | public: |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame^] | 26 | SecPolicyChronoChatInvitation(const std::string& chatroomName, |
| 27 | const ndn::Name& signingIdentity, |
| 28 | int stepLimit = 10); |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 29 | |
| 30 | virtual |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame^] | 31 | ~SecPolicyChronoChatInvitation(); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 32 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 33 | bool |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 34 | skipVerifyAndTrust (const ndn::Data& data); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 35 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 36 | bool |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 37 | requireVerify (const ndn::Data& data); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 38 | |
Yingdi Yu | 6420611 | 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 | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 44 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 45 | bool |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 46 | checkSigningPolicy(const ndn::Name& dataName, |
| 47 | const ndn::Name& certificateName); |
| 48 | |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 49 | ndn::Name |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 50 | inferSigningIdentity(const ndn::Name& dataName); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 51 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 52 | void |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 53 | addTrustAnchor(const EndorseCertificate& selfEndorseCertificate); |
Yingdi Yu | 42f6646 | 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 | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 58 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 59 | ndn::ptr_lib::shared_ptr<ndn::IdentityCertificate> |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 60 | getValidatedDskCertificate(const ndn::Name& certName); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 61 | |
| 62 | private: |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 63 | void |
Yingdi Yu | 6420611 | 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 | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 68 | |
| 69 | void |
Yingdi Yu | 6420611 | 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 | |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 74 | private: |
| 75 | std::string m_chatroomName; |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 76 | ndn::Name m_signingIdentity; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 77 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 78 | int m_stepLimit; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 79 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 80 | ndn::TTLCertificateCache m_certificateCache; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 81 | |
Yingdi Yu | eaa84e2 | 2014-01-16 10:30:26 -0800 | [diff] [blame^] | 82 | ndn::ptr_lib::shared_ptr<ndn::SecRuleIdentity> m_invitationPolicyRule; |
| 83 | ndn::ptr_lib::shared_ptr<ndn::SecRuleIdentity> m_dskRule; |
| 84 | std::map<ndn::Name, SecRuleChronoChat, ndn::Name::BreadthFirstLess> m_chatDataRules; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 85 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 86 | ndn::ptr_lib::shared_ptr<ndn::Regex> m_kskRegex; |
| 87 | ndn::ptr_lib::shared_ptr<ndn::Regex> m_keyNameRegex; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 88 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 89 | std::map<ndn::Name, ndn::PublicKey, ndn::Name::BreadthFirstLess> m_trustAnchors; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 90 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 91 | std::map<ndn::Name, ndn::ptr_lib::shared_ptr<ndn::IdentityCertificate>, ndn::Name::BreadthFirstLess> m_dskCertificates; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 92 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 95 | #endif //CHATROOM_POLICY_MANAGER_H |