blob: f2cfc1cca9b22f228f80c2a152405a30de7f1d06 [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,
Yingdi Yub35b8652013-11-07 11:32:40 -080027 const ndn::Name& signingIdentity,
28 int stepLimit = 10,
29 ndn::Ptr<ndn::security::CertificateCache> certificateCache = NULL);
Yingdi Yu42f66462013-10-31 17:38:22 -070030
31 virtual
32 ~InvitationPolicyManager();
Yingdi Yuea5f1c62013-10-22 16:59:43 -070033
Yingdi Yuea5f1c62013-10-22 16:59:43 -070034 bool
Yingdi Yu42f66462013-10-31 17:38:22 -070035 skipVerifyAndTrust (const ndn::Data& data);
Yingdi Yuea5f1c62013-10-22 16:59:43 -070036
Yingdi Yuea5f1c62013-10-22 16:59:43 -070037 bool
Yingdi Yu42f66462013-10-31 17:38:22 -070038 requireVerify (const ndn::Data& data);
Yingdi Yuea5f1c62013-10-22 16:59:43 -070039
Yingdi Yu53eb8a72013-10-23 11:50:51 -070040 ndn::Ptr<ndn::security::ValidationRequest>
Yingdi Yuea5f1c62013-10-22 16:59:43 -070041 checkVerificationPolicy(ndn::Ptr<ndn::Data> data,
Yingdi Yu42f66462013-10-31 17:38:22 -070042 const int& stepCount,
Yingdi Yuea5f1c62013-10-22 16:59:43 -070043 const ndn::DataCallback& verifiedCallback,
44 const ndn::UnverifiedCallback& unverifiedCallback);
45
Yingdi Yuea5f1c62013-10-22 16:59:43 -070046 bool
Yingdi Yu42f66462013-10-31 17:38:22 -070047 checkSigningPolicy(const ndn::Name& dataName,
48 const ndn::Name& certificateName);
49
Yingdi Yu53eb8a72013-10-23 11:50:51 -070050 ndn::Name
Yingdi Yu42f66462013-10-31 17:38:22 -070051 inferSigningIdentity(const ndn::Name& dataName);
Yingdi Yuea5f1c62013-10-22 16:59:43 -070052
Yingdi Yuea5f1c62013-10-22 16:59:43 -070053 void
Yingdi Yu53eb8a72013-10-23 11:50:51 -070054 addTrustAnchor(const EndorseCertificate& selfEndorseCertificate);
Yingdi Yu42f66462013-10-31 17:38:22 -070055
56 // void
57 // addChatDataRule(const ndn::Name& prefix,
58 // const ndn::security::IdentityCertificate identityCertificate);
Yingdi Yuea5f1c62013-10-22 16:59:43 -070059
Yingdi Yu42f66462013-10-31 17:38:22 -070060 ndn::Ptr<ndn::security::IdentityCertificate>
61 getValidatedDskCertificate(const ndn::Name& certName);
Yingdi Yuea5f1c62013-10-22 16:59:43 -070062
63private:
Yingdi Yu42f66462013-10-31 17:38:22 -070064 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
75private:
76 std::string m_chatroomName;
Yingdi Yub35b8652013-11-07 11:32:40 -080077 ndn::Name m_signingIdentity;
Yingdi Yu42f66462013-10-31 17:38:22 -070078
Yingdi Yuea5f1c62013-10-22 16:59:43 -070079 int m_stepLimit;
Yingdi Yu42f66462013-10-31 17:38:22 -070080
Yingdi Yuea5f1c62013-10-22 16:59:43 -070081 ndn::Ptr<ndn::security::CertificateCache> m_certificateCache;
Yingdi Yu42f66462013-10-31 17:38:22 -070082
83 ndn::Ptr<ndn::security::IdentityPolicyRule> m_invitationPolicyRule;
Yingdi Yu53eb8a72013-10-23 11:50:51 -070084 ndn::Ptr<ndn::security::IdentityPolicyRule> m_dskRule;
Yingdi Yu42f66462013-10-31 17:38:22 -070085 std::map<ndn::Name, ChatPolicyRule> m_chatDataRules;
86
Yingdi Yued8cfc42013-11-01 17:37:51 -070087 ndn::Ptr<ndn::Regex> m_kskRegex;
Yingdi Yu53eb8a72013-10-23 11:50:51 -070088 ndn::Ptr<ndn::Regex> m_keyNameRegex;
Yingdi Yu42f66462013-10-31 17:38:22 -070089
Yingdi Yu53eb8a72013-10-23 11:50:51 -070090 std::map<ndn::Name, ndn::security::Publickey> m_trustAnchors;
Yingdi Yu42f66462013-10-31 17:38:22 -070091
92 std::map<ndn::Name, ndn::Ptr<ndn::security::IdentityCertificate> > m_dskCertificates;
93
Yingdi Yuea5f1c62013-10-22 16:59:43 -070094};
95
Yingdi Yu42f66462013-10-31 17:38:22 -070096#endif //CHATROOM_POLICY_MANAGER_H