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