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

#include <ndn-cpp/security/certificate/certificate.hpp>
#include <ndn-cpp/security/certificate/identity-certificate.hpp>

class SyncIntroCertificate : public ndn::Certificate
{
public:
  struct Error : public ndn::Certificate::Error { Error(const std::string &what) : ndn::Certificate::Error(what) {} };

  enum IntroType{
    PRODUCER,
    INTRODUCER
  };
  
public:
  SyncIntroCertificate ();
  
  SyncIntroCertificate (const ndn::Name& nameSpace,
                        const ndn::Name& keyName,
                        const ndn::Name& signerName,
                        const ndn::MillisecondsSince1970& notBefore,
                        const ndn::MillisecondsSince1970& notAfter,
                        const ndn::PublicKey& key,
                        const IntroType& introType = PRODUCER);
  
  SyncIntroCertificate (const ndn::Name& nameSpace,
                        const ndn::IdentityCertificate& identityCertificate,
                        const ndn::Name& signerName,
                        const IntroType& introType);
  
  SyncIntroCertificate (const ndn::Data& data);
  
  SyncIntroCertificate (const SyncIntroCertificate& chronosIntroCertificate);
  
  
  virtual 
  ~SyncIntroCertificate ()
  {}
  
  ndn::Data&
  setName (const ndn::Name& name);
  
  inline virtual ndn::Name 
  getPublicKeyName () const
  { return m_keyName; }
  
  inline IntroType
  getIntroType()
  { return m_introType; }

  static bool
  isSyncIntroCertificate(const ndn::Certificate& certificate);

protected:
  ndn::Name m_keyName;
  IntroType m_introType;
};

#endif
