blob: a72755253f1cfe329e2efb4e10b5214844d68f4b [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>
Yingdi Yu64206112013-12-24 11:16:32 +080015#include <ndn-cpp/data.hpp>
16#include <ndn-cpp/security/certificate/identity-certificate.hpp>
17#include <ndn-cpp/security/certificate/certificate-extension.hpp>
Yingdi Yu3c2a9762013-10-11 11:02:09 -070018
19#include "profile-data.h"
20
Yingdi Yu64206112013-12-24 11:16:32 +080021class ProfileExtension : public ndn::CertificateExtension
Yingdi Yu5ff62102013-10-13 17:24:50 -070022{
23public:
Yingdi Yuc9ffa9f2014-01-13 11:19:47 -080024 struct Error : public ndn::CertificateExtension::Error { Error(const std::string &what) : ndn::CertificateExtension::Error(what) {} };
25
Yingdi Yu5ff62102013-10-13 17:24:50 -070026 ProfileExtension(const ProfileData& profileData);
27
28 ProfileExtension(const ProfileExtension& profileExtension);
29
30 ProfileExtension(const CertificateExtension& extension);
31
32 ~ProfileExtension() {}
33
Yingdi Yu64206112013-12-24 11:16:32 +080034 ndn::ptr_lib::shared_ptr<ProfileData>
Yingdi Yu5ff62102013-10-13 17:24:50 -070035 getProfileData();
36};
37
Yingdi Yu64206112013-12-24 11:16:32 +080038class EndorseExtension : public ndn::CertificateExtension
Yingdi Yu3c2a9762013-10-11 11:02:09 -070039{
40public:
Yingdi Yuc9ffa9f2014-01-13 11:19:47 -080041 struct Error : public ndn::CertificateExtension::Error { Error(const std::string &what) : ndn::CertificateExtension::Error(what) {} };
42
Yingdi Yu64206112013-12-24 11:16:32 +080043 EndorseExtension(const std::vector<std::string>& endorseList);
Yingdi Yu3c2a9762013-10-11 11:02:09 -070044
Yingdi Yu5ff62102013-10-13 17:24:50 -070045 EndorseExtension(const EndorseExtension& endorseExtension);
46
47 EndorseExtension(const CertificateExtension& extension);
48
Yingdi Yu3c2a9762013-10-11 11:02:09 -070049 ~EndorseExtension() {}
Yingdi Yu5ff62102013-10-13 17:24:50 -070050
51 std::vector<std::string>
Yingdi Yu64206112013-12-24 11:16:32 +080052 getEndorseList();
Yingdi Yu5ff62102013-10-13 17:24:50 -070053
54private:
Yingdi Yuc9ffa9f2014-01-13 11:19:47 -080055 static ndn::Buffer
Yingdi Yu64206112013-12-24 11:16:32 +080056 encodeEndorseList(const std::vector<std::string>& endorsedList);
Yingdi Yu3c2a9762013-10-11 11:02:09 -070057};
58
Yingdi Yu64206112013-12-24 11:16:32 +080059class EndorseCertificate : public ndn::Certificate
Yingdi Yu3c2a9762013-10-11 11:02:09 -070060{
61public:
Yingdi Yuc9ffa9f2014-01-13 11:19:47 -080062 struct Error : public ndn::Certificate::Error { Error(const std::string &what) : ndn::Certificate::Error(what) {} };
63
Yingdi Yuc29fb982013-10-20 19:43:10 -070064 EndorseCertificate() {}
65
Yingdi Yu64206112013-12-24 11:16:32 +080066 EndorseCertificate(const ndn::IdentityCertificate& kskCertificate,
67 const ProfileData& profileData,
Yingdi Yu8dacdf22013-11-05 23:06:43 -080068 const std::vector<std::string>& endorseList = std::vector<std::string>());
Yingdi Yu5ff62102013-10-13 17:24:50 -070069
70 EndorseCertificate(const EndorseCertificate& endorseCertificate,
Yingdi Yu3c2a9762013-10-11 11:02:09 -070071 const ndn::Name& signer,
Yingdi Yu5ff62102013-10-13 17:24:50 -070072 const std::vector<std::string>& endorseList);
Yingdi Yu3c2a9762013-10-11 11:02:09 -070073
74 EndorseCertificate(const EndorseCertificate& endorseCertificate);
75
76 EndorseCertificate(const ndn::Data& data);
77
78 virtual
79 ~EndorseCertificate()
80 {}
81
Yingdi Yu64206112013-12-24 11:16:32 +080082 const ndn::Name&
Yingdi Yu3c2a9762013-10-11 11:02:09 -070083 getSigner() const
84 { return m_signer; }
85
Yingdi Yu64206112013-12-24 11:16:32 +080086 const ProfileData&
Yingdi Yu5ff62102013-10-13 17:24:50 -070087 getProfileData() const
88 { return m_profileData; }
Yingdi Yu3c2a9762013-10-11 11:02:09 -070089
Yingdi Yu64206112013-12-24 11:16:32 +080090 const std::vector<std::string>&
Yingdi Yu5ff62102013-10-13 17:24:50 -070091 getEndorseList() const
92 { return m_endorseList; }
93
Yingdi Yu64206112013-12-24 11:16:32 +080094 virtual ndn::Name
Yingdi Yu5ff62102013-10-13 17:24:50 -070095 getPublicKeyName () const
Yingdi Yu3c2a9762013-10-11 11:02:09 -070096 { return m_keyName; }
97
Yingdi Yu5ff62102013-10-13 17:24:50 -070098protected:
Yingdi Yu3c2a9762013-10-11 11:02:09 -070099 ndn::Name m_keyName;
100 ndn::Name m_signer;
Yingdi Yu64206112013-12-24 11:16:32 +0800101 ProfileData m_profileData;
Yingdi Yu5ff62102013-10-13 17:24:50 -0700102 std::vector<std::string> m_endorseList;
Yingdi Yu3c2a9762013-10-11 11:02:09 -0700103};
104
105#endif