xref: /illumos-gate/usr/src/lib/libgss/g_inq_context_oid.c (revision 69a119caa6570c7077699161b7c28b6ee9f8b0f4)
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 (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
27  */
28 
29 /*
30  *  glue routine for gss_inquire_sec_context_by_oid
31  */
32 
33 #include "mglueP.h"
34 #include "gssapiP_generic.h"
35 
36 #define gssint_get_mechanism __gss_get_mechanism /* SUNW17PACresync */
37 
38 OM_uint32
39 gss_inquire_sec_context_by_oid (OM_uint32 *minor_status,
40 	                        const gss_ctx_id_t context_handle,
41 	                        const gss_OID desired_object,
42 	                        gss_buffer_set_t *data_set)
43 {
44     OM_uint32		status;
45     gss_union_ctx_id_t	ctx;
46     gss_mechanism	mech;
47 
48     if (minor_status == NULL)
49 	return GSS_S_CALL_INACCESSIBLE_WRITE;
50 
51     if (context_handle == GSS_C_NO_CONTEXT)
52 	return GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT;
53 
54     /*
55      * select the approprate underlying mechanism routine and
56      * call it.
57      */
58 
59     ctx = (gss_union_ctx_id_t) context_handle;
60     mech = gssint_get_mechanism (ctx->mech_type);
61 
62     if (mech != NULL) {
63 	if (mech->gss_inquire_sec_context_by_oid != NULL) {
64 	    status = mech->gss_inquire_sec_context_by_oid(minor_status,
65 							  ctx->internal_ctx_id,
66 							  desired_object,
67 							  data_set);
68 	    if (status != GSS_S_COMPLETE)
69 		map_error(minor_status, mech);
70 	} else
71 	    status = GSS_S_BAD_MECH;
72 
73 	return status;
74     }
75 
76     return GSS_S_NO_CONTEXT;
77 }
78 
79