1 .\" Copyright (c) 2003 - 2005 Kungliga Tekniska Högskolan
2 .\" (Royal Institute of Technology, Stockholm, Sweden).
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the Institute nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" $Heimdal: krb5_ccache.3 22071 2007-11-14 20:04:50Z lha $
44 .Nm krb5_cc_clear_mcred ,
46 .Nm krb5_cc_copy_cache ,
48 .Nm krb5_cc_default_name ,
50 .Nm krb5_cc_end_seq_get ,
52 .Nm krb5_cc_get_full_name ,
53 .Nm krb5_cc_get_name ,
55 .Nm krb5_cc_get_prefix_ops ,
56 .Nm krb5_cc_get_principal ,
57 .Nm krb5_cc_get_type ,
58 .Nm krb5_cc_get_version ,
59 .Nm krb5_cc_initialize ,
60 .Nm krb5_cc_next_cred ,
61 .Nm krb5_cc_next_cred_match ,
62 .Nm krb5_cc_new_unique ,
63 .Nm krb5_cc_register ,
64 .Nm krb5_cc_remove_cred ,
66 .Nm krb5_cc_retrieve_cred ,
67 .Nm krb5_cc_set_default_name ,
68 .Nm krb5_cc_set_flags ,
69 .Nm krb5_cc_start_seq_get ,
70 .Nm krb5_cc_store_cred
71 .Nd mange credential cache
73 Kerberos 5 Library (libkrb5, -lkrb5)
77 .Li "struct krb5_ccache;"
79 .Li "struct krb5_cc_cursor;"
81 .Li "struct krb5_cc_ops;"
83 .Li "struct krb5_cc_ops *krb5_fcc_ops;"
85 .Li "struct krb5_cc_ops *krb5_mcc_ops;"
88 .Fo krb5_cc_clear_mcred
89 .Fa "krb5_creds *mcred"
93 .Fa "krb5_context context"
97 .Fo krb5_cc_copy_cache
98 .Fa "krb5_context context"
99 .Fa "const krb5_ccache from"
104 .Fa "krb5_context context"
105 .Fa "krb5_ccache *id"
108 .Fo krb5_cc_default_name
109 .Fa "krb5_context context"
113 .Fa "krb5_context context"
117 .Fo krb5_cc_end_seq_get
118 .Fa "krb5_context context"
119 .Fa "const krb5_ccache id"
120 .Fa "krb5_cc_cursor *cursor"
124 .Fa "krb5_context context"
125 .Fa "const krb5_cc_ops *ops"
126 .Fa "krb5_ccache *id"
129 .Fo krb5_cc_get_full_name
130 .Fa "krb5_context context"
136 .Fa "krb5_context context"
140 .Fo krb5_cc_get_principal
141 .Fa "krb5_context context"
143 .Fa "krb5_principal *principal"
147 .Fa "krb5_context context"
150 .Ft "const krb5_cc_ops *"
152 .Fa "krb5_context context"
155 .Ft "const krb5_cc_ops *"
156 .Fo krb5_cc_get_prefix_ops
157 .Fa "krb5_context context"
158 .Fa "const char *prefix"
161 .Fo krb5_cc_get_version
162 .Fa "krb5_context context"
163 .Fa "const krb5_ccache id"
166 .Fo krb5_cc_initialize
167 .Fa "krb5_context context"
169 .Fa "krb5_principal primary_principal"
173 .Fa "krb5_context context"
174 .Fa "const krb5_cc_ops *ops"
175 .Fa "krb5_boolean override"
179 .Fa "krb5_context context"
180 .Fa "const char *name"
181 .Fa "krb5_ccache *id"
184 .Fo krb5_cc_retrieve_cred
185 .Fa "krb5_context context"
187 .Fa "krb5_flags whichfields"
188 .Fa "const krb5_creds *mcreds"
189 .Fa "krb5_creds *creds"
192 .Fo krb5_cc_remove_cred
193 .Fa "krb5_context context"
195 .Fa "krb5_flags which"
196 .Fa "krb5_creds *cred"
199 .Fo krb5_cc_set_default_name
200 .Fa "krb5_context context"
201 .Fa "const char *name"
204 .Fo krb5_cc_start_seq_get
205 .Fa "krb5_context context"
206 .Fa "const krb5_ccache id"
207 .Fa "krb5_cc_cursor *cursor"
210 .Fo krb5_cc_store_cred
211 .Fa "krb5_context context"
213 .Fa "krb5_creds *creds"
216 .Fo krb5_cc_set_flags
217 .Fa "krb5_context context"
218 .Fa "krb5_cc_set_flags id"
219 .Fa "krb5_flags flags"
222 .Fo krb5_cc_next_cred
223 .Fa "krb5_context context"
224 .Fa "const krb5_ccache id"
225 .Fa "krb5_cc_cursor *cursor"
226 .Fa "krb5_creds *creds"
229 .Fo krb5_cc_next_cred_match
230 .Fa "krb5_context context"
231 .Fa "const krb5_ccache id"
232 .Fa "krb5_cc_cursor *cursor"
233 .Fa "krb5_creds *creds"
234 .Fa "krb5_flags whichfields"
235 .Fa "const krb5_creds *mcreds"
238 .Fo krb5_cc_new_unique
239 .Fa "krb5_context context"
240 .Fa "const char *type"
241 .Fa "const char *hint"
242 .Fa "krb5_ccache *id"
247 structure holds a Kerberos credential cache.
251 structure holds current position in a credential cache when
252 iterating over the cache.
256 structure holds a set of operations that can me preformed on a
259 There is no component inside
264 that is directly referable.
268 holds a Kerberos credential, see manpage for
271 .Fn krb5_cc_default_name
273 .Fn krb5_cc_set_default_name
274 gets and sets the default name for the
278 opens the default credential cache in
280 Return 0 or an error code.
283 generates a new credential cache of type
287 Return 0 or an error code.
288 The Heimdal version of this function also runs
289 .Fn krb5_cc_initialize
290 on the credential cache, but since the MIT version doesn't, portable
291 code must call krb5_cc_initialize.
293 .Fn krb5_cc_new_unique
294 generates a new unique credential cache of
300 the library chooses the default credential cache type.
305 is a string that the credential cache type can use to base the name of
306 the credential on, this is to make it easier for the user to
307 differentiate the credentials.
308 The returned credential cache
310 should be freed using
313 .Fn krb5_cc_destroy .
314 Returns 0 or an error code.
317 finds and allocates a credential cache in
319 from the specification in
321 If the credential cache name doesn't contain any colon (:), interpret it as a
323 Return 0 or an error code.
325 .Fn krb5_cc_initialize
326 creates a new credential cache in
329 .Fa primary_principal .
330 Return 0 or an error code.
333 stops using the credential cache
335 and frees the related resources.
336 Return 0 or an error code.
338 removes the credential cache
339 and closes (by calling
342 Return 0 or an error code.
344 .Fn krb5_cc_copy_cache
345 copys the contents of
350 .Fn krb5_cc_get_full_name
351 returns the complete resolvable name of the credential cache
358 Returns 0 or an error, on error
364 returns the name of the credential cache
367 .Fn krb5_cc_get_principal
368 returns the principal of
372 Return 0 or an error code.
375 returns the type of the credential cache
379 returns the ops of the credential cache
382 .Fn krb5_cc_get_version
383 returns the version of
387 Adds a new credential cache type with operations
389 overwriting any existing one if
391 Return an error code or 0.
393 .Fn krb5_cc_get_prefix_ops
394 Get the cc ops that is registered in
402 .Fn krb5_cc_remove_cred
403 removes the credential identified by
409 .Fn krb5_cc_store_cred
412 in the credential cache
414 Return 0 or an error code.
416 .Fn krb5_cc_set_flags
422 .Fn krb5_cc_clear_mcred
425 argument so it is reset and can be used with
426 .Fa krb5_cc_retrieve_cred .
428 .Fn krb5_cc_retrieve_cred ,
429 retrieves the credential identified by
438 should be freed using
439 .Fn krb5_free_cred_contents .
440 Return 0 or an error code.
442 .Fn krb5_cc_start_seq_get
445 structure to be used for iteration over the credential cache.
447 .Fn krb5_cc_next_cred
448 retrieves the next cred pointed to by
455 Return 0 or an error code.
457 .Fn krb5_cc_next_cred_match
459 .Fn krb5_cc_next_cred
460 except that it will only return creds matching
465 .Xr krb5_compare_creds 3 . )
467 .Fn krb5_cc_end_seq_get
471 This is a minimalistic version of
475 #include <krb5/krb5.h>
478 main (int argc, char **argv)
480 krb5_context context;
481 krb5_cc_cursor cursor;
486 if (krb5_init_context (&context) != 0)
487 errx(1, "krb5_context");
489 ret = krb5_cc_default (context, &id);
491 krb5_err(context, 1, ret, "krb5_cc_default");
493 ret = krb5_cc_start_seq_get(context, id, &cursor);
495 krb5_err(context, 1, ret, "krb5_cc_start_seq_get");
497 while((ret = krb5_cc_next_cred(context, id, &cursor, &creds)) == 0){
500 krb5_unparse_name_short(context, creds.server, &principal);
501 printf("principal: %s\\n", principal);
503 krb5_free_cred_contents (context, &creds);
505 ret = krb5_cc_end_seq_get(context, id, &cursor);
507 krb5_err(context, 1, ret, "krb5_cc_end_seq_get");
509 krb5_cc_close(context, id);
511 krb5_free_context(context);