1 /*
2 * Copyright 1999-2006 University of Chicago
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
18 /** @file globus_service_engine_register_session.c Register Service Engine Session
19 */
20
21 #include "globus_i_service_engine.h"
22 #include "globus_i_soap_message.h"
23 #include "globus_xio_tcp_driver.h"
24 #include "globus_xio_gsi.h"
25 #include "globus_xio_http.h"
26 #include "gssapi.h"
27 #include "openssl/rand.h"
28 #include <syslog.h>
29
30 #define SOAP_ACTION_HEADER "SOAPAction"
31 #define CONTENT_TYPE_HEADER "Content-Type"
32
33 static
34 void
35 globus_l_service_engine_accept_callback(
36 globus_xio_server_t server,
37 globus_xio_handle_t new_handle,
38 globus_result_t result,
39 void * arg);
40
41 static
42 void
43 globus_l_service_engine_open_callback(
44 globus_xio_handle_t handle,
45 globus_result_t result,
46 void * arg);
47
48 static
49 globus_result_t
50 globus_l_service_engine_service_module_copy(
51 void ** ne,
52 const void * e);
53
54 static
55 void
56 globus_l_service_engine_service_module_destroy(
57 void * e);
58 #endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */
59
60 /**
61 * Register a new service session
62 * @ingroup globus_service_engine
63 * @internal
64 *
65 * Accepts a new SOAP connection and associates a session with it. When the
66 * session is ready to be processed, the @a callback function is called.
67 *
68 * @param engine
69 * Service engine reference to accept the new session from.
70 * @param callback
71 * Function to call when the session has been accepted.
72 * @param arg
73 * Application-specific parameter to @a callback.
74 *
75 * @retval GLOBUS_SUCCESS
76 * Session accept registered successfully.
77 * @retval GLOBUS_SOAP_MESSAGE_ERROR_TYPE_NULL_PARAM
78 * One of @a engine or @a callback is NULL.
79 * @retval GLOBUS_SOAP_MESSAGE_ERROR_TYPE_FAILED_TRANSPORT
80 * XIO accept failed.
81 *
82 * @see globus_service_engine_register_process()
83 */
84 globus_result_t
85 globus_service_engine_register_session(
86 globus_service_engine_t engine,
87 globus_service_session_callback_func_t
88 callback,
89 void * arg)
90 5389 {
91 5389 globus_i_session_callback_handle_t *callback_handle = NULL;
92 5389 globus_result_t result = GLOBUS_SUCCESS;
93 GlobusFuncName(globus_service_engine_register_session);
94 5389 GlobusServiceEngineDebugEnter();
95
96 5389 if (engine == NULL || callback == NULL)
97 {
98 0 result = GlobusSoapMessageErrorNullParam;
99
100 0 goto out;
101 }
102 5389 callback_handle = calloc(1, sizeof(globus_i_session_callback_handle_t));
103 5389 if(!callback_handle)
104 {
105 0 result = GlobusServiceEngineErrorOutOfMemory;
106
107 0 goto out;
108 }
109
110 5389 callback_handle->callback = callback;
111 5389 callback_handle->args = arg;
112 5389 callback_handle->engine = engine;
113 5389 callback_handle->faulting = GLOBUS_FALSE;
114
115 5389 result = globus_xio_server_register_accept(
116 engine->server,
117 globus_l_service_engine_accept_callback,
118 callback_handle);
119 5389 if(result != GLOBUS_SUCCESS)
120 {
121 0 result = GlobusSoapMessageErrorFailedTransport(
122 result,
123 "XIO Accept failed");
124
125 0 goto free_callback_handle_out;
126 }
127
128 5389 if (result != GLOBUS_SUCCESS)
129 {
130 0 free_callback_handle_out:
131 0 free(callback_handle);
132 }
133 5389 out:
134
135 5389 GlobusServiceEngineDebugExit();
136 5389 return result;
137 }
138 /* globus_service_engine_register_session() */
139
140 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
141 /**
142 * Session accept complete callback
143 *
144 * This callback is called after the XIO accept function has completed.
145 * If successful, an XIO open will be initiated; otherwise, the session
146 * callback will be called with a
147 * GLOBUS_SERVICE_ENGINE_ERROR_TYPE_REQUEST_FAILED error result.
148 *
149 * @param server
150 * XIO server associated with the engine that the new session is being
151 * accepted on.
152 * @param new_handle
153 * New handle created by XIO as a result of the accept. This will be NULL
154 * if the accept failed.
155 * @param result
156 * Result of the accept operation. If not GLOBUS_SUCCESS, the value of
157 * @a new_handle is NULL.
158 * @param arg
159 * The @a globus_i_session_callback_handle_t associated with the new
160 * session.
161 */
162 static
163 void
164 globus_l_service_engine_accept_callback(
165 globus_xio_server_t server,
166 globus_xio_handle_t new_handle,
167 globus_result_t result,
168 void * arg)
169 5372 {
170 5372 char * peer_contact = NULL;
171 globus_xio_attr_t attr;
172 5372 globus_soap_message_handle_t message = NULL;
173 globus_i_session_callback_handle_t *callback_handle;
174 GlobusFuncName(globus_l_service_engine_accept_callback);
175 5372 GlobusServiceEngineDebugEnter();
176
177 5372 callback_handle = arg;
178
179 5372 if(result != GLOBUS_SUCCESS)
180 {
181 286 result = GlobusServiceEngineErrorFailedRequest(result);
182 286 goto out;
183 }
184
185 5086 result = globus_soap_message_handle_init(&message, new_handle);
186 5086 if(result != GLOBUS_SUCCESS)
187 {
188 0 result = GlobusServiceEngineErrorFailedRequest(result);
189 0 goto out;
190 }
191
192 5086 GlobusServiceEngineLock(callback_handle->engine);
193
194 5086 result = globus_soap_message_handle_set_attrs(
195 message,
196 callback_handle->engine->attrs);
197 5086 if(result != GLOBUS_SUCCESS)
198 {
199 0 goto unlock_and_destroy_message_out;
200 }
201 5086 result = globus_soap_message_handle_set_attr(
202 message,
203 GLOBUS_I_SESSION_HANDLE_KEY,
204 NULL,
205 NULL,
206 callback_handle);
207 5086 if(result != GLOBUS_SUCCESS)
208 {
209 0 result = GlobusServiceEngineErrorFailedRequest(result);
210 0 goto unlock_and_destroy_message_out;
211 }
212
213 5086 result = globus_xio_attr_init(&attr);
214 5086 if(result != GLOBUS_SUCCESS)
215 {
216 0 result = GlobusServiceEngineErrorFailedRequest(result);
217 0 goto unlock_and_destroy_message_out;
218 }
219
220 5086 result = globus_xio_handle_cntl(
221 new_handle, globus_i_soap_message_tcp_driver,
222 GLOBUS_XIO_TCP_GET_REMOTE_CONTACT,
223 &peer_contact);
224 5086 if(result != GLOBUS_SUCCESS)
225 {
226 0 result = globus_xio_handle_cntl(
227 new_handle, globus_i_soap_message_tcp_driver,
228 GLOBUS_XIO_TCP_GET_REMOTE_NUMERIC_CONTACT,
229 &peer_contact);
230
231 0 if (result != GLOBUS_SUCCESS)
232 {
233 0 result = GlobusServiceEngineErrorFailedRequest(result);
234 0 goto destroy_attr_out;
235 }
236 }
237 5086 if (callback_handle->engine->logger != NULL)
238 {
239 unsigned char randbytes;
240
241 0 RAND_pseudo_bytes(&randbytes, sizeof(randbytes));
242 0 sprintf(callback_handle->id, "%hu", randbytes);
243
244 0 globus_logging_write(
245 callback_handle->engine->logger,
246 LOG_INFO,
247 "event=globus_service_engine.session.start "
248 "engine_id=%s "
249 "session_id=%s "
250 "client=%s\n",
251 callback_handle->engine->id,
252 callback_handle->id,
253 peer_contact);
254 }
255
256 5086 result = globus_xio_register_open(
257 new_handle, peer_contact, attr,
258 globus_l_service_engine_open_callback, callback_handle);
259 5086 if(result != GLOBUS_SUCCESS)
260 {
261 0 result = GlobusServiceEngineErrorFailedRequest(result);
262 0 goto destroy_attr_out;
263 }
264
265 5086 callback_handle->message = message;
266 5086 GlobusServiceEngineUnlock(callback_handle->engine);
267
268 5086 destroy_attr_out:
269 5086 globus_xio_attr_destroy(attr);
270 5086 if(result != GLOBUS_SUCCESS)
271 {
272 0 unlock_and_destroy_message_out:
273 0 GlobusServiceEngineUnlock(callback_handle->engine);
274 0 globus_soap_message_handle_destroy(message);
275 0 message = NULL;
276
277 286 out:
278 286 callback_handle->callback(result, callback_handle->engine,
279 message, callback_handle->args);
280 286 free(callback_handle);
281 }
282
283 5372 GlobusServiceEngineDebugExit();
284 5372 }
285 /* globus_l_service_engine_accept_callback() */
286
287 /**
288 * Session open callback
289 *
290 * This callback is called after the XIO open function has completed.
291 * If successful, an XIO read will be initiated to retrieve the HTTP headers;
292 * otherwise, the SOAP message handle (and XIO handle) associated with this
293 * session callback will be destroyed and the new session callback will be
294 * called with a * GLOBUS_SERVICE_ENGINE_ERROR_TYPE_REQUEST_FAILED error
295 * result.
296 *
297 * @param handle
298 * XIO handle associated with the session that the new session is being
299 * opened on.
300 * @param result
301 * Result of the open operation.
302 * @param arg
303 * The @a globus_i_session_callback_handle_t associated with the new
304 * session.
305 */
306 static
307 void
308 globus_l_service_engine_open_callback(
309 globus_xio_handle_t handle,
310 globus_result_t result,
311 void * arg)
312 5086 {
313 5086 globus_i_session_callback_handle_t *callback_handle = NULL;
314 static globus_byte_t buffer[1];
315 GlobusFuncName(globus_l_service_engine_open_callback);
316 5086 GlobusServiceEngineDebugEnter();
317
318 5086 callback_handle = arg;
319
320 5086 GlobusServiceEngineLock(callback_handle->engine);
321 5086 if(result == GLOBUS_SUCCESS)
322 {
323 5086 result = globus_i_service_engine_set_identity(callback_handle);
324 5086 if (result != GLOBUS_SUCCESS)
325 {
326 0 goto cleanup;
327 }
328 5086 result = globus_xio_register_read(handle,
329 buffer,
330 0,
331 0,
332 NULL,
333 globus_i_service_engine_request_ready_callback,
334 callback_handle);
335 }
336
337 5086 cleanup:
338 5086 GlobusServiceEngineUnlock(callback_handle->engine);
339
340 5086 if (result != GLOBUS_SUCCESS)
341 {
342 0 globus_soap_message_handle_destroy(callback_handle->message);
343 0 callback_handle->message = NULL;
344 0 callback_handle->callback(
345 result, callback_handle->engine,
346 NULL, callback_handle->args);
347 }
348 5086 GlobusServiceEngineDebugExit();
349 5086 }
350 /* globus_l_service_engine_open_callback() */
351
352 /**
353 * HTTP Header read callback
354 *
355 * This callback is invoked when the HTTP headers are read from an XIO
356 * handle associated with a SOAP message handle for a new session, or for
357 * a secondary read on an existing session when persistent connections are
358 * used. No data is read into the buffer, but the data descriptor has HTTP
359 * request header information associated with it. The service is loaded
360 * if it has not already been so based on the service URI. If this is a new
361 * session, then the register_session callback will be invoked to let the
362 * user decide when to process it; otherwise, it will continue to be processed.
363 *
364 * @param handle
365 * XIO handle associated with the SOAP message handle.
366 * @param result
367 * Result of the read operation.
368 * @param buffer
369 * IGNORED
370 * @param len
371 * IGNORED
372 * @param nbytes
373 * IGNORED
374 * @param data_desc
375 * Data descriptor handle. This will be queried to determine the HTTP
376 * header information.
377 * @param arg
378 * The @a globus_i_session_callback_handle_t associated with the new
379 * session.
380 */
381 void
382 globus_i_service_engine_request_ready_callback(
383 globus_xio_handle_t handle,
384 globus_result_t result,
385 globus_byte_t * buffer,
386 globus_size_t len,
387 globus_size_t nbytes,
388 globus_xio_data_descriptor_t data_desc,
389 void * arg)
390 15096 {
391 15096 globus_xio_http_header_t * soap_action = NULL;
392 15096 globus_xio_http_header_t * content_type = NULL;
393 15096 globus_xio_http_header_t * connection = NULL;
394 15096 char * method = NULL;
395 15096 char * uri = NULL;
396 globus_xio_http_version_t http_version;
397 globus_hashtable_t headers;
398 char * svcinfo;
399
400 15096 globus_i_session_callback_handle_t *callback_handle = arg;
401 GlobusFuncName(globus_i_service_engine_request_ready_callback);
402 15096 GlobusServiceEngineDebugEnter();
403
404 15096 if (result == GLOBUS_SUCCESS)
405 {
406 10102 result = globus_xio_data_descriptor_cntl(
407 data_desc,
408 globus_i_soap_message_http_driver,
409 GLOBUS_XIO_HTTP_GET_REQUEST,
410 &method,
411 &uri,
412 &http_version,
413 &headers);
414 10102 if (callback_handle->engine->logger)
415 {
416 0 globus_logging_write(
417 callback_handle->engine->logger,
418 LOG_INFO,
419 "event=globus_service_engine.process.start "
420 "session_id=%s "
421 "method=%s "
422 "uri=%s\n",
423 callback_handle->id,
424 method ? method : "NULL",
425 uri ? uri : "NULL");
426 }
427 }
428
429 20169 if (method == NULL || result != GLOBUS_SUCCESS)
430 {
431 5073 result = GlobusServiceEngineErrorMethodNotAllowed(method);
432 5073 if (callback_handle->process_callback != NULL)
433 {
434 /* This handle has been used before. Error will be ignored */
435 5073 callback_handle->state = GLOBUS_L_SERVICE_ENGINE_RESPONSE_CLOSE;
436 5073 globus_soap_message_handle_set_attr(
437 callback_handle->message,
438 GLOBUS_SOAP_MESSAGE_CONNECTION_KEY,
439 globus_soap_message_attr_copy_string,
440 globus_libc_free,
441 (void *) "close");
442 }
443 }
444 10023 else if(!strcmp(method, "POST"))
445 {
446 globus_service_descriptor_t * service_desc;
447
448 10023 soap_action = globus_hashtable_lookup(&headers, SOAP_ACTION_HEADER);
449 10023 if(!soap_action)
450 {
451 0 GlobusServiceEngineDebugPrintf(
452 GLOBUS_L_SERVICE_ENGINE_DEBUG_DEBUG,
453 ("Service request: %s does not "
454 "have a SOAPAction header entry\n",
455 uri));
456 }
457
458 10023 content_type = globus_hashtable_lookup(&headers, CONTENT_TYPE_HEADER);
459 10023 if(!content_type || !content_type->value ||
460 !strstr(content_type->value, "text/xml"))
461 {
462 0 result = GlobusServiceEngineErrorUnsupportedMediaType(
463 (content_type && content_type->value)
464 ? content_type->value
465 : "(null)");
466 0 goto exit;
467 }
468 10023 if (http_version != GLOBUS_XIO_HTTP_VERSION_1_0)
469 {
470 /*
471 * Assume persistent connection with HTTP/1.1 unless told
472 * otherwise
473 */
474 10023 connection = globus_hashtable_lookup(
475 &headers,
476 (void *) "Connection");
477 10023 if (connection && connection->value &&
478 strstr(connection->value, "close"))
479 {
480 0 result = globus_soap_message_handle_set_attr(
481 callback_handle->message,
482 GLOBUS_SOAP_MESSAGE_CONNECTION_KEY,
483 globus_soap_message_attr_copy_string,
484 globus_libc_free,
485 (void *) "close");
486
487 0 if (result != GLOBUS_SUCCESS)
488 {
489 0 result = GlobusServiceEngineErrorFailedRequest(result);
490
491 0 goto exit;
492 }
493 }
494 }
495 else
496 {
497 0 result = globus_soap_message_handle_set_attr(
498 callback_handle->message,
499 GLOBUS_SOAP_MESSAGE_CONNECTION_KEY,
500 globus_soap_message_attr_copy_string,
501 globus_libc_free,
502 (void *) "close");
503 }
504 10023 if (result != GLOBUS_SUCCESS)
505 {
506 0 goto exit;
507 }
508
509 10023 result = globus_i_service_engine_get_descriptor(
510 uri,
511 callback_handle->message,
512 &service_desc);
513
514 10023 if (result != GLOBUS_SUCCESS)
515 {
516 2 goto exit;
517 }
518
519 10021 svcinfo = globus_hashtable_lookup(
520 &callback_handle->engine->services,
521 uri);
522 10021 if (!svcinfo)
523 {
524 10021 char prefix[] = "/wsrf/services/";
525
526 10021 if (strncmp(uri, prefix, sizeof(prefix)-1) == 0)
527 {
528 10021 svcinfo = globus_libc_strdup(uri + sizeof(prefix)-1);
529 }
530 else
531 {
532 0 svcinfo = globus_libc_strdup(uri);
533 }
534
535 10021 globus_hashtable_insert(
536 &callback_handle->engine->services,
537 svcinfo,
538 svcinfo);
539 }
540 10021 if(soap_action)
541 {
542 10021 result = globus_soap_message_handle_set_attr(
543 callback_handle->message,
544 GLOBUS_SOAP_MESSAGE_SOAP_ACTION_KEY,
545 globus_soap_message_attr_copy_string,
546 globus_libc_free,
547 (void *)soap_action->value);
548 10021 if(result != GLOBUS_SUCCESS)
549 {
550 0 result = GlobusServiceEngineErrorReadRequestFailed(result);
551 0 goto exit;
552 }
553 }
554 }
555 /* TODO: Add support for GET of svc?WSDL */
556 else
557 {
558 0 result = GlobusServiceEngineErrorMethodNotAllowed(method);
559 0 goto exit;
560 }
561
562 15096 exit:
563 /* Reused handle, call session processing callback, not the new session
564 * callback
565 */
566 15096 if (callback_handle->process_callback)
567 {
568 10010 globus_i_service_session_callback(callback_handle);
569 }
570 else
571 {
572 5086 if(result != GLOBUS_SUCCESS)
573 {
574 2 callback_handle->result = result;
575 2 globus_soap_message_handle_set_attr(
576 callback_handle->message,
577 GLOBUS_SOAP_MESSAGE_CONNECTION_KEY,
578 globus_soap_message_attr_copy_string,
579 globus_libc_free,
580 (void *) "close");
581 }
582
583 /*
584 * Session started callback, which may register a new accept and then
585 * kick off process session for this session
586 */
587 5086 callback_handle->callback(
588 result, callback_handle->engine,
589 callback_handle->message, callback_handle->args);
590 }
591
592 15096 GlobusServiceEngineDebugExit();
593 15096 }
594 /* globus_i_service_engine_request_ready_callback() */
595
596 /**
597 * Get the service descriptor related to an service URI.
598 */
599 globus_result_t
600 globus_i_service_engine_get_descriptor(
601 char * uri,
602 globus_soap_message_handle_t message,
603 globus_service_descriptor_t ** service_desc_p)
604 10023 {
605 10023 globus_result_t result = GLOBUS_SUCCESS;
606 char * uriref;
607 char * service_path;
608 10023 globus_service_descriptor_t * service_desc = NULL;
609 globus_extension_handle_t ext;
610 10023 globus_bool_t free_service_path = GLOBUS_TRUE;
611
612 10023 uriref = uri;
613 30069 while (*uriref == '/')
614 {
615 10023 uriref++;
616 }
617 10023 service_path = globus_common_create_string(
618 GLOBUS_SERVICE_ENGINE_MODULE_PATH_PREFIX "/%s", uriref);
619
620 10023 if (service_path == NULL)
621 {
622 0 result = GlobusSoapMessageErrorOutOfMemory;
623
624 0 goto out;
625 }
626 10023 service_desc = globus_extension_lookup(
627 &ext,
628 GLOBUS_SERVICE_REGISTRY,
629 service_path);
630 10023 if(!service_desc)
631 {
632 int res;
633
634 274 res = globus_extension_activate(service_path);
635
636 274 if(res != GLOBUS_SUCCESS)
637 {
638 2 globus_object_t * tmp_err = globus_error_get((globus_result_t) res);
639 2 if(GlobusServiceEngineDebug(GLOBUS_L_SERVICE_ENGINE_DEBUG_DEBUG))
640 {
641 char * serror = globus_error_print_chain(
642 0 tmp_err);
643 0 GlobusServiceEngineDebugPrintf(
644 GLOBUS_L_SERVICE_ENGINE_DEBUG_DEBUG,
645 ("Module Activation Failed:\n\n%s\n",
646 serror));
647 0 globus_free(serror);
648 }
649
650 2 result = GlobusServiceEngineErrorServiceLoadFailed(uri, tmp_err);
651 2 goto free_service_path_out;
652 }
653
654 272 GlobusServiceEngineExtensionLock();
655 272 globus_list_insert(&globus_i_service_engine_extensions,
656 service_path);
657 272 free_service_path = GLOBUS_FALSE;
658 272 GlobusServiceEngineExtensionUnlock();
659
660 272 service_desc = globus_extension_lookup(
661 &ext,
662 GLOBUS_SERVICE_REGISTRY,
663 service_path);
664 272 if(!service_desc)
665 {
666 0 result = GlobusServiceEngineErrorServiceLoadFailed(uri, NULL);
667 0 goto remove_extension_from_list_out;
668 }
669 }
670
671 10021 result = globus_soap_message_handle_set_attr(
672 message,
673 GLOBUS_SOAP_MESSAGE_SERVICE_ENDPOINT_KEY,
674 globus_soap_message_attr_copy_string,
675 free,
676 uri);
677 10021 if(result != GLOBUS_SUCCESS)
678 {
679 0 result = GlobusServiceEngineErrorReadRequestFailed(result);
680
681 0 goto remove_extension_from_list_out;
682 }
683
684 10021 result = globus_soap_message_handle_set_attr(
685 message,
686 GLOBUS_I_SERVICE_DESCRIPTOR_KEY,
687 globus_l_service_engine_service_module_copy,
688 globus_l_service_engine_service_module_destroy,
689 (void *)ext);
690
691 10021 if(result != GLOBUS_SUCCESS)
692 {
693 globus_list_t * tmp;
694 0 result = GlobusServiceEngineErrorReadRequestFailed(result);
695
696 0 globus_soap_message_handle_remove_attr(
697 message,
698 GLOBUS_SOAP_MESSAGE_SERVICE_ENDPOINT_KEY);
699
700 0 remove_extension_from_list_out:
701 0 GlobusServiceEngineExtensionLock();
702 0 tmp = globus_list_search(globus_i_service_engine_extensions,
703 service_path);
704
705 0 if (tmp != NULL)
706 {
707 0 globus_list_remove(&globus_i_service_engine_extensions, tmp);
708 }
709 0 GlobusServiceEngineExtensionUnlock();
710 0 globus_extension_deactivate(service_path);
711 }
712 10023 free_service_path_out:
713 10023 if (result != GLOBUS_SUCCESS || free_service_path)
714 {
715 9751 free(service_path);
716 }
717 10023 out:
718 10023 *service_desc_p = service_desc;
719
720 10023 return result;
721 }
722 /* globus_i_service_engine_get_descriptor() */
723
724 static
725 globus_result_t
726 globus_l_service_engine_service_module_copy(
727 void ** ne,
728 const void * e)
729 10021 {
730 10021 globus_extension_reference((globus_extension_handle_t)e);
731 10021 *ne = (void *) e;
732 10021 return GLOBUS_SUCCESS;
733 }
734
735 static
736 void
737 globus_l_service_engine_service_module_destroy(
738 void * e)
739 10021 {
740 10021 globus_extension_release((globus_extension_handle_t)e);
741 10021 }
742
743 /**
744 * Set the peer identity attribute
745 *
746 * If the message associated with the callback_handle is transported over
747 * https, look up the identity of the peer in the XIO handle and set the
748 * GLOBUS_SOAP_MESSAGE_PEER_IDENTITY_KEY attribute to that value
749 */
750 globus_result_t
751 globus_i_service_engine_set_identity(
752 globus_i_session_callback_handle_t *callback_handle)
753 15107 {
754 15107 globus_result_t result = GLOBUS_SUCCESS;
755
756 15107 if (callback_handle->engine->https)
757 {
758 6745 gss_name_t peer_name = NULL;
759
760 /* Set Security attribute related to our peer */
761 6745 result = globus_xio_handle_cntl(
762 callback_handle->message->xio_handle,
763 globus_i_soap_message_gsi_driver,
764 GLOBUS_XIO_GSI_GET_PEER_NAME,
765 &peer_name);
766
767 6745 if (result != GLOBUS_SUCCESS)
768 {
769 0 goto out;
770 }
771 6745 result = globus_soap_message_handle_set_attr(
772 callback_handle->message,
773 GLOBUS_SOAP_MESSAGE_PEER_IDENTITY_KEY,
774 NULL,
775 NULL,
776 (void *) peer_name);
777 if (result != GLOBUS_SUCCESS)
778 {
779 6745 goto out;
780 }
781 }
782 15107 out:
783 15107 return result;
784 }
785 /* globus_i_service_engine_set_identity() */
786
787