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).
44
* Prototypes and data structures for datastore.
49
#ifndef __CCDATASTOREH__
50
#define __CCDATASTOREH__
52
#include "CredentialsCache.h"
62
struct cc_generic_list_node_t {
65
struct cc_generic_list_node_t* next;
66
struct cc_generic_list_node_t* prev;
68
typedef struct cc_generic_list_node_t cc_generic_list_node_t;
70
struct cc_generic_list_head_t {
71
enum cc_list_type type;
72
cc_generic_list_node_t* head;
73
cc_generic_list_node_t* tail;
75
typedef struct cc_generic_list_head_t cc_generic_list_head_t;
78
struct cc_generic_iterate_t {
79
cc_generic_list_node_t* next;
81
typedef struct cc_generic_iterate_t cc_generic_iterate_t;
83
typedef cc_generic_list_head_t cc_context_list_head_t;
84
typedef cc_generic_list_node_t cc_context_list_node_t;
86
typedef cc_generic_list_head_t cc_ccache_list_head_t;
87
typedef cc_generic_list_node_t cc_ccache_list_node_t;
89
typedef cc_generic_list_head_t cc_credentials_list_head_t;
90
typedef cc_generic_list_node_t cc_credentials_list_node_t;
92
struct cc_context_iterate_t {
93
cc_context_list_node_t* next;
95
typedef struct cc_context_iterate_t cc_context_iterate_t;
97
struct cc_ccache_iterate_t {
98
cc_ccache_list_node_t* next;
100
typedef struct cc_ccache_iterate_t cc_ccache_iterate_t;
102
struct cc_credentials_iterate_t {
103
cc_credentials_list_node_t* next;
105
typedef struct cc_credentials_iterate_t cc_credentials_iterate_t;
108
cc_uint32 read_locks; /* count of read locks (>= 0) */
109
cc_uint32 write_locks; /* count of write locks (0 or 1) */
110
void * platform_data; /* platform specific implementation data */
112
typedef struct cc_lock cc_lock_t;
115
struct cc_server_context_t {
116
cc_ccache_list_head_t* ccaches; /*our ccaches*/
117
cc_generic_list_head_t* active_iterators; /*active ccache iterators*/
118
cc_int32 api_version; /*Version our client passed in on init (ccapi_version_X) */
119
cc_auth_info_t* auth_info; /*auth info passed in from RPC*/
120
cc_session_info_t* session_info; /*session info passed in from RPC*/
121
cc_time_t changed; /*date of last change to this context*/
122
cc_int32 error; /*last error code*/
123
cc_lock_t locks; /*are we locked?*/
125
typedef struct cc_server_context_t cc_server_context_t;
127
struct cc_server_ccache_t {
128
char* name; /*name of this ccache*/
129
char* principal_v4; /*v4 principal associated with this cache*/
130
char* principal_v5; /*v5 principal associated with this cache*/
131
cc_uint32 versions; /*versions of creds supported (from cc_credentials enum in CredentialsCache.h)*/
132
cc_time_t changed; /*date of last change to ccache*/
133
cc_int32 kdc_set; /*is the KDC time offset initialized?*/
134
cc_time_t kdc_offset; /*offset of our clock relative kdc*/
135
cc_time_t last_default; /*the last date when we were default*/
136
cc_int32 is_default; /*is this the default cred on this ccache?*/
137
cc_generic_list_head_t* active_iterators; /*iterators which clients have opened on this cache*/
138
cc_credentials_list_head_t* creds; /*list of creds stored in this ccache*/
139
cc_server_context_t* mycontext; /*context to which I belong*/
140
cc_lock_t locks; /*are we locked?*/
142
typedef struct cc_server_ccache_t cc_server_ccache_t;
144
struct cc_server_credentials_t {
145
cc_int32 is_default; /*Are we the default cred? (first in list)*/
146
cc_credentials_union creds;
148
typedef struct cc_server_credentials_t cc_server_credentials_t;
151
/*Note: cci means Credential Cache Internal, to differentiate from exported API macros*/
153
cc_int32 cci_generic_iterate_has_next(cc_generic_iterate_t *iterate);
154
cc_int32 cci_generic_iterate_next(cc_generic_iterate_t *iterate, cc_generic_list_node_t**);
156
cc_int32 cci_generic_list_new(cc_generic_list_head_t **);
157
cc_int32 cci_generic_list_append(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t**);
158
cc_int32 cci_generic_list_prepend(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t**);
159
cc_int32 cci_generic_list_remove_element(cc_generic_list_head_t* head, cc_generic_list_node_t* rem);
160
cc_int32 cci_generic_free_element(cc_generic_list_node_t* node);
161
cc_int32 cci_generic_list_destroy(cc_generic_list_head_t* head);
162
cc_int32 cci_generic_list_copy(cc_generic_list_head_t* head, cc_generic_list_head_t**);
163
cc_int32 cci_generic_list_iterator(cc_generic_list_head_t *head, cc_generic_iterate_t**);
164
cc_int32 cci_generic_free_iterator(cc_generic_iterate_t* iterator);
166
cc_int32 cci_context_iterate_has_next(struct cc_context_iterate_t *iterate);
167
cc_int32 cci_context_iterate_next(struct cc_context_iterate_t *iterate, cc_context_list_node_t**);
169
cc_int32 cci_ccache_iterate_has_next(struct cc_ccache_iterate_t *iterate);
170
cc_int32 cci_ccache_iterate_next(struct cc_ccache_iterate_t *iterate, cc_ccache_list_node_t**);
172
cc_int32 cci_credentials_iterate_has_next(cc_credentials_iterate_t *iterate);
173
cc_int32 cci_credentials_iterate_next(cc_credentials_iterate_t *iterate, cc_credentials_list_node_t **);
175
cc_int32 cci_context_list_new(cc_context_list_head_t**);
176
cc_int32 cci_context_list_append(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t**);
177
cc_int32 cci_context_list_prepend(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t**);
178
cc_int32 cci_context_list_remove_element(cc_context_list_head_t* head, cc_context_list_node_t* rem);
179
cc_int32 cci_context_list_iterator(cc_context_list_head_t *head, struct cc_context_iterate_t**);
180
cc_int32 cci_context_free_iterator(struct cc_context_iterate_t *iterator);
181
cc_int32 cci_context_list_destroy(cc_context_list_head_t* head) ;
182
cc_int32 cci_context_list_copy(cc_context_list_head_t* head, cc_context_list_head_t**);
184
cc_int32 cci_ccache_list_new(cc_ccache_list_head_t**);
185
cc_int32 cci_ccache_list_append(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t**);
186
cc_int32 cci_ccache_list_prepend(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t**);
187
cc_int32 cci_ccache_list_remove_element(cc_ccache_list_head_t* head, cc_ccache_list_node_t* rem);
188
cc_int32 cci_ccache_list_iterator(cc_ccache_list_head_t *head, struct cc_ccache_iterate_t**);
189
cc_int32 cci_ccache_free_iterator(struct cc_ccache_iterate_t *iterator);
190
cc_int32 cci_ccache_list_destroy(cc_ccache_list_head_t* head) ;
191
cc_int32 cci_ccache_list_copy(cc_ccache_list_head_t* head, cc_ccache_list_head_t**);
194
cc_int32 cci_credentials_list_new(cc_credentials_list_head_t**);
195
cc_int32 cci_credentials_list_append(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t**);
196
cc_int32 cci_credentials_list_prepend(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t**);
197
cc_int32 cci_credentials_list_remove_element(cc_credentials_list_head_t* head, cc_credentials_list_node_t* rem);
198
cc_int32 cci_credentials_list_iterator(cc_credentials_list_head_t *head, cc_credentials_iterate_t**);
199
cc_int32 cci_credentials_free_iterator(cc_credentials_iterate_t* iterator);
200
cc_int32 cci_credentials_list_destroy(cc_credentials_list_head_t* head) ;
201
cc_int32 cci_credentials_list_copy(cc_credentials_list_head_t* head, cc_credentials_list_head_t**) ;
204
cc_int32 cci_context_new(int api_version, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_server_context_t** ) ;
205
cc_int32 cci_context_get_default_ccache_name(cc_server_context_t* ctx, char **);
206
cc_int32 cci_context_find_ccache(cc_server_context_t* ctx, char *name, cc_server_ccache_t**);
207
cc_int32 cci_context_open_ccache(cc_server_context_t* ctx, char *name, cc_server_ccache_t** );
208
cc_int32 cci_context_create_ccache(cc_server_context_t* ctx, char *name, int creds_version, char *principal, cc_server_ccache_t**);
209
cc_int32 cci_context_create_default_ccache(cc_server_context_t* ctx, int creds_version, char *principal, cc_server_ccache_t**);
210
cc_int32 cci_context_ccache_iterator(cc_server_context_t* ctx, cc_ccache_iterate_t**);
211
cc_int32 cci_context_compare(cc_server_context_t* a, cc_server_context_t* b);
212
cc_int32 cci_context_destroy(cc_server_context_t* ctx);
213
cc_int32 cci_context_rem_ccache(cc_server_context_t* ctx, cc_server_ccache_t* ccache);
215
cc_int32 cci_ccache_new(char *name, char *principal, int cred_vers, cc_server_ccache_t**);
216
cc_int32 cci_ccache_check_version(const cc_server_ccache_t *ccache, const cc_credentials_union* creds, cc_uint32* compat);
217
cc_int32 cci_ccache_check_principal(const cc_server_ccache_t *ccache, const cc_credentials_union* creds, cc_uint32* compat);
218
cc_int32 cci_ccache_store_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials);
219
cc_int32 cci_ccache_rem_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials);
220
cc_int32 cci_ccache_move(cc_server_ccache_t *source, cc_server_ccache_t* destination);
221
cc_int32 cci_ccache_get_kdc_time_offset(cc_server_ccache_t* ccache, cc_time_t* offset);
222
cc_int32 cci_ccache_set_kdc_time_offset(cc_server_ccache_t* ccache, cc_time_t offset);
223
cc_int32 cci_ccache_clear_kdc_time_offset(cc_server_ccache_t* ccache);
224
cc_int32 cci_ccache_new_iterator(cc_server_ccache_t* ccache, cc_credentials_iterate_t** iterator);
225
cc_int32 cci_ccache_get_principal(cc_server_ccache_t* ccache, cc_int32 version, char ** principal);
226
cc_int32 cci_ccache_set_principal(cc_server_ccache_t* ccache, cc_int32 version, char * principal);
227
cc_int32 cci_ccache_free_principal(char * principal);
228
cc_int32 cci_ccache_destroy(cc_server_ccache_t* ccache);
229
void cci_ccache_changed(cc_server_ccache_t* ccache);
230
cc_int32 cci_ccache_compare(cc_server_ccache_t* ccache1, cc_server_ccache_t* ccache2, cc_uint32 *result);
231
#endif /*__CCDATASTOREH__*/