Home | History | Annotate | Download | only in mech
      1 #pragma ident	"%Z%%M%	%I%	%E% SMI"
      2 
      3 /*
      4  * Copyright 1993 by OpenVision Technologies, Inc.
      5  *
      6  * Permission to use, copy, modify, distribute, and sell this software
      7  * and its documentation for any purpose is hereby granted without fee,
      8  * provided that the above copyright notice appears in all copies and
      9  * that both that copyright notice and this permission notice appear in
     10  * supporting documentation, and that the name of OpenVision not be used
     11  * in advertising or publicity pertaining to distribution of the software
     12  * without specific, written prior permission. OpenVision makes no
     13  * representations about the suitability of this software for any
     14  * purpose.  It is provided "as is" without express or implied warranty.
     15  *
     16  * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
     17  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
     18  * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
     19  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
     20  * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
     21  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
     22  * PERFORMANCE OF THIS SOFTWARE.
     23  */
     24 
     25 #include "gssapiP_krb5.h"
     26 
     27 OM_uint32
     28 krb5_gss_display_name(minor_status, input_name, output_name_buffer,
     29 		      output_name_type)
     30      OM_uint32 *minor_status;
     31      gss_name_t input_name;
     32      gss_buffer_t output_name_buffer;
     33      gss_OID *output_name_type;
     34 {
     35    krb5_context context;
     36    krb5_error_code code;
     37    char *str;
     38 
     39    code = krb5_gss_init_context(&context);
     40    if (code) {
     41        *minor_status = code;
     42        return GSS_S_FAILURE;
     43    }
     44 
     45    output_name_buffer->length = 0;
     46    output_name_buffer->value = NULL;
     47 
     48    if (! kg_validate_name(input_name)) {
     49       *minor_status = (OM_uint32) G_VALIDATE_FAILED;
     50       krb5_free_context(context);
     51       return(GSS_S_CALL_BAD_STRUCTURE|GSS_S_BAD_NAME);
     52    }
     53 
     54    if ((code = krb5_unparse_name(context,
     55 				 (krb5_principal) input_name, &str))) {
     56       *minor_status = code;
     57       krb5_free_context(context);
     58       return(GSS_S_FAILURE);
     59    }
     60 
     61    if (! g_make_string_buffer(str, output_name_buffer)) {
     62       krb5_free_unparsed_name(context, str);
     63       krb5_free_context(context);
     64 
     65       *minor_status = (OM_uint32) G_BUFFER_ALLOC;
     66       return(GSS_S_FAILURE);
     67    }
     68 
     69    krb5_free_unparsed_name(context, str);
     70    krb5_free_context(context);
     71 
     72    *minor_status = 0;
     73    if (output_name_type)
     74       *output_name_type = (gss_OID) gss_nt_krb5_name;
     75    return(GSS_S_COMPLETE);
     76 }
     77