rx: Remove RX_CALL_BUSY
[openafs.git] / src / WINNT / netidmgr_plugin / afscred.h
1 /*
2  * Copyright (c) 2005-2008 Secure Endpoints Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person
5  * obtaining a copy of this software and associated documentation
6  * files (the "Software"), to deal in the Software without
7  * restriction, including without limitation the rights to use, copy,
8  * modify, merge, publish, distribute, sublicense, and/or sell copies
9  * of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
19  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
20  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24
25 /* $Id$ */
26
27 #ifndef __KHIMAIRA_AFSCRED_H
28 #define __KHIMAIRA_AFSCRED_H
29
30 #ifndef _WIN64
31 #define _USE_32BIT_TIME_T 1
32 #endif
33
34 #include <afsconfig.h>
35 #include <afs/param.h>
36 #include <roken.h>
37
38 #define _WINSOCKAPI_
39 #include<windows.h>
40 #include<time.h>
41
42 #define KHERR_FACILITY L"AfsCred"
43 #define KHERR_HMODULE hResModule
44 #include<netidmgr.h>
45
46 #include<langres.h>
47
48 #include <afs/stds.h>
49 #include <afs/cm_config.h>
50 #include <afs/auth.h>
51 #include <afs/ptserver.h>
52 #include <afs/ptuser.h>
53
54 #include<afspext.h>
55
56 #include<afsfuncs.h>
57 #include<afsnewcreds.h>
58
59 #ifndef NOSTRSAFE
60 #include<strsafe.h>
61 #endif
62
63 #define AFS_PLUGIN_NAME         L"AfsCred"
64 #define AFS_CREDTYPE_NAME       L"AfsCred"
65
66 #define AFS_PLUGIN_DEPS         L"Krb5Cred\0"
67
68 #define KRB5_CREDTYPE_NAME      L"Krb5Cred"
69 #define KRB4_CREDTYPE_NAME      L"Krb4Cred"
70
71 #define AFS_TYPENAME_PRINCIPAL      L"AFSPrincipal"
72 #define AFS_TYPENAME_METHOD         L"AFSTokenMethod"
73 #define AFS_ATTRNAME_CLIENT_PRINC   L"AFSClientPrinc"
74 #define AFS_ATTRNAME_SERVER_PRINC   L"AFSServerPrinc"
75 #define AFS_ATTRNAME_CELL           L"AFSCell"
76 #define AFS_ATTRNAME_METHOD         L"AFSMethod"
77 #define AFS_ATTRNAME_REALM          L"AFSRealm"
78
79 #define AFS_VALID_CELL_CHARS    L"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-"
80 #define AFS_VALID_REALM_CHARS   AFS_VALID_CELL_CHARS
81
82 #define AFS_CONFIG_NODE_IDS     L"AfsIdentities"
83 #define AFS_CONFIG_NODE_ID      L"AfsIdentity"
84 #define AFS_CONFIG_NODE_MAIN    L"AfsOptions"
85
86 #define AFS_HELPFILE            L"afsplhlp.chm"
87
88 /* token acquisition methods provided by extensions begin with this
89    ID */
90 #define AFS_TOKEN_USER          8
91
92 void init_afs();
93 void exit_afs();
94 KHMEXP khm_int32 KHMAPI init_module(kmm_module h_module);
95 KHMEXP khm_int32 KHMAPI exit_module(kmm_module h_module);
96
97 /* globals */
98 extern kmm_module h_khModule;
99 extern HMODULE hResModule;
100 extern HINSTANCE hInstance;
101
102 extern khm_int32 afs_credtype_id;
103 extern khm_int32 krb5_credtype_id;
104 extern khm_int32 krb4_credtype_id;
105 extern khm_int32 afs_msg_type_id;
106 extern khm_handle afs_credset;
107
108 extern khm_int32 afs_type_principal;
109 extern khm_int32 afs_attr_client_princ;
110 extern khm_int32 afs_attr_server_princ;
111 extern khm_int32 afs_attr_cell;
112 extern khm_int32 afs_attr_method;
113 extern khm_int32 afs_attr_realm;
114
115 /* Configuration spaces */
116 #define CSNAME_PLUGINS      L"Plugins"
117 #define CSNAME_AFSCRED      L"AfsCred"
118 #define CSNAME_PARAMS       L"Parameters"
119
120 extern khm_handle csp_plugins;
121 extern khm_handle csp_afscred;
122 extern khm_handle csp_params;
123
124 extern khm_handle afs_sub;
125
126 /* defined in afsconfig.c which is generated from afsconfig.csv */
127 extern kconf_schema schema_afsconfig[];
128
129
130 /* plugin callback procedure */
131 khm_int32 KHMAPI
132 afs_plugin_cb(khm_int32 msg_type,
133               khm_int32 msg_subtype,
134               khm_ui_4 uparam,
135               void * vparam);
136
137 INT_PTR CALLBACK
138 afs_cfg_ids_proc(HWND hwnd,
139                  UINT uMsg,
140                  WPARAM wParam,
141                  LPARAM lParam);
142
143 INT_PTR CALLBACK
144 afs_cfg_id_proc(HWND hwnd,
145                 UINT uMsg,
146                 WPARAM wParam,
147                 LPARAM lParam);
148
149 INT_PTR CALLBACK
150 afs_cfg_main_proc(HWND hwnd,
151                   UINT uMsg,
152                   WPARAM wParam,
153                   LPARAM lParam);
154
155 HWND
156 afs_html_help(HWND caller,
157               wchar_t * postfix,
158               UINT cmd,
159               DWORD_PTR data);
160
161 /* extensions */
162 typedef afs_msg_announce afs_extension;
163
164 /* not thread safe. only call from the plugin thread */
165 afs_extension *
166 afs_find_extension(const wchar_t * name);
167
168 /* not thread safe. only call from the plugin thread */
169 afs_extension *
170 afs_get_extension(khm_size i);
171
172 /* not thread safe.  only call from the plugin thread */
173 afs_extension *
174 afs_get_next_token_acq(afs_extension * f);
175
176 /* not thread safe.  only call from the plugin thread */
177 khm_boolean
178 afs_is_valid_method_id(afs_tk_method method);
179
180 afs_tk_method
181 afs_get_next_method_id(afs_tk_method method);
182
183 afs_tk_method
184 afs_get_method_id(wchar_t * name);
185
186 khm_boolean
187 afs_get_method_name(afs_tk_method method, wchar_t * buf, khm_size cbbuf);
188
189 afs_extension *
190 afs_get_method_ext(afs_tk_method method);
191
192 khm_boolean
193 afs_method_describe(afs_tk_method method, khm_int32 flags,
194                     wchar_t * wbuf, khm_size cbbuf);
195
196 khm_boolean
197 afs_ext_resolve_token(const wchar_t * cell,
198                       const struct ktc_token * token,
199                       const struct ktc_principal * serverp,
200                       const struct ktc_principal * clientp,
201                       khm_handle * pident,
202                       afs_tk_method * pmethod);
203
204 khm_boolean
205 afs_ext_klog(afs_tk_method method,
206              khm_handle   identity,
207              const char * service,
208              const char * cell,
209              const char * realm,
210              const afs_conf_cell * cell_config,
211              khm_int32    lifetime);
212
213 BOOL
214 afs_cfg_get_afscreds_shortcut(wchar_t * wpath);
215
216 /* Notificaiton icon functions */
217
218 enum notification_icon_state {
219     AFSICON_REPORT_TOKENS,
220     AFSICON_SERVICE_STOPPED,
221     AFSICON_SERVICE_ERROR
222 };
223
224 void
225 afs_icon_set_state(enum notification_icon_state state,
226                    khm_handle credset_with_tokens);
227
228 void
229 afs_remove_icon(void);
230
231
232 /* Compatibility */
233 #if KH_VERSION_API < 7
234
235 #ifdef _WIN64
236 #define NIMDLLNAME L"nidmgr64.dll"
237 #define API_khui_action_lock "khui_action_lock"
238 #define API_khui_action_unlock "khui_action_unlock"
239 #define API_khui_refresh_actions "khui_refresh_actions"
240 #define API_khui_request_UI_callback "khui_request_UI_callback"
241 #else
242 #define NIMDLLNAME L"nidmgr32.dll"
243 #define API_khui_action_lock "_khui_action_lock@0"
244 #define API_khui_action_unlock "_khui_action_unlock@0"
245 #define API_khui_refresh_actions "_khui_refresh_actions@0"
246 #define API_khui_request_UI_callback "_khui_request_UI_callback@8"
247 #endif
248
249 extern void
250 (KHMAPI * pkhui_action_lock)(void);
251
252 extern void
253 (KHMAPI * pkhui_action_unlock)(void);
254
255 extern void
256 (KHMAPI * pkhui_refresh_actions)(void);
257
258 typedef khm_int32
259 (KHMAPI * khm_ui_callback)(HWND hwnd_main_wnd, void * rock);
260
261 extern khm_int32
262 (KHMAPI * pkhui_request_UI_callback)(khm_ui_callback cb,
263                                      void * rock);
264
265 #define khui_action_lock         (*pkhui_action_lock)
266 #define khui_action_unlock       (*pkhui_action_unlock)
267 #define khui_refresh_actions     (*pkhui_refresh_actions)
268 #define khui_request_UI_callback (*pkhui_request_UI_callback)
269
270 #endif
271
272 #endif