4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
26 * glue routine for gss_display_name()
30 #include <mechglueP.h>
31 #include "gssapiP_generic.h"
40 OM_uint32
*minor_status
,
41 gss_name_t input_name
,
42 gss_buffer_t output_name_buffer
,
43 gss_OID
*output_name_type
)
46 /* Initialize outputs. */
48 if (minor_status
!= NULL
)
51 if (output_name_buffer
!= GSS_C_NO_BUFFER
) {
52 output_name_buffer
->length
= 0;
53 output_name_buffer
->value
= NULL
;
56 if (output_name_type
!= NULL
)
57 *output_name_type
= GSS_C_NO_OID
;
59 /* Validate arguments. */
61 if (minor_status
== NULL
)
62 return (GSS_S_CALL_INACCESSIBLE_WRITE
);
64 if (output_name_buffer
== GSS_C_NO_BUFFER
)
65 return (GSS_S_CALL_INACCESSIBLE_WRITE
);
67 if (input_name
== GSS_C_NO_NAME
)
68 return (GSS_S_CALL_INACCESSIBLE_READ
| GSS_S_BAD_NAME
);
70 return (GSS_S_COMPLETE
);
74 gss_display_name(minor_status
,
79 OM_uint32
* minor_status
;
80 const gss_name_t input_name
;
81 gss_buffer_t output_name_buffer
;
82 gss_OID
* output_name_type
;
85 OM_uint32 major_status
;
86 gss_union_name_t union_name
;
88 major_status
= val_dsp_name_args(minor_status
, input_name
,
89 output_name_buffer
, output_name_type
);
90 if (major_status
!= GSS_S_COMPLETE
)
91 return (major_status
);
93 union_name
= (gss_union_name_t
)input_name
;
95 if (union_name
->mech_type
) {
97 * OK, we have a mechanism-specific name; let's use it!
99 return (__gss_display_internal_name(minor_status
,
100 union_name
->mech_type
,
101 union_name
->mech_name
,
107 * copy the value of the external_name component of the union
108 * name into the output_name_buffer and point the output_name_type
109 * to the name_type component of union_name
111 if (output_name_type
!= NULL
&&
112 union_name
->name_type
!= GSS_C_NULL_OID
) {
113 major_status
= generic_gss_copy_oid(minor_status
,
114 union_name
->name_type
,
116 if (major_status
!= GSS_S_COMPLETE
) {
117 map_errcode(minor_status
);
118 return (major_status
);
122 if ((output_name_buffer
->value
=
123 malloc(union_name
->external_name
->length
+ 1)) == NULL
) {
124 if (output_name_type
&& *output_name_type
!= GSS_C_NULL_OID
) {
125 (void) generic_gss_release_oid(minor_status
,
127 *output_name_type
= NULL
;
129 return (GSS_S_FAILURE
);
131 output_name_buffer
->length
= union_name
->external_name
->length
;
132 (void) memcpy(output_name_buffer
->value
,
133 union_name
->external_name
->value
,
134 union_name
->external_name
->length
);
135 ((char *)output_name_buffer
->value
)[output_name_buffer
->length
] = '\0';
137 return (GSS_S_COMPLETE
);