7 #include "gssapi_utils.h"
10 gss_construct_sec_context(
12 gss_cred_id_t unused_cred_handle,
13 gss_ctx_id_t *context_handle,
14 gss_name_t target_name,
18 gss_channel_bindings_t unused_input_chan_bindings)
20 gss_buffer_desc input_token;
21 gss_OID actual_mech_type;
22 gss_buffer_desc output_token;
26 gss_cred_id_t cred_handle = GSS_C_NO_CREDENTIAL;
27 gss_channel_bindings_t input_chan_bindings = GSS_C_NO_CHANNEL_BINDINGS;
29 /* Setup - input validation */
32 /* nothing much to be done here */
33 return(GSS_S_CALL_INACCESSIBLE_WRITE);
36 if (target_name == NULL)
38 /* Kinda hard to do any meaningful processing here ... */
39 status->major = GSS_S_CALL_INACCESSIBLE_READ;
46 gss_buffer_desc printable;
49 maj = gss_display_name(&min, target_name, &printable, &nametype);
51 fprintf(stderr, "target_name:\n");
52 fprintf(stderr, " value: %s\n", (char *)(printable.value) );
53 fprintf(stderr, " nametype: [ length: %u, elements: %s ]\n",
55 (char *)(nametype->elements));
58 if (mech_type == NULL)
60 fprintf(stderr, "NULL mech_type; putting in one for SPNEGO\n");
61 /* Defaut to SPNEGO - 1.3.6.1.5.5.2 */
64 gss_buffer_desc spnego_str;
68 spnego_str.value = "1.3.6.1.5.5.2";
69 spnego_str.length = 13;
70 mech_type = (gss_OID)malloc(sizeof(gss_OID_desc));
71 maj = gss_str_to_oid(&min, &spnego_str, &mech_type);
73 elems = (char *)malloc(mech_type->length + 1);
74 strncpy(elems, (char *)(mech_type->elements), mech_type->length);
75 elems[mech_type->length] = '\0';
76 fprintf(stderr, "str_to_oid major/minor %u/%u\n", maj, min);
77 fprintf(stderr, "mech_type: [length: %u, elements: %s]\n",
84 status->major = gss_init_sec_context(&(status->minor),
98 if (status->major != 0)
102 OM_uint32 context = 0;
103 gss_buffer_desc statbuf;
105 fprintf(stderr, "major status is: 0x%x\n", status->major);
107 maj = gss_display_status(&min, status->major, GSS_C_GSS_CODE,
108 mech_type, &context, &statbuf);
109 fprintf(stderr, "Major status: %s\n", (char *)(statbuf.value));
110 } while(context != 0);
112 if (actual_mech_type == NULL)
113 fprintf(stderr, "actual mech type is NULL.\n");
116 fprintf(stderr, "actual_mech_type: [length: %u, elements: %s]\n",
117 actual_mech_type->length,
118 (char *)(actual_mech_type->elements));
122 if (status->minor != 0)
126 OM_uint32 context = 0;
127 gss_buffer_desc statbuf;
129 fprintf(stderr, "minor status is: %d/%s\n", status->minor, strerror(status->minor));
131 maj = gss_display_status(&min, status->minor, GSS_C_MECH_CODE,
132 mech_type, &context, &statbuf);
133 fprintf(stderr, "Minor status: %s\n", (char *)(statbuf.value));
134 } while(context != 0);