Yingdi Yu | 43e7161 | 2013-10-30 22:19:31 -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 | |
| 11 | #ifndef SYNC_INTRO_CERTIFICATE_H |
| 12 | #define SYNC_INTRO_CERTIFICATE_H |
| 13 | |
Yingdi Yu | e815471 | 2014-01-21 10:20:14 -0800 | [diff] [blame] | 14 | #include <ndn-cpp-dev/security/certificate.hpp> |
| 15 | #include <ndn-cpp-dev/security/identity-certificate.hpp> |
Yingdi Yu | 43e7161 | 2013-10-30 22:19:31 -0700 | [diff] [blame] | 16 | |
Yingdi Yu | 46c9f1a | 2013-12-18 15:15:46 +0800 | [diff] [blame] | 17 | class SyncIntroCertificate : public ndn::Certificate |
Yingdi Yu | 43e7161 | 2013-10-30 22:19:31 -0700 | [diff] [blame] | 18 | { |
| 19 | public: |
Yingdi Yu | 0cb0f2b | 2014-01-09 13:51:16 -0800 | [diff] [blame] | 20 | struct Error : public ndn::Certificate::Error { Error(const std::string &what) : ndn::Certificate::Error(what) {} }; |
| 21 | |
Yingdi Yu | 43e7161 | 2013-10-30 22:19:31 -0700 | [diff] [blame] | 22 | enum IntroType{ |
| 23 | PRODUCER, |
| 24 | INTRODUCER |
| 25 | }; |
| 26 | |
| 27 | public: |
| 28 | SyncIntroCertificate (); |
| 29 | |
| 30 | SyncIntroCertificate (const ndn::Name& nameSpace, |
| 31 | const ndn::Name& keyName, |
| 32 | const ndn::Name& signerName, |
Yingdi Yu | 46c9f1a | 2013-12-18 15:15:46 +0800 | [diff] [blame] | 33 | const ndn::MillisecondsSince1970& notBefore, |
| 34 | const ndn::MillisecondsSince1970& notAfter, |
| 35 | const ndn::PublicKey& key, |
Yingdi Yu | 43e7161 | 2013-10-30 22:19:31 -0700 | [diff] [blame] | 36 | const IntroType& introType = PRODUCER); |
| 37 | |
| 38 | SyncIntroCertificate (const ndn::Name& nameSpace, |
Yingdi Yu | 46c9f1a | 2013-12-18 15:15:46 +0800 | [diff] [blame] | 39 | const ndn::IdentityCertificate& identityCertificate, |
Yingdi Yu | 43e7161 | 2013-10-30 22:19:31 -0700 | [diff] [blame] | 40 | const ndn::Name& signerName, |
| 41 | const IntroType& introType); |
| 42 | |
| 43 | SyncIntroCertificate (const ndn::Data& data); |
| 44 | |
| 45 | SyncIntroCertificate (const SyncIntroCertificate& chronosIntroCertificate); |
| 46 | |
| 47 | |
| 48 | virtual |
| 49 | ~SyncIntroCertificate () |
| 50 | {} |
| 51 | |
Yingdi Yu | 46c9f1a | 2013-12-18 15:15:46 +0800 | [diff] [blame] | 52 | ndn::Data& |
Yingdi Yu | 43e7161 | 2013-10-30 22:19:31 -0700 | [diff] [blame] | 53 | setName (const ndn::Name& name); |
| 54 | |
Yingdi Yu | 286eb18 | 2014-01-23 23:20:43 -0800 | [diff] [blame^] | 55 | inline const ndn::Name & |
| 56 | getPublicKeyName() const; |
Yingdi Yu | 43e7161 | 2013-10-30 22:19:31 -0700 | [diff] [blame] | 57 | |
| 58 | inline IntroType |
Yingdi Yu | 286eb18 | 2014-01-23 23:20:43 -0800 | [diff] [blame^] | 59 | getIntroType(); |
Yingdi Yu | 43e7161 | 2013-10-30 22:19:31 -0700 | [diff] [blame] | 60 | |
Yingdi Yu | 286eb18 | 2014-01-23 23:20:43 -0800 | [diff] [blame^] | 61 | inline const ndn::Name & |
| 62 | getNameSpace() const; |
| 63 | |
Yingdi Yu | 43e7161 | 2013-10-30 22:19:31 -0700 | [diff] [blame] | 64 | static bool |
Yingdi Yu | 46c9f1a | 2013-12-18 15:15:46 +0800 | [diff] [blame] | 65 | isSyncIntroCertificate(const ndn::Certificate& certificate); |
Yingdi Yu | 43e7161 | 2013-10-30 22:19:31 -0700 | [diff] [blame] | 66 | |
| 67 | protected: |
Yingdi Yu | 286eb18 | 2014-01-23 23:20:43 -0800 | [diff] [blame^] | 68 | ndn::Name m_nameSpace; |
Yingdi Yu | 43e7161 | 2013-10-30 22:19:31 -0700 | [diff] [blame] | 69 | ndn::Name m_keyName; |
| 70 | IntroType m_introType; |
| 71 | }; |
| 72 | |
Yingdi Yu | 286eb18 | 2014-01-23 23:20:43 -0800 | [diff] [blame^] | 73 | SyncIntroCertificate::IntroType |
| 74 | SyncIntroCertificate::getIntroType() |
| 75 | { return m_introType; } |
| 76 | |
| 77 | const ndn::Name & |
| 78 | SyncIntroCertificate::getPublicKeyName () const |
| 79 | { return m_keyName; } |
| 80 | |
| 81 | const ndn::Name & |
| 82 | SyncIntroCertificate::getNameSpace() const |
| 83 | { return m_nameSpace; } |
| 84 | |
Yingdi Yu | 43e7161 | 2013-10-30 22:19:31 -0700 | [diff] [blame] | 85 | #endif |