blob: 1b9b897e314802e88af5d0c2f59cb41b1ff3b27b [file] [log] [blame]
Yingdi Yu3c2a9762013-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 Yu5ff62102013-10-13 17:24:50 -070011#ifndef LINKNDN_ENDORSE_CERTIFICATE_H
12#define LINKNDN_ENDORSE_CERTIFICATE_H
Yingdi Yu3c2a9762013-10-11 11:02:09 -070013
14#include <vector>
15#include <ndn.cxx/data.h>
16#include <ndn.cxx/security/certificate/identity-certificate.h>
17#include <ndn.cxx/security/certificate/certificate-extension.h>
18
19#include "profile-data.h"
20
Yingdi Yu5ff62102013-10-13 17:24:50 -070021class ProfileExtension : public ndn::security::CertificateExtension
22{
23public:
24 ProfileExtension(const ProfileData& profileData);
25
26 ProfileExtension(const ProfileExtension& profileExtension);
27
28 ProfileExtension(const CertificateExtension& extension);
29
30 ~ProfileExtension() {}
31
32 ndn::Ptr<ProfileData>
33 getProfileData();
34};
35
Yingdi Yu3c2a9762013-10-11 11:02:09 -070036class EndorseExtension : public ndn::security::CertificateExtension
37{
38public:
Yingdi Yu5ff62102013-10-13 17:24:50 -070039 EndorseExtension(const std::vector<std::string>& endorsedList);
Yingdi Yu3c2a9762013-10-11 11:02:09 -070040
Yingdi Yu5ff62102013-10-13 17:24:50 -070041 EndorseExtension(const EndorseExtension& endorseExtension);
42
43 EndorseExtension(const CertificateExtension& extension);
44
Yingdi Yu3c2a9762013-10-11 11:02:09 -070045 ~EndorseExtension() {}
Yingdi Yu5ff62102013-10-13 17:24:50 -070046
47 std::vector<std::string>
48 getEndorsedList();
49
50private:
51 static ndn::Ptr<ndn::Blob>
52 prepareValue(const std::vector<std::string>& endorsedList);
Yingdi Yu3c2a9762013-10-11 11:02:09 -070053};
54
55class EndorseCertificate : public ndn::security::Certificate
56{
57public:
Yingdi Yuc29fb982013-10-20 19:43:10 -070058 EndorseCertificate() {}
59
Yingdi Yu8dacdf22013-11-05 23:06:43 -080060 // EndorseCertificate(const ndn::security::IdentityCertificate& kskCertificate);
61
Yingdi Yu3c2a9762013-10-11 11:02:09 -070062 EndorseCertificate(const ndn::security::IdentityCertificate& kskCertificate,
Yingdi Yu5ff62102013-10-13 17:24:50 -070063 ndn::Ptr<ProfileData> profileData,
Yingdi Yu8dacdf22013-11-05 23:06:43 -080064 const std::vector<std::string>& endorseList = std::vector<std::string>());
Yingdi Yu5ff62102013-10-13 17:24:50 -070065
66 EndorseCertificate(const EndorseCertificate& endorseCertificate,
Yingdi Yu3c2a9762013-10-11 11:02:09 -070067 const ndn::Name& signer,
Yingdi Yu5ff62102013-10-13 17:24:50 -070068 const std::vector<std::string>& endorseList);
Yingdi Yu3c2a9762013-10-11 11:02:09 -070069
70 EndorseCertificate(const EndorseCertificate& endorseCertificate);
71
72 EndorseCertificate(const ndn::Data& data);
73
74 virtual
75 ~EndorseCertificate()
76 {}
77
Yingdi Yu3c2a9762013-10-11 11:02:09 -070078 inline const ndn::Name&
79 getSigner() const
80 { return m_signer; }
81
Yingdi Yu5ff62102013-10-13 17:24:50 -070082 inline ndn::Ptr<ProfileData>
83 getProfileData() const
84 { return m_profileData; }
Yingdi Yu3c2a9762013-10-11 11:02:09 -070085
Yingdi Yu5ff62102013-10-13 17:24:50 -070086 inline const std::vector<std::string>&
87 getEndorseList() const
88 { return m_endorseList; }
89
90 inline virtual ndn::Name
91 getPublicKeyName () const
Yingdi Yu3c2a9762013-10-11 11:02:09 -070092 { return m_keyName; }
93
Yingdi Yu5ff62102013-10-13 17:24:50 -070094protected:
Yingdi Yu3c2a9762013-10-11 11:02:09 -070095 ndn::Name m_keyName;
96 ndn::Name m_signer;
Yingdi Yu5ff62102013-10-13 17:24:50 -070097 ndn::Ptr<ProfileData> m_profileData;
98 std::vector<std::string> m_endorseList;
Yingdi Yu3c2a9762013-10-11 11:02:09 -070099};
100
101#endif