1131377Stjr/*
217651Speter * Copyright (c) 2010, PADL Software Pty Ltd.
3250261Sdelphij * All rights reserved.
4131377Stjr *
5131377Stjr * Redistribution and use in source and binary forms, with or without
6237410Sdelphij * modification, are permitted provided that the following conditions
7237410Sdelphij * are met:
8131377Stjr *
933904Ssteve * 1. Redistributions of source code must retain the above copyright
10205471Sdelphij *    notice, this list of conditions and the following disclaimer.
11237410Sdelphij *
12237410Sdelphij * 2. Redistributions in binary form must reproduce the above copyright
13237410Sdelphij *    notice, this list of conditions and the following disclaimer in the
14237410Sdelphij *    documentation and/or other materials provided with the distribution.
1517651Speter *
16131377Stjr * 3. Neither the name of PADL Software nor the names of its contributors
17205471Sdelphij *    may be used to endorse or promote products derived from this software
18237410Sdelphij *    without specific prior written permission.
19237410Sdelphij *
20206708Sdelphij * THIS SOFTWARE IS PROVIDED BY PADL SOFTWARE AND CONTRIBUTORS ``AS IS'' AND
2117651Speter * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22131377Stjr * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23205471Sdelphij * ARE DISCLAIMED.  IN NO EVENT SHALL PADL SOFTWARE OR CONTRIBUTORS BE LIABLE
24205471Sdelphij * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25205471Sdelphij * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26205471Sdelphij * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2742468Speter * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28205471Sdelphij * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2992111Sgreen * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30205471Sdelphij * SUCH DAMAGE.
31205471Sdelphij */
32205471Sdelphij
3317651Speter#include "mech_locl.h"
34250261Sdelphij
3517651SpeterGSSAPI_LIB_FUNCTION OM_uint32 GSSAPI_LIB_CALL
36205471Sdelphijgss_get_name_attribute(OM_uint32 *minor_status,
3733904Ssteve		       gss_name_t input_name,
38205471Sdelphij		       gss_buffer_t attr,
39205471Sdelphij		       int *authenticated,
4033904Ssteve		       int *complete,
41205471Sdelphij		       gss_buffer_t value,
42205471Sdelphij		       gss_buffer_t display_value,
43205471Sdelphij		       int *more)
4417651Speter{
45145474Skientzle    OM_uint32 major_status = GSS_S_UNAVAILABLE;
46131377Stjr    struct _gss_name *name = (struct _gss_name *) input_name;
47237410Sdelphij    struct _gss_mechanism_name *mn;
4817651Speter
49205471Sdelphij    *minor_status = 0;
5033904Ssteve    if (authenticated != NULL)
51131377Stjr        *authenticated = 0;
52131377Stjr    if (complete != NULL)
53131377Stjr        *complete = 0;
5433904Ssteve    _mg_buffer_zero(value);
5542468Speter    _mg_buffer_zero(display_value);
5617651Speter
5717651Speter    if (input_name == GSS_C_NO_NAME)
58131377Stjr        return GSS_S_BAD_NAME;
5917651Speter
60131377Stjr    HEIM_SLIST_FOREACH(mn, &name->gn_mn, gmn_link) {
61131377Stjr        gssapi_mech_interface m = mn->gmn_mech;
62131377Stjr
6333904Ssteve        if (!m->gm_get_name_attribute)
64131377Stjr            continue;
65131377Stjr
6617651Speter        major_status = m->gm_get_name_attribute(minor_status,
67131377Stjr                                                mn->gmn_name,
68131377Stjr                                                attr,
6917651Speter                                                authenticated,
70131377Stjr                                                complete,
71131377Stjr                                                value,
7242468Speter                                                display_value,
73205471Sdelphij                                                more);
7417651Speter        if (GSS_ERROR(major_status))
75131377Stjr            _gss_mg_error(m, major_status, *minor_status);
7617651Speter        else
7733904Ssteve            break;
7817651Speter    }
7917651Speter
80205471Sdelphij    return major_status;
81205471Sdelphij}
82205471Sdelphij