xref: /titanic_44/usr/src/lib/libgss/g_inq_context_oid.c (revision cab25e88571b90083876d2876f790fdf153773a2)
1 /*
2  * Copyright 2008 by the Massachusetts Institute of Technology.
3  * All Rights Reserved.
4  *
5  * Export of this software from the United States of America may
6  *   require a specific license from the United States Government.
7  *   It is the responsibility of any person or organization contemplating
8  *   export to obtain such a license before exporting.
9  *
10  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
11  * distribute this software and its documentation for any purpose and
12  * without fee is hereby granted, provided that the above copyright
13  * notice appear in all copies and that both that copyright notice and
14  * this permission notice appear in supporting documentation, and that
15  * the name of M.I.T. not be used in advertising or publicity pertaining
16  * to distribution of the software without specific, written prior
17  * permission.  Furthermore if you modify this software you must label
18  * your software as modified software and not distribute it in such a
19  * fashion that it might be confused with the original M.I.T. software.
20  * M.I.T. makes no representations about the suitability of
21  * this software for any purpose.  It is provided "as is" without express
22  * or implied warranty.
23  *
24  */
25 /*
26  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
27  * Use is subject to license terms.
28  */
29 
30 /*
31  *  glue routine for gss_inquire_sec_context_by_oid
32  */
33 
34 #include "mglueP.h"
35 #define gssint_get_mechanism __gss_get_mechanism /* SUNW17PACresync */
36 
37 OM_uint32
38 gss_inquire_sec_context_by_oid (OM_uint32 *minor_status,
39 	                        const gss_ctx_id_t context_handle,
40 	                        const gss_OID desired_object,
41 	                        gss_buffer_set_t *data_set)
42 {
43     OM_uint32		status;
44     gss_union_ctx_id_t	ctx;
45     gss_mechanism	mech;
46 
47     if (minor_status == NULL)
48 	return GSS_S_CALL_INACCESSIBLE_WRITE;
49 
50     if (context_handle == GSS_C_NO_CONTEXT)
51 	return GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT;
52 
53     /*
54      * select the approprate underlying mechanism routine and
55      * call it.
56      */
57 
58     ctx = (gss_union_ctx_id_t) context_handle;
59     mech = gssint_get_mechanism (ctx->mech_type);
60 
61     if (mech != NULL) {
62 	if (mech->gss_inquire_sec_context_by_oid != NULL) {
63 	    status = mech->gss_inquire_sec_context_by_oid(minor_status,
64 							  ctx->internal_ctx_id,
65 							  desired_object,
66 							  data_set);
67 	    if (status != GSS_S_COMPLETE)
68 		map_error(minor_status, mech);
69 	} else
70 	    status = GSS_S_BAD_MECH;
71 
72 	return status;
73     }
74 
75     return GSS_S_NO_CONTEXT;
76 }
77 
78