Yingdi Yu | 3c2a976 | 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 | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 11 | #ifndef LINKNDN_ENDORSE_CERTIFICATE_H |
| 12 | #define LINKNDN_ENDORSE_CERTIFICATE_H |
Yingdi Yu | 3c2a976 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 13 | |
| 14 | #include <vector> |
Yingdi Yu | 6420611 | 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 | 3c2a976 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 18 | |
| 19 | #include "profile-data.h" |
| 20 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 21 | class ProfileExtension : public ndn::CertificateExtension |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 22 | { |
| 23 | public: |
Yingdi Yu | c9ffa9f | 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 | 5ff6210 | 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 | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 34 | ndn::ptr_lib::shared_ptr<ProfileData> |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 35 | getProfileData(); |
| 36 | }; |
| 37 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 38 | class EndorseExtension : public ndn::CertificateExtension |
Yingdi Yu | 3c2a976 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 39 | { |
| 40 | public: |
Yingdi Yu | c9ffa9f | 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 | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 43 | EndorseExtension(const std::vector<std::string>& endorseList); |
Yingdi Yu | 3c2a976 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 44 | |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 45 | EndorseExtension(const EndorseExtension& endorseExtension); |
| 46 | |
| 47 | EndorseExtension(const CertificateExtension& extension); |
| 48 | |
Yingdi Yu | 3c2a976 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 49 | ~EndorseExtension() {} |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 50 | |
| 51 | std::vector<std::string> |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 52 | getEndorseList(); |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 53 | |
| 54 | private: |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame^] | 55 | static ndn::Buffer |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 56 | encodeEndorseList(const std::vector<std::string>& endorsedList); |
Yingdi Yu | 3c2a976 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 57 | }; |
| 58 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 59 | class EndorseCertificate : public ndn::Certificate |
Yingdi Yu | 3c2a976 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 60 | { |
| 61 | public: |
Yingdi Yu | c9ffa9f | 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 | c29fb98 | 2013-10-20 19:43:10 -0700 | [diff] [blame] | 64 | EndorseCertificate() {} |
| 65 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 66 | EndorseCertificate(const ndn::IdentityCertificate& kskCertificate, |
| 67 | const ProfileData& profileData, |
Yingdi Yu | 8dacdf2 | 2013-11-05 23:06:43 -0800 | [diff] [blame] | 68 | const std::vector<std::string>& endorseList = std::vector<std::string>()); |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 69 | |
| 70 | EndorseCertificate(const EndorseCertificate& endorseCertificate, |
Yingdi Yu | 3c2a976 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 71 | const ndn::Name& signer, |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 72 | const std::vector<std::string>& endorseList); |
Yingdi Yu | 3c2a976 | 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 | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 82 | const ndn::Name& |
Yingdi Yu | 3c2a976 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 83 | getSigner() const |
| 84 | { return m_signer; } |
| 85 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 86 | const ProfileData& |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 87 | getProfileData() const |
| 88 | { return m_profileData; } |
Yingdi Yu | 3c2a976 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 89 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 90 | const std::vector<std::string>& |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 91 | getEndorseList() const |
| 92 | { return m_endorseList; } |
| 93 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 94 | virtual ndn::Name |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 95 | getPublicKeyName () const |
Yingdi Yu | 3c2a976 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 96 | { return m_keyName; } |
| 97 | |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 98 | protected: |
Yingdi Yu | 3c2a976 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 99 | ndn::Name m_keyName; |
| 100 | ndn::Name m_signer; |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 101 | ProfileData m_profileData; |
Yingdi Yu | 5ff6210 | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 102 | std::vector<std::string> m_endorseList; |
Yingdi Yu | 3c2a976 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 103 | }; |
| 104 | |
| 105 | #endif |