140123Sdes/*- 266830Sobrien * Copyright (c) 2005 Doug Rabson 366830Sobrien * All rights reserved. 466830Sobrien * 566830Sobrien * Redistribution and use in source and binary forms, with or without 666830Sobrien * modification, are permitted provided that the following conditions 766830Sobrien * are met: 866830Sobrien * 1. Redistributions of source code must retain the above copyright 966830Sobrien * notice, this list of conditions and the following disclaimer. 1066830Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1166830Sobrien * notice, this list of conditions and the following disclaimer in the 1266830Sobrien * documentation and/or other materials provided with the distribution. 1366830Sobrien * 1466830Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1566830Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1666830Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1766830Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1866830Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1966830Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2066830Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2166830Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2266830Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2366830Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2466830Sobrien * SUCH DAMAGE. 2566830Sobrien * 2666830Sobrien * $FreeBSD: src/lib/libgssapi/gss_display_name.c,v 1.1 2005/12/29 14:40:20 dfr Exp $ 2750472Speter */ 28709Swollman 2966830Sobrien#include "mech_locl.h" 3037Srgrimes 3137SrgrimesGSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL 3237Srgrimesgss_display_name(OM_uint32 *minor_status, 3337Srgrimes const gss_name_t input_name, 3437Srgrimes gss_buffer_t output_name_buffer, 3537Srgrimes gss_OID *output_name_type) 3651231Ssheldonh{ 3751231Ssheldonh OM_uint32 major_status; 3851231Ssheldonh struct _gss_name *name = (struct _gss_name *) input_name; 3951231Ssheldonh struct _gss_mechanism_name *mn; 408460Sjkh 4137Srgrimes _mg_buffer_zero(output_name_buffer); 4237Srgrimes if (output_name_type) 4337Srgrimes *output_name_type = GSS_C_NO_OID; 4437Srgrimes 4551231Ssheldonh if (name == NULL) { 4637Srgrimes *minor_status = 0; 4737Srgrimes return (GSS_S_BAD_NAME); 4837Srgrimes } 4968985Sdougb 5068985Sdougb /* 5151231Ssheldonh * If we know it, copy the buffer used to import the name in 5220684Sjoerg * the first place. Otherwise, ask all the MNs in turn if 5351231Ssheldonh * they can display the thing. 5437Srgrimes */ 5543179Sdillon if (name->gn_value.value) { 5643803Sdillon output_name_buffer->value = malloc(name->gn_value.length); 5743179Sdillon if (!output_name_buffer->value) { 5851231Ssheldonh *minor_status = ENOMEM; 5943375Sdillon return (GSS_S_FAILURE); 6043375Sdillon } 6143803Sdillon output_name_buffer->length = name->gn_value.length; 6243179Sdillon memcpy(output_name_buffer->value, name->gn_value.value, 6343179Sdillon output_name_buffer->length); 6443179Sdillon if (output_name_type) 6543219Speter *output_name_type = &name->gn_type; 6643219Speter 6751231Ssheldonh *minor_status = 0; 6843849Sjkh return (GSS_S_COMPLETE); 6959674Ssheldonh } else { 7051231Ssheldonh HEIM_SLIST_FOREACH(mn, &name->gn_mn, gmn_link) { 7143219Speter major_status = mn->gmn_mech->gm_display_name( 7243219Speter minor_status, mn->gmn_name, 7343219Speter output_name_buffer, 7469876Sobrien output_name_type); 7569876Sobrien if (major_status == GSS_S_COMPLETE) 7669876Sobrien return (GSS_S_COMPLETE); 7769876Sobrien } 7869876Sobrien } 7969876Sobrien 8069876Sobrien *minor_status = 0; 8169876Sobrien return (GSS_S_FAILURE); 8269876Sobrien} 8369876Sobrien