3
* Copyright 2004 by the Massachusetts Institute of Technology.
7
* Export of this software from the United States of America may require a
8
* specific license from the United States Government. It is the
9
* responsibility of any person or organization contemplating export to
10
* obtain such a license before exporting.
12
* WITHIN THAT CONSTRAINT, permission to use, copy, modify, and distribute
13
* this software and its documentation for any purpose and without fee is
14
* hereby granted, provided that the above copyright notice appear in all
15
* copies and that both that copyright notice and this permission notice
16
* appear in supporting documentation, and that the name of M.I.T. not be
17
* used in advertising or publicity pertaining to distribution of the
18
* software without specific, written prior permission. Furthermore if you
19
* modify this software you must label your software as modified software
20
* and not distribute it in such a fashion that it might be confused with
21
* the original MIT software. M.I.T. makes no representations about the
22
* suitability of this software for any purpose. It is provided "as is"
23
* without express or implied warranty.
25
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
26
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
27
* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
* Individual source code files are copyright MIT, Cygnus Support,
30
* OpenVision, Oracle, Sun Soft, FundsXpress, and others.
32
* Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira,
33
* and Zephyr are trademarks of the Massachusetts Institute of Technology
34
* (MIT). No commercial use of these trademarks may be made without prior
35
* written permission of MIT.
37
* "Commercial use" means use of a name in a product or other for-profit
38
* manner. It does NOT prevent a commercial firm from referring to the MIT
39
* trademarks in order to convey information (although in doing so,
40
* recognition of their trademark status should be given).
48
#include "CredentialsCache.h"
49
#include "datastore.h"
52
cc_server_credentials_t *cred1, *cred2, *cred3;
53
cc_credentials_iterate_t* iterator;
54
cc_server_credentials_t* stored_cred;
55
cc_credentials_list_node_t *node;
56
cc_server_ccache_t *c1, *c2;
62
code = cci_ccache_new("The first", p1, cc_credentials_v4_v5, &c1);
63
code = cci_ccache_new("The 2nd", p2, cc_credentials_v4_v5, &c2);
65
cred1 = (cc_server_credentials_t*)malloc(sizeof(cc_server_credentials_t));
66
memset(cred1,0,sizeof(cc_server_credentials_t));
67
cred2 = (cc_server_credentials_t*)malloc(sizeof(cc_server_credentials_t));
68
memset(cred2,0,sizeof(cc_server_credentials_t));
69
cred3 = (cc_server_credentials_t*)malloc(sizeof(cc_server_credentials_t));
70
memset(cred3,0,sizeof(cc_server_credentials_t));
72
cred1->creds.version = cred2->creds.version = cc_credentials_v4;
73
cred3->creds.version = cc_credentials_v5;
75
cred1->creds.credentials.credentials_v4 = (cc_credentials_v4_t*)malloc(sizeof(cc_credentials_v4_t));
76
memset(cred1->creds.credentials.credentials_v4,0,sizeof(cc_credentials_v4_t));
77
cred2->creds.credentials.credentials_v4 = (cc_credentials_v4_t*)malloc(sizeof(cc_credentials_v4_t));
78
memset(cred2->creds.credentials.credentials_v4,0,sizeof(cc_credentials_v4_t));
79
cred3->creds.credentials.credentials_v5 = (cc_credentials_v5_t*)malloc(sizeof(cc_credentials_v5_t));
80
memset(cred3->creds.credentials.credentials_v5,0,sizeof(cc_credentials_v5_t));
82
strncpy(cred1->creds.credentials.credentials_v4->principal, p1, strlen(p1));
83
strncpy(cred2->creds.credentials.credentials_v4->principal, p1, strlen(p1));
84
cred3->creds.credentials.credentials_v5->client = p1;
86
code = cci_ccache_store_creds(c1, &cred1->creds);
87
printf("(c1, cred1) -> %d\n",code);
89
code = cci_ccache_store_creds(c1, &cred2->creds);
90
printf("(c1, cred2) -> %d\n",code);
92
code = cci_ccache_store_creds(c2, &cred3->creds);
93
printf("(c2, cred3) -> %d\n",code);
95
code = cci_ccache_store_creds(c1, &cred3->creds);
96
printf("(c1, cred3) -> %d\n",code);
99
code = cci_ccache_move(c1, c2);
100
code = cci_ccache_destroy(c1);
101
code = cci_ccache_new_iterator(c2, &iterator);
102
while (cci_credentials_iterate_has_next(iterator)) {
104
code = cci_credentials_iterate_next(iterator, &node);
105
stored_cred = (cc_server_credentials_t *)node->data;
106
printf("%d %d %s\n", stored_cred->is_default, stored_cred->creds.version, stored_cred->creds.credentials.credentials_v4->principal);
109
code = cci_ccache_rem_creds(c2,&cred2->creds);
110
printf("(c2 rem cred2) -> %d\n",code);