00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef qpid_framing_AccessRequestBody__
00029 #define qpid_framing_AccessRequestBody__
00030
00031 #include <string>
00032 #include <sstream>
00033
00034 #include "qpid/framing/amqp_types.h"
00035 #include "qpid/framing/AMQRequestBody.h"
00036 #include "qpid/framing/Buffer.h"
00037 #include "qpid/framing/FieldTable.h"
00038 #include "qpid/framing/FramingContent.h"
00039
00040 namespace qpid
00041 {
00042 namespace framing
00043 {
00044
00045
00046 class AccessRequestBody : public AMQRequestBody
00047 {
00048
00049
00050
00051 string realm;
00052 bool exclusive;
00053 bool passive;
00054 bool active;
00055 bool write;
00056 bool read;
00057
00058
00059 public:
00060 static const ClassId CLASS_ID= 30;
00061 static const MethodId METHOD_ID = 10;
00062
00063 typedef boost::shared_ptr<AccessRequestBody> shared_ptr;
00064
00065
00066
00067 AccessRequestBody(ProtocolVersion version,
00068 const string& realm,
00069 bool exclusive,
00070 bool passive,
00071 bool active,
00072 bool write,
00073 bool read
00074 ) : AMQRequestBody(version),
00075 realm(realm),
00076 exclusive(exclusive),
00077 passive(passive),
00078 active(active),
00079 write(write),
00080 read(read)
00081 { }
00082
00083
00084 AccessRequestBody(ProtocolVersion version): AMQRequestBody(version) {}
00085 virtual ~AccessRequestBody() {}
00086
00087
00088
00089 const string& getRealm() { return realm; }
00090 bool getExclusive() { return exclusive; }
00091 bool getPassive() { return passive; }
00092 bool getActive() { return active; }
00093 bool getWrite() { return write; }
00094 bool getRead() { return read; }
00095
00096
00097
00098 inline void print(std::ostream& out) const
00099 {
00100 printPrefix(out);
00101 out << "AccessRequest: ";
00102 out << "realm=" << realm;
00103 out << "; exclusive=" << exclusive;
00104 out << "; passive=" << passive;
00105 out << "; active=" << active;
00106 out << "; write=" << write;
00107 out << "; read=" << read;
00108 }
00109
00110 inline ClassId amqpClassId() const { return CLASS_ID; }
00111 inline MethodId amqpMethodId() const { return METHOD_ID; }
00112
00113 u_int32_t size() const
00114 {
00115 u_int32_t sz = baseSize();
00116 sz += 1 + realm.length();
00117 sz += 1;
00118 return sz;
00119 }
00120
00121 void encodeContent(Buffer& buffer) const
00122 {
00123 buffer.putShortString(realm);
00124 u_int8_t flags_5[1] = {0};
00125 flags_5[0] |= exclusive << 0;
00126 flags_5[0] |= passive << 1;
00127 flags_5[0] |= active << 2;
00128 flags_5[0] |= write << 3;
00129 flags_5[0] |= read << 4;
00130 buffer.putOctet(flags_5[0]);
00131 }
00132
00133 inline void decodeContent(Buffer& buffer)
00134 {
00135 buffer.getShortString(realm);
00136 u_int8_t flags_5[1];
00137 flags_5[0] = buffer.getOctet();
00138 exclusive = (1 << 0) & flags_5[0];
00139 passive = (1 << 1) & flags_5[0];
00140 active = (1 << 2) & flags_5[0];
00141 write = (1 << 3) & flags_5[0];
00142 read = (1 << 4) & flags_5[0];
00143 }
00144
00145 void invoke(AMQP_ServerOperations& target, const MethodContext& context)
00146 {
00147 target.getAccessHandler()->request(context,
00148 realm,
00149 exclusive,
00150 passive,
00151 active,
00152 write,
00153 read
00154 );
00155 }
00156
00157
00158 };
00159
00160
00161 }
00162 }
00163
00164 #endif
00165