2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A/*
2N/A * glue routine for gss_inquire_context
2N/A */
2N/A
2N/A#include <mglueP.h>
2N/A#include "gssapiP_generic.h"
2N/A
2N/A#define MAX_MECH_OID_PAIRS 32
2N/A
2N/A/* Last argument new for V2 */
2N/AOM_uint32
2N/Agss_inquire_names_for_mech(minor_status, mechanism, name_types)
2N/A
2N/AOM_uint32 * minor_status;
2N/Aconst gss_OID mechanism;
2N/Agss_OID_set * name_types;
2N/A
2N/A{
2N/A OM_uint32 status;
2N/A gss_mechanism mech;
2N/A
2N/A /* Initialize outputs. */
2N/A
2N/A if (minor_status != NULL)
2N/A *minor_status = 0;
2N/A
2N/A if (name_types != NULL)
2N/A *name_types = GSS_C_NO_OID_SET;
2N/A
2N/A /* Validate arguments. */
2N/A
2N/A if (minor_status == NULL)
2N/A return (GSS_S_CALL_INACCESSIBLE_WRITE);
2N/A
2N/A if (name_types == NULL)
2N/A return (GSS_S_CALL_INACCESSIBLE_WRITE);
2N/A
2N/A /*
2N/A * select the approprate underlying mechanism routine and
2N/A * call it.
2N/A */
2N/A
2N/A mech = __gss_get_mechanism(mechanism);
2N/A
2N/A if (mech) {
2N/A
2N/A if (mech->gss_inquire_names_for_mech) {
2N/A status = mech->gss_inquire_names_for_mech(
2N/A minor_status,
2N/A mechanism,
2N/A name_types);
2N/A if (status != GSS_S_COMPLETE)
2N/A map_error(minor_status, mech);
2N/A } else
2N/A status = GSS_S_UNAVAILABLE;
2N/A
2N/A return (status);
2N/A }
2N/A
2N/A return (GSS_S_BAD_MECH);
2N/A}
2N/A
2N/Astatic OM_uint32 val_inq_mechs4name_args(
2N/A OM_uint32 *minor_status,
2N/A const gss_name_t input_name,
2N/A gss_OID_set *mech_set)
2N/A{
2N/A
2N/A /* Initialize outputs. */
2N/A if (minor_status != NULL)
2N/A *minor_status = 0;
2N/A
2N/A if (mech_set != NULL)
2N/A *mech_set = GSS_C_NO_OID_SET;
2N/A
2N/A /* Validate arguments. */
2N/A
2N/A if (minor_status == NULL)
2N/A return (GSS_S_CALL_INACCESSIBLE_WRITE);
2N/A
2N/A if (input_name == GSS_C_NO_NAME)
2N/A return (GSS_S_BAD_NAME);
2N/A
2N/A return (GSS_S_COMPLETE);
2N/A}
2N/A
2N/AOM_uint32
2N/Agss_inquire_mechs_for_name(minor_status, input_name, mech_set)
2N/A
2N/AOM_uint32 * minor_status;
2N/Aconst gss_name_t input_name;
2N/Agss_OID_set * mech_set;
2N/A
2N/A{
2N/A OM_uint32 status;
2N/A static char *mech_list[MAX_MECH_OID_PAIRS+1];
2N/A gss_OID_set mech_name_types;
2N/A int present;
2N/A char *mechanism;
2N/A gss_OID mechOid;
2N/A gss_OID name_type;
2N/A gss_buffer_desc name_buffer;
2N/A int i;
2N/A
2N/A status = val_inq_mechs4name_args(minor_status, input_name, mech_set);
2N/A if (status != GSS_S_COMPLETE)
2N/A return (status);
2N/A
2N/A status = gss_create_empty_oid_set(minor_status, mech_set);
2N/A if (status != GSS_S_COMPLETE)
2N/A return (status);
2N/A *mech_list = NULL;
2N/A status = __gss_get_mechanisms(mech_list, MAX_MECH_OID_PAIRS+1);
2N/A if (status != GSS_S_COMPLETE)
2N/A return (status);
2N/A for (i = 0; i < MAX_MECH_OID_PAIRS && mech_list[i] != NULL; i++) {
2N/A mechanism = mech_list[i];
2N/A if (__gss_mech_to_oid(mechanism, &mechOid) == GSS_S_COMPLETE) {
2N/A status = gss_inquire_names_for_mech(
2N/A minor_status,
2N/A mechOid,
2N/A &mech_name_types);
2N/A if (status == GSS_S_COMPLETE) {
2N/A status = gss_display_name(minor_status,
2N/A input_name,
2N/A &name_buffer,
2N/A &name_type);
2N/A
2N/A (void) gss_release_buffer(NULL, &name_buffer);
2N/A
2N/A if (status == GSS_S_COMPLETE && name_type) {
2N/A status = gss_test_oid_set_member(
2N/A minor_status,
2N/A name_type,
2N/A mech_name_types,
2N/A &present);
2N/A if (status == GSS_S_COMPLETE &&
2N/A present) {
2N/A status = gss_add_oid_set_member(
2N/A minor_status,
2N/A mechOid,
2N/A mech_set);
2N/A if (status != GSS_S_COMPLETE) {
2N/A (void) gss_release_oid_set(
2N/A minor_status,
2N/A &mech_name_types);
2N/A (void) gss_release_oid_set(
2N/A minor_status,
2N/A mech_set);
2N/A return (status);
2N/A }
2N/A }
2N/A }
2N/A (void) gss_release_oid_set(
2N/A minor_status,
2N/A &mech_name_types);
2N/A }
2N/A } else {
2N/A (void) gss_release_oid_set(
2N/A minor_status,
2N/A mech_set);
2N/A return (GSS_S_FAILURE);
2N/A }
2N/A }
2N/A return (GSS_S_COMPLETE);
2N/A}