1
2 #include "SecureCounterService_skeleton.h"
3 #include "SecureCounterService_internal_skeleton.h"
4
5 #include "globus_wsrf_resource.h"
6 #include "globus_wsrf_core_tools.h"
7 #include "globus_soap_message_handle.h"
8
9 #include "globus_ws_addressing.h"
10 #include "globus_ws_security.h"
11
12 #include "counter_Value.h"
13
14 extern globus_service_descriptor_t SecureCounterService_descriptor;
15
16
17 globus_result_t
18 SecureCounterService_init(
19 globus_service_descriptor_t * service_desc)
20 1 {
21 1 globus_result_t result = GLOBUS_SUCCESS;
22 GlobusFuncName(SecureCounterService_init);
23 1 SecureCounterServiceDebugEnter();
24
25 1 result = (globus_result_t)
26 globus_module_activate(GLOBUS_WSRF_RESOURCE_MODULE);
27 1 if(result != GLOBUS_SUCCESS)
28 {
29 0 goto exit;
30 }
31
32 1 if(!service_desc->handlers)
33 {
34 1 globus_handler_chain_init(&service_desc->handlers);
35 }
36
37 1 result = globus_extension_activate(
38 GLOBUS_HANDLER_WS_SECMESS_LIB);
39 1 if(result != GLOBUS_SUCCESS)
40 {
41 0 goto exit;
42 }
43
44 1 result = globus_extension_activate(
45 GLOBUS_HANDLER_WS_ADDRESSING_LIB);
46 1 if(result != GLOBUS_SUCCESS)
47 {
48 0 goto exit;
49 }
50
51 1 result = globus_handler_chain_push(
52 service_desc->handlers,
53 GLOBUS_HANDLER_TYPE_ALL,
54 GLOBUS_HANDLER_WS_ADDRESSING_SERVER);
55 1 if(result != GLOBUS_SUCCESS)
56 {
57 0 goto exit;
58 }
59
60 1 result = globus_handler_chain_push(
61 service_desc->handlers,
62 GLOBUS_HANDLER_TYPE_ALL,
63 GLOBUS_HANDLER_WS_SECMESS_SERVER);
64 if(result != GLOBUS_SUCCESS)
65 {
66 1 goto exit;
67 }
68
69 1 exit:
70 1 SecureCounterServiceDebugExit();
71 1 return result;
72 }
73
74 globus_result_t
75 SecureCounterService_finalize(
76 globus_service_descriptor_t * service_desc)
77 0 {
78 0 globus_result_t result = GLOBUS_SUCCESS;
79 GlobusFuncName(SecureCounterService_finalize);
80
81 0 SecureCounterServiceDebugEnter();
82
83 /* do any service specific finalize stuff here,
84 * opposite of CounterService_init
85 */
86
87 0 if(service_desc->handlers)
88 {
89 0 globus_handler_chain_destroy(
90 service_desc->handlers);
91 0 service_desc->handlers = NULL;
92 }
93
94 0 result = globus_extension_deactivate(
95 GLOBUS_HANDLER_WS_SECMESS_LIB);
96 0 if(result != GLOBUS_SUCCESS)
97 {
98 0 goto exit;
99 }
100
101 0 result = globus_extension_deactivate(
102 GLOBUS_HANDLER_WS_ADDRESSING_LIB);
103 0 if(result != GLOBUS_SUCCESS)
104 {
105 0 goto exit;
106 }
107
108 0 result = globus_module_deactivate(GLOBUS_WSRF_RESOURCE_MODULE);
109
110 0 exit:
111 0 SecureCounterServiceDebugExit();
112 0 return result;
113 }
114
115 globus_result_t
116 CounterPortType_GetCurrentMessage_impl(
117 globus_service_engine_t engine,
118 globus_soap_message_handle_t message,
119 globus_service_descriptor_t * service,
120 wsnt_GetCurrentMessageType * GetCurrentMessage,
121 wsnt_GetCurrentMessageResponseType * GetCurrentMessageResponse,
122 xsd_any * fault)
123 0 {
124 /* add function local variable declarations here */
125 0 globus_result_t result = GLOBUS_SUCCESS;
126
127 /* initialize trace debugging info */
128 GlobusFuncName(CounterPortType_GetCurrentMessage_impl);
129 0 SecureCounterServiceDebugEnter();
130
131 /* This is where it all happens. Service implementer must
132 * implmenent this function. Asume that GetCurrentMessage has
133 * been initialized and filled with request values.
134 * GetCurrentMessageResponse must be set by the implementer.
135 */
136
137 0 result = SecureCounterServiceErrorNotImplemented(
138 "CounterPorType_GetCurrentMessage_impl");
139
140 0 SecureCounterServiceDebugExit();
141 0 return result;
142 }
143
144 globus_result_t
145 CounterPortType_Subscribe_impl(
146 globus_service_engine_t engine,
147 globus_soap_message_handle_t message,
148 globus_service_descriptor_t * service,
149 wsnt_SubscribeType * Subscribe,
150 wsnt_SubscribeResponseType * SubscribeResponse,
151 xsd_any * fault)
152 0 {
153 /* add function local variable declarations here */
154 0 globus_result_t result = GLOBUS_SUCCESS;
155
156 /* initialize trace debugging info */
157 GlobusFuncName(CounterPortType_Subscribe_impl);
158 0 SecureCounterServiceDebugEnter();
159
160 /* This is where it all happens. Service implementer must
161 * implmenent this function. Asume that Subscribe has
162 * been initialized and filled with request values.
163 * SubscribeResponse must be set by the implementer.
164 */
165
166 0 result = SecureCounterServiceErrorNotImplemented(
167 "CounterPortType_Subscribe_impl");
168
169 0 SecureCounterServiceDebugExit();
170 0 return result;
171 }
172
173 globus_result_t
174 CounterPortType_GetMultipleResourceProperties_impl(
175 globus_service_engine_t engine,
176 globus_soap_message_handle_t message,
177 globus_service_descriptor_t * service,
178 wsrp_GetMultipleResourcePropertiesType * GetResourceProperty,
179 wsrp_GetMultipleResourcePropertiesResponseType * GetMultipleResourcePropertiesResponse,
180 xsd_any * fault)
181 0 {
182 /* add function local variable declarations here */
183 0 globus_result_t result = GLOBUS_SUCCESS;
184
185 /* initialize trace debugging info */
186 GlobusFuncName(CounterPortType_GetMultipleResourceProperties_impl);
187 0 SecureCounterServiceDebugEnter();
188
189 /* This is where it all happens. Service implementer must
190 * implmenent this function. Asume that GetResourceProperty has
191 * been initialized and filled with request values.
192 * GetResourcePropertyResponse must be set by the implementer.
193 */
194
195 0 result = SecureCounterServiceErrorNotImplemented(
196 "CounterPortType_GetMultipleResourceProperties_impl");
197
198 0 SecureCounterServiceDebugExit();
199 0 return result;
200 }
201
202 globus_result_t
203 CounterPortType_GetResourceProperty_impl(
204 globus_service_engine_t engine,
205 globus_soap_message_handle_t message,
206 globus_service_descriptor_t * service,
207 xsd_QName * GetResourceProperty,
208 wsrp_GetResourcePropertyResponseType * GetResourcePropertyResponse,
209 xsd_any * fault)
210 0 {
211 /* add function local variable declarations here */
212 0 globus_result_t result = GLOBUS_SUCCESS;
213
214 /* initialize trace debugging info */
215 GlobusFuncName(CounterPortType_GetResourceProperty_impl);
216 0 SecureCounterServiceDebugEnter();
217
218 /* This is where it all happens. Service implementer must
219 * implmenent this function. Asume that GetResourceProperty has
220 * been initialized and filled with request values.
221 * GetResourcePropertyResponse must be set by the implementer.
222 */
223
224 0 result = SecureCounterServiceErrorNotImplemented(
225 "CounterPortType_GetResourceProperty_impl");
226
227 0 SecureCounterServiceDebugExit();
228 0 return result;
229 }
230
231 globus_result_t
232 CounterPortType_QueryResourceProperties_impl(
233 globus_service_engine_t engine,
234 globus_soap_message_handle_t message,
235 globus_service_descriptor_t * descriptor,
236 wsrp_QueryResourcePropertiesType * QueryResourceProperties,
237 wsrp_QueryResourcePropertiesResponseType * QueryResourcePropertiesResponse,
238 xsd_any * fault)
239 0 {
240 /* add function local variable declarations here */
241 0 globus_result_t result = GLOBUS_SUCCESS;
242
243 /* initialize trace debugging info */
244 GlobusFuncName(CounterPortType_QueryResourceProperties_impl);
245 0 SecureCounterServiceDebugEnter();
246
247 /* This is where it all happens. Service implementer must
248 * implmenent this function. Asume that QueryResourceProperties has
249 * been initialized and filled with request values.
250 * QueryResourcePropertiesResponse must be set by the implementer.
251 */
252
253 0 result = SecureCounterServiceErrorNotImplemented(
254 "CounterPortType_QueryResourceProperties_impl");
255
256 0 SecureCounterServiceDebugExit();
257 0 return result;
258 }
259
260 globus_result_t
261 CounterPortType_Destroy_impl(
262 globus_service_engine_t engine,
263 globus_soap_message_handle_t message,
264 globus_service_descriptor_t * service,
265 wsrl_DestroyType * Destroy,
266 wsrl_DestroyResponseType * DestroyResponse,
267 xsd_any * fault)
268 0 {
269 /* add function local variable declarations here */
270 0 globus_result_t result = GLOBUS_SUCCESS;
271
272 /* initialize trace debugging info */
273 GlobusFuncName(CounterPortType_Destroy_impl);
274 0 SecureCounterServiceDebugEnter();
275
276 /* This is where it all happens. Service implementer must
277 * implmenent this function. Asume that Destroy has
278 * been initialized and filled with request values.
279 * DestroyResponse must be set by the implementer.
280 */
281
282 0 result = SecureCounterServiceErrorNotImplemented(
283 "CounterPortType_Destroy_impl");
284
285 0 SecureCounterServiceDebugExit();
286 0 return result;
287 }
288
289 globus_result_t
290 CounterPortType_SetTerminationTime_impl(
291 globus_service_engine_t engine,
292 globus_soap_message_handle_t message,
293 globus_service_descriptor_t * service,
294 wsrl_SetTerminationTimeType * SetTerminationTime,
295 wsrl_SetTerminationTimeResponseType * SetTerminationTimeResponse,
296 xsd_any * fault)
297 0 {
298 /* add function local variable declarations here */
299 0 globus_result_t result = GLOBUS_SUCCESS;
300
301 /* initialize trace debugging info */
302 GlobusFuncName(CounterPortType_SetTerminationTime_impl);
303 0 SecureCounterServiceDebugEnter();
304
305 /* This is where it all happens. Service implementer must
306 * implmenent this function. Asume that SetTerminationTime has
307 * been initialized and filled with request values.
308 * SetTerminationTimeResponse must be set by the implementer.
309 */
310
311 0 result = SecureCounterServiceErrorNotImplemented(
312 "CounterPortType_SetTerminationTime_impl");
313
314 0 SecureCounterServiceDebugExit();
315 0 return result;
316 }
317
318
319 globus_result_t
320 CounterPortType_add_impl(
321 globus_service_engine_t engine,
322 globus_soap_message_handle_t message,
323 globus_service_descriptor_t * service,
324 xsd_int * add,
325 xsd_int * addResponse,
326 xsd_any * fault)
327 1 {
328 /* add function local variable declarations here */
329 1 xsd_int * counter_value = NULL;
330 1 globus_soap_message_handle_t memory_message = NULL;
331 1 globus_resource_t resource = NULL;
332 1 globus_result_t result = GLOBUS_SUCCESS;
333
334 /* initialize trace debugging info */
335 GlobusFuncName(CounterPortType_add_impl);
336 1 SecureCounterServiceDebugEnter();
337
338 1 result = globus_wsrf_core_get_resource(
339 message,
340 service,
341 &resource);
342 1 if(result != GLOBUS_SUCCESS)
343 {
344 0 result = CounterPortType_add_chain_error(
345 result,
346 "Failed to get resource from EPR");
347 0 goto exit;
348 }
349
350 1 result = globus_resource_get_property(resource,
351 &counter_Value_qname, (void **)&counter_value, NULL);
352 1 if(result != GLOBUS_SUCCESS)
353 {
354 0 result = CounterPortType_add_chain_error(
355 result,
356 "Failed to get CounterRP resource property from resource");
357 0 goto finish_exit;
358 }
359
360 1 *counter_value += *add;
361 1 *addResponse = *counter_value;
362
363 1 finish_exit:
364 1 globus_resource_finish(resource);
365 1 exit:
366
367 1 if(memory_message)
368 {
369 0 globus_soap_message_handle_destroy(memory_message);
370 }
371
372 1 SecureCounterServiceDebugExit();
373 1 return result;
374 }
375
376 globus_result_t
377 CounterPortType_createCounter_impl(
378 globus_service_engine_t engine,
379 globus_soap_message_handle_t message,
380 globus_service_descriptor_t * service,
381 counter_createCounterType * createCounter,
382 counter_createCounterResponseType * createCounterResponse,
383 xsd_any * fault)
384 1 {
385 /* add function local variable declarations here */
386 xsd_any * counter_key;
387 char * resource_id;
388 xsd_int * counter_value;
389 globus_resource_t resource;
390 char * endpoint;
391 1 globus_result_t result = GLOBUS_SUCCESS;
392
393 /* initialize trace debugging info */
394 GlobusFuncName(CounterPortType_createCounter_impl);
395 1 SecureCounterServiceDebugEnter();
396
397 1 resource_id = globus_common_create_string("%d", random());
398
399 1 globus_resource_create(
400 resource_id, &resource);
401
402 1 memset(createCounterResponse, 0, sizeof(counter_createCounterResponseType));
403
404 1 wsa_ReferenceParametersType_init(
405 &createCounterResponse->EndpointReference.ReferenceParameters);
406
407 1 counter_key = xsd_any_array_push(
408 &createCounterResponse->EndpointReference.ReferenceParameters->any);
409
410 1 counter_key->any_info = &xsd_string_info;
411 1 xsd_QName_init(&counter_key->element);
412 1 counter_key->element->local = globus_libc_strdup("CounterKey");
413 1 counter_key->element->Namespace = globus_libc_strdup(
414 SecureCounterService_service_qname.Namespace);
415 1 xsd_string_init_cstr((xsd_string **)&counter_key->value, resource_id);
416
417 1 globus_service_engine_get_contact(engine, &endpoint);
418
419 1 createCounterResponse->EndpointReference.Address.base_value =
420 globus_common_create_string("%s/%s", endpoint,
421 SECURECOUNTERSERVICE_BASE_PATH);
422
423 1 result = SecureCounterServiceInitResource(
424 &createCounterResponse->EndpointReference);
425 1 if(result != GLOBUS_SUCCESS)
426 {
427 0 result = CounterPortType_add_chain_error(
428 result, "Failed to initialize resource with service");
429 0 goto exit;
430 }
431
432 1 xsd_int_init(&counter_value);
433 1 *counter_value = 0;
434
435 1 result = globus_resource_create_property(
436 resource,
437 &counter_Value_qname,
438 &xsd_int_info, counter_value);
439 1 if(result != GLOBUS_SUCCESS)
440 {
441 0 result = CounterPortType_add_chain_error(
442 result, "Failed to create resource property for CounterRP");
443 0 goto exit;
444 }
445
446 1 exit:
447 1 if (result != GLOBUS_SUCCESS)
448 {
449 0 globus_resource_destroy(resource);
450 }
451 else
452 {
453 1 globus_resource_finish(resource);
454 }
455
456 1 SecureCounterServiceDebugExit();
457 1 return result;