blob: 51b3b5086ff53bbdb91c33ac0689ae119052fa95 [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>
Qiuhan Ding0cfc1512015-02-17 17:44:11 -08009 * Qiuhan Ding <qiuhanding@cs.ucla.edu>
Yingdi Yuc972c452013-10-11 11:02:09 -070010 */
11
Yingdi Yueb692ac2015-02-10 18:46:18 -080012#ifndef CHRONOCHAT_ENDORSE_CERTIFICATE_HPP
13#define CHRONOCHAT_ENDORSE_CERTIFICATE_HPP
Yingdi Yuc972c452013-10-11 11:02:09 -070014
Yingdi Yu0b0a7362014-08-05 16:31:30 -070015#include "profile.hpp"
Yingdi Yuf8f572d2014-01-13 11:19:47 -080016
Yingdi Yueb692ac2015-02-10 18:46:18 -080017namespace chronochat {
Yingdi Yuc972c452013-10-11 11:02:09 -070018
Yingdi Yu76dd8002013-12-24 11:16:32 +080019class EndorseCertificate : public ndn::Certificate
Yingdi Yuc972c452013-10-11 11:02:09 -070020{
21public:
Yingdi Yu0b0a7362014-08-05 16:31:30 -070022 class Error : public ndn::Certificate::Error
23 {
24 public:
25 Error(const std::string& what)
26 : ndn::Certificate::Error(what)
27 {
28 }
29 };
Yingdi Yuf8f572d2014-01-13 11:19:47 -080030
Yingdi Yu348f5ea2014-03-01 14:47:25 -080031 static const std::vector<std::string> DEFAULT_ENDORSE_LIST;
32
Yingdi Yud95c5642013-10-20 19:43:10 -070033 EndorseCertificate() {}
34
Yingdi Yu76dd8002013-12-24 11:16:32 +080035 EndorseCertificate(const ndn::IdentityCertificate& kskCertificate,
Yingdi Yufa4ce792014-02-06 18:09:22 -080036 const Profile& profile,
Yingdi Yu348f5ea2014-03-01 14:47:25 -080037 const std::vector<std::string>& endorseList = DEFAULT_ENDORSE_LIST);
Yingdi Yub4be64a2013-10-13 17:24:50 -070038
39 EndorseCertificate(const EndorseCertificate& endorseCertificate,
Yingdi Yu0b0a7362014-08-05 16:31:30 -070040 const Name& signer,
Yingdi Yu348f5ea2014-03-01 14:47:25 -080041 const std::vector<std::string>& endorseList = DEFAULT_ENDORSE_LIST);
42
Yingdi Yu0b0a7362014-08-05 16:31:30 -070043 EndorseCertificate(const Name& keyName,
Yingdi Yu348f5ea2014-03-01 14:47:25 -080044 const ndn::PublicKey& key,
Yingdi Yu0b0a7362014-08-05 16:31:30 -070045 const time::system_clock::TimePoint& notBefore,
46 const time::system_clock::TimePoint& notAfter,
47 const Name& signer,
Yingdi Yu348f5ea2014-03-01 14:47:25 -080048 const Profile& profile,
49 const std::vector<std::string>& endorseList = DEFAULT_ENDORSE_LIST);
Yingdi Yuc972c452013-10-11 11:02:09 -070050
51 EndorseCertificate(const EndorseCertificate& endorseCertificate);
52
Yingdi Yu0b0a7362014-08-05 16:31:30 -070053 EndorseCertificate(const Data& data);
Yingdi Yuc972c452013-10-11 11:02:09 -070054
55 virtual
56 ~EndorseCertificate()
Yingdi Yu0b0a7362014-08-05 16:31:30 -070057 {
58 }
Yingdi Yuc972c452013-10-11 11:02:09 -070059
Yingdi Yu0b0a7362014-08-05 16:31:30 -070060 const Name&
Yingdi Yuc972c452013-10-11 11:02:09 -070061 getSigner() const
Yingdi Yu0b0a7362014-08-05 16:31:30 -070062 {
63 return m_signer;
64 }
Yingdi Yuc972c452013-10-11 11:02:09 -070065
Yingdi Yufa4ce792014-02-06 18:09:22 -080066 const Profile&
67 getProfile() const
Yingdi Yu0b0a7362014-08-05 16:31:30 -070068 {
69 return m_profile;
70 }
Yingdi Yuc972c452013-10-11 11:02:09 -070071
Yingdi Yu76dd8002013-12-24 11:16:32 +080072 const std::vector<std::string>&
Yingdi Yub4be64a2013-10-13 17:24:50 -070073 getEndorseList() const
Yingdi Yu0b0a7362014-08-05 16:31:30 -070074 {
75 return m_endorseList;
76 }
Yingdi Yub4be64a2013-10-13 17:24:50 -070077
Yingdi Yu0b0a7362014-08-05 16:31:30 -070078 const Name&
Yingdi Yub4be64a2013-10-13 17:24:50 -070079 getPublicKeyName () const
Yingdi Yu0b0a7362014-08-05 16:31:30 -070080 {
81 return m_keyName;
82 }
Yingdi Yuc972c452013-10-11 11:02:09 -070083
Yingdi Yufa4ce792014-02-06 18:09:22 -080084private:
85 static const ndn::OID PROFILE_EXT_OID;
86 static const ndn::OID ENDORSE_EXT_OID;
87
Yingdi Yu0b0a7362014-08-05 16:31:30 -070088 Name m_keyName;
89 Name m_signer; // signing key name
Yingdi Yufa4ce792014-02-06 18:09:22 -080090 Profile m_profile;
Yingdi Yub4be64a2013-10-13 17:24:50 -070091 std::vector<std::string> m_endorseList;
Yingdi Yu0b0a7362014-08-05 16:31:30 -070092
Yingdi Yuc972c452013-10-11 11:02:09 -070093};
94
Yingdi Yueb692ac2015-02-10 18:46:18 -080095} // namespace chronochat
Yingdi Yufa4ce792014-02-06 18:09:22 -080096
Yingdi Yueb692ac2015-02-10 18:46:18 -080097#endif // CHRONOCHAT_ENDORSE_CERTIFICATE_HPP