]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/UserIdentification/UserProfileManagerDxe/UserProfileManager.h
Update UID drivers to align with latest UEFI spec 2.3.1.
[mirror_edk2.git] / SecurityPkg / UserIdentification / UserProfileManagerDxe / UserProfileManager.h
1 /** @file
2 The header file for user profile manager driver.
3
4 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef __EFI_USER_PROFILE_MANAGER_H__
16 #define __EFI_USER_PROFILE_MANAGER_H__
17
18 #include <Uefi.h>
19
20 #include <Guid/GlobalVariable.h>
21 #include <Guid/MdeModuleHii.h>
22
23 #include <Protocol/HiiConfigAccess.h>
24 #include <Protocol/DevicePathToText.h>
25 #include <Protocol/UserCredential2.h>
26 #include <Protocol/UserManager.h>
27
28 #include <Library/UefiRuntimeServicesTableLib.h>
29 #include <Library/UefiBootServicesTableLib.h>
30 #include <Library/MemoryAllocationLib.h>
31 #include <Library/BaseMemoryLib.h>
32 #include <Library/DevicePathLib.h>
33 #include <Library/DebugLib.h>
34 #include <Library/UefiLib.h>
35 #include <Library/PrintLib.h>
36 #include <Library/HiiLib.h>
37
38 #include "UserProfileManagerData.h"
39
40 #define USER_NAME_LENGTH 17
41
42 //
43 // Credential Provider Information.
44 //
45 typedef struct {
46 UINTN Count;
47 EFI_USER_CREDENTIAL2_PROTOCOL *Provider[1];
48 } CREDENTIAL_PROVIDER_INFO;
49
50 //
51 // User profile information structure.
52 //
53 typedef struct {
54 UINT64 UsageCount;
55 EFI_TIME CreateDate;
56 EFI_TIME UsageDate;
57 UINTN AccessPolicyLen;
58 UINTN IdentityPolicyLen;
59 UINTN NewIdentityPolicyLen;
60 UINT8 *AccessPolicy;
61 UINT8 *IdentityPolicy;
62 UINT8 *NewIdentityPolicy;
63 CHAR16 UserName[USER_NAME_LENGTH];
64 BOOLEAN CreateDateExist;
65 BOOLEAN UsageDateExist;
66 BOOLEAN AccessPolicyModified;
67 BOOLEAN IdentityPolicyModified;
68 BOOLEAN NewIdentityPolicyModified;
69 } USER_INFO;
70
71 //
72 // User access information structure.
73 //
74 typedef struct {
75 UINTN LoadPermitLen;
76 UINTN LoadForbidLen;
77 UINTN ConnectPermitLen;
78 UINTN ConnectForbidLen;
79 UINT8 *LoadPermit;
80 UINT8 *LoadForbid;
81 UINT8 *ConnectPermit;
82 UINT8 *ConnectForbid;
83 UINT32 AccessBootOrder;
84 UINT8 AccessRight;
85 UINT8 AccessSetup;
86 } USER_INFO_ACCESS;
87
88 #define USER_PROFILE_MANAGER_SIGNATURE SIGNATURE_32 ('U', 'P', 'M', 'S')
89
90 typedef struct {
91 UINTN Signature;
92 EFI_HANDLE DriverHandle;
93 EFI_HII_HANDLE HiiHandle;
94 EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;
95 } USER_PROFILE_MANAGER_CALLBACK_INFO;
96
97 //
98 // HII specific Vendor Device Path definition.
99 //
100 typedef struct {
101 VENDOR_DEVICE_PATH VendorDevicePath;
102 EFI_DEVICE_PATH_PROTOCOL End;
103 } HII_VENDOR_DEVICE_PATH;
104
105 //
106 // This is the generated IFR binary data for each formset defined in VFR.
107 //
108 extern UINT8 UserProfileManagerVfrBin[];
109
110 //
111 // This is the generated String package data for .UNI file.
112 //
113 extern UINT8 UserProfileManagerStrings[];
114
115 //
116 // The user manager protocol, used in several function.
117 //
118 extern EFI_USER_MANAGER_PROTOCOL *mUserManager;
119
120 //
121 // The credential providers database in system.
122 //
123 extern CREDENTIAL_PROVIDER_INFO *mProviderInfo;
124
125 //
126 // The variables used to update identity policy.
127 //
128 extern UINT8 mProviderChoice;
129 extern UINT8 mConncetLogical;
130
131 //
132 // The variables used to update access policy.
133 //
134 extern USER_INFO_ACCESS mAccessInfo;
135
136 //
137 // The user information used to record all data in UI.
138 //
139 extern USER_INFO mUserInfo;
140
141 extern USER_PROFILE_MANAGER_CALLBACK_INFO *mCallbackInfo;
142
143 extern EFI_USER_PROFILE_HANDLE mModifyUser;
144
145 /**
146 Get string by string id from HII Interface.
147
148
149 @param[in] Id String ID to get the string from.
150
151 @retval CHAR16 * String from ID.
152 @retval NULL If error occurs.
153
154 **/
155 CHAR16 *
156 GetStringById (
157 IN EFI_STRING_ID Id
158 );
159
160 /**
161 Add a new user profile into the user profile database.
162
163 **/
164 VOID
165 CallAddUser (
166 VOID
167 );
168
169 /**
170 Display user select form; can select a user to modify.
171
172 **/
173 VOID
174 SelectUserToModify (
175 VOID
176 );
177
178 /**
179 Display user select form, cab select a user to delete.
180
181 **/
182 VOID
183 SelectUserToDelete (
184 VOID
185 );
186
187 /**
188 Delete the user specified by UserIndex in user profile database.
189
190 @param[in] UserIndex The index of user in the user name list to be deleted.
191
192 **/
193 VOID
194 DeleteUser (
195 IN UINT8 UserIndex
196 );
197
198 /**
199 Add a username item in form.
200
201 @param[in] User Points to the user profile whose username is added.
202 @param[in] Index The index of the user in the user name list.
203 @param[in] OpCodeHandle Points to container for dynamic created opcodes.
204
205 **/
206 VOID
207 AddUserToForm (
208 IN EFI_USER_PROFILE_HANDLE User,
209 IN UINT16 Index,
210 IN VOID *OpCodeHandle
211 );
212
213 /**
214 Display modify user information form
215
216 In this form, username, create Date, usage date, usage count, identity policy,
217 and access policy are displayed.
218
219 @param[in] UserIndex The index of the user in display list to modify.
220
221 **/
222 VOID
223 ModifyUserInfo (
224 IN UINT8 UserIndex
225 );
226
227 /**
228 Get the username from user input and update username string in Hii
229 database with it.
230
231 **/
232 VOID
233 ModifyUserName (
234 VOID
235 );
236
237 /**
238 Display the form of modifying user identity policy.
239
240 **/
241 VOID
242 ModifyIdentityPolicy (
243 VOID
244 );
245
246 /**
247 Update the mUserInfo.NewIdentityPolicy and UI when 'add option' is pressed.
248
249 **/
250 VOID
251 AddIdentityPolicyItem (
252 VOID
253 );
254
255 /**
256 Save the identity policy and update UI with it.
257
258 This funciton will verify the new identity policy, in current implementation,
259 the identity policy can be: T, P & P & P & ..., P | P | P | ...
260 Here, "T" means "True", "P" means "Credential Provider", "&" means "and", "|" means "or".
261 Other identity policies are not supported.
262
263 **/
264 VOID
265 SaveIdentityPolicy (
266 VOID
267 );
268
269 /**
270 Display modify user access policy form
271
272 In this form, access right, access setu,p and access boot order are dynamically
273 added. Load devicepath and connect devicepath are displayed too.
274
275 **/
276 VOID
277 ModidyAccessPolicy (
278 VOID
279 );
280
281 /**
282 Collect all the access policy data to mUserInfo.AccessPolicy,
283 and save it to user profile.
284
285 **/
286 VOID
287 SaveAccessPolicy (
288 VOID
289 );
290
291 /**
292 Get current user's access rights.
293
294 @param[out] AccessRight Points to the buffer used for user's access rights.
295
296 @retval EFI_SUCCESS Get current user access rights successfully.
297 @retval others Fail to get current user access rights.
298
299 **/
300 EFI_STATUS
301 GetAccessRight (
302 OUT UINT32 *AccessRight
303 );
304
305 /**
306 Display the permit load device path in the loadable device path list.
307
308 **/
309 VOID
310 DisplayLoadPermit(
311 VOID
312 );
313
314 /**
315 Display the forbid load device path list (mAccessInfo.LoadForbid).
316
317 **/
318 VOID
319 DisplayLoadForbid (
320 VOID
321 );
322
323 /**
324 Display the permit connect device path.
325
326 **/
327 VOID
328 DisplayConnectPermit (
329 VOID
330 );
331
332 /**
333 Display the forbid connect device path list.
334
335 **/
336 VOID
337 DisplayConnectForbid (
338 VOID
339 );
340
341 /**
342 Delete the specified device path by DriverIndex from the forbid device path
343 list (mAccessInfo.LoadForbid).
344
345 @param[in] DriverIndex The index of driver in a forbidden device path list.
346
347 **/
348 VOID
349 DeleteFromForbidLoad (
350 IN UINT16 DriverIndex
351 );
352
353 /**
354 Add the specified device path by DriverIndex to the forbid device path
355 list (mAccessInfo.LoadForbid).
356
357 @param[in] DriverIndex The index of driver saved in driver options.
358
359 **/
360 VOID
361 AddToForbidLoad (
362 IN UINT16 DriverIndex
363 );
364
365 /**
366 Get user name from the popup windows.
367
368 @param[in, out] UserNameLen On entry, point to the buffer lengh of UserName.
369 On exit, point to the input user name length.
370 @param[out] UserName The buffer to hold the input user name.
371
372 @retval EFI_ABORTED It is given up by pressing 'ESC' key.
373 @retval EFI_NOT_READY Not a valid input at all.
374 @retval EFI_SUCCESS Get a user name successfully.
375
376 **/
377 EFI_STATUS
378 GetUserNameInput (
379 IN OUT UINTN *UserNameLen,
380 OUT CHAR16 *UserName
381 );
382
383 /**
384 Find the specified info in User profile by the InfoType.
385
386 @param[in] User Handle of the user whose information will be searched.
387 @param[in] InfoType The user information type to find.
388 @param[out] UserInfo Points to user information handle found.
389
390 @retval EFI_SUCCESS Find the user information successfully.
391 @retval Others Fail to find the user information.
392
393 **/
394 EFI_STATUS
395 FindInfoByType (
396 IN EFI_USER_PROFILE_HANDLE User,
397 IN UINT8 InfoType,
398 OUT EFI_USER_INFO_HANDLE *UserInfo
399 );
400
401 /**
402 Convert the identity policy to a unicode string and update the Hii database
403 IpStringId string with it.
404
405 @param[in] Ip Points to identity policy.
406 @param[in] IpLen The identity policy length.
407 @param[in] IpStringId String ID in the HII database to be replaced.
408
409 **/
410 VOID
411 ResolveIdentityPolicy (
412 IN UINT8 *Ip,
413 IN UINTN IpLen,
414 IN EFI_STRING_ID IpStringId
415 );
416
417 /**
418 Expand access policy memory size.
419
420 @param[in] ValidLen The valid access policy length.
421 @param[in] ExpandLen The length that is needed to expand.
422
423 **/
424 VOID
425 ExpandMemory (
426 IN UINTN ValidLen,
427 IN UINTN ExpandLen
428 );
429
430 /**
431 Delete User's credental from all the providers that exist in User's identity policy.
432
433 @param[in] IdentityPolicy Point to User's identity policy.
434 @param[in] IdentityPolicyLen The length of the identity policy.
435 @param[in] User Points to user profile.
436
437 **/
438 VOID
439 DeleteCredentialFromProviders (
440 IN UINT8 *IdentityPolicy,
441 IN UINTN IdentityPolicyLen,
442 IN EFI_USER_PROFILE_HANDLE User
443 );
444
445 #endif