blob: d17a14421d2375dbf167e1e14c249c3c921fb79a [file] [log] [blame]
Yingdi Yu42f66462013-10-31 17:38:22 -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
11#ifndef CHRONOS_INVITATION_H
12#define CHRONOS_INVITATION_H
13
14
Yingdi Yu6df61252014-01-21 11:05:11 -080015#include <ndn-cpp-dev/name.hpp>
16#include <ndn-cpp-dev/signature.hpp>
Yingdi Yu42f66462013-10-31 17:38:22 -070017
18class ChronosInvitation
19{
Yingdi Yu6df61252014-01-21 11:05:11 -080020/*
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 Yu42f66462013-10-31 17:38:22 -070031public:
Yingdi Yuc9ffa9f2014-01-13 11:19:47 -080032 struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
33
Yingdi Yu42f66462013-10-31 17:38:22 -070034 ChronosInvitation() {}
35
36 ChronosInvitation(const ndn::Name& interestName);
37
Yingdi Yu6df61252014-01-21 11:05:11 -080038 ChronosInvitation(const ndn::Name &inviteeNameSpace,
39 const ndn::Name &chatroom,
40 const ndn::Name &inviterRoutingPrefix,
41 const ndn::Name &inviterCertificateName);
42
Yingdi Yu42f66462013-10-31 17:38:22 -070043 ChronosInvitation(const ChronosInvitation& invitation);
44
45 virtual
46 ~ChronosInvitation() {};
47
Yingdi Yu64206112013-12-24 11:16:32 +080048 const ndn::Name&
Yingdi Yu42f66462013-10-31 17:38:22 -070049 getInviteeNameSpace() const
50 { return m_inviteeNameSpace; }
51
Yingdi Yu64206112013-12-24 11:16:32 +080052 const ndn::Name&
Yingdi Yu42f66462013-10-31 17:38:22 -070053 getChatroom() const
54 { return m_chatroom; }
55
Yingdi Yu64206112013-12-24 11:16:32 +080056 const ndn::Name&
Yingdi Yu6df61252014-01-21 11:05:11 -080057 getInviterRoutingPrefix() const
58 { return m_inviterRoutingPrefix; }
Yingdi Yu42f66462013-10-31 17:38:22 -070059
Yingdi Yu64206112013-12-24 11:16:32 +080060 const ndn::Name&
Yingdi Yu42f66462013-10-31 17:38:22 -070061 getInviterCertificateName() const
62 { return m_inviterCertificateName; }
63
Yingdi Yu6df61252014-01-21 11:05:11 -080064 const ndn::Signature&
65 getSignature() const
66 { return m_signature; }
Yingdi Yu42f66462013-10-31 17:38:22 -070067
Yingdi Yu64206112013-12-24 11:16:32 +080068 const ndn::Name&
Yingdi Yu42f66462013-10-31 17:38:22 -070069 getInviterNameSpace() const
70 { return m_inviterNameSpace; }
71
Yingdi Yuc9ffa9f2014-01-13 11:19:47 -080072 const ndn::Buffer&
Yingdi Yu42f66462013-10-31 17:38:22 -070073 getSignedBlob() const
74 { return m_signedBlob; }
75
Yingdi Yu64206112013-12-24 11:16:32 +080076 const ndn::Name&
Yingdi Yu42f66462013-10-31 17:38:22 -070077 getInterestName() const
Yingdi Yu6df61252014-01-21 11:05:11 -080078 {
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 Yu42f66462013-10-31 17:38:22 -070087
88private:
89 ndn::Name m_interestName;
Yingdi Yu6df61252014-01-21 11:05:11 -080090 ndn::Buffer m_signedBlob;
Yingdi Yu42f66462013-10-31 17:38:22 -070091
92 ndn::Name m_inviteeNameSpace;
93 ndn::Name m_chatroom;
Yingdi Yu6df61252014-01-21 11:05:11 -080094 ndn::Name m_inviterRoutingPrefix;
Yingdi Yu42f66462013-10-31 17:38:22 -070095 ndn::Name m_inviterCertificateName;
Yingdi Yu6df61252014-01-21 11:05:11 -080096 ndn::Signature m_signature;
97
Yingdi Yu42f66462013-10-31 17:38:22 -070098 ndn::Name m_inviterNameSpace;
99
Yingdi Yu6df61252014-01-21 11:05:11 -0800100 bool m_isSigned;
Yingdi Yu42f66462013-10-31 17:38:22 -0700101};
102
103#endif