2 * lib/krb5/ccache/ccfns.c
4 * Copyright 2000, 2007 by the Massachusetts Institute of Technology.
7 * Export of this software from the United States of America may
8 * require a specific license from the United States Government.
9 * It is the responsibility of any person or organization contemplating
10 * export to obtain such a license before exporting.
12 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13 * distribute this software and its documentation for any purpose and
14 * without fee is hereby granted, provided that the above copyright
15 * notice appear in all copies and that both that copyright notice and
16 * this permission notice appear in supporting documentation, and that
17 * the name of M.I.T. not be used in advertising or publicity pertaining
18 * to distribution of the software without specific, written prior
19 * permission. Furthermore if you modify this software you must label
20 * your software as modified software and not distribute it in such a
21 * fashion that it might be confused with the original M.I.T. software.
22 * M.I.T. makes no representations about the suitability of
23 * this software for any purpose. It is provided "as is" without express
24 * or implied warranty.
28 * Dispatch methods for credentials cache code.
33 const char * KRB5_CALLCONV
34 krb5_cc_get_name (krb5_context context
, krb5_ccache cache
)
36 return cache
->ops
->get_name(context
, cache
);
39 krb5_error_code KRB5_CALLCONV
40 krb5_cc_gen_new (krb5_context context
, krb5_ccache
*cache
)
42 return (*cache
)->ops
->gen_new(context
, cache
);
45 krb5_error_code KRB5_CALLCONV
46 krb5_cc_initialize(krb5_context context
, krb5_ccache cache
,
47 krb5_principal principal
)
49 return cache
->ops
->init(context
, cache
, principal
);
52 krb5_error_code KRB5_CALLCONV
53 krb5_cc_destroy (krb5_context context
, krb5_ccache cache
)
55 return cache
->ops
->destroy(context
, cache
);
58 krb5_error_code KRB5_CALLCONV
59 krb5_cc_close (krb5_context context
, krb5_ccache cache
)
61 return cache
->ops
->close(context
, cache
);
64 krb5_error_code KRB5_CALLCONV
65 krb5_cc_store_cred (krb5_context context
, krb5_ccache cache
,
70 krb5_principal s1
, s2
;
72 ret
= cache
->ops
->store(context
, cache
, creds
);
76 * If creds->server and the server in the decoded ticket differ,
77 * store both principals.
80 ret
= decode_krb5_ticket(&creds
->ticket
, &tkt
);
81 /* Bail out on errors in case someone is storing a non-ticket. */
84 if (!krb5_principal_compare(context
, s1
, s2
)) {
86 ret
= cache
->ops
->store(context
, cache
, creds
);
89 krb5_free_ticket(context
, tkt
);
93 krb5_error_code KRB5_CALLCONV
94 krb5_cc_retrieve_cred (krb5_context context
, krb5_ccache cache
,
95 krb5_flags flags
, krb5_creds
*mcreds
,
101 ret
= cache
->ops
->retrieve(context
, cache
, flags
, mcreds
, creds
);
102 if (ret
!= KRB5_CC_NOTFOUND
)
104 if (!krb5_is_referral_realm(&mcreds
->server
->realm
))
108 * Retry using client's realm if service has referral realm.
110 tmprealm
= mcreds
->server
->realm
;
111 mcreds
->server
->realm
= mcreds
->client
->realm
;
112 ret
= cache
->ops
->retrieve(context
, cache
, flags
, mcreds
, creds
);
113 mcreds
->server
->realm
= tmprealm
;
117 krb5_error_code KRB5_CALLCONV
118 krb5_cc_get_principal (krb5_context context
, krb5_ccache cache
,
119 krb5_principal
*principal
)
121 return cache
->ops
->get_princ(context
, cache
, principal
);
124 krb5_error_code KRB5_CALLCONV
125 krb5_cc_start_seq_get (krb5_context context
, krb5_ccache cache
,
126 krb5_cc_cursor
*cursor
)
128 return cache
->ops
->get_first(context
, cache
, cursor
);
131 krb5_error_code KRB5_CALLCONV
132 krb5_cc_next_cred (krb5_context context
, krb5_ccache cache
,
133 krb5_cc_cursor
*cursor
, krb5_creds
*creds
)
135 return cache
->ops
->get_next(context
, cache
, cursor
, creds
);
138 krb5_error_code KRB5_CALLCONV
139 krb5_cc_end_seq_get (krb5_context context
, krb5_ccache cache
,
140 krb5_cc_cursor
*cursor
)
142 return cache
->ops
->end_get(context
, cache
, cursor
);
145 krb5_error_code KRB5_CALLCONV
146 krb5_cc_remove_cred (krb5_context context
, krb5_ccache cache
, krb5_flags flags
,
149 return cache
->ops
->remove_cred(context
, cache
, flags
, creds
);
152 krb5_error_code KRB5_CALLCONV
153 krb5_cc_set_flags (krb5_context context
, krb5_ccache cache
, krb5_flags flags
)
155 return cache
->ops
->set_flags(context
, cache
, flags
);
158 krb5_error_code KRB5_CALLCONV
159 krb5_cc_get_flags (krb5_context context
, krb5_ccache cache
, krb5_flags
*flags
)
161 return cache
->ops
->get_flags(context
, cache
, flags
);
164 const char * KRB5_CALLCONV
165 krb5_cc_get_type (krb5_context context
, krb5_ccache cache
)
167 return cache
->ops
->prefix
;