1 /* 2 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 3 * Use is subject to license terms. 4 */ 5 6 | #pragma ident "@(#)g_inquire_names.c 1.17 04/09/08 SMI" 6 | #pragma ident "@(#)g_inquire_names.c 1.16 04/02/23 SMI" 7 8 /* 9 * glue routine for gss_inquire_context 10 */ 11 12 #include <mechglueP.h> 13 14 #define MAX_MECH_OID_PAIRS 32 15 16 /* Last argument new for V2 */ 17 OM_uint32 18 gss_inquire_names_for_mech(minor_status, mechanism, name_types) 19 20 OM_uint32 * minor_status; 21 const gss_OID mechanism; 22 gss_OID_set * name_types; 23 24 { 25 OM_uint32 status; 26 gss_mechanism mech; 27 28 | gss_initialize(); 28 | if (minor_status == NULL) 29 + return (GSS_S_CALL_INACCESSIBLE_WRITE); 30 + *minor_status = 0; 31 32 + if (name_types == NULL) 33 + return (GSS_S_CALL_INACCESSIBLE_WRITE); 34 + 35 /* 36 * select the approprate underlying mechanism routine and 37 * call it. 38 */ 39 40 mech = __gss_get_mechanism(mechanism); 41 42 if (mech) { 43 44 if (mech->gss_inquire_names_for_mech) 45 status = mech->gss_inquire_names_for_mech( 46 mech->context, 47 minor_status, 48 mechanism, 49 name_types); 50 else 46 | status = GSS_S_BAD_BINDINGS; 51 | status = GSS_S_UNAVAILABLE; 52 53 return (status); 54 } 55 51 | return (GSS_S_NO_CONTEXT); 56 | return (GSS_S_BAD_MECH); 57 } 58 59 + OM_uint32 60 + gss_inquire_mechs_for_name(minor_status, input_name, mech_set) 61 + 62 + OM_uint32 * minor_status; 63 + const gss_name_t input_name; 64 + gss_OID_set * mech_set; 65 + 66 + { 67 + OM_uint32 status; 68 + static char *mech_list[MAX_MECH_OID_PAIRS+1]; 69 + gss_OID_set mech_name_types; 70 + int present; 71 + char *mechanism; 72 + gss_OID mechOid; 73 + gss_OID name_type; 74 + gss_buffer_desc name_buffer; 75 + int i; 76 + 77 + if (minor_status == NULL) 78 + return (GSS_S_CALL_INACCESSIBLE_WRITE); 79 + *minor_status = 0; 80 + 81 + if (input_name == NULL) 82 + return (GSS_S_BAD_NAME); 83 + 84 + status = gss_create_empty_oid_set(minor_status, mech_set); 85 + if (status != GSS_S_COMPLETE) 86 + return (status); 87 + *mech_list = NULL; 88 + status = __gss_get_mechanisms(mech_list, MAX_MECH_OID_PAIRS+1); 89 + if (status != GSS_S_COMPLETE) 90 + return (status); 91 + for (i = 0; i < MAX_MECH_OID_PAIRS && mech_list[i] != NULL; i++) { 92 + mechanism = mech_list[i]; 93 + if (__gss_mech_to_oid(mechanism, &mechOid) == GSS_S_COMPLETE) { 94 + status = gss_inquire_names_for_mech( 95 + minor_status, 96 + mechOid, 97 + &mech_name_types); 98 + if (status == GSS_S_COMPLETE) { 99 + status = gss_display_name(minor_status, 100 + input_name, 101 + &name_buffer, 102 + &name_type); 103 + 104 + (void) gss_release_buffer(NULL, &name_buffer); 105 + 106 + if (status == GSS_S_COMPLETE && name_type) { 107 + status = gss_test_oid_set_member( 108 + minor_status, 109 + name_type, 110 + mech_name_types, 111 + &present); 112 + if (status == GSS_S_COMPLETE && 113 + present) { 114 + status = gss_add_oid_set_member( 115 + minor_status, 116 + mechOid, 117 + mech_set); 118 + if (status != GSS_S_COMPLETE) { 119 + (void) gss_release_oid_set( 120 + minor_status, 121 + &mech_name_types); 122 + (void) gss_release_oid_set( 123 + minor_status, 124 + mech_set); 125 + return (status); 126 + } 127 + } 128 + } 129 + (void) gss_release_oid_set( 130 + minor_status, 131 + &mech_name_types); 132 + } 133 + } else { 134 + (void) gss_release_oid_set( 135 + minor_status, 136 + mech_set); 137 + return (GSS_S_FAILURE); 138 + } 139 + } 140 + return (GSS_S_COMPLETE); 141 + }