1 #include "server_interceptors.h"
3 #include "tao/AnyTypeCode/DynamicC.h"
4 #include "tao/AnyTypeCode/TypeCode.h"
5 #include "ace/OS_NS_string.h"
6 #include "ace/Log_Msg.h"
8 const CORBA::ULong request_ctx_id
= 0xdead;
9 //const CORBA::ULong reply_ctx_id = 0xbeef; // Never used.
11 Vault_Server_Request_Interceptor::Vault_Server_Request_Interceptor (void)
12 : myname_ ("Vault_Server_Interceptor")
16 Vault_Server_Request_Interceptor::~Vault_Server_Request_Interceptor ()
21 Vault_Server_Request_Interceptor::name (void)
23 return CORBA::string_dup (this->myname_
);
27 Vault_Server_Request_Interceptor::destroy (void)
32 Vault_Server_Request_Interceptor::receive_request_service_contexts (
33 PortableInterceptor::ServerRequestInfo_ptr
)
39 Vault_Server_Request_Interceptor::receive_request (
40 PortableInterceptor::ServerRequestInfo_ptr ri
)
43 CORBA::String_var op
= ri
->operation ();
45 if (ACE_OS::strcmp (op
.in (), "authenticate") == 0)
47 IOP::ServiceId id
= request_ctx_id
;
48 IOP::ServiceContext_var sc
=
49 ri
->get_request_service_context (id
);
52 reinterpret_cast<const char *> (sc
->context_data
.get_buffer ());
54 if (ACE_OS::strcmp (buf
, "root123") != 0)
55 throw CORBA::NO_PERMISSION ();
58 if (ACE_OS::strcmp (op
.in (), "update_records") == 0)
60 Dynamic::ParameterList_var paramlist
=
63 const Test_Interceptors::Secure_Vault::Record
*record
= 0;
65 CORBA::ULong i
= 0; // index -- explicitly used to avoid
66 // overloaded operator ambiguity.
67 paramlist
[i
++].argument
>>= id
;
68 paramlist
[i
].argument
>>= record
;
73 Vault_Server_Request_Interceptor::send_reply (
74 PortableInterceptor::ServerRequestInfo_ptr ri
)
77 CORBA::String_var op
= ri
->operation ();
79 if (ACE_OS::strcmp (op
.in (), "update_records") == 0)
82 CORBA::Any_var result_any
= ri
->result ();
84 (result_any
.in ()) >>= result
;
89 Vault_Server_Request_Interceptor::send_exception (
90 PortableInterceptor::ServerRequestInfo_ptr
)
96 Vault_Server_Request_Interceptor::send_other (
97 PortableInterceptor::ServerRequestInfo_ptr
)
103 ////////////////////////////////// Context /////////////////////////
105 Vault_Server_Request_Context_Interceptor::Vault_Server_Request_Context_Interceptor (void)
106 : myname_ ("Vault_Server_Context_Interceptor")
110 Vault_Server_Request_Context_Interceptor::~Vault_Server_Request_Context_Interceptor ()
115 Vault_Server_Request_Context_Interceptor::name ()
117 return CORBA::string_dup (this->myname_
);
121 Vault_Server_Request_Context_Interceptor::destroy ()
126 Vault_Server_Request_Context_Interceptor::receive_request_service_contexts(
127 PortableInterceptor::ServerRequestInfo_ptr
)
133 Vault_Server_Request_Context_Interceptor::receive_request (
134 PortableInterceptor::ServerRequestInfo_ptr ri
)
137 IOP::ServiceId id
= request_ctx_id
;
138 IOP::ServiceContext_var sc
=
139 ri
->get_request_service_context (id
);
141 const char *buf
= reinterpret_cast<const char *> (sc
->context_data
.get_buffer ());
143 if (ACE_OS::strcmp (buf
, "root123") !=0)
144 throw CORBA::NO_PERMISSION ();
148 Vault_Server_Request_Context_Interceptor::send_reply (
149 PortableInterceptor::ServerRequestInfo_ptr
)
155 Vault_Server_Request_Context_Interceptor::send_exception (
156 PortableInterceptor::ServerRequestInfo_ptr
)
161 Vault_Server_Request_Context_Interceptor::send_other (
162 PortableInterceptor::ServerRequestInfo_ptr
)
167 ///////////////////////////////////Dynamic ////////////////////////////////////
169 Vault_Server_Request_Dynamic_Interceptor::Vault_Server_Request_Dynamic_Interceptor (void)
170 : myname_ ("Vault_Server_Dynamic_Interceptor")
174 Vault_Server_Request_Dynamic_Interceptor::~Vault_Server_Request_Dynamic_Interceptor ()
179 Vault_Server_Request_Dynamic_Interceptor::name ()
181 return CORBA::string_dup (this->myname_
);
185 Vault_Server_Request_Dynamic_Interceptor::destroy ()
190 Vault_Server_Request_Dynamic_Interceptor::receive_request (
191 PortableInterceptor::ServerRequestInfo_ptr ri
)
194 CORBA::String_var op
= ri
->operation ();
196 if (ACE_OS::strcmp (op
.in (), "authenticate") == 0)
198 Dynamic::ParameterList_var paramlist
=
202 CORBA::ULong i
= 0; // index -- explicitly used to avoid
203 // overloaded operator ambiguity.
204 paramlist
[i
].argument
>>= user
;
207 if (ACE_OS::strcmp (op
.in (), "update_records") == 0)
209 Dynamic::ParameterList_var paramlist
=
212 const Test_Interceptors::Secure_Vault::Record
*record
= 0;
214 CORBA::ULong i
= 0; // index -- explicitly used to avoid
215 // overloaded operator ambiguity.
216 paramlist
[i
++].argument
>>= id
;
217 paramlist
[i
].argument
>>= record
;
222 Vault_Server_Request_Dynamic_Interceptor::receive_request_service_contexts(
223 PortableInterceptor::ServerRequestInfo_ptr
)
229 Vault_Server_Request_Dynamic_Interceptor::send_reply (
230 PortableInterceptor::ServerRequestInfo_ptr ri
)
233 CORBA::String_var op
= ri
->operation ();
235 if (ACE_OS::strcmp (op
.in (), "ready") == 0)
238 CORBA::Any_var result_any
= ri
->result ();
240 (result_any
.in ()) >>= result
;
243 if (ACE_OS::strcmp (op
.in (), "update_records") == 0)
246 CORBA::Any_var result_any
= ri
->result ();
248 (result_any
.in ()) >>= result
;
253 Vault_Server_Request_Dynamic_Interceptor::send_exception (
254 PortableInterceptor::ServerRequestInfo_ptr
)
259 Vault_Server_Request_Dynamic_Interceptor::send_other (
260 PortableInterceptor::ServerRequestInfo_ptr
)
265 //////////////////////////////NOOP///////////////////////////////////////
267 Vault_Server_Request_NOOP_Interceptor::Vault_Server_Request_NOOP_Interceptor (void)
268 : myname_ ("Vault_Server_NOOP_Interceptor")
272 Vault_Server_Request_NOOP_Interceptor::~Vault_Server_Request_NOOP_Interceptor ()
277 Vault_Server_Request_NOOP_Interceptor::name (void)
279 return CORBA::string_dup (this->myname_
);
283 Vault_Server_Request_NOOP_Interceptor::destroy ()
288 Vault_Server_Request_NOOP_Interceptor::receive_request (
289 PortableInterceptor::ServerRequestInfo_ptr
)
294 Vault_Server_Request_NOOP_Interceptor::receive_request_service_contexts(
295 PortableInterceptor::ServerRequestInfo_ptr
)
301 Vault_Server_Request_NOOP_Interceptor::send_reply (
302 PortableInterceptor::ServerRequestInfo_ptr
)
308 Vault_Server_Request_NOOP_Interceptor::send_exception (
309 PortableInterceptor::ServerRequestInfo_ptr
)
314 Vault_Server_Request_NOOP_Interceptor::send_other (
315 PortableInterceptor::ServerRequestInfo_ptr
)