1 /*
2 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
5
6 #pragma ident "@(#)g_inquire_context.c 1.16 04/09/08 SMI"
7
8 /*
9 * glue routine for gss_inquire_context
10 */
11
12 #include <mechglueP.h>
13 #include <stdlib.h>
14
15 /* Last argument new for V2 */
16 OM_uint32
17 gss_inquire_context(
18 minor_status,
19 context_handle,
20 src_name,
21 targ_name,
22 lifetime_rec,
23 mech_type,
24 ctx_flags,
25 locally_initiated,
26 open)
27
28 OM_uint32 *minor_status;
29 const gss_ctx_id_t context_handle;
30 gss_name_t *src_name;
31 gss_name_t *targ_name;
32 OM_uint32 *lifetime_rec;
33 gss_OID *mech_type;
34 OM_uint32 *ctx_flags;
35 int *locally_initiated;
36 int *open;
37
38 {
39 gss_union_ctx_id_t ctx;
40 gss_mechanism mech;
41 OM_uint32 status, temp_minor;
42
43 gss_initialize();
44
45 /* if the context_handle is Null, return NO_CONTEXT error */
46
47 if (context_handle == GSS_C_NO_CONTEXT)
48 return (GSS_S_NO_CONTEXT);
49
50 /*
51 * select the approprate underlying mechanism routine and
52 * call it.
53 */
54
55 ctx = (gss_union_ctx_id_t)context_handle;
56 mech = __gss_get_mechanism(ctx->mech_type);
57
58 if (!mech || !mech->gss_inquire_context || !mech->gss_display_name) {
59 return (GSS_S_NO_CONTEXT);
60 }
61
62 status = mech->gss_inquire_context(
63 mech->context,
64 minor_status,
65 ctx->internal_ctx_id,
66 src_name,
67 targ_name,
68 lifetime_rec,
69 mech_type,
70 ctx_flags,
71 locally_initiated,
72 open);
73
74 if (status != GSS_S_COMPLETE) {
75 return (status);
76 }
77
78 /* need to convert names */
79 if (src_name) {
80 status = __gss_convert_name_to_union_name(minor_status, mech,
81 *src_name, src_name);
82 if (status != GSS_S_COMPLETE) {
83 mech->gss_release_name(mech->context,
84 &temp_minor, src_name);
85 mech->gss_release_name(mech->context,
86 &temp_minor, targ_name);
87 if (mech_type) {
88 gss_release_oid(&temp_minor, mech_type);
89 }
90 return (GSS_S_FAILURE);
91 }
92 }
93
94 if (targ_name) {
95 status = __gss_convert_name_to_union_name(minor_status, mech,
96 *targ_name, targ_name);
97
98 if (status != GSS_S_COMPLETE) {
99 if (mech_type)
100 (void) gss_release_oid(&temp_minor, mech_type);
101
102 return (GSS_S_FAILURE);
103 }
104 }
105
106 return (GSS_S_COMPLETE);
107 }
|
1 /*
2 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
4 */
5
6 #pragma ident "@(#)g_inquire_context.c 1.15 04/02/23 SMI"
7
8 /*
9 * glue routine for gss_inquire_context
10 */
11
12 #include <mechglueP.h>
13 #include <stdlib.h>
14
15 /* Last argument new for V2 */
16 OM_uint32
17 gss_inquire_context(
18 minor_status,
19 context_handle,
20 src_name,
21 targ_name,
22 lifetime_rec,
23 mech_type,
24 ctx_flags,
25 locally_initiated,
26 open)
27
28 OM_uint32 *minor_status;
29 const gss_ctx_id_t context_handle;
30 gss_name_t *src_name;
31 gss_name_t *targ_name;
32 OM_uint32 *lifetime_rec;
33 gss_OID *mech_type;
34 OM_uint32 *ctx_flags;
35 int *locally_initiated;
36 int *open;
37
38 {
39 gss_union_ctx_id_t ctx;
40 gss_mechanism mech;
41 OM_uint32 status, temp_minor;
42 gss_name_t localTargName = NULL, localSourceName = NULL;
43
44 if (!minor_status)
45 return (GSS_S_CALL_INACCESSIBLE_WRITE);
46
47 *minor_status = 0;
48
49 /* if the context_handle is Null, return NO_CONTEXT error */
50 if (context_handle == GSS_C_NO_CONTEXT)
51 return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT);
52
53 /* set all output value to NULL */
54 if (src_name)
55 *src_name = NULL;
56
57 if (targ_name)
58 *targ_name = NULL;
59
60 if (mech_type)
61 *mech_type = NULL;
62
63 /*
64 * select the approprate underlying mechanism routine and
65 * call it.
66 */
67
68 ctx = (gss_union_ctx_id_t)context_handle;
69 mech = __gss_get_mechanism(ctx->mech_type);
70
71 if (!mech || !mech->gss_inquire_context || !mech->gss_display_name ||
72 !mech->gss_release_name) {
73 return (GSS_S_UNAVAILABLE);
74 }
75
76 status = mech->gss_inquire_context(
77 mech->context,
78 minor_status,
79 ctx->internal_ctx_id,
80 (src_name ? &localSourceName : NULL),
81 (targ_name ? &localTargName : NULL),
82 lifetime_rec,
83 NULL,
84 ctx_flags,
85 locally_initiated,
86 open);
87
88 if (status != GSS_S_COMPLETE) {
89 return (status);
90 }
91
92 /* need to convert names */
93 if (src_name) {
94 status = __gss_convert_name_to_union_name(minor_status, mech,
95 localSourceName, src_name);
96 if (status != GSS_S_COMPLETE) {
97 if (localTargName)
98 mech->gss_release_name(mech->context,
99 &temp_minor, &localTargName);
100 return (status);
101 }
102 }
103
104 if (targ_name) {
105 status = __gss_convert_name_to_union_name(minor_status, mech,
106 localTargName, targ_name);
107
108 if (status != GSS_S_COMPLETE) {
109 if (src_name)
110 (void) gss_release_name(&temp_minor, src_name);
111
112 return (status);
113 }
114 }
115
116 /* spec says mech type must point to static storage */
117 if (mech_type)
118 *mech_type = &mech->mech_type;
119 return (GSS_S_COMPLETE);
120 }
|