blob: 970b5b76f3d3f608c6c07ce13680265114166287 [file] [log] [blame]
Yingdi Yuc972c452013-10-11 11:02:09 -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
Yingdi Yufa4ce792014-02-06 18:09:22 -080011#ifndef CHRONOS_ENDORSE_CERTIFICATE_H
12#define CHRONOS_ENDORSE_CERTIFICATE_H
Yingdi Yuc972c452013-10-11 11:02:09 -070013
Yingdi Yufa4ce792014-02-06 18:09:22 -080014#include "profile.h"
Yingdi Yuc972c452013-10-11 11:02:09 -070015#include <vector>
Yingdi Yufa0b6a02014-04-30 14:26:42 -070016#include <ndn-cxx/security/identity-certificate.hpp>
Yingdi Yuf8f572d2014-01-13 11:19:47 -080017
Yingdi Yufa4ce792014-02-06 18:09:22 -080018namespace chronos{
Yingdi Yuc972c452013-10-11 11:02:09 -070019
Yingdi Yu76dd8002013-12-24 11:16:32 +080020class EndorseCertificate : public ndn::Certificate
Yingdi Yuc972c452013-10-11 11:02:09 -070021{
22public:
Yingdi Yuf8f572d2014-01-13 11:19:47 -080023 struct Error : public ndn::Certificate::Error { Error(const std::string &what) : ndn::Certificate::Error(what) {} };
24
Yingdi Yu348f5ea2014-03-01 14:47:25 -080025 static const std::vector<std::string> DEFAULT_ENDORSE_LIST;
26
Yingdi Yud95c5642013-10-20 19:43:10 -070027 EndorseCertificate() {}
28
Yingdi Yu76dd8002013-12-24 11:16:32 +080029 EndorseCertificate(const ndn::IdentityCertificate& kskCertificate,
Yingdi Yufa4ce792014-02-06 18:09:22 -080030 const Profile& profile,
Yingdi Yu348f5ea2014-03-01 14:47:25 -080031 const std::vector<std::string>& endorseList = DEFAULT_ENDORSE_LIST);
Yingdi Yub4be64a2013-10-13 17:24:50 -070032
33 EndorseCertificate(const EndorseCertificate& endorseCertificate,
Yingdi Yuc972c452013-10-11 11:02:09 -070034 const ndn::Name& signer,
Yingdi Yu348f5ea2014-03-01 14:47:25 -080035 const std::vector<std::string>& endorseList = DEFAULT_ENDORSE_LIST);
36
37 EndorseCertificate(const ndn::Name& keyName,
38 const ndn::PublicKey& key,
Yingdi Yua7876722014-03-25 14:46:55 -070039 const ndn::time::system_clock::TimePoint& notBefore,
40 const ndn::time::system_clock::TimePoint& notAfter,
Yingdi Yu348f5ea2014-03-01 14:47:25 -080041 const ndn::Name& signer,
42 const Profile& profile,
43 const std::vector<std::string>& endorseList = DEFAULT_ENDORSE_LIST);
Yingdi Yuc972c452013-10-11 11:02:09 -070044
45 EndorseCertificate(const EndorseCertificate& endorseCertificate);
46
47 EndorseCertificate(const ndn::Data& data);
48
49 virtual
50 ~EndorseCertificate()
51 {}
52
Yingdi Yu76dd8002013-12-24 11:16:32 +080053 const ndn::Name&
Yingdi Yuc972c452013-10-11 11:02:09 -070054 getSigner() const
55 { return m_signer; }
56
Yingdi Yufa4ce792014-02-06 18:09:22 -080057 const Profile&
58 getProfile() const
59 { return m_profile; }
Yingdi Yuc972c452013-10-11 11:02:09 -070060
Yingdi Yu76dd8002013-12-24 11:16:32 +080061 const std::vector<std::string>&
Yingdi Yub4be64a2013-10-13 17:24:50 -070062 getEndorseList() const
63 { return m_endorseList; }
64
Yingdi Yufa4ce792014-02-06 18:09:22 -080065 const ndn::Name&
Yingdi Yub4be64a2013-10-13 17:24:50 -070066 getPublicKeyName () const
Yingdi Yuc972c452013-10-11 11:02:09 -070067 { return m_keyName; }
68
Yingdi Yufa4ce792014-02-06 18:09:22 -080069private:
70 static const ndn::OID PROFILE_EXT_OID;
71 static const ndn::OID ENDORSE_EXT_OID;
72
Yingdi Yuc972c452013-10-11 11:02:09 -070073 ndn::Name m_keyName;
Yingdi Yu348f5ea2014-03-01 14:47:25 -080074 ndn::Name m_signer; // signing key name
Yingdi Yufa4ce792014-02-06 18:09:22 -080075 Profile m_profile;
Yingdi Yub4be64a2013-10-13 17:24:50 -070076 std::vector<std::string> m_endorseList;
Yingdi Yuc972c452013-10-11 11:02:09 -070077};
78
Yingdi Yufa4ce792014-02-06 18:09:22 -080079}//chronos
80
Yingdi Yuc972c452013-10-11 11:02:09 -070081#endif