blob: 5f076f2ad8076f01c8d35090ad74fc501d6ae9ec [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 Yub4be64a2013-10-13 17:24:50 -070011#ifndef LINKNDN_ENDORSE_CERTIFICATE_H
12#define LINKNDN_ENDORSE_CERTIFICATE_H
Yingdi Yuc972c452013-10-11 11:02:09 -070013
14#include <vector>
Yingdi Yu76dd8002013-12-24 11:16:32 +080015#include <ndn-cpp/data.hpp>
16#include <ndn-cpp/security/certificate/identity-certificate.hpp>
17#include <ndn-cpp/security/certificate/certificate-extension.hpp>
Yingdi Yuc972c452013-10-11 11:02:09 -070018
19#include "profile-data.h"
20
Yingdi Yu76dd8002013-12-24 11:16:32 +080021class ProfileExtension : public ndn::CertificateExtension
Yingdi Yub4be64a2013-10-13 17:24:50 -070022{
23public:
24 ProfileExtension(const ProfileData& profileData);
25
26 ProfileExtension(const ProfileExtension& profileExtension);
27
28 ProfileExtension(const CertificateExtension& extension);
29
30 ~ProfileExtension() {}
31
Yingdi Yu76dd8002013-12-24 11:16:32 +080032 ndn::ptr_lib::shared_ptr<ProfileData>
Yingdi Yub4be64a2013-10-13 17:24:50 -070033 getProfileData();
34};
35
Yingdi Yu76dd8002013-12-24 11:16:32 +080036class EndorseExtension : public ndn::CertificateExtension
Yingdi Yuc972c452013-10-11 11:02:09 -070037{
38public:
Yingdi Yu76dd8002013-12-24 11:16:32 +080039 EndorseExtension(const std::vector<std::string>& endorseList);
Yingdi Yuc972c452013-10-11 11:02:09 -070040
Yingdi Yub4be64a2013-10-13 17:24:50 -070041 EndorseExtension(const EndorseExtension& endorseExtension);
42
43 EndorseExtension(const CertificateExtension& extension);
44
Yingdi Yuc972c452013-10-11 11:02:09 -070045 ~EndorseExtension() {}
Yingdi Yub4be64a2013-10-13 17:24:50 -070046
47 std::vector<std::string>
Yingdi Yu76dd8002013-12-24 11:16:32 +080048 getEndorseList();
Yingdi Yub4be64a2013-10-13 17:24:50 -070049
50private:
Yingdi Yu76dd8002013-12-24 11:16:32 +080051 static ndn::Blob
52 encodeEndorseList(const std::vector<std::string>& endorsedList);
Yingdi Yuc972c452013-10-11 11:02:09 -070053};
54
Yingdi Yu76dd8002013-12-24 11:16:32 +080055class EndorseCertificate : public ndn::Certificate
Yingdi Yuc972c452013-10-11 11:02:09 -070056{
57public:
Yingdi Yud95c5642013-10-20 19:43:10 -070058 EndorseCertificate() {}
59
Yingdi Yu76dd8002013-12-24 11:16:32 +080060 EndorseCertificate(const ndn::IdentityCertificate& kskCertificate,
61 const ProfileData& profileData,
Yingdi Yub2e747d2013-11-05 23:06:43 -080062 const std::vector<std::string>& endorseList = std::vector<std::string>());
Yingdi Yub4be64a2013-10-13 17:24:50 -070063
64 EndorseCertificate(const EndorseCertificate& endorseCertificate,
Yingdi Yuc972c452013-10-11 11:02:09 -070065 const ndn::Name& signer,
Yingdi Yub4be64a2013-10-13 17:24:50 -070066 const std::vector<std::string>& endorseList);
Yingdi Yuc972c452013-10-11 11:02:09 -070067
68 EndorseCertificate(const EndorseCertificate& endorseCertificate);
69
70 EndorseCertificate(const ndn::Data& data);
71
72 virtual
73 ~EndorseCertificate()
74 {}
75
Yingdi Yu76dd8002013-12-24 11:16:32 +080076 const ndn::Name&
Yingdi Yuc972c452013-10-11 11:02:09 -070077 getSigner() const
78 { return m_signer; }
79
Yingdi Yu76dd8002013-12-24 11:16:32 +080080 const ProfileData&
Yingdi Yub4be64a2013-10-13 17:24:50 -070081 getProfileData() const
82 { return m_profileData; }
Yingdi Yuc972c452013-10-11 11:02:09 -070083
Yingdi Yu76dd8002013-12-24 11:16:32 +080084 const std::vector<std::string>&
Yingdi Yub4be64a2013-10-13 17:24:50 -070085 getEndorseList() const
86 { return m_endorseList; }
87
Yingdi Yu76dd8002013-12-24 11:16:32 +080088 virtual ndn::Name
Yingdi Yub4be64a2013-10-13 17:24:50 -070089 getPublicKeyName () const
Yingdi Yuc972c452013-10-11 11:02:09 -070090 { return m_keyName; }
91
Yingdi Yub4be64a2013-10-13 17:24:50 -070092protected:
Yingdi Yuc972c452013-10-11 11:02:09 -070093 ndn::Name m_keyName;
94 ndn::Name m_signer;
Yingdi Yu76dd8002013-12-24 11:16:32 +080095 ProfileData m_profileData;
Yingdi Yub4be64a2013-10-13 17:24:50 -070096 std::vector<std::string> m_endorseList;
Yingdi Yuc972c452013-10-11 11:02:09 -070097};
98
99#endif