blob: a49124ff9081a6c2c4f72ea0911a6db61576b037 [file] [log] [blame]
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2013, Regents of the University of California
* Yingdi Yu
*
* BSD license, See the LICENSE file for more information
*
* Author: Yingdi Yu <yingdi@cs.ucla.edu>
*/
#ifndef INVITATION_POLICY_MANAGER_H
#define INVITATION_POLICY_MANAGER_H
#include <ndn-cpp/security/policy/policy-manager.hpp>
#include <ndn-cpp-et/policy-manager/identity-policy-rule.hpp>
#include <ndn-cpp-et/cache/ttl-certificate-cache.hpp>
#include <ndn-cpp-et/regex/regex.hpp>
#include <map>
#include "endorse-certificate.h"
#include "chat-policy-rule.h"
class InvitationPolicyManager : public ndn::PolicyManager
{
public:
InvitationPolicyManager(const std::string& chatroomName,
const ndn::Name& signingIdentity,
int stepLimit = 10);
virtual
~InvitationPolicyManager();
bool
skipVerifyAndTrust (const ndn::Data& data);
bool
requireVerify (const ndn::Data& data);
ndn::ptr_lib::shared_ptr<ndn::ValidationRequest>
checkVerificationPolicy(const ndn::ptr_lib::shared_ptr<ndn::Data>& data,
int stepCount,
const ndn::OnVerified& onVerified,
const ndn::OnVerifyFailed& onVerifyFailed);
bool
checkSigningPolicy(const ndn::Name& dataName,
const ndn::Name& certificateName);
ndn::Name
inferSigningIdentity(const ndn::Name& dataName);
void
addTrustAnchor(const EndorseCertificate& selfEndorseCertificate);
// void
// addChatDataRule(const ndn::Name& prefix,
// const ndn::security::IdentityCertificate identityCertificate);
ndn::ptr_lib::shared_ptr<ndn::IdentityCertificate>
getValidatedDskCertificate(const ndn::Name& certName);
private:
void
onDskCertificateVerified(const ndn::ptr_lib::shared_ptr<ndn::Data>& certData,
ndn::ptr_lib::shared_ptr<ndn::Data> originalData,
const ndn::OnVerified& onVerified,
const ndn::OnVerifyFailed& onVerifyFailed);
void
onDskCertificateVerifyFailed(const ndn::ptr_lib::shared_ptr<ndn::Data>& certData,
ndn::ptr_lib::shared_ptr<ndn::Data> originalData,
const ndn::OnVerifyFailed& onVerifyFailed);
static bool
isSameKey(const ndn::Blob& keyA, const ndn::Blob& keyB);
private:
std::string m_chatroomName;
ndn::Name m_signingIdentity;
int m_stepLimit;
ndn::TTLCertificateCache m_certificateCache;
ndn::ptr_lib::shared_ptr<ndn::IdentityPolicyRule> m_invitationPolicyRule;
ndn::ptr_lib::shared_ptr<ndn::IdentityPolicyRule> m_dskRule;
std::map<ndn::Name, ChatPolicyRule, ndn::Name::BreadthFirstLess> m_chatDataRules;
ndn::ptr_lib::shared_ptr<ndn::Regex> m_kskRegex;
ndn::ptr_lib::shared_ptr<ndn::Regex> m_keyNameRegex;
std::map<ndn::Name, ndn::PublicKey, ndn::Name::BreadthFirstLess> m_trustAnchors;
std::map<ndn::Name, ndn::ptr_lib::shared_ptr<ndn::IdentityCertificate>, ndn::Name::BreadthFirstLess> m_dskCertificates;
};
#endif //CHATROOM_POLICY_MANAGER_H