Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -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 CHRONOS_INVITATION_H |
| 12 | #define CHRONOS_INVITATION_H |
| 13 | |
| 14 | |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 15 | #include <ndn-cpp-dev/name.hpp> |
| 16 | #include <ndn-cpp-dev/signature.hpp> |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 17 | |
| 18 | class ChronosInvitation |
| 19 | { |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 20 | /* |
| 21 | * /ndn/broadcast/chronos/invitation/[invitee_namespace]/<chatroom_name>/<inviter_routing_prefix>/<keylocator>/<signature> |
| 22 | */ |
| 23 | static const size_t NAME_SIZE_MIN; |
| 24 | static const size_t INVITEE_START; |
| 25 | static const ssize_t SIGNATURE; |
| 26 | static const ssize_t KEY_LOCATOR; |
| 27 | static const ssize_t INVITER_PREFIX; |
| 28 | static const ssize_t CHATROOM; |
| 29 | static const ndn::Name INVITATION_PREFIX; |
| 30 | |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 31 | public: |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 32 | struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} }; |
| 33 | |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 34 | ChronosInvitation() {} |
| 35 | |
| 36 | ChronosInvitation(const ndn::Name& interestName); |
| 37 | |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 38 | ChronosInvitation(const ndn::Name &inviteeNameSpace, |
| 39 | const ndn::Name &chatroom, |
| 40 | const ndn::Name &inviterRoutingPrefix, |
| 41 | const ndn::Name &inviterCertificateName); |
| 42 | |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 43 | ChronosInvitation(const ChronosInvitation& invitation); |
| 44 | |
| 45 | virtual |
| 46 | ~ChronosInvitation() {}; |
| 47 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 48 | const ndn::Name& |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 49 | getInviteeNameSpace() const |
| 50 | { return m_inviteeNameSpace; } |
| 51 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 52 | const ndn::Name& |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 53 | getChatroom() const |
| 54 | { return m_chatroom; } |
| 55 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 56 | const ndn::Name& |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 57 | getInviterRoutingPrefix() const |
| 58 | { return m_inviterRoutingPrefix; } |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 59 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 60 | const ndn::Name& |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 61 | getInviterCertificateName() const |
| 62 | { return m_inviterCertificateName; } |
| 63 | |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 64 | const ndn::Signature& |
| 65 | getSignature() const |
| 66 | { return m_signature; } |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 67 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 68 | const ndn::Name& |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 69 | getInviterNameSpace() const |
| 70 | { return m_inviterNameSpace; } |
| 71 | |
Yingdi Yu | c9ffa9f | 2014-01-13 11:19:47 -0800 | [diff] [blame] | 72 | const ndn::Buffer& |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 73 | getSignedBlob() const |
| 74 | { return m_signedBlob; } |
| 75 | |
Yingdi Yu | 6420611 | 2013-12-24 11:16:32 +0800 | [diff] [blame] | 76 | const ndn::Name& |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 77 | getInterestName() const |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 78 | { |
| 79 | if(m_isSigned) |
| 80 | return m_interestName; |
| 81 | else |
| 82 | throw Error("Invitation is not signed!"); |
| 83 | } |
| 84 | |
| 85 | void |
| 86 | setSignatureValue(const ndn::Block &signatureValue); |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 87 | |
| 88 | private: |
| 89 | ndn::Name m_interestName; |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 90 | ndn::Buffer m_signedBlob; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 91 | |
| 92 | ndn::Name m_inviteeNameSpace; |
| 93 | ndn::Name m_chatroom; |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 94 | ndn::Name m_inviterRoutingPrefix; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 95 | ndn::Name m_inviterCertificateName; |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 96 | ndn::Signature m_signature; |
| 97 | |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 98 | ndn::Name m_inviterNameSpace; |
| 99 | |
Yingdi Yu | 6df6125 | 2014-01-21 11:05:11 -0800 | [diff] [blame^] | 100 | bool m_isSigned; |
Yingdi Yu | 42f6646 | 2013-10-31 17:38:22 -0700 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | #endif |