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
19 #include "globus_common.h"
20 #include "globus_i_wsrf_options.h"
21 #include "globus_wsrf_core_tools.h"
22 #include "gssapi.h"
23 #include "globus_error_gssapi.h"
24 #include "version.h"
25
26 #ifndef GSS_IMPEXP_MECH_SPECIFIC
27 #define GSS_IMPEXP_MECH_SPECIFIC 1
28 #endif
29 #ifndef GSS_IMPEXP_OPAQUE_FORM
30 #define GSS_IMPEXP_OPAQUE_FORM 0
31 #endif
32
33 static
34 globus_result_t
35 globus_l_wsrf_options_set_anonymous(
36     globus_options_handle_t             opts_handle,
37     char *                              cmd,
38     char *                              param[],
39     void *                              arg,
40     int *                               out_params_used)
41 0 {
42 0     globus_result_t                     result;
43 0     globus_i_wsrf_options_handle_t *    options = arg;
44
45 0     result = globus_soap_message_attr_set(
46             options->attr,
47             GLOBUS_SOAP_MESSAGE_AUTH_ANONYMOUS_KEY,
48             NULL,
49             NULL,
50             (void *) 1);
51     
52 0     return result;
53 }
54 /* globus_l_wsrf_options_set_anonymous() */
55
56 #if 0
57 static
58 globus_result_t
59 globus_l_wsrf_options_set_server_certificate(
60     globus_options_handle_t             opts_handle,
61     char *                              cmd,
62     char *                              param[],
63     void *                              arg,
64     int *                               out_params_used)
65 {
66     return GLOBUS_FAILURE;
67 }
68 /* globus_l_wsrf_options_set_server_certificate() */
69 #endif
70
71 static
72 globus_result_t
73 globus_l_wsrf_options_set_debug(
74     globus_options_handle_t             opts_handle,
75     char *                              cmd,
76     char *                              param[],
77     void *                              arg,
78     int *                               out_params_used)
79 0 {
80 0     globus_i_wsrf_options_handle_t *    options = arg;
81
82 0     options->debug = GLOBUS_TRUE;
83 #ifdef BUILD_DEBUG
84 0     globus_i_GLOBUS_SOAP_MESSAGE_debug_handle.levels |= GLOBUS_SOAP_MESSAGE_DEBUG_MESSAGES;
85 #endif
86
87 0     return GLOBUS_SUCCESS;
88 }
89 /* globus_l_wsrf_options_set_debug() */
90
91 static
92 globus_result_t
93 globus_l_wsrf_options_set_epr(
94     globus_options_handle_t             opts_handle,
95     char *                              cmd,
96     char *                              param[],
97     void *                              arg,
98     int *                               out_params_used)
99 0 {
100 0     globus_i_wsrf_options_handle_t *    options = arg;
101 0     globus_result_t                     result;
102
103 0     if (options->epr)
104     {
105 0         wsa_EndpointReferenceType_destroy(options->epr);
106     }
107 0     result = globus_wsrf_core_import_endpoint_reference(
108             param[0],
109             &options->epr,
110             NULL);
111
112 0     return result;
113 }
114 /* globus_l_wsrf_options_set_epr() */
115
116 #if 0
117 static
118 globus_result_t
119 globus_l_wsrf_options_set_descriptor(
120     globus_options_handle_t             opts_handle,
121     char *                              cmd,
122     char *                              param[],
123     void *                              arg,
124     int *                               out_params_used)
125 {
126     return GLOBUS_FAILURE;
127 }
128 /* globus_l_wsrf_options_set_descriptor() */
129 #endif
130
131 #if 0
132 static
133 globus_result_t
134 globus_l_wsrf_options_set_delegation(
135     globus_options_handle_t             opts_handle,
136     char *                              cmd,
137     char *                              param[],
138     void *                              arg,
139     int *                               out_params_used)
140 {
141     return GLOBUS_FAILURE;
142 }
143 /* globus_l_wsrf_options_set_delegation() */
144 #endif
145
146 static
147 globus_result_t
148 globus_l_wsrf_options_set_help(
149     globus_options_handle_t             opts_handle,
150     char *                              cmd,
151     char *                              param[],
152     void *                              arg,
153     int *                               out_params_used)
154 0 {
155 0     globus_i_wsrf_options_handle_t *    options = arg;
156 0     const char *                        tmp;
157
158 0     if (options->application_name)
159     {
160 0         tmp = strrchr(options->application_name, '/');
161 0         tmp = tmp ? tmp+1 : options->application_name;
162     }
163     else
164     {
165 0         tmp = "globus_wsrf_core_tools";
166     }
167 0     if (options->usage)
168     {
169 0         printf("Usage: %s %s\nOptions:\n", tmp, options->usage);
170     }
171 0     globus_options_help(opts_handle);
172
173 0     if (options->post_banner)
174     {
175 0         printf("\n%s\n", options->post_banner);
176     }
177 0     return globus_error_put(globus_error_construct_error(
178         NULL,
179         NULL,
180         GLOBUS_OPTIONS_HELP,
181         __FILE__,
182         "globus_l_wsrf_options_help",
183         __LINE__,
184         "Help"));
185 }
186 /* globus_l_wsrf_options_set_help() */
187
188 static
189 globus_result_t
190 globus_l_wsrf_options_set_usage(
191     globus_options_handle_t             opts_handle,
192     char *                              cmd,
193     char *                              param[],
194     void *                              arg,
195     int *                               out_params_used)
196 0 {
197 0     globus_i_wsrf_options_handle_t *    options = arg;
198 0     const char *                        tmp;
199
200 0     if (options->application_name)
201     {
202 0         tmp = strrchr(options->application_name, '/');
203 0         tmp = tmp ? tmp+1 : options->application_name;
204     }
205     else
206     {
207 0         tmp = "globus_wsrf_core_tools";
208     }
209 0     if (options->usage)
210     {
211 0         printf("Usage: %s %s\n", tmp, options->usage);
212     }
213 0     return globus_error_put(globus_error_construct_error(
214         NULL,
215         NULL,
216         GLOBUS_OPTIONS_HELP,
217         __FILE__,
218         "globus_l_wsrf_options_usage",
219         __LINE__,
220         "usage"));
221 }
222 /* globus_l_wsrf_options_set_usage() */
223
224 static
225 globus_result_t
226 globus_l_wsrf_options_set_key(
227     globus_options_handle_t             opts_handle,
228     char *                              cmd,
229     char *                              param[],
230     void *                              arg,
231     int *                               out_params_used)
232 0 {
233 0     globus_i_wsrf_options_handle_t *    options = arg;
234 0     char *                              tmp;
235 0     globus_result_t                     result;
236 0     char *                              key = param[0];
237 0     xsd_any *                           any;
238 0     xsd_string *                        val;
239
240 0     if (options->epr && options->epr->ReferenceProperties)
241     {
242 0         wsa_ReferencePropertiesType_destroy(options->epr->ReferenceProperties);
243     }
244 0     else if (!options->epr)
245     {
246 0         result = wsa_EndpointReferenceType_init(&options->epr);
247
248 0         if (result != GLOBUS_SUCCESS)
249         {
250 0             goto out;
251         }
252     }
253 0     result = wsa_ReferencePropertiesType_init(&options->epr->ReferenceProperties);
254 0     if (result != GLOBUS_SUCCESS)
255     {
256 0         goto out;
257     }
258
259 0     any = xsd_any_array_push(&options->epr->ReferenceProperties->any);
260
261 0     if (!any)
262     {
263 0         result = GlobusSoapMessageErrorOutOfMemory;
264
265 0         goto out;
266     }
267
268 0     result = xsd_QName_init(&any->element);
269
270 0     if (result != GLOBUS_SUCCESS)
271     {
272 0         goto out;
273     }
274
275 0     if (key[0] == '{' && ((tmp = strchr(key, '}')) != NULL))
276     {
277 0         *tmp = '\0';
278         /* key is a QName in {Namespace}local form */
279 0         any->element->Namespace = globus_libc_strdup(key+1);
280 0         if (any->element->Namespace == NULL)
281         {
282 0             result = GlobusSoapMessageErrorOutOfMemory;
283
284 0             goto out;
285         }
286
287 0         any->element->local = globus_libc_strdup(tmp+1);
288 0         if (any->element->local == NULL)
289         {
290 0             result = GlobusSoapMessageErrorOutOfMemory;
291
292 0             goto out;
293         }
294     }
295     else
296     {
297 0         any->element->Namespace = NULL;
298 0         any->element->local = globus_libc_strdup(key);;
299 0         if (any->element->local == NULL)
300         {
301 0             result = GlobusSoapMessageErrorOutOfMemory;
302
303 0             goto out;
304         }
305     }
306 0     any->any_info = &xsd_string_info;
307 0     result = xsd_string_init(&val);
308 0     if (result != GLOBUS_SUCCESS)
309     {
310 0         goto out;
311     }
312 0     any->value = val;
313 0     result = xsd_string_copy_contents(
314             val,
315             &param[1]);
316 0     if (result != GLOBUS_SUCCESS)
317     {
318 0         goto out;
319     }
320
321 out:
322 0     return result;
323 }
324 /* globus_l_wsrf_options_set_key() */
325
326 #if 0
327 static
328 globus_result_t
329 globus_l_wsrf_options_set_context_lifetime(
330     globus_options_handle_t             opts_handle,
331     char *                              cmd,
332     char *                              param[],
333     void *                              arg,
334     int *                               out_params_used)
335 {
336     return GLOBUS_FAILURE;
337 }
338 /* globus_l_wsrf_options_set_context_lifetime() */
339 #endif
340
341 static
342 globus_result_t
343 globus_l_wsrf_options_set_security_mech(
344     globus_options_handle_t             opts_handle,
345     char *                              cmd,
346     char *                              param[],
347     void *                              arg,
348     int *                               out_params_used)
349 0 {
350 0     globus_i_wsrf_options_handle_t *    options = arg;
351 0     globus_result_t                     result;
352
353 0     if (strcmp(param[0], "msg") == 0)
354     {
355 0         result = globus_soap_message_attr_set(
356                 options->attr,
357                 GLOBUS_SOAP_MESSAGE_AUTHENTICATION_METHOD_KEY,
358                 NULL,
359                 NULL,
360                 (void *) GLOBUS_SOAP_MESSAGE_AUTH_SECURE_MESSAGE);
361     }
362 0     else if (strcmp(param[0], "conv") == 0)
363     {
364 0         result = globus_soap_message_attr_set(
365                 options->attr,
366                 GLOBUS_SOAP_MESSAGE_AUTH_PROTECTION_KEY,
367                 NULL,
368                 NULL,
369                 (void *) GLOBUS_SOAP_MESSAGE_AUTH_SECURE_CONVERSATION);
370     }
371     else
372     {
373 0         result = globus_error_put(globus_error_construct_error(
374             NULL,
375             NULL,
376             GLOBUS_OPTIONS_INVALID_PARAMETER,
377             __FILE__,
378             "globus_l_wsrf_options_set_security_mech",
379             __LINE__,
380             "Unknown security mechanism %s.",
381             param[0]));
382     }
383 0     return GLOBUS_SUCCESS;
384 }
385 /* globus_l_wsrf_options_set_security_mech() */
386
387 static
388 globus_result_t
389 globus_l_wsrf_options_set_protection(
390     globus_options_handle_t             opts_handle,
391     char *                              cmd,
392     char *                              param[],
393     void *                              arg,
394     int *                               out_params_used)
395 0 {
396 0     globus_i_wsrf_options_handle_t *    options = arg;
397 0     globus_result_t                     result;
398
399 0     if (strcmp(param[0], "sig") == 0)
400     {
401 0         result = globus_soap_message_attr_set(
402                 options->attr,
403                 GLOBUS_SOAP_MESSAGE_AUTH_PROTECTION_KEY,
404                 NULL,
405                 NULL,
406                 (void *) GLOBUS_SOAP_MESSAGE_AUTH_PROTECTION_INTEGRITY);
407     }
408 0     else if (strcmp(param[0], "enc") == 0)
409     {
410 0         result = globus_soap_message_attr_set(
411                 options->attr,
412                 GLOBUS_SOAP_MESSAGE_AUTH_PROTECTION_KEY,
413                 NULL,
414                 NULL,
415                 (void *) GLOBUS_SOAP_MESSAGE_AUTH_PROTECTION_PRIVACY);
416     }
417     else
418     {
419 0         return GLOBUS_FAILURE;
420     }
421 0     return GLOBUS_SUCCESS;
422 }
423 /* globus_l_wsrf_options_set_protection() */
424
425 static
426 globus_result_t
427 globus_l_wsrf_options_set_service(
428     globus_options_handle_t             opts_handle,
429     char *                              cmd,
430     char *                              param[],
431     void *                              arg,
432     int *                               out_params_used)
433 0 {
434 0     globus_i_wsrf_options_handle_t *    options = arg;
435 0     globus_result_t                     result;
436
437 0     if (options->epr && options->epr->Address.base_value)
438     {
439 0         wsa_AttributedURI_destroy(&options->epr->Address);
440     }
441 0     else if (!options->epr)
442     {
443 0         result = wsa_EndpointReferenceType_init(&options->epr);
444
445 0         if (result != GLOBUS_SUCCESS)
446         {
447 0             goto out;
448         }
449     }
450 0     result = xsd_anyURI_copy_contents(
451             &options->epr->Address.base_value,
452             param);
453
454 out:
455 0     return result;
456 }
457 /* globus_l_wsrf_options_set_service() */
458
459 static
460 globus_result_t
461 globus_l_reltime_copy(
462     void **                             new_attr,
463     const void *                        attr)
464 0 {
465 0     *new_attr = malloc(sizeof(globus_reltime_t));
466
467 0     memcpy(*new_attr, attr, sizeof(globus_reltime_t));
468
469 0     return GLOBUS_SUCCESS;
470 }
471 /* globus_l_reltime_copy() */
472
473 static
474 globus_result_t
475 globus_l_wsrf_options_set_timeout(
476     globus_options_handle_t             opts_handle,
477     char *                              cmd,
478     char *                              param[],
479     void *                              arg,
480     int *                               out_params_used)
481 0 {
482 0     globus_i_wsrf_options_handle_t *    options = arg;
483 0     globus_reltime_t                    timeout;
484 0     globus_result_t                     result;
485
486 0     timeout.tv_sec = atoi(param[0]);
487 0     timeout.tv_usec = 0;
488
489 0     result = globus_soap_message_attr_set(
490             options->attr,
491             GLOBUS_SOAP_MESSAGE_TIMEOUT_KEY,
492             globus_l_reltime_copy,
493             free,
494             &timeout);
495
496 0     return result;
497 }
498 /* globus_l_wsrf_options_set_timeout() */
499
500 static
501 globus_result_t
502 globus_l_wsrf_options_set_cert_key_files(
503     globus_options_handle_t             opts_handle,
504     char *                              cmd,
505     char *                              param[],
506     void *                              arg,
507     int *                               out_params_used)
508 0 {
509 0     globus_i_wsrf_options_handle_t *    options = arg;
510 0     char *                              b;
511 0     FILE *                              cert_in;
512 0     FILE *                              key_in;
513 0     size_t                              cert_size;
514 0     size_t                              key_size;
515 0     int                                 rc;
516 0     globus_result_t                     result;
517 0     gss_cred_id_t                       cred;
518 0     OM_uint32                           maj_stat;
519 0     OM_uint32                           min_stat;
520 0     gss_buffer_desc                     import_buffer;
521
522 0     cert_in = fopen(param[0], "r");
523 0     if (cert_in == NULL)
524     {
525 0         result = globus_error_put(globus_error_construct_error(
526             NULL,
527             NULL,
528             GLOBUS_OPTIONS_INVALID_PARAMETER,
529             __FILE__,
530             "globus_l_wsrf_options_set_cert_key_files",
531             __LINE__,
532             "Unable to open cert file %s for reading.",
533             param[0]));
534
535 0         goto out;
536     }
537
538 0     if (fseek(cert_in, 0, SEEK_END) != 0)
539     {
540 0         result = globus_error_put(globus_error_construct_error(
541             NULL,
542             NULL,
543             GLOBUS_OPTIONS_INVALID_PARAMETER,
544             __FILE__,
545             "globus_l_wsrf_options_set_cert_key_files",
546             __LINE__,
547             "Unable to seek cert file %s.",
548             param[0]));
549 0         goto close_cert_out;
550     }
551 0     cert_size = ftell(cert_in);
552 0     rewind(cert_in);
553
554 0     key_in = fopen(param[1], "r");
555 0     if (key_in == NULL)
556     {
557 0         result = globus_error_put(globus_error_construct_error(
558             NULL,
559             NULL,
560             GLOBUS_OPTIONS_INVALID_PARAMETER,
561             __FILE__,
562             "globus_l_wsrf_options_set_cert_key_files",
563             __LINE__,
564             "Unable to open key file %s for reading.",
565             param[1]));
566 0         goto close_cert_out;
567     }
568
569 0     if (fseek(key_in, 0, SEEK_END) != 0)
570     {
571 0         result = globus_error_put(globus_error_construct_error(
572             NULL,
573             NULL,
574             GLOBUS_OPTIONS_INVALID_PARAMETER,
575             __FILE__,
576             "globus_l_wsrf_options_set_cert_key_files",
577             __LINE__,
578             "Unable to seek key file %s.",
579             param[1]));
580
581 0         goto close_key_file_out;
582     }
583 0     key_size = ftell(key_in);
584 0     rewind(key_in);
585
586 0     b = malloc(cert_size+key_size+2);
587 0     if (!b)
588     {
589 0         result = GlobusSoapMessageErrorOutOfMemory;
590
591 0         goto close_key_file_out;
592     }
593 0     rc = fread(b, 1, cert_size, cert_in);
594 0     b[rc++] = '\n';
595 0     rc += fread(b+rc, 1, key_size, key_in);
596 0     b[rc++] = '\0';
597
598 0     import_buffer.value = b;
599
600 0     import_buffer.length = strlen(b);
601
602 0     maj_stat = gss_import_cred(
603             &min_stat,
604             &cred,
605             GSS_C_NO_OID,
606             GSS_IMPEXP_OPAQUE_FORM,
607             &import_buffer,
608             0,
609             NULL);
610 0     if (maj_stat != GSS_S_COMPLETE)
611     {
612 0         result = globus_error_put(
613                 globus_error_construct_gssapi_error(NULL, NULL, maj_stat, min_stat));
614 0         goto free_import_buffer_out;
615
616     }
617
618     /* This will leak the cred because there is no cred copy function */
619 0     result = globus_soap_message_attr_set(
620             options->attr,
621             GLOBUS_SOAP_MESSAGE_USER_CREDENTIAL_KEY,
622             NULL,
623             NULL,
624             cred);
625
626 free_import_buffer_out:
627 0     free(import_buffer.value);
628 close_key_file_out:
629 0     fclose(key_in);
630 close_cert_out:
631 0     fclose(cert_in);
632 out:
633 0     return result;
634 }
635 /* globus_l_wsrf_options_set_cert_key_files() */
636
637 static
638 globus_result_t
639 globus_l_wsrf_options_set_proxy_file_name(
640     globus_options_handle_t             opts_handle,
641     char *                              cmd,
642     char *                              param[],
643     void *                              arg,
644     int *                               out_params_used)
645 0 {
646 0     globus_i_wsrf_options_handle_t *    options = arg;
647 0     globus_result_t                     result;
648 0     gss_cred_id_t                       cred;
649 0     OM_uint32                           maj_stat;
650 0     OM_uint32                           min_stat;
651 0     gss_buffer_desc                     import_buffer;
652
653 0     import_buffer.value = globus_common_create_string(
654             "X509_USER_PROXY=%s",
655             param[0]);
656 0     if (import_buffer.value == NULL)
657     {
658 0         result = GlobusSoapMessageErrorOutOfMemory;
659
660 0         goto out;
661     }
662 0     import_buffer.length = strlen(import_buffer.value);
663
664 0     maj_stat = gss_import_cred(
665             &min_stat,
666             &cred,
667             GSS_C_NO_OID,
668             GSS_IMPEXP_MECH_SPECIFIC,
669             &import_buffer,
670             0,
671             NULL);
672 0     if (maj_stat != GSS_S_COMPLETE)
673     {
674 0         result = globus_error_put(
675                 globus_error_construct_gssapi_error(NULL, NULL, maj_stat, min_stat));
676 0         goto free_import_buffer_out;
677
678     }
679
680     /* This will leak the cred because there is no cred copy function */
681 0     result = globus_soap_message_attr_set(
682             options->attr,
683             GLOBUS_SOAP_MESSAGE_USER_CREDENTIAL_KEY,
684             NULL,
685             NULL,
686             cred);
687
688 free_import_buffer_out:
689 0     free(import_buffer.value);
690 out:
691 0     return result;
692 }
693 /* globus_l_wsrf_options_set_proxy_file_name() */
694
695 static
696 globus_result_t
697 globus_l_wsrf_options_set_authorization(
698     globus_options_handle_t             opts_handle,
699     char *                              cmd,
700     char *                              param[],
701     void *                              arg,
702     int *                               out_params_used)
703 0 {
704 0     globus_i_wsrf_options_handle_t *    options = arg;
705 0     globus_result_t                     result;
706
707 0     if (strcmp(param[0], "self") == 0)
708     {
709 0         result = globus_soap_message_attr_set(
710                 options->attr,
711                 GLOBUS_SOAP_MESSAGE_AUTHZ_METHOD_KEY,
712                 NULL,
713                 NULL,
714                 (void *) GLOBUS_SOAP_MESSAGE_AUTHZ_SELF);
715     }
716 0     else if (strcmp(param[0], "host") == 0)
717     {
718 0         result = globus_soap_message_attr_set(
719                 options->attr,
720                 GLOBUS_SOAP_MESSAGE_AUTHZ_METHOD_KEY,
721                 NULL,
722                 NULL,
723                 (void *) GLOBUS_SOAP_MESSAGE_AUTHZ_HOST);
724     }
725 0     else if (strcmp(param[0], "none") == 0)
726     {
727 0         result = globus_soap_message_attr_set(
728                 options->attr,
729                 GLOBUS_SOAP_MESSAGE_AUTHZ_METHOD_KEY,
730                 NULL,
731                 NULL,
732                 (void *) GLOBUS_SOAP_MESSAGE_AUTHZ_NONE);
733     }
734     else
735     {
736 0         gss_buffer_desc buff;
737 0         gss_name_t name;
738 0         OM_uint32 min_stat;
739 0         OM_uint32 maj_stat;
740
741         /* Subject */
742 0         result = globus_soap_message_attr_set(
743                 options->attr,
744                 GLOBUS_SOAP_MESSAGE_AUTHZ_METHOD_KEY,
745                 NULL,
746                 NULL,
747                 (void *) GLOBUS_SOAP_MESSAGE_AUTHZ_IDENTITY);
748
749 0         buff.value = param;
750 0         buff.length = strlen(buff.value);
751
752 0         maj_stat = gss_import_name(
753                 &min_stat,
754                 &buff,
755                 GSS_C_NO_OID,
756                 &name);
757
758 0         result = globus_soap_message_attr_set(
759                 options->attr,
760                 GLOBUS_SOAP_MESSAGE_AUTHZ_TARGET_NAME_KEY,
761                 NULL,
762                 NULL,
763                 name);
764
765     }
766
767 0     return GLOBUS_SUCCESS;
768 }
769 /* globus_l_wsrf_options_set_authorization() */
770
771 static
772 globus_result_t
773 globus_l_wsrf_options_set_version(
774     globus_options_handle_t             opts_handle,
775     char *                              cmd,
776     char *                              param[],
777     void *                              arg,
778     int *                               out_params_used)
779 0 {
780 0     globus_i_wsrf_options_handle_t *    options = arg;
781 0     const char *                        tmp;
782 0     const globus_version_t *            version;
783
784 0     if (options->application_name)
785     {
786 0         tmp = strrchr(options->application_name,'/');
787 0         tmp = tmp ? tmp+1 : options->application_name;
788     }
789     else
790     {
791 0         tmp = "globus_wsrf_core_tools";
792     }
793
794 0     if (options->application_version)
795     {
796 0         version = options->application_version;
797     }
798     else
799     {
800 0         version = &local_version;
801     }
802
803 0     globus_version_print(
804             tmp,
805             version,
806             stdout,
807             1);
808
809 0     return globus_error_put(globus_error_construct_error(
810         NULL,
811         NULL,
812         GLOBUS_OPTIONS_HELP,
813         __FILE__,
814         "globus_l_wsrf_options_set_version",
815         __LINE__,
816         "Program versions"));
817 }
818 /* globus_l_wsrf_options_set_version() */
819
820 static
821 globus_result_t
822 globus_l_wsrf_options_set_versions(
823     globus_options_handle_t             opts_handle,
824     char *                              cmd,
825     char *                              param[],
826     void *                              arg,
827     int *                               out_params_used)
828 0 {
829 0     globus_module_print_activated_versions(
830             stdout,
831             1);
832
833 0     return globus_error_put(globus_error_construct_error(
834         NULL,
835         NULL,
836         GLOBUS_OPTIONS_HELP,
837         __FILE__,
838         "globus_l_wsrf_options_set_versions",
839         __LINE__,
840         "Program versions"));
841
842 }
843 /* globus_l_wsrf_options_set_versions() */
844 #endif /* GLOBUS_DONT_DOCUMENT_INTERNAL */
845
846 /**
847  * @page globus_wsrf_options_options Common WSRF Client Options
848  *
849  * @ingroup globus_wsrf_options
850  * <pre>
851  * -a | --anonymous            Use anonymous authentication. Requires either -m
852  *                             'conv' or transport (https) security.
853  * -d | --debug                Enable debug mode
854  * -e | --eprFile FILENAME     Load service EPR from FILENAME
855  * -h | --help                 Print this help message.
856  * -k | --key KEYNAME VALUE    Set resource key in service EPR to be named
857  *                             KEYNAME with VALUE as its value.
858  * -m | --securityMech TYPE    Set authentication mechanism. TYPE is one of
859  *                             'msg' for WS-SecureMessage or 'conv' for
860  *                             WS-SecureConversation.
861  * -p | --protection LEVEL     Set message protection level. LEVEL is one of
862  *                             'sig' for digital signature or 'enc' for
863  *                             encryption.
864  * -s | --service ENDPOINT     Set ENDPOINT the service URL to use.
865  * -t | --timeout SECONDS      Set client timeout to SECONDS.
866  * -u | --usage                Print short usage message.
867  * -V | --version              Show version information and exit.
868  * -v | --certKeyFiles CERTIFICATE-FILENAME KEY-FILENAME
869  *                             Use credentials located in CERTIFICATE-FILENAME
870  *                             and KEY-FILENAME. The key file must be
871  *                             unencrypted.
872  * -x | --proxyFilename FILENAME
873  *                             Use proxy credentials located in FILENAME
874  * -z | --authorization TYPE   Set authorization mode. TYPE can be 'self',
875  *                             'host', 'none', or a string specifying the
876  *                             identity of the remote party.
877  * --versions                  Show version information for all loaded modules
878  *                             and exit.
879  * </pre>
880  */
881 #ifndef GLOBUS_DONT_DOCUMENT_INTERNAL
882 globus_options_entry_t
883 globus_i_wsrf_common_options_table[] =
884 {
885     {
886         "anonymous",
887         "a",
888         NULL,
889         NULL,
890         "Use anonymous authentication. Requires either -m 'conv' or transport (https) "
891             "security.",
892         0,
893         globus_l_wsrf_options_set_anonymous
894     },
895 #if 0
896     {
897         "serviceCertificate",
898         "c",
899         NULL,
900         "FILENAME",
901         "Use server's certificate located in FILENAME for encryption with GSI Secure "
902             "Message",
903         1,
904         globus_l_wsrf_options_set_server_certificate
905     },
906 #endif
907     {
908         "debug",
909         "d",
910         NULL,
911         NULL,
912         "Enable debug mode",
913         0,
914         globus_l_wsrf_options_set_debug
915     },
916     {
917         "eprFile",
918         "e",
919         NULL,
920         "FILENAME",
921         "Load service EPR from FILENAME",
922         1,
923         globus_l_wsrf_options_set_epr
924     },
925 #if 0
926     {
927         "descriptor",
928         "f",
929         NULL,
930         "FILENAME",
931         "Read client security descriptor from FILENAME",
932         1,
933         globus_l_wsrf_options_set_descriptor
934     },
935 #endif
936 #if 0
937     {
938         "delegation",
939         "g",
940         NULL,
941         "MODE",
942         "Delegate credentials to service. MODE can be either 'limited' or 'full'. "
943         "Requires -m 'conv' option.",
944         1,
945         globus_l_wsrf_options_set_delegation
946     },
947 #endif
948     {
949         "help",
950         "h",
951         NULL,
952         NULL,
953         "Print this help message.",
954         0,
955         globus_l_wsrf_options_set_help
956     },
957     {
958         "usage",
959         "u",
960         NULL,
961         NULL,
962         "Print short usage message.",
963         0,
964         globus_l_wsrf_options_set_usage
965     },
966     {
967         "key",
968         "k",
969         NULL,
970         "KEYNAME VALUE",
971         "Set resource key in service EPR to be named KEYNAME with VALUE as its value.",
972         2,
973         globus_l_wsrf_options_set_key
974     },
975 #if 0
976     {
977         "contextLifetime",
978         "l",
979         NULL,
980         "SECONDS?",
981         "Set lifetime of GSI security context.",
982         1,
983         globus_l_wsrf_options_set_context_lifetime
984     },
985 #endif
986     {
987         "securityMech",
988         "m",
989         NULL,
990         "TYPE",
991         "Set authentication mechanism. TYPE is one of 'msg' for WS-SecureMessage or "
992         "'conv' for WS-SecureConversation.",
993         1,
994         globus_l_wsrf_options_set_security_mech
995     },
996     {
997         "protection",
998         "p",
999         NULL,
1000         "LEVEL",
1001         "Set message protection level. LEVEL is one of 'sig' for digital signature or "
1002         "'enc' for encryption. The default is 'sig'.",
1003         1,
1004         globus_l_wsrf_options_set_protection
1005     },
1006     {
1007         "service",
1008         "s",
1009         NULL,
1010         "ENDPOINT",
1011         "Set ENDPOINT the service URL to use.",
1012         1,
1013         globus_l_wsrf_options_set_service
1014     },
1015     {
1016         "timeout",
1017         "t",
1018         NULL,
1019         "SECONDS",
1020         "Set client timeout to SECONDS.",
1021         1,
1022         globus_l_wsrf_options_set_timeout
1023     },
1024     {
1025         "certKeyFiles",
1026         "v",
1027         NULL,
1028         "CERTIFICATE-FILENAME KEY-FILENAME",
1029         "Use credentials located in CERTIFICATE-FILENAME and KEY-FILENAME. The key file "
1030         "must be unencrypted.",
1031         2,
1032         globus_l_wsrf_options_set_cert_key_files
1033     },
1034     {
1035         "proxyFilename",
1036         "x",
1037         NULL,
1038         "FILENAME",
1039         "Use proxy credentials located in FILENAME",
1040         1,
1041         globus_l_wsrf_options_set_proxy_file_name
1042     },
1043     {
1044         "authorization",
1045         "z",
1046         NULL,
1047         "TYPE",
1048         "Set authorization mode. TYPE can be 'self', 'host', 'none', or a string "
1049         "specifying the identity of the remote party. The default is 'self'.",
1050         1,
1051         globus_l_wsrf_options_set_authorization
1052     },
1053     {
1054         "version",
1055         "V",
1056         NULL,
1057         NULL,
1058         "Show version information and exit.",
1059         0,
1060         globus_l_wsrf_options_set_version
1061     },
1062     {
1063         "versions",
1064         NULL,
1065         NULL,
1066         NULL,
1067         "Show version information for all loaded modules and exit.",
1068         0,
1069         globus_l_wsrf_options_set_versions
1070     },
1071     GLOBUS_OPTIONS_END
1072 };