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 | |
| 14 | #include <ndn.cxx/security/policy/policy-manager.h> |
| 15 | #include <ndn.cxx/security/policy/identity-policy-rule.h> |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 16 | #include <ndn.cxx/security/cache/certificate-cache.h> |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 17 | #include <ndn.cxx/regex/regex.h> |
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 | |
| 23 | class InvitationPolicyManager : public ndn::security::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, |
| 27 | int stepLimit = 10, |
| 28 | ndn::Ptr<ndn::security::CertificateCache> certificateCache = NULL); |
| 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 | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 39 | ndn::Ptr<ndn::security::ValidationRequest> |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 40 | checkVerificationPolicy(ndn::Ptr<ndn::Data> data, |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 41 | const int& stepCount, |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 42 | const ndn::DataCallback& verifiedCallback, |
| 43 | const ndn::UnverifiedCallback& unverifiedCallback); |
| 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 | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 59 | ndn::Ptr<ndn::security::IdentityCertificate> |
| 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 |
| 64 | onDskCertificateVerified(ndn::Ptr<ndn::Data> certData, |
| 65 | ndn::Ptr<ndn::Data> originalData, |
| 66 | const ndn::DataCallback& verifiedCallback, |
| 67 | const ndn::UnverifiedCallback& unverifiedCallback); |
| 68 | |
| 69 | void |
| 70 | onDskCertificateUnverified(ndn::Ptr<ndn::Data> certData, |
| 71 | ndn::Ptr<ndn::Data> originalData, |
| 72 | const ndn::UnverifiedCallback& unverifiedCallback); |
| 73 | |
| 74 | private: |
| 75 | std::string m_chatroomName; |
| 76 | |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 77 | int m_stepLimit; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 78 | |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 79 | ndn::Ptr<ndn::security::CertificateCache> m_certificateCache; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 80 | |
| 81 | ndn::Ptr<ndn::security::IdentityPolicyRule> m_invitationPolicyRule; |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 82 | ndn::Ptr<ndn::security::IdentityPolicyRule> m_dskRule; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 83 | std::map<ndn::Name, ChatPolicyRule> m_chatDataRules; |
| 84 | |
Yingdi Yu | 9b34b1f | 2013-11-01 17:37:51 -0700 | [diff] [blame] | 85 | ndn::Ptr<ndn::Regex> m_kskRegex; |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 86 | ndn::Ptr<ndn::Regex> m_keyNameRegex; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 87 | |
Yingdi Yu | 978b3ae | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 88 | std::map<ndn::Name, ndn::security::Publickey> m_trustAnchors; |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 89 | |
| 90 | std::map<ndn::Name, ndn::Ptr<ndn::security::IdentityCertificate> > m_dskCertificates; |
| 91 | |
Yingdi Yu | 1ec26de | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 92 | }; |
| 93 | |
Yingdi Yu | 7989eb2 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 94 | #endif //CHATROOM_POLICY_MANAGER_H |