2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
5 * Copyright 1997 by Massachusetts Institute of Technology
8 * Export of this software from the United States of America may
9 * require a specific license from the United States Government.
10 * It is the responsibility of any person or organization contemplating
11 * export to obtain such a license before exporting.
13 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
14 * distribute this software and its documentation for any purpose and
15 * without fee is hereby granted, provided that the above copyright
16 * notice appear in all copies and that both that copyright notice and
17 * this permission notice appear in supporting documentation, and that
18 * the name of M.I.T. not be used in advertising or publicity pertaining
19 * to distribution of the software without specific, written prior
20 * permission. Furthermore if you modify this software you must label
21 * your software as modified software and not distribute it in such a
22 * fashion that it might be confused with the original M.I.T. software.
23 * M.I.T. makes no representations about the suitability of
24 * this software for any purpose. It is provided "as is" without express
25 * or implied warranty.
29 #include "gssapiP_krb5.h"
32 * Check to see whether or not a GSSAPI krb5 credential is valid. If
33 * it is not, return an error.
37 krb5_gss_validate_cred_1(OM_uint32
*minor_status
, gss_cred_id_t cred_handle
,
40 krb5_gss_cred_id_t cred
;
44 if (!kg_validate_cred_id(cred_handle
)) {
45 *minor_status
= (OM_uint32
) G_VALIDATE_FAILED
;
46 return(GSS_S_CALL_BAD_STRUCTURE
|GSS_S_DEFECTIVE_CREDENTIAL
);
49 cred
= (krb5_gss_cred_id_t
) cred_handle
;
51 code
= k5_mutex_lock(&cred
->lock
);
58 if ((code
= krb5_cc_get_principal(context
, cred
->ccache
, &princ
))) {
59 k5_mutex_unlock(&cred
->lock
);
61 return(GSS_S_DEFECTIVE_CREDENTIAL
);
63 if (!krb5_principal_compare(context
, princ
, cred
->princ
)) {
64 k5_mutex_unlock(&cred
->lock
);
65 *minor_status
= KG_CCACHE_NOMATCH
;
66 return(GSS_S_DEFECTIVE_CREDENTIAL
);
68 (void)krb5_free_principal(context
, princ
);
71 return GSS_S_COMPLETE
;
75 krb5_gss_validate_cred(minor_status
, cred_handle
)
76 OM_uint32
*minor_status
;
77 gss_cred_id_t cred_handle
;
83 code
= krb5_gss_init_context(&context
);
89 maj
= krb5_gss_validate_cred_1(minor_status
, cred_handle
, context
);
91 krb5_gss_cred_id_t cred
= (krb5_gss_cred_id_t
) cred_handle
;
92 k5_mutex_assert_locked(&cred
->lock
);
93 k5_mutex_unlock(&cred
->lock
);
94 } else /* Solaris Kerberos - added this else */
95 save_error_info(*minor_status
, context
);
96 krb5_free_context(context
);