Yingdi Yu | ad3f6cd | 2013-10-23 15:09:15 -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 CHATROOM_POLICY_MANAGER_H |
| 12 | #define CHATROOM_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 <ndn.cxx/regex/regex.h> |
| 18 | #include <map> |
| 19 | |
| 20 | #include "endorse-certificate.h" |
| 21 | |
| 22 | class ChatroomPolicyManager : public ndn::security::PolicyManager |
| 23 | { |
| 24 | public: |
| 25 | ChatroomPolicyManager(int stepLimit = 10, |
| 26 | ndn::Ptr<ndn::security::CertificateCache> certificateCache = NULL); |
| 27 | |
| 28 | virtual |
| 29 | ~ChatroomPolicyManager(); |
| 30 | |
| 31 | bool |
| 32 | skipVerifyAndTrust (const ndn::Data& data); |
| 33 | |
| 34 | bool |
| 35 | requireVerify (const ndn::Data& data); |
| 36 | |
| 37 | ndn::Ptr<ndn::security::ValidationRequest> |
| 38 | checkVerificationPolicy(ndn::Ptr<ndn::Data> data, |
| 39 | const int& stepCount, |
| 40 | const ndn::DataCallback& verifiedCallback, |
| 41 | const ndn::UnverifiedCallback& unverifiedCallback); |
| 42 | |
| 43 | bool |
| 44 | checkSigningPolicy(const ndn::Name& dataName, |
| 45 | const ndn::Name& certificateName); |
| 46 | |
| 47 | ndn::Name |
| 48 | inferSigningIdentity(const ndn::Name& dataName); |
| 49 | |
| 50 | void |
| 51 | addTrustAnchor(const EndorseCertificate& selfEndorseCertificate); |
| 52 | |
| 53 | private: |
| 54 | void |
| 55 | onCertificateVerified(ndn::Ptr<ndn::Data> certData, |
| 56 | ndn::Ptr<ndn::Data> originalData, |
| 57 | const ndn::DataCallback& verifiedCallback, |
| 58 | const ndn::UnverifiedCallback& unverifiedCallback); |
| 59 | |
| 60 | void |
| 61 | onCertificateUnverified(ndn::Ptr<ndn::Data> certData, |
| 62 | ndn::Ptr<ndn::Data> originalData, |
| 63 | const ndn::UnverifiedCallback& unverifiedCallback); |
| 64 | |
| 65 | private: |
| 66 | int m_stepLimit; |
| 67 | ndn::Ptr<ndn::security::CertificateCache> m_certificateCache; |
| 68 | |
| 69 | ndn::Ptr<ndn::security::IdentityPolicyRule> m_invitationPolicyRule; |
| 70 | ndn::Ptr<ndn::security::IdentityPolicyRule> m_dskRule; |
| 71 | |
| 72 | ndn::Ptr<ndn::Regex> m_keyNameRegex; |
| 73 | |
| 74 | std::map<ndn::Name, ndn::security::Publickey> m_trustAnchors; |
| 75 | |
| 76 | }; |
| 77 | |
| 78 | #endif //CHATROOM_POLICY_MANAGER_H |