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> |
| 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 Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 21 | class ProfileExtension : public ndn::security::CertificateExtension |
| 22 | { |
| 23 | public: |
| 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 Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 36 | class EndorseExtension : public ndn::security::CertificateExtension |
| 37 | { |
| 38 | public: |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 39 | EndorseExtension(const std::vector<std::string>& endorsedList); |
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> |
| 48 | getEndorsedList(); |
| 49 | |
| 50 | private: |
| 51 | static ndn::Ptr<ndn::Blob> |
| 52 | prepareValue(const std::vector<std::string>& endorsedList); |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | class EndorseCertificate : public ndn::security::Certificate |
| 56 | { |
| 57 | public: |
Yingdi Yu | d95c564 | 2013-10-20 19:43:10 -0700 | [diff] [blame^] | 58 | EndorseCertificate() {} |
| 59 | |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 60 | EndorseCertificate(const ndn::security::IdentityCertificate& kskCertificate, |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 61 | const ndn::Time& notBefore, |
| 62 | const ndn::Time& notAfter, |
| 63 | ndn::Ptr<ProfileData> profileData, |
| 64 | const std::vector<std::string>& endorseList); |
| 65 | |
| 66 | EndorseCertificate(const EndorseCertificate& endorseCertificate, |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 67 | const ndn::Name& signer, |
| 68 | const ndn::Time& notBefore, |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 69 | const ndn::Time& notAfter, |
| 70 | const std::vector<std::string>& endorseList); |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 71 | |
| 72 | EndorseCertificate(const EndorseCertificate& endorseCertificate); |
| 73 | |
| 74 | EndorseCertificate(const ndn::Data& data); |
| 75 | |
| 76 | virtual |
| 77 | ~EndorseCertificate() |
| 78 | {} |
| 79 | |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 80 | inline const ndn::Name& |
| 81 | getSigner() const |
| 82 | { return m_signer; } |
| 83 | |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 84 | inline ndn::Ptr<ProfileData> |
| 85 | getProfileData() const |
| 86 | { return m_profileData; } |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 87 | |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 88 | inline const std::vector<std::string>& |
| 89 | getEndorseList() const |
| 90 | { return m_endorseList; } |
| 91 | |
| 92 | inline virtual ndn::Name |
| 93 | getPublicKeyName () const |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 94 | { return m_keyName; } |
| 95 | |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 96 | protected: |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 97 | ndn::Name m_keyName; |
| 98 | ndn::Name m_signer; |
Yingdi Yu | b4be64a | 2013-10-13 17:24:50 -0700 | [diff] [blame] | 99 | ndn::Ptr<ProfileData> m_profileData; |
| 100 | std::vector<std::string> m_endorseList; |
Yingdi Yu | c972c45 | 2013-10-11 11:02:09 -0700 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | #endif |