r8302: import mini HEIMDAL into the tree
[samba.git] / source4 / heimdal / lib / krb5 / krb5_ccapi.h
1 /*
2  * Copyright (c) 2004 Kungliga Tekniska Högskolan
3  * (Royal Institute of Technology, Stockholm, Sweden). 
4  * All rights reserved. 
5  *
6  * Redistribution and use in source and binary forms, with or without 
7  * modification, are permitted provided that the following conditions 
8  * are met: 
9  *
10  * 1. Redistributions of source code must retain the above copyright 
11  *    notice, this list of conditions and the following disclaimer. 
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright 
14  *    notice, this list of conditions and the following disclaimer in the 
15  *    documentation and/or other materials provided with the distribution. 
16  *
17  * 3. Neither the name of the Institute nor the names of its contributors 
18  *    may be used to endorse or promote products derived from this software 
19  *    without specific prior written permission. 
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
31  * SUCH DAMAGE. 
32  */
33
34 /* $Id: krb5_ccapi.h,v 1.1 2004/09/11 04:00:42 lha Exp $ */
35
36 #ifndef KRB5_CCAPI_H
37 #define KRB5_CCAPI_H 1
38
39 #include <krb5-types.h>
40
41 enum {
42     cc_credentials_v5 = 2
43 };
44
45 enum {
46     ccapi_version_3 = 3
47 };
48
49 enum {
50     ccNoError                                           = 0,
51     
52     ccIteratorEnd                                       = 201,
53     ccErrBadParam,
54     ccErrNoMem,
55     ccErrInvalidContext,
56     ccErrInvalidCCache,
57
58     ccErrInvalidString,                                 /* 206 */
59     ccErrInvalidCredentials,
60     ccErrInvalidCCacheIterator,
61     ccErrInvalidCredentialsIterator,
62     ccErrInvalidLock,
63     
64     ccErrBadName,                                       /* 211 */
65     ccErrBadCredentialsVersion,
66     ccErrBadAPIVersion,
67     ccErrContextLocked,
68     ccErrContextUnlocked,
69     
70     ccErrCCacheLocked,                                  /* 216 */
71     ccErrCCacheUnlocked,
72     ccErrBadLockType,
73     ccErrNeverDefault,
74     ccErrCredentialsNotFound,
75     
76     ccErrCCacheNotFound,                                /* 221 */
77     ccErrContextNotFound,
78     ccErrServerUnavailable,
79     ccErrServerInsecure,
80     ccErrServerCantBecomeUID,
81     
82     ccErrTimeOffsetNotSet                               /* 226 */
83 };
84
85 typedef int32_t cc_int32;
86 typedef u_int32_t cc_uint32;
87 typedef struct cc_context_t *cc_context_t;
88 typedef struct cc_ccache_t *cc_ccache_t;
89 typedef struct cc_ccache_iterator_t *cc_ccache_iterator_t;
90 typedef struct cc_credentials_v5_t cc_credentials_v5_t;
91 typedef struct cc_credentials_t *cc_credentials_t;
92 typedef struct cc_credentials_iterator_t *cc_credentials_iterator_t;
93 typedef struct cc_string_t *cc_string_t;
94 typedef time_t cc_time_t;
95
96 typedef struct cc_data {
97     cc_uint32 type;
98     cc_uint32 length;
99     void *data;
100 } cc_data;
101
102 struct cc_credentials_v5_t {
103     char *client;
104     char *server;
105     cc_data keyblock;
106     cc_time_t authtime;
107     cc_time_t starttime;
108     cc_time_t endtime;
109     cc_time_t renew_till;
110     cc_uint32 is_skey;
111     cc_uint32 ticket_flags; /* XXX ticket flags undefined */
112     cc_data **addresses;
113     cc_data ticket;
114     cc_data second_ticket;
115     cc_data **authdata;
116 };
117
118
119 typedef struct cc_string_functions {
120     cc_int32 (*release)(cc_string_t);
121 } cc_string_functions;
122
123 struct cc_string_t {
124     const char *data;
125     const cc_string_functions *func;
126 };
127
128 typedef struct cc_credentials_union {
129     cc_int32 version;
130     union {
131         cc_credentials_v5_t* credentials_v5;
132     } credentials;
133 } cc_credentials_union;
134
135 struct cc_credentials_functions {
136     cc_int32 (*release)(cc_credentials_t);
137     cc_int32 (*compare)(cc_credentials_t, cc_credentials_t, cc_uint32*);
138 };
139
140 struct cc_credentials_t {
141     const cc_credentials_union* data;
142     const struct cc_credentials_functions* func;
143 };
144
145 struct cc_credentials_iterator_functions {
146     cc_int32 (*release)(cc_credentials_iterator_t);
147     cc_int32 (*next)(cc_credentials_iterator_t, cc_credentials_t*);
148 };
149
150 struct cc_credentials_iterator_t {
151     const struct cc_credentials_iterator_functions *func;
152 };
153
154 struct cc_ccache_iterator_functions {
155     cc_int32 (*release) (cc_ccache_iterator_t);
156     cc_int32 (*next)(cc_ccache_iterator_t, cc_ccache_t*);
157 };
158
159 struct cc_ccache_iterator_t {
160     const struct cc_ccache_iterator_functions* func;
161 };
162
163 typedef struct cc_ccache_functions {
164     cc_int32 (*release)(cc_ccache_t);
165     cc_int32 (*destroy)(cc_ccache_t);
166     cc_int32 (*set_default)(cc_ccache_t);
167     cc_int32 (*get_credentials_version)(cc_ccache_t, cc_uint32*);
168     cc_int32 (*get_name)(cc_ccache_t ccache,cc_string_t*);
169     cc_int32 (*get_principal)(cc_ccache_t, cc_uint32, cc_string_t*);
170     cc_int32 (*set_principal)(cc_ccache_t, cc_uint32, const char*);
171     cc_int32 (*store_credentials)(cc_ccache_t, const cc_credentials_union*);
172     cc_int32 (*remove_credentials)(cc_ccache_t, cc_credentials_t);
173     cc_int32 (*new_credentials_iterator)(cc_ccache_t,
174                                          cc_credentials_iterator_t*);
175     cc_int32 (*move)(cc_ccache_t source, cc_ccache_t);
176     cc_int32 (*lock)(cc_ccache_t, cc_uint32, cc_uint32);
177     cc_int32 (*unlock)(cc_ccache_t);
178     cc_int32 (*get_last_default_time)(cc_ccache_t, cc_time_t*);
179     cc_int32 (*get_change_time)(cc_ccache_t ccache, cc_time_t*);
180     cc_int32 (*compare)(cc_ccache_t, cc_ccache_t, cc_uint32*);
181     cc_int32 (*get_kdc_time_offset)(cc_ccache_t, cc_int32, cc_time_t *);
182     cc_int32 (*set_kdc_time_offset)(cc_ccache_t, cc_int32, cc_time_t);
183     cc_int32 (*clear_kdc_time_offset)(cc_ccache_t, cc_int32);
184 } cc_ccache_functions;
185
186 struct cc_ccache_t {
187     const cc_ccache_functions *func;
188 };
189
190 struct  cc_context_functions {
191     cc_int32 (*release)(cc_context_t);
192     cc_int32 (*get_change_time)(cc_context_t, cc_time_t *);
193     cc_int32 (*get_default_ccache_name)(cc_context_t, cc_string_t*);
194     cc_int32 (*open_ccache)(cc_context_t, const char*, cc_ccache_t *);
195     cc_int32 (*open_default_ccache)(cc_context_t, cc_ccache_t*);
196     cc_int32 (*create_ccache)(cc_context_t,const char*, cc_uint32,
197                               const char*, cc_ccache_t*);
198     cc_int32 (*create_default_ccache)(cc_context_t, cc_uint32,
199                                       const char*, cc_ccache_t*);
200     cc_int32 (*create_new_ccache)(cc_context_t, cc_uint32,
201                                   const char*, cc_ccache_t*);
202     cc_int32 (*new_ccache_iterator)(cc_context_t, cc_ccache_iterator_t*);
203     cc_int32 (*lock)(cc_context_t, cc_uint32, cc_uint32);
204     cc_int32 (*unlock)(cc_context_t);
205     cc_int32 (*compare)(cc_context_t, cc_context_t, cc_uint32*);
206 };
207
208 struct cc_context_t {
209     const struct cc_context_functions* func;
210 };
211
212 typedef cc_int32 
213 (*cc_initialize_func)(cc_context_t*, cc_int32, cc_int32 *, char const **);
214
215 #endif /* KRB5_CCAPI_H */