/* -*- 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 SEC_POLICY_CHRONO_CHAT_PANEL_H
#define SEC_POLICY_CHRONO_CHAT_PANEL_H

#include <ndn-cpp-dev/security/sec-policy.hpp>
#include <ndn-cpp-et/policy/sec-rule-relative.hpp>
#include <ndn-cpp-et/cache/ttl-certificate-cache.hpp>
#include <map>

#include "endorse-certificate.h"

class SecPolicyChronoChatPanel : public ndn::SecPolicy
{
public:
  SecPolicyChronoChatPanel(const int & stepLimit = 10);

  ~SecPolicyChronoChatPanel()
  {}

  /**
   * @brief check if the received data packet can escape from verification
   * @param data the received data packet
   * @return true if the data does not need to be verified, otherwise false
   */
  bool 
  skipVerifyAndTrust (const ndn::Data & data);

  /**
   * @brief check if PolicyManager has the verification rule for the received data
   * @param data the received data packet
   * @return true if the data must be verified, otherwise false
   */
  bool
  requireVerify (const ndn::Data & data);

  /**
   * @brief check whether received data packet complies with the verification policy, and get the indication of next verification step
   * @param data the received data packet
   * @param stepCount the number of verification steps that have been done, used to track the verification progress
   * @param verifiedCallback the callback function that will be called if the received data packet has been validated
   * @param unverifiedCallback the callback function that will be called if the received data packet cannot be validated
   * @return the indication of next verification step, NULL if there is no further step
   */
  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);

    
  /**
   * @brief check if the signing certificate name and data name satify the signing policy 
   * @param dataName the name of data to be signed
   * @param certificateName the name of signing certificate
   * @return true if the signing certificate can be used to sign the data, otherwise false
   */
  bool 
  checkSigningPolicy(const ndn::Name & dataName, const ndn::Name & certificateName);
  
  /**
   * @brief Infer signing identity name according to policy, if the signing identity cannot be inferred, it should return empty name
   * @param dataName, the name of data to be signed
   * @return the signing identity. 
   */
  ndn::Name 
  inferSigningIdentity(const ndn::Name & dataName);

  
  void
  addTrustAnchor(const EndorseCertificate& selfEndorseCertificate);

  void
  removeTrustAnchor(const ndn::Name& keyName);

  ndn::ptr_lib::shared_ptr<ndn::PublicKey>
  getTrustedKey(const ndn::Name& inviterCertName);

private:
  int m_stepLimit;
  ndn::TTLCertificateCache m_certificateCache;
  ndn::ptr_lib::shared_ptr<ndn::Regex> m_localPrefixRegex;
  ndn::ptr_lib::shared_ptr<ndn::SecRuleRelative> m_invitationDataSigningRule;
  ndn::ptr_lib::shared_ptr<ndn::Regex> m_kskRegex;
  ndn::ptr_lib::shared_ptr<ndn::SecRuleRelative> m_dskRule;
  ndn::ptr_lib::shared_ptr<ndn::SecRuleRelative> m_endorseeRule;
  ndn::ptr_lib::shared_ptr<ndn::Regex> m_keyNameRegex;
  ndn::ptr_lib::shared_ptr<ndn::Regex> m_signingCertificateRegex;
  std::map<ndn::Name, ndn::PublicKey> m_trustAnchors;
  
};

#endif
