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