blob: cc37d7bc3fc92c56ca8058042d2041a081179110 [file] [log] [blame]
Yingdi Yuea5f1c62013-10-22 16:59:43 -07001/* -*- 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 Yu53eb8a72013-10-23 11:50:51 -070016#include <ndn.cxx/security/cache/certificate-cache.h>
Yingdi Yu42f66462013-10-31 17:38:22 -070017#include <ndn.cxx/regex/regex.h>
Yingdi Yuea5f1c62013-10-22 16:59:43 -070018#include <map>
19
Yingdi Yu53eb8a72013-10-23 11:50:51 -070020#include "endorse-certificate.h"
Yingdi Yu42f66462013-10-31 17:38:22 -070021#include "chat-policy-rule.h"
Yingdi Yu53eb8a72013-10-23 11:50:51 -070022
23class InvitationPolicyManager : public ndn::security::PolicyManager
Yingdi Yuea5f1c62013-10-22 16:59:43 -070024{
25public:
Yingdi Yu42f66462013-10-31 17:38:22 -070026 InvitationPolicyManager(const std::string& chatroomName,
27 int stepLimit = 10,
28 ndn::Ptr<ndn::security::CertificateCache> certificateCache = NULL);
29
30 virtual
31 ~InvitationPolicyManager();
Yingdi Yuea5f1c62013-10-22 16:59:43 -070032
Yingdi Yuea5f1c62013-10-22 16:59:43 -070033 bool
Yingdi Yu42f66462013-10-31 17:38:22 -070034 skipVerifyAndTrust (const ndn::Data& data);
Yingdi Yuea5f1c62013-10-22 16:59:43 -070035
Yingdi Yuea5f1c62013-10-22 16:59:43 -070036 bool
Yingdi Yu42f66462013-10-31 17:38:22 -070037 requireVerify (const ndn::Data& data);
Yingdi Yuea5f1c62013-10-22 16:59:43 -070038
Yingdi Yu53eb8a72013-10-23 11:50:51 -070039 ndn::Ptr<ndn::security::ValidationRequest>
Yingdi Yuea5f1c62013-10-22 16:59:43 -070040 checkVerificationPolicy(ndn::Ptr<ndn::Data> data,
Yingdi Yu42f66462013-10-31 17:38:22 -070041 const int& stepCount,
Yingdi Yuea5f1c62013-10-22 16:59:43 -070042 const ndn::DataCallback& verifiedCallback,
43 const ndn::UnverifiedCallback& unverifiedCallback);
44
Yingdi Yuea5f1c62013-10-22 16:59:43 -070045 bool
Yingdi Yu42f66462013-10-31 17:38:22 -070046 checkSigningPolicy(const ndn::Name& dataName,
47 const ndn::Name& certificateName);
48
Yingdi Yu53eb8a72013-10-23 11:50:51 -070049 ndn::Name
Yingdi Yu42f66462013-10-31 17:38:22 -070050 inferSigningIdentity(const ndn::Name& dataName);
Yingdi Yuea5f1c62013-10-22 16:59:43 -070051
Yingdi Yuea5f1c62013-10-22 16:59:43 -070052 void
Yingdi Yu53eb8a72013-10-23 11:50:51 -070053 addTrustAnchor(const EndorseCertificate& selfEndorseCertificate);
Yingdi Yu42f66462013-10-31 17:38:22 -070054
55 // void
56 // addChatDataRule(const ndn::Name& prefix,
57 // const ndn::security::IdentityCertificate identityCertificate);
Yingdi Yuea5f1c62013-10-22 16:59:43 -070058
Yingdi Yu42f66462013-10-31 17:38:22 -070059 ndn::Ptr<ndn::security::IdentityCertificate>
60 getValidatedDskCertificate(const ndn::Name& certName);
Yingdi Yuea5f1c62013-10-22 16:59:43 -070061
62private:
Yingdi Yu42f66462013-10-31 17:38:22 -070063 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
74private:
75 std::string m_chatroomName;
76
Yingdi Yuea5f1c62013-10-22 16:59:43 -070077 int m_stepLimit;
Yingdi Yu42f66462013-10-31 17:38:22 -070078
Yingdi Yuea5f1c62013-10-22 16:59:43 -070079 ndn::Ptr<ndn::security::CertificateCache> m_certificateCache;
Yingdi Yu42f66462013-10-31 17:38:22 -070080
81 ndn::Ptr<ndn::security::IdentityPolicyRule> m_invitationPolicyRule;
Yingdi Yu53eb8a72013-10-23 11:50:51 -070082 ndn::Ptr<ndn::security::IdentityPolicyRule> m_dskRule;
Yingdi Yu42f66462013-10-31 17:38:22 -070083 std::map<ndn::Name, ChatPolicyRule> m_chatDataRules;
84
Yingdi Yued8cfc42013-11-01 17:37:51 -070085 ndn::Ptr<ndn::Regex> m_kskRegex;
Yingdi Yu53eb8a72013-10-23 11:50:51 -070086 ndn::Ptr<ndn::Regex> m_keyNameRegex;
Yingdi Yu42f66462013-10-31 17:38:22 -070087
Yingdi Yu53eb8a72013-10-23 11:50:51 -070088 std::map<ndn::Name, ndn::security::Publickey> m_trustAnchors;
Yingdi Yu42f66462013-10-31 17:38:22 -070089
90 std::map<ndn::Name, ndn::Ptr<ndn::security::IdentityCertificate> > m_dskCertificates;
91
Yingdi Yuea5f1c62013-10-22 16:59:43 -070092};
93
Yingdi Yu42f66462013-10-31 17:38:22 -070094#endif //CHATROOM_POLICY_MANAGER_H