Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 1 | /* -*- 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 Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 11 | #ifndef LINKNDN_ENDORSE_CERTIFICATE_H |
| 12 | #define LINKNDN_ENDORSE_CERTIFICATE_H |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 13 | |
| 14 | #include <vector> |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 15 | #include <ndn-cpp/data.hpp> |
| 16 | #include <ndn-cpp/security/certificate/identity-certificate.hpp> |
| 17 | #include <ndn-cpp/security/certificate/certificate-extension.hpp> |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 18 | |
| 19 | #include "profile-data.h" |
| 20 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 21 | class ProfileExtension : public ndn::CertificateExtension |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 22 | { |
| 23 | public: |
| 24 | ProfileExtension(const ProfileData& profileData); |
| 25 | |
| 26 | ProfileExtension(const ProfileExtension& profileExtension); |
| 27 | |
| 28 | ProfileExtension(const CertificateExtension& extension); |
| 29 | |
| 30 | ~ProfileExtension() {} |
| 31 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 32 | ndn::ptr_lib::shared_ptr<ProfileData> |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 33 | getProfileData(); |
| 34 | }; |
| 35 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 36 | class EndorseExtension : public ndn::CertificateExtension |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 37 | { |
| 38 | public: |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 39 | EndorseExtension(const std::vector<std::string>& endorseList); |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 40 | |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 41 | EndorseExtension(const EndorseExtension& endorseExtension); |
| 42 | |
| 43 | EndorseExtension(const CertificateExtension& extension); |
| 44 | |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 45 | ~EndorseExtension() {} |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 46 | |
| 47 | std::vector<std::string> |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 48 | getEndorseList(); |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 49 | |
| 50 | private: |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 51 | static ndn::Blob |
| 52 | encodeEndorseList(const std::vector<std::string>& endorsedList); |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 55 | class EndorseCertificate : public ndn::Certificate |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 56 | { |
| 57 | public: |
Yingdi Yu | d95c564 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 58 | EndorseCertificate() {} |
| 59 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 60 | EndorseCertificate(const ndn::IdentityCertificate& kskCertificate, |
| 61 | const ProfileData& profileData, |
Yingdi Yu | b2e747d | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 62 | const std::vector<std::string>& endorseList = std::vector<std::string>()); |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 63 | |
| 64 | EndorseCertificate(const EndorseCertificate& endorseCertificate, |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 65 | const ndn::Name& signer, |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 66 | const std::vector<std::string>& endorseList); |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 67 | |
| 68 | EndorseCertificate(const EndorseCertificate& endorseCertificate); |
| 69 | |
| 70 | EndorseCertificate(const ndn::Data& data); |
| 71 | |
| 72 | virtual |
| 73 | ~EndorseCertificate() |
| 74 | {} |
| 75 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 76 | const ndn::Name& |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 77 | getSigner() const |
| 78 | { return m_signer; } |
| 79 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 80 | const ProfileData& |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 81 | getProfileData() const |
| 82 | { return m_profileData; } |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 83 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 84 | const std::vector<std::string>& |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 85 | getEndorseList() const |
| 86 | { return m_endorseList; } |
| 87 | |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 88 | virtual ndn::Name |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 89 | getPublicKeyName () const |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 90 | { return m_keyName; } |
| 91 | |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 92 | protected: |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 93 | ndn::Name m_keyName; |
| 94 | ndn::Name m_signer; |
Yingdi Yu | 76dd800 | 2013-12-24 11:16:32 +0800 | [diff] [blame^] | 95 | ProfileData m_profileData; |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 96 | std::vector<std::string> m_endorseList; |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 97 | }; |
| 98 | |
| 99 | #endif |