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 | |
| 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 | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 16 | #include <ndn.cxx/security/cache/certificate-cache.h> |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 17 | #include <ndn.cxx/regex/regex.h> |
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 | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 21 | #include "chat-policy-rule.h" |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 22 | |
| 23 | class InvitationPolicyManager : public ndn::security::PolicyManager |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 24 | { |
| 25 | public: |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 26 | InvitationPolicyManager(const std::string& chatroomName, |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 27 | const ndn::Name& signingIdentity, |
| 28 | int stepLimit = 10, |
| 29 | ndn::Ptr<ndn::security::CertificateCache> certificateCache = NULL); |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 30 | |
| 31 | virtual |
| 32 | ~InvitationPolicyManager(); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 33 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 34 | bool |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 35 | skipVerifyAndTrust (const ndn::Data& data); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 36 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 37 | bool |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 38 | requireVerify (const ndn::Data& data); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 39 | |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 40 | ndn::Ptr<ndn::security::ValidationRequest> |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 41 | checkVerificationPolicy(ndn::Ptr<ndn::Data> data, |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 42 | const int& stepCount, |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 43 | const ndn::DataCallback& verifiedCallback, |
| 44 | const ndn::UnverifiedCallback& unverifiedCallback); |
| 45 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 46 | bool |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 47 | checkSigningPolicy(const ndn::Name& dataName, |
| 48 | const ndn::Name& certificateName); |
| 49 | |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 50 | ndn::Name |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 51 | inferSigningIdentity(const ndn::Name& dataName); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 52 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 53 | void |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 54 | addTrustAnchor(const EndorseCertificate& selfEndorseCertificate); |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 55 | |
| 56 | // void |
| 57 | // addChatDataRule(const ndn::Name& prefix, |
| 58 | // const ndn::security::IdentityCertificate identityCertificate); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 59 | |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 60 | ndn::Ptr<ndn::security::IdentityCertificate> |
| 61 | getValidatedDskCertificate(const ndn::Name& certName); |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 62 | |
| 63 | private: |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 64 | void |
| 65 | onDskCertificateVerified(ndn::Ptr<ndn::Data> certData, |
| 66 | ndn::Ptr<ndn::Data> originalData, |
| 67 | const ndn::DataCallback& verifiedCallback, |
| 68 | const ndn::UnverifiedCallback& unverifiedCallback); |
| 69 | |
| 70 | void |
| 71 | onDskCertificateUnverified(ndn::Ptr<ndn::Data> certData, |
| 72 | ndn::Ptr<ndn::Data> originalData, |
| 73 | const ndn::UnverifiedCallback& unverifiedCallback); |
| 74 | |
| 75 | private: |
| 76 | std::string m_chatroomName; |
Yingdi Yu | b35b865 | 2013-11-07 11:32:40 -0800 | [diff] [blame] | 77 | ndn::Name m_signingIdentity; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 78 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 79 | int m_stepLimit; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 80 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 81 | ndn::Ptr<ndn::security::CertificateCache> m_certificateCache; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 82 | |
| 83 | ndn::Ptr<ndn::security::IdentityPolicyRule> m_invitationPolicyRule; |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 84 | ndn::Ptr<ndn::security::IdentityPolicyRule> m_dskRule; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 85 | std::map<ndn::Name, ChatPolicyRule> m_chatDataRules; |
| 86 | |
Yingdi Yu | ed8cfc4 | 2013-11-01 17:37:51 -0700 | [diff] [blame] | 87 | ndn::Ptr<ndn::Regex> m_kskRegex; |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 88 | ndn::Ptr<ndn::Regex> m_keyNameRegex; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 89 | |
Yingdi Yu | 53eb8a7 | 2013-10-23 11:50:51 -0700 | [diff] [blame] | 90 | std::map<ndn::Name, ndn::security::Publickey> m_trustAnchors; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 91 | |
| 92 | std::map<ndn::Name, ndn::Ptr<ndn::security::IdentityCertificate> > m_dskCertificates; |
| 93 | |
Yingdi Yu | ea5f1c6 | 2013-10-22 16:59:43 -0700 | [diff] [blame] | 94 | }; |
| 95 | |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 96 | #endif //CHATROOM_POLICY_MANAGER_H |