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 ()
12 : myname_ ("Vault_Server_Interceptor")
16 Vault_Server_Request_Interceptor::~Vault_Server_Request_Interceptor ()
21 Vault_Server_Request_Interceptor::name ()
23 return CORBA::string_dup (this->myname_
);
27 Vault_Server_Request_Interceptor::destroy ()
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
)
42 CORBA::String_var op
= ri
->operation ();
44 if (ACE_OS::strcmp (op
.in (), "authenticate") == 0)
46 IOP::ServiceId id
= request_ctx_id
;
47 IOP::ServiceContext_var sc
=
48 ri
->get_request_service_context (id
);
51 reinterpret_cast<const char *> (sc
->context_data
.get_buffer ());
53 if (ACE_OS::strcmp (buf
, "root123") != 0)
54 throw CORBA::NO_PERMISSION ();
57 if (ACE_OS::strcmp (op
.in (), "update_records") == 0)
59 Dynamic::ParameterList_var paramlist
=
62 const Test_Interceptors::Secure_Vault::Record
*record
= 0;
64 CORBA::ULong i
= 0; // index -- explicitly used to avoid
65 // overloaded operator ambiguity.
66 paramlist
[i
++].argument
>>= id
;
67 paramlist
[i
].argument
>>= record
;
72 Vault_Server_Request_Interceptor::send_reply (
73 PortableInterceptor::ServerRequestInfo_ptr ri
)
75 CORBA::String_var op
= ri
->operation ();
77 if (ACE_OS::strcmp (op
.in (), "update_records") == 0)
80 CORBA::Any_var result_any
= ri
->result ();
82 (result_any
.in ()) >>= result
;
87 Vault_Server_Request_Interceptor::send_exception (
88 PortableInterceptor::ServerRequestInfo_ptr
)
94 Vault_Server_Request_Interceptor::send_other (
95 PortableInterceptor::ServerRequestInfo_ptr
)
101 ////////////////////////////////// Context /////////////////////////
103 Vault_Server_Request_Context_Interceptor::Vault_Server_Request_Context_Interceptor ()
104 : myname_ ("Vault_Server_Context_Interceptor")
108 Vault_Server_Request_Context_Interceptor::~Vault_Server_Request_Context_Interceptor ()
113 Vault_Server_Request_Context_Interceptor::name ()
115 return CORBA::string_dup (this->myname_
);
119 Vault_Server_Request_Context_Interceptor::destroy ()
124 Vault_Server_Request_Context_Interceptor::receive_request_service_contexts(
125 PortableInterceptor::ServerRequestInfo_ptr
)
131 Vault_Server_Request_Context_Interceptor::receive_request (
132 PortableInterceptor::ServerRequestInfo_ptr ri
)
134 IOP::ServiceId id
= request_ctx_id
;
135 IOP::ServiceContext_var sc
=
136 ri
->get_request_service_context (id
);
138 const char *buf
= reinterpret_cast<const char *> (sc
->context_data
.get_buffer ());
140 if (ACE_OS::strcmp (buf
, "root123") !=0)
141 throw CORBA::NO_PERMISSION ();
145 Vault_Server_Request_Context_Interceptor::send_reply (
146 PortableInterceptor::ServerRequestInfo_ptr
)
151 Vault_Server_Request_Context_Interceptor::send_exception (
152 PortableInterceptor::ServerRequestInfo_ptr
)
157 Vault_Server_Request_Context_Interceptor::send_other (
158 PortableInterceptor::ServerRequestInfo_ptr
)
163 ///////////////////////////////////Dynamic ////////////////////////////////////
165 Vault_Server_Request_Dynamic_Interceptor::Vault_Server_Request_Dynamic_Interceptor ()
166 : myname_ ("Vault_Server_Dynamic_Interceptor")
170 Vault_Server_Request_Dynamic_Interceptor::~Vault_Server_Request_Dynamic_Interceptor ()
175 Vault_Server_Request_Dynamic_Interceptor::name ()
177 return CORBA::string_dup (this->myname_
);
181 Vault_Server_Request_Dynamic_Interceptor::destroy ()
186 Vault_Server_Request_Dynamic_Interceptor::receive_request (
187 PortableInterceptor::ServerRequestInfo_ptr ri
)
189 CORBA::String_var op
= ri
->operation ();
191 if (ACE_OS::strcmp (op
.in (), "authenticate") == 0)
193 Dynamic::ParameterList_var paramlist
=
197 CORBA::ULong i
= 0; // index -- explicitly used to avoid
198 // overloaded operator ambiguity.
199 paramlist
[i
].argument
>>= user
;
202 if (ACE_OS::strcmp (op
.in (), "update_records") == 0)
204 Dynamic::ParameterList_var paramlist
=
207 const Test_Interceptors::Secure_Vault::Record
*record
= 0;
209 CORBA::ULong i
= 0; // index -- explicitly used to avoid
210 // overloaded operator ambiguity.
211 paramlist
[i
++].argument
>>= id
;
212 paramlist
[i
].argument
>>= record
;
217 Vault_Server_Request_Dynamic_Interceptor::receive_request_service_contexts(
218 PortableInterceptor::ServerRequestInfo_ptr
)
224 Vault_Server_Request_Dynamic_Interceptor::send_reply (
225 PortableInterceptor::ServerRequestInfo_ptr ri
)
227 CORBA::String_var op
= ri
->operation ();
229 if (ACE_OS::strcmp (op
.in (), "ready") == 0)
232 CORBA::Any_var result_any
= ri
->result ();
234 (result_any
.in ()) >>= result
;
237 if (ACE_OS::strcmp (op
.in (), "update_records") == 0)
240 CORBA::Any_var result_any
= ri
->result ();
242 (result_any
.in ()) >>= result
;
247 Vault_Server_Request_Dynamic_Interceptor::send_exception (
248 PortableInterceptor::ServerRequestInfo_ptr
)
253 Vault_Server_Request_Dynamic_Interceptor::send_other (
254 PortableInterceptor::ServerRequestInfo_ptr
)
259 //////////////////////////////NOOP///////////////////////////////////////
261 Vault_Server_Request_NOOP_Interceptor::Vault_Server_Request_NOOP_Interceptor ()
262 : myname_ ("Vault_Server_NOOP_Interceptor")
266 Vault_Server_Request_NOOP_Interceptor::~Vault_Server_Request_NOOP_Interceptor ()
271 Vault_Server_Request_NOOP_Interceptor::name ()
273 return CORBA::string_dup (this->myname_
);
277 Vault_Server_Request_NOOP_Interceptor::destroy ()
282 Vault_Server_Request_NOOP_Interceptor::receive_request (
283 PortableInterceptor::ServerRequestInfo_ptr
)
288 Vault_Server_Request_NOOP_Interceptor::receive_request_service_contexts(
289 PortableInterceptor::ServerRequestInfo_ptr
)
295 Vault_Server_Request_NOOP_Interceptor::send_reply (
296 PortableInterceptor::ServerRequestInfo_ptr
)
301 Vault_Server_Request_NOOP_Interceptor::send_exception (
302 PortableInterceptor::ServerRequestInfo_ptr
)
307 Vault_Server_Request_NOOP_Interceptor::send_other (
308 PortableInterceptor::ServerRequestInfo_ptr
)