2 This driver manages user information and produces user manager protocol.
4 Copyright (c) 2009 - 2014, 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
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.
15 #include "UserIdentifyManager.h"
20 CHAR16 mUserName
[] = L
"Administrator";
23 // Points to the user profile database.
25 USER_PROFILE_DB
*mUserProfileDb
= NULL
;
28 // Points to the credential providers found in system.
30 CREDENTIAL_PROVIDER_INFO
*mProviderDb
= NULL
;
33 // Current user shared in multi function.
35 EFI_USER_PROFILE_HANDLE mCurrentUser
= NULL
;
38 // Flag indicates a user is identified.
40 BOOLEAN mIdentified
= FALSE
;
41 USER_MANAGER_CALLBACK_INFO
*mCallbackInfo
= NULL
;
42 HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath
= {
48 (UINT8
) (sizeof (VENDOR_DEVICE_PATH
)),
49 (UINT8
) ((sizeof (VENDOR_DEVICE_PATH
)) >> 8)
52 USER_IDENTIFY_MANAGER_GUID
56 END_ENTIRE_DEVICE_PATH_SUBTYPE
,
58 (UINT8
) (END_DEVICE_PATH_LENGTH
),
59 (UINT8
) ((END_DEVICE_PATH_LENGTH
) >> 8)
65 EFI_USER_MANAGER_PROTOCOL gUserIdentifyManager
= {
75 UserProfileDeleteInfo
,
76 UserProfileGetNextInfo
,
81 Find the specified user in the user database.
83 This function searches the specified user from the beginning of the user database.
84 And if NextUser is TRUE, return the next User in the user database.
86 @param[in, out] User On entry, points to the user profile entry to search.
87 On return, points to the user profile entry or NULL if not found.
88 @param[in] NextUser If FALSE, find the user in user profile database specifyed by User
89 If TRUE, find the next user in user profile database specifyed
91 @param[out] ProfileIndex A pointer to the index of user profile database that matches the
92 user specifyed by User.
94 @retval EFI_NOT_FOUND User was NULL, or User was not found, or the next user was not found.
95 @retval EFI_SUCCESS User or the next user are found in user profile database
100 IN OUT USER_PROFILE_ENTRY
**User
,
102 OUT UINTN
*ProfileIndex OPTIONAL
110 if ((mUserProfileDb
== NULL
) || (User
== NULL
)) {
111 return EFI_NOT_FOUND
;
115 // Check whether the user profile is in the user profile database.
117 for (Index
= 0; Index
< mUserProfileDb
->UserProfileNum
; Index
++) {
118 if (mUserProfileDb
->UserProfile
[Index
] == *User
) {
119 if (ProfileIndex
!= NULL
) {
120 *ProfileIndex
= Index
;
128 // Find the next user profile.
131 if (Index
< mUserProfileDb
->UserProfileNum
) {
132 *User
= mUserProfileDb
->UserProfile
[Index
];
133 } else if (Index
== mUserProfileDb
->UserProfileNum
) {
135 return EFI_NOT_FOUND
;
137 if ((mUserProfileDb
->UserProfileNum
> 0) && (*User
== NULL
)) {
138 *User
= mUserProfileDb
->UserProfile
[0];
141 return EFI_NOT_FOUND
;
144 } else if (Index
== mUserProfileDb
->UserProfileNum
) {
145 return EFI_NOT_FOUND
;
152 Find the specified user information record in the specified User profile.
154 This function searches the specified user information record from the beginning of the user
155 profile. And if NextInfo is TRUE, return the next info in the user profile.
157 @param[in] User Points to the user profile entry.
158 @param[in, out] Info On entry, points to the user information record or NULL to start
159 searching with the first user information record.
160 On return, points to the user information record or NULL if not found.
161 @param[in] NextInfo If FALSE, find the user information record in profile specifyed by User.
162 If TRUE, find the next user information record in profile specifyed
164 @param[out] Offset A pointer to the offset of the information record in the user profile.
166 @retval EFI_INVALID_PARAMETER Info is NULL
167 @retval EFI_NOT_FOUND Info was not found, or the next Info was not found.
168 @retval EFI_SUCCESS Info or the next info are found in user profile.
173 IN USER_PROFILE_ENTRY
* User
,
174 IN OUT EFI_USER_INFO
**Info
,
176 OUT UINTN
*Offset OPTIONAL
180 EFI_USER_INFO
*UserInfo
;
184 return EFI_INVALID_PARAMETER
;
188 // Check user profile entry
190 Status
= FindUserProfile (&User
, FALSE
, NULL
);
191 if (EFI_ERROR (Status
)) {
196 // Find user information in the specified user record.
199 while (InfoLen
< User
->UserProfileSize
) {
200 UserInfo
= (EFI_USER_INFO
*) (User
->ProfileInfo
+ InfoLen
);
201 if (UserInfo
== *Info
) {
202 if (Offset
!= NULL
) {
207 InfoLen
+= ALIGN_VARIABLE (UserInfo
->InfoSize
);
211 // Check whether to find the next user information.
214 if (InfoLen
< User
->UserProfileSize
) {
215 UserInfo
= (EFI_USER_INFO
*) (User
->ProfileInfo
+ InfoLen
);
216 InfoLen
+= ALIGN_VARIABLE (UserInfo
->InfoSize
);
217 if (InfoLen
< User
->UserProfileSize
) {
218 *Info
= (EFI_USER_INFO
*) (User
->ProfileInfo
+ InfoLen
);
219 if (Offset
!= NULL
) {
222 } else if (InfoLen
== User
->UserProfileSize
) {
224 return EFI_NOT_FOUND
;
228 *Info
= (EFI_USER_INFO
*) User
->ProfileInfo
;
229 if (Offset
!= NULL
) {
234 return EFI_NOT_FOUND
;
237 } else if (InfoLen
== User
->UserProfileSize
) {
238 return EFI_NOT_FOUND
;
245 Find a user infomation record by the information record type.
247 This function searches all user information records of User. The search starts with the
248 user information record following Info and continues until either the information is found
249 or there are no more user infomation record.
250 A match occurs when a Info.InfoType field matches the user information record type.
252 @param[in] User Points to the user profile record to search.
253 @param[in, out] Info On entry, points to the user information record or NULL to start
254 searching with the first user information record.
255 On return, points to the user information record or NULL if not found.
256 @param[in] InfoType The infomation type to be searched.
258 @retval EFI_SUCCESS User information was found. Info points to the user information record.
259 @retval EFI_NOT_FOUND User information was not found.
260 @retval EFI_INVALID_PARAMETER User is NULL or Info is NULL.
265 IN USER_PROFILE_ENTRY
*User
,
266 IN OUT EFI_USER_INFO
**Info
,
271 EFI_USER_INFO
*UserInfo
;
275 return EFI_INVALID_PARAMETER
;
279 // Check whether the user has the specified user information.
283 Status
= FindUserProfile (&User
, FALSE
, NULL
);
285 Status
= FindUserInfo (User
, Info
, TRUE
, &InfoLen
);
288 if (EFI_ERROR (Status
)) {
289 return EFI_NOT_FOUND
;
292 while (InfoLen
< User
->UserProfileSize
) {
293 UserInfo
= (EFI_USER_INFO
*) (User
->ProfileInfo
+ InfoLen
);
294 if (UserInfo
->InfoType
== InfoType
) {
295 if (UserInfo
!= *Info
) {
301 InfoLen
+= ALIGN_VARIABLE (UserInfo
->InfoSize
);
305 return EFI_NOT_FOUND
;
309 Find a user using a user information record.
311 This function searches all user profiles for the specified user information record. The
312 search starts with the user information record handle following UserInfo and continues
313 until either the information is found or there are no more user profiles.
314 A match occurs when the Info.InfoType field matches the user information record type and the
315 user information record data matches the portion of Info passed the EFI_USER_INFO header.
317 @param[in, out] User On entry, points to the previously returned user profile record,
318 or NULL to start searching with the first user profile.
319 On return, points to the user profile entry, or NULL if not found.
320 @param[in, out] UserInfo On entry, points to the previously returned user information record,
321 or NULL to start searching with the first.
322 On return, points to the user information record, or NULL if not found.
323 @param[in] Info Points to the buffer containing the user information to be compared
324 to the user information record.
325 @param[in] InfoSize The size of Info, in bytes. Same as Info->InfoSize.
327 @retval EFI_SUCCESS User information was found. User points to the user profile record,
328 and UserInfo points to the user information record.
329 @retval EFI_NOT_FOUND User information was not found.
330 @retval EFI_INVALID_PARAMETER User is NULL; Info is NULL; or, InfoSize is too small.
334 FindUserProfileByInfo (
335 IN OUT USER_PROFILE_ENTRY
**User
,
336 IN OUT EFI_USER_INFO
**UserInfo
, OPTIONAL
337 IN EFI_USER_INFO
*Info
,
342 EFI_USER_INFO
*InfoEntry
;
345 if ((User
== NULL
) || (Info
== NULL
)) {
346 return EFI_INVALID_PARAMETER
;
349 if (InfoSize
< sizeof (EFI_USER_INFO
)) {
350 return EFI_INVALID_PARAMETER
;
353 if (UserInfo
!= NULL
) {
354 InfoEntry
= *UserInfo
;
359 // Find user profile according to information.
362 *User
= mUserProfileDb
->UserProfile
[0];
366 // Check user profile handle.
368 Status
= FindUserProfile (User
, FALSE
, NULL
);
370 while (!EFI_ERROR (Status
)) {
372 // Find the user information in a user profile.
375 Status
= FindUserInfoByType (*User
, &InfoEntry
, Info
->InfoType
);
376 if (EFI_ERROR (Status
)) {
380 if (InfoSize
== Info
->InfoSize
) {
381 if (CompareMem ((UINT8
*) (InfoEntry
+ 1), (UINT8
*) (Info
+ 1), InfoSize
- sizeof (EFI_USER_INFO
)) == 0) {
383 // Found the infomation record.
385 if (UserInfo
!= NULL
) {
386 *UserInfo
= InfoEntry
;
394 // Get next user profile.
397 Status
= FindUserProfile (User
, TRUE
, NULL
);
400 return EFI_NOT_FOUND
;
405 Check whether the access policy is valid.
407 @param[in] PolicyInfo Point to the access policy.
408 @param[in] InfoLen The policy length.
410 @retval TRUE The policy is a valid access policy.
411 @retval FALSE The access policy is not a valid access policy.
416 IN UINT8
*PolicyInfo
,
423 EFI_USER_INFO_ACCESS_CONTROL Access
;
424 EFI_DEVICE_PATH_PROTOCOL
*Path
;
428 while (TotalLen
< InfoLen
) {
430 // Check access policy according to type.
432 CopyMem (&Access
, PolicyInfo
+ TotalLen
, sizeof (Access
));
433 ValueLen
= Access
.Size
- sizeof (EFI_USER_INFO_ACCESS_CONTROL
);
434 switch (Access
.Type
) {
435 case EFI_USER_INFO_ACCESS_FORBID_LOAD
:
436 case EFI_USER_INFO_ACCESS_PERMIT_LOAD
:
437 case EFI_USER_INFO_ACCESS_FORBID_CONNECT
:
438 case EFI_USER_INFO_ACCESS_PERMIT_CONNECT
:
440 while (OffSet
< ValueLen
) {
441 Path
= (EFI_DEVICE_PATH_PROTOCOL
*) (PolicyInfo
+ TotalLen
+ sizeof (Access
) + OffSet
);
442 PathSize
= GetDevicePathSize (Path
);
445 if (OffSet
!= ValueLen
) {
450 case EFI_USER_INFO_ACCESS_SETUP
:
451 if (ValueLen
% sizeof (EFI_GUID
) != 0) {
456 case EFI_USER_INFO_ACCESS_BOOT_ORDER
:
457 if (ValueLen
% sizeof (EFI_USER_INFO_ACCESS_BOOT_ORDER_HDR
) != 0) {
462 case EFI_USER_INFO_ACCESS_ENROLL_SELF
:
463 case EFI_USER_INFO_ACCESS_ENROLL_OTHERS
:
464 case EFI_USER_INFO_ACCESS_MANAGE
:
475 TotalLen
+= Access
.Size
;
478 if (TotalLen
!= InfoLen
) {
487 Check whether the identity policy is valid.
489 @param[in] PolicyInfo Point to the identity policy.
490 @param[in] InfoLen The policy length.
492 @retval TRUE The policy is a valid identity policy.
493 @retval FALSE The access policy is not a valid identity policy.
497 CheckIdentityPolicy (
498 IN UINT8
*PolicyInfo
,
504 EFI_USER_INFO_IDENTITY_POLICY
*Identity
;
509 // Check each part of policy expression.
511 while (TotalLen
< InfoLen
) {
513 // Check access polisy according to type.
515 Identity
= (EFI_USER_INFO_IDENTITY_POLICY
*) (PolicyInfo
+ TotalLen
);
516 ValueLen
= Identity
->Length
- sizeof (EFI_USER_INFO_IDENTITY_POLICY
);
517 switch (Identity
->Type
) {
519 // Check False option.
521 case EFI_USER_INFO_IDENTITY_FALSE
:
528 // Check True option.
530 case EFI_USER_INFO_IDENTITY_TRUE
:
537 // Check negative operation.
539 case EFI_USER_INFO_IDENTITY_NOT
:
546 // Check and operation.
548 case EFI_USER_INFO_IDENTITY_AND
:
555 // Check or operation.
557 case EFI_USER_INFO_IDENTITY_OR
:
564 // Check credential provider by type.
566 case EFI_USER_INFO_IDENTITY_CREDENTIAL_TYPE
:
567 if (ValueLen
!= sizeof (EFI_GUID
)) {
573 // Check credential provider by ID.
575 case EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER
:
576 if (ValueLen
!= sizeof (EFI_GUID
)) {
586 TotalLen
+= Identity
->Length
;
589 if (TotalLen
!= InfoLen
) {
598 Check whether the user information is a valid user information record.
600 @param[in] Info points to the user information.
602 @retval TRUE The info is a valid user information record.
603 @retval FALSE The info is not a valid user information record.
608 IN CONST EFI_USER_INFO
*Info
617 // Check user information according to information type.
619 InfoLen
= Info
->InfoSize
- sizeof (EFI_USER_INFO
);
620 switch (Info
->InfoType
) {
621 case EFI_USER_INFO_EMPTY_RECORD
:
627 case EFI_USER_INFO_NAME_RECORD
:
628 case EFI_USER_INFO_CREDENTIAL_TYPE_NAME_RECORD
:
629 case EFI_USER_INFO_CREDENTIAL_PROVIDER_NAME_RECORD
:
632 case EFI_USER_INFO_CREATE_DATE_RECORD
:
633 case EFI_USER_INFO_USAGE_DATE_RECORD
:
634 if (InfoLen
!= sizeof (EFI_TIME
)) {
639 case EFI_USER_INFO_USAGE_COUNT_RECORD
:
640 if (InfoLen
!= sizeof (UINT64
)) {
645 case EFI_USER_INFO_IDENTIFIER_RECORD
:
651 case EFI_USER_INFO_CREDENTIAL_TYPE_RECORD
:
652 case EFI_USER_INFO_CREDENTIAL_PROVIDER_RECORD
:
653 case EFI_USER_INFO_GUID_RECORD
:
654 if (InfoLen
!= sizeof (EFI_GUID
)) {
659 case EFI_USER_INFO_PKCS11_RECORD
:
660 case EFI_USER_INFO_CBEFF_RECORD
:
663 case EFI_USER_INFO_FAR_RECORD
:
664 case EFI_USER_INFO_RETRY_RECORD
:
670 case EFI_USER_INFO_ACCESS_POLICY_RECORD
:
671 if(!CheckAccessPolicy ((UINT8
*) (Info
+ 1), InfoLen
)) {
676 case EFI_USER_INFO_IDENTITY_POLICY_RECORD
:
677 if (!CheckIdentityPolicy ((UINT8
*) (Info
+ 1), InfoLen
)) {
692 Check the user profile data format to be added.
694 @param[in] UserProfileInfo Points to the user profile data.
695 @param[in] UserProfileSize The length of user profile data.
697 @retval TRUE It is a valid user profile.
698 @retval FALSE It is not a valid user profile.
703 IN UINT8
*UserProfileInfo
,
704 IN UINTN UserProfileSize
710 if (UserProfileInfo
== NULL
) {
715 // Check user profile information length.
718 while (ChkLen
< UserProfileSize
) {
719 Info
= (EFI_USER_INFO
*) (UserProfileInfo
+ ChkLen
);
721 // Check user information format.
723 if (!CheckUserInfo (Info
)) {
727 ChkLen
+= ALIGN_VARIABLE (Info
->InfoSize
);
730 if (ChkLen
!= UserProfileSize
) {
739 Find the specified RightType in current user profile.
741 @param[in] RightType Could be EFI_USER_INFO_ACCESS_MANAGE,
742 EFI_USER_INFO_ACCESS_ENROLL_OTHERS or
743 EFI_USER_INFO_ACCESS_ENROLL_SELF.
745 @retval TRUE Find the specified RightType in current user profile.
746 @retval FALSE Can't find the right in the profile.
750 CheckCurrentUserAccessRight (
758 EFI_USER_INFO_ACCESS_CONTROL Access
;
761 // Get user access right information.
764 Status
= FindUserInfoByType (
765 (USER_PROFILE_ENTRY
*) mCurrentUser
,
767 EFI_USER_INFO_ACCESS_POLICY_RECORD
769 if (EFI_ERROR (Status
)) {
773 ASSERT (Info
!= NULL
);
774 TotalLen
= Info
->InfoSize
- sizeof (EFI_USER_INFO
);
776 while (CheckLen
< TotalLen
) {
778 // Check right according to access type.
780 CopyMem (&Access
, (UINT8
*) (Info
+ 1) + CheckLen
, sizeof (Access
));
781 if (Access
.Type
== RightType
) {
785 CheckLen
+= Access
.Size
;
793 Create a unique user identifier.
795 @param[out] Identifier This points to the identifier.
800 OUT UINT8
*Identifier
804 UINT64 MonotonicCount
;
805 UINT32
*MonotonicPointer
;
809 // Create a unique user identifier.
811 gRT
->GetTime (&Time
, NULL
);
812 CopyMem (Identifier
, &Time
, sizeof (EFI_TIME
));
816 for (Index
= 0; Index
< sizeof (EFI_TIME
); Index
++) {
817 if (Identifier
[Index
] == 0) {
818 Identifier
[Index
] = 0x5a;
822 MonotonicPointer
= (UINT32
*) Identifier
;
823 gBS
->GetNextMonotonicCount (&MonotonicCount
);
824 MonotonicPointer
[0] += (UINT32
) MonotonicCount
;
825 MonotonicPointer
[1] += (UINT32
) MonotonicCount
;
826 MonotonicPointer
[2] += (UINT32
) MonotonicCount
;
827 MonotonicPointer
[3] += (UINT32
) MonotonicCount
;
832 Generate unique user ID.
834 @param[out] UserId Points to the user identifer.
843 USER_PROFILE_ENTRY
*UserProfile
;
844 EFI_USER_INFO
*UserInfo
;
848 // Generate unique user ID
851 GenerateIdentifier (UserId
);
853 // Check whether it's unique in user profile database.
855 if (mUserProfileDb
== NULL
) {
859 for (Index
= 0; Index
< mUserProfileDb
->UserProfileNum
; Index
++) {
860 UserProfile
= (USER_PROFILE_ENTRY
*) (mUserProfileDb
->UserProfile
[Index
]);
862 Status
= FindUserInfoByType (UserProfile
, &UserInfo
, EFI_USER_INFO_IDENTIFIER_RECORD
);
863 if (EFI_ERROR (Status
)) {
867 if (CompareMem ((UINT8
*) (UserInfo
+ 1), UserId
, sizeof (EFI_USER_INFO_IDENTIFIER
)) == 0) {
872 if (Index
== mUserProfileDb
->UserProfileNum
) {
880 Expand user profile database.
882 @retval TRUE Success to expand user profile database.
883 @retval FALSE Fail to expand user profile database.
887 ExpandUsermUserProfileDb (
892 USER_PROFILE_DB
*NewDataBase
;
895 // Create new user profile database.
897 if (mUserProfileDb
== NULL
) {
898 MaxNum
= USER_NUMBER_INC
;
900 MaxNum
= mUserProfileDb
->MaxProfileNum
+ USER_NUMBER_INC
;
903 NewDataBase
= AllocateZeroPool (
904 sizeof (USER_PROFILE_DB
) - sizeof (EFI_USER_PROFILE_HANDLE
) +
905 MaxNum
* sizeof (EFI_USER_PROFILE_HANDLE
)
907 if (NewDataBase
== NULL
) {
911 NewDataBase
->MaxProfileNum
= MaxNum
;
914 // Copy old user profile database value
916 if (mUserProfileDb
== NULL
) {
917 NewDataBase
->UserProfileNum
= 0;
919 NewDataBase
->UserProfileNum
= mUserProfileDb
->UserProfileNum
;
921 NewDataBase
->UserProfile
,
922 mUserProfileDb
->UserProfile
,
923 NewDataBase
->UserProfileNum
* sizeof (EFI_USER_PROFILE_HANDLE
)
925 FreePool (mUserProfileDb
);
928 mUserProfileDb
= NewDataBase
;
936 @param[in] User Points to user profile.
937 @param[in] ExpandSize The size of user profile.
939 @retval TRUE Success to expand user profile size.
940 @retval FALSE Fail to expand user profile size.
945 IN USER_PROFILE_ENTRY
*User
,
953 // Allocate new memory.
956 User
->MaxProfileSize
+= ((ExpandSize
+ InfoSizeInc
- 1) / InfoSizeInc
) * InfoSizeInc
;
957 Info
= AllocateZeroPool (User
->MaxProfileSize
);
963 // Copy exist information.
965 if (User
->UserProfileSize
> 0) {
966 CopyMem (Info
, User
->ProfileInfo
, User
->UserProfileSize
);
967 FreePool (User
->ProfileInfo
);
970 User
->ProfileInfo
= Info
;
976 Save the user profile to non-volatile memory, or delete it from non-volatile memory.
978 @param[in] User Point to the user profile
979 @param[in] Delete If TRUE, delete the found user profile.
980 If FALSE, save the user profile.
981 @retval EFI_SUCCESS Save or delete user profile successfully.
982 @retval Others Fail to change the profile.
987 IN USER_PROFILE_ENTRY
*User
,
994 // Check user profile entry.
996 Status
= FindUserProfile (&User
, FALSE
, NULL
);
997 if (EFI_ERROR (Status
)) {
1002 // Save the user profile to non-volatile memory.
1004 Status
= gRT
->SetVariable (
1006 &gUserIdentifyManagerGuid
,
1007 EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
,
1008 Delete
? 0 : User
->UserProfileSize
,
1015 Add one new user info into the user's profile.
1017 @param[in] User point to the user profile
1018 @param[in] Info Points to the user information payload.
1019 @param[in] InfoSize The size of the user information payload, in bytes.
1020 @param[out] UserInfo Point to the new info in user profile
1021 @param[in] Save If TRUE, save the profile to NV flash.
1022 If FALSE, don't need to save the profile to NV flash.
1024 @retval EFI_SUCCESS Add user info to user profile successfully.
1025 @retval Others Fail to add user info to user profile.
1030 IN USER_PROFILE_ENTRY
*User
,
1033 OUT EFI_USER_INFO
**UserInfo
, OPTIONAL
1039 if ((Info
== NULL
) || (User
== NULL
)) {
1040 return EFI_INVALID_PARAMETER
;
1044 // Check user profile handle.
1046 Status
= FindUserProfile (&User
, FALSE
, NULL
);
1047 if (EFI_ERROR (Status
)) {
1052 // Check user information memory size.
1054 if (User
->MaxProfileSize
- User
->UserProfileSize
< ALIGN_VARIABLE (InfoSize
)) {
1055 if (!ExpandUserProfile (User
, ALIGN_VARIABLE (InfoSize
))) {
1056 return EFI_OUT_OF_RESOURCES
;
1061 // Add new user information.
1063 CopyMem (User
->ProfileInfo
+ User
->UserProfileSize
, Info
, InfoSize
);
1064 if (UserInfo
!= NULL
) {
1065 *UserInfo
= (EFI_USER_INFO
*) (User
->ProfileInfo
+ User
->UserProfileSize
);
1067 User
->UserProfileSize
+= ALIGN_VARIABLE (InfoSize
);
1070 // Save user profile information.
1073 Status
= SaveNvUserProfile (User
, FALSE
);
1081 Get the user info from the specified user info handle.
1083 @param[in] User Point to the user profile.
1084 @param[in] UserInfo Point to the user information record to get.
1085 @param[out] Info On entry, points to a buffer of at least *InfoSize bytes.
1086 On exit, holds the user information.
1087 @param[in, out] InfoSize On entry, points to the size of Info.
1088 On return, points to the size of the user information.
1089 @param[in] ChkRight If TRUE, check the user info attribute.
1090 If FALSE, don't check the user info attribute.
1093 @retval EFI_ACCESS_DENIED The information cannot be accessed by the current user.
1094 @retval EFI_INVALID_PARAMETER InfoSize is NULL or UserInfo is NULL.
1095 @retval EFI_BUFFER_TOO_SMALL The number of bytes specified by *InfoSize is too small to hold the
1096 returned data. The actual size required is returned in *InfoSize.
1097 @retval EFI_SUCCESS Information returned successfully.
1102 IN USER_PROFILE_ENTRY
*User
,
1103 IN EFI_USER_INFO
*UserInfo
,
1104 OUT EFI_USER_INFO
*Info
,
1105 IN OUT UINTN
*InfoSize
,
1111 if ((InfoSize
== NULL
) || (UserInfo
== NULL
)) {
1112 return EFI_INVALID_PARAMETER
;
1115 if ((*InfoSize
!= 0) && (Info
== NULL
)) {
1116 return EFI_INVALID_PARAMETER
;
1120 // Find the user information to get.
1122 Status
= FindUserInfo (User
, &UserInfo
, FALSE
, NULL
);
1123 if (EFI_ERROR (Status
)) {
1128 // Check information attributes.
1131 switch (UserInfo
->InfoAttribs
& EFI_USER_INFO_ACCESS
) {
1132 case EFI_USER_INFO_PRIVATE
:
1133 case EFI_USER_INFO_PROTECTED
:
1134 if (User
!= mCurrentUser
) {
1135 return EFI_ACCESS_DENIED
;
1139 case EFI_USER_INFO_PUBLIC
:
1143 return EFI_INVALID_PARAMETER
;
1149 // Get user information.
1151 if (UserInfo
->InfoSize
> *InfoSize
) {
1152 *InfoSize
= UserInfo
->InfoSize
;
1153 return EFI_BUFFER_TOO_SMALL
;
1156 *InfoSize
= UserInfo
->InfoSize
;
1158 CopyMem (Info
, UserInfo
, *InfoSize
);
1166 Delete the specified user information from user profile.
1168 @param[in] User Point to the user profile.
1169 @param[in] Info Point to the user information record to delete.
1170 @param[in] Save If TRUE, save the profile to NV flash.
1171 If FALSE, don't need to save the profile to NV flash.
1173 @retval EFI_SUCCESS Delete user info from user profile successfully.
1174 @retval Others Fail to delete user info from user profile.
1179 IN USER_PROFILE_ENTRY
*User
,
1180 IN EFI_USER_INFO
*Info
,
1189 // Check user information handle.
1191 Status
= FindUserInfo (User
, &Info
, FALSE
, &Offset
);
1192 if (EFI_ERROR (Status
)) {
1196 if (Info
->InfoType
== EFI_USER_INFO_IDENTIFIER_RECORD
) {
1197 return EFI_ACCESS_DENIED
;
1201 // Delete the specified user information.
1203 NextOffset
= Offset
+ ALIGN_VARIABLE (Info
->InfoSize
);
1204 User
->UserProfileSize
-= ALIGN_VARIABLE (Info
->InfoSize
);
1205 if (Offset
< User
->UserProfileSize
) {
1206 CopyMem (User
->ProfileInfo
+ Offset
, User
->ProfileInfo
+ NextOffset
, User
->UserProfileSize
- Offset
);
1210 Status
= SaveNvUserProfile (User
, FALSE
);
1218 Add or update user information.
1220 @param[in] User Point to the user profile.
1221 @param[in, out] UserInfo On entry, points to the user information to modify,
1222 or NULL to add a new UserInfo.
1223 On return, points to the modified user information.
1224 @param[in] Info Points to the new user information.
1225 @param[in] InfoSize The size of Info,in bytes.
1227 @retval EFI_INVALID_PARAMETER UserInfo is NULL or Info is NULL.
1228 @retval EFI_ACCESS_DENIED The record is exclusive.
1229 @retval EFI_SUCCESS User information was successfully changed/added.
1234 IN USER_PROFILE_ENTRY
*User
,
1235 IN OUT EFI_USER_INFO
**UserInfo
,
1236 IN CONST EFI_USER_INFO
*Info
,
1242 EFI_USER_INFO
*OldInfo
;
1244 if ((UserInfo
== NULL
) || (Info
== NULL
)) {
1245 return EFI_INVALID_PARAMETER
;
1248 if (InfoSize
< sizeof (EFI_USER_INFO
) || InfoSize
!= Info
->InfoSize
) {
1249 return EFI_INVALID_PARAMETER
;
1253 // Check user information.
1255 if (Info
->InfoType
== EFI_USER_INFO_IDENTIFIER_RECORD
) {
1256 return EFI_ACCESS_DENIED
;
1259 if (!CheckUserInfo (Info
)) {
1260 return EFI_INVALID_PARAMETER
;
1264 if (*UserInfo
== NULL
) {
1266 // Add new user information.
1270 Status
= FindUserInfoByType (User
, &OldInfo
, Info
->InfoType
);
1271 if (EFI_ERROR (Status
)) {
1274 ASSERT (OldInfo
!= NULL
);
1276 if (((OldInfo
->InfoAttribs
& EFI_USER_INFO_EXCLUSIVE
) != 0) ||
1277 ((Info
->InfoAttribs
& EFI_USER_INFO_EXCLUSIVE
) != 0)) {
1279 // Same type can not co-exist for exclusive information.
1281 return EFI_ACCESS_DENIED
;
1285 // Check whether it exists in DB.
1287 if (Info
->InfoSize
!= OldInfo
->InfoSize
) {
1291 if (!CompareGuid (&OldInfo
->Credential
, &Info
->Credential
)) {
1295 PayloadLen
= Info
->InfoSize
- sizeof (EFI_USER_INFO
);
1296 if (PayloadLen
== 0) {
1300 if (CompareMem ((UINT8
*)(OldInfo
+ 1), (UINT8
*)(Info
+ 1), PayloadLen
) != 0) {
1305 // Yes. The new info is as same as the one in profile.
1308 } while (!EFI_ERROR (Status
));
1310 Status
= AddUserInfo (User
, (UINT8
*) Info
, InfoSize
, UserInfo
, TRUE
);
1315 // Modify existing user information.
1317 OldInfo
= *UserInfo
;
1318 if (OldInfo
->InfoType
!= Info
->InfoType
) {
1319 return EFI_INVALID_PARAMETER
;
1322 if (((Info
->InfoAttribs
& EFI_USER_INFO_EXCLUSIVE
) != 0) &&
1323 (OldInfo
->InfoAttribs
& EFI_USER_INFO_EXCLUSIVE
) == 0) {
1325 // Try to add exclusive attrib in new info.
1326 // Check whether there is another information with the same type in profile.
1330 Status
= FindUserInfoByType (User
, &OldInfo
, Info
->InfoType
);
1331 if (EFI_ERROR (Status
)) {
1334 if (OldInfo
!= *UserInfo
) {
1336 // There is another information with the same type in profile.
1337 // Therefore, can't modify existing user information to add exclusive attribute.
1339 return EFI_ACCESS_DENIED
;
1344 Status
= DelUserInfo (User
, *UserInfo
, FALSE
);
1345 if (EFI_ERROR (Status
)) {
1349 return AddUserInfo (User
, (UINT8
*) Info
, InfoSize
, UserInfo
, TRUE
);
1354 Delete the user profile from non-volatile memory and database.
1356 @param[in] User Points to the user profile.
1358 @retval EFI_SUCCESS Delete user from the user profile successfully.
1359 @retval Others Fail to delete user from user profile
1364 IN USER_PROFILE_ENTRY
*User
1371 // Check whether it is in the user profile database.
1373 Status
= FindUserProfile (&User
, FALSE
, &Index
);
1374 if (EFI_ERROR (Status
)) {
1375 return EFI_INVALID_PARAMETER
;
1379 // Check whether it is the current user.
1381 if (User
== mCurrentUser
) {
1382 return EFI_ACCESS_DENIED
;
1386 // Delete user profile from the non-volatile memory.
1388 Status
= SaveNvUserProfile (mUserProfileDb
->UserProfile
[mUserProfileDb
->UserProfileNum
- 1], TRUE
);
1389 if (EFI_ERROR (Status
)) {
1392 mUserProfileDb
->UserProfileNum
--;
1395 // Modify user profile database.
1397 if (Index
!= mUserProfileDb
->UserProfileNum
) {
1398 mUserProfileDb
->UserProfile
[Index
] = mUserProfileDb
->UserProfile
[mUserProfileDb
->UserProfileNum
];
1400 ((USER_PROFILE_ENTRY
*) mUserProfileDb
->UserProfile
[Index
])->UserVarName
,
1402 sizeof (User
->UserVarName
)
1404 Status
= SaveNvUserProfile (mUserProfileDb
->UserProfile
[Index
], FALSE
);
1405 if (EFI_ERROR (Status
)) {
1410 // Delete user profile information.
1412 if (User
->ProfileInfo
!= NULL
) {
1413 FreePool (User
->ProfileInfo
);
1422 Add user profile to user profile database.
1424 @param[out] UserProfile Point to the newly added user profile.
1425 @param[in] ProfileSize The size of the user profile.
1426 @param[in] ProfileInfo Point to the user profie data.
1427 @param[in] Save If TRUE, save the new added profile to NV flash.
1428 If FALSE, don't save the profile to NV flash.
1430 @retval EFI_SUCCESS Add user profile to user profile database successfully.
1431 @retval Others Fail to add user profile to user profile database.
1436 OUT USER_PROFILE_ENTRY
**UserProfile
, OPTIONAL
1437 IN UINTN ProfileSize
,
1438 IN UINT8
*ProfileInfo
,
1443 USER_PROFILE_ENTRY
*User
;
1446 // Check the data format to be added.
1448 if (!CheckProfileInfo (ProfileInfo
, ProfileSize
)) {
1449 return EFI_SECURITY_VIOLATION
;
1453 // Create user profile entry.
1455 User
= AllocateZeroPool (sizeof (USER_PROFILE_ENTRY
));
1457 return EFI_OUT_OF_RESOURCES
;
1460 // Add the entry to the user profile database.
1462 if (mUserProfileDb
->UserProfileNum
== mUserProfileDb
->MaxProfileNum
) {
1463 if (!ExpandUsermUserProfileDb ()) {
1465 return EFI_OUT_OF_RESOURCES
;
1471 sizeof (User
->UserVarName
),
1473 mUserProfileDb
->UserProfileNum
1475 User
->UserProfileSize
= 0;
1476 User
->MaxProfileSize
= 0;
1477 User
->ProfileInfo
= NULL
;
1478 mUserProfileDb
->UserProfile
[mUserProfileDb
->UserProfileNum
] = (EFI_USER_PROFILE_HANDLE
) User
;
1479 mUserProfileDb
->UserProfileNum
++;
1482 // Add user profile information.
1484 Status
= AddUserInfo (User
, ProfileInfo
, ProfileSize
, NULL
, Save
);
1485 if (EFI_ERROR (Status
)) {
1486 DelUserProfile (User
);
1490 // Set new user profile handle.
1492 if (UserProfile
!= NULL
) {
1493 *UserProfile
= User
;
1501 This function creates a new user profile with only a new user identifier
1502 attached and returns its handle. The user profile is non-volatile, but the
1503 handle User can change across reboots.
1505 @param[out] User Handle of a new user profile.
1507 @retval EFI_SUCCESS User profile was successfully created.
1508 @retval Others Fail to create user profile
1513 OUT USER_PROFILE_ENTRY
**User
1517 EFI_USER_INFO
*UserInfo
;
1520 return EFI_INVALID_PARAMETER
;
1523 // Generate user id information.
1525 UserInfo
= AllocateZeroPool (sizeof (EFI_USER_INFO
) + sizeof (EFI_USER_INFO_IDENTIFIER
));
1526 if (UserInfo
== NULL
) {
1527 return EFI_OUT_OF_RESOURCES
;
1530 UserInfo
->InfoType
= EFI_USER_INFO_IDENTIFIER_RECORD
;
1531 UserInfo
->InfoSize
= sizeof (EFI_USER_INFO
) + sizeof (EFI_USER_INFO_IDENTIFIER
);
1532 UserInfo
->InfoAttribs
= EFI_USER_INFO_STORAGE_PLATFORM_NV
| EFI_USER_INFO_PUBLIC
| EFI_USER_INFO_EXCLUSIVE
;
1533 GenerateUserId ((UINT8
*) (UserInfo
+ 1));
1536 // Add user profile to the user profile database.
1538 Status
= AddUserProfile (User
, UserInfo
->InfoSize
, (UINT8
*) UserInfo
, TRUE
);
1539 FreePool (UserInfo
);
1545 Add a default user profile to user profile database.
1547 @retval EFI_SUCCESS A default user profile is added successfully.
1548 @retval Others Fail to add a default user profile
1552 AddDefaultUserProfile (
1557 USER_PROFILE_ENTRY
*User
;
1558 EFI_USER_INFO
*Info
;
1559 EFI_USER_INFO
*NewInfo
;
1560 EFI_USER_INFO_CREATE_DATE CreateDate
;
1561 EFI_USER_INFO_USAGE_COUNT UsageCount
;
1562 EFI_USER_INFO_ACCESS_CONTROL
*Access
;
1563 EFI_USER_INFO_IDENTITY_POLICY
*Policy
;
1566 // Create a user profile.
1568 Status
= CreateUserProfile (&User
);
1569 if (EFI_ERROR (Status
)) {
1574 // Allocate a buffer to add all default user information.
1576 Info
= AllocateZeroPool (sizeof (EFI_USER_INFO
) + INFO_PAYLOAD_SIZE
);
1578 return EFI_OUT_OF_RESOURCES
;
1584 Info
->InfoType
= EFI_USER_INFO_NAME_RECORD
;
1585 Info
->InfoAttribs
= EFI_USER_INFO_STORAGE_PLATFORM_NV
| EFI_USER_INFO_PUBLIC
| EFI_USER_INFO_EXCLUSIVE
;
1586 Info
->InfoSize
= sizeof (EFI_USER_INFO
) + sizeof (mUserName
);
1587 CopyMem ((UINT8
*) (Info
+ 1), mUserName
, sizeof (mUserName
));
1589 Status
= ModifyUserInfo (User
, &NewInfo
, Info
, Info
->InfoSize
);
1590 if (EFI_ERROR (Status
)) {
1595 // Add user profile create date record.
1597 Info
->InfoType
= EFI_USER_INFO_CREATE_DATE_RECORD
;
1598 Info
->InfoAttribs
= EFI_USER_INFO_STORAGE_PLATFORM_NV
| EFI_USER_INFO_PUBLIC
| EFI_USER_INFO_EXCLUSIVE
;
1599 Info
->InfoSize
= sizeof (EFI_USER_INFO
) + sizeof (EFI_USER_INFO_CREATE_DATE
);
1600 Status
= gRT
->GetTime (&CreateDate
, NULL
);
1601 if (EFI_ERROR (Status
)) {
1605 CopyMem ((UINT8
*) (Info
+ 1), &CreateDate
, sizeof (EFI_USER_INFO_CREATE_DATE
));
1607 Status
= ModifyUserInfo (User
, &NewInfo
, Info
, Info
->InfoSize
);
1608 if (EFI_ERROR (Status
)) {
1613 // Add user profile usage count record.
1615 Info
->InfoType
= EFI_USER_INFO_USAGE_COUNT_RECORD
;
1616 Info
->InfoAttribs
= EFI_USER_INFO_STORAGE_PLATFORM_NV
| EFI_USER_INFO_PUBLIC
| EFI_USER_INFO_EXCLUSIVE
;
1617 Info
->InfoSize
= sizeof (EFI_USER_INFO
) + sizeof (EFI_USER_INFO_USAGE_COUNT
);
1619 CopyMem ((UINT8
*) (Info
+ 1), &UsageCount
, sizeof (EFI_USER_INFO_USAGE_COUNT
));
1621 Status
= ModifyUserInfo (User
, &NewInfo
, Info
, Info
->InfoSize
);
1622 if (EFI_ERROR (Status
)) {
1627 // Add user access right.
1629 Info
->InfoType
= EFI_USER_INFO_ACCESS_POLICY_RECORD
;
1630 Info
->InfoAttribs
= EFI_USER_INFO_STORAGE_PLATFORM_NV
| EFI_USER_INFO_PUBLIC
| EFI_USER_INFO_EXCLUSIVE
;
1631 Access
= (EFI_USER_INFO_ACCESS_CONTROL
*) (Info
+ 1);
1632 Access
->Type
= EFI_USER_INFO_ACCESS_MANAGE
;
1633 Access
->Size
= sizeof (EFI_USER_INFO_ACCESS_CONTROL
);
1634 Info
->InfoSize
= sizeof (EFI_USER_INFO
) + Access
->Size
;
1636 Status
= ModifyUserInfo (User
, &NewInfo
, Info
, Info
->InfoSize
);
1637 if (EFI_ERROR (Status
)) {
1642 // Add user identity policy.
1644 Info
->InfoType
= EFI_USER_INFO_IDENTITY_POLICY_RECORD
;
1645 Info
->InfoAttribs
= EFI_USER_INFO_STORAGE_PLATFORM_NV
| EFI_USER_INFO_PRIVATE
| EFI_USER_INFO_EXCLUSIVE
;
1646 Policy
= (EFI_USER_INFO_IDENTITY_POLICY
*) (Info
+ 1);
1647 Policy
->Type
= EFI_USER_INFO_IDENTITY_TRUE
;
1648 Policy
->Length
= sizeof (EFI_USER_INFO_IDENTITY_POLICY
);
1649 Info
->InfoSize
= sizeof (EFI_USER_INFO
) + Policy
->Length
;
1651 Status
= ModifyUserInfo (User
, &NewInfo
, Info
, Info
->InfoSize
);
1660 Publish current user information into EFI System Configuration Table.
1662 By UEFI spec, the User Identity Manager will publish the current user profile
1663 into the EFI System Configuration Table. Currently, only the user identifier and user
1666 @retval EFI_SUCCESS Current user information is published successfully.
1667 @retval Others Fail to publish current user information
1676 EFI_CONFIGURATION_TABLE
*EfiConfigurationTable
;
1677 EFI_USER_INFO_TABLE
*UserInfoTable
;
1678 EFI_USER_INFO
*IdInfo
;
1679 EFI_USER_INFO
*NameInfo
;
1681 Status
= EfiGetSystemConfigurationTable (
1682 &gEfiUserManagerProtocolGuid
,
1683 (VOID
**) &EfiConfigurationTable
1685 if (!EFI_ERROR (Status
)) {
1687 // The table existed!
1693 // Get user ID information.
1696 Status
= FindUserInfoByType (mCurrentUser
, &IdInfo
, EFI_USER_INFO_IDENTIFIER_RECORD
);
1697 if (EFI_ERROR (Status
)) {
1702 // Get user name information.
1705 Status
= FindUserInfoByType (mCurrentUser
, &NameInfo
, EFI_USER_INFO_NAME_RECORD
);
1706 if (EFI_ERROR (Status
)) {
1711 // Allocate a buffer for user information table.
1713 UserInfoTable
= (EFI_USER_INFO_TABLE
*) AllocateRuntimePool (
1714 sizeof (EFI_USER_INFO_TABLE
) +
1718 if (UserInfoTable
== NULL
) {
1719 Status
= EFI_OUT_OF_RESOURCES
;
1723 UserInfoTable
->Size
= sizeof (EFI_USER_INFO_TABLE
);
1726 // Append the user information to the user info table
1728 CopyMem ((UINT8
*) UserInfoTable
+ UserInfoTable
->Size
, (UINT8
*) IdInfo
, IdInfo
->InfoSize
);
1729 UserInfoTable
->Size
+= IdInfo
->InfoSize
;
1731 CopyMem ((UINT8
*) UserInfoTable
+ UserInfoTable
->Size
, (UINT8
*) NameInfo
, NameInfo
->InfoSize
);
1732 UserInfoTable
->Size
+= NameInfo
->InfoSize
;
1734 Status
= gBS
->InstallConfigurationTable (&gEfiUserManagerProtocolGuid
, (VOID
*) UserInfoTable
);
1740 Get the user's identity type.
1742 The identify manager only supports the identity policy in which the credential
1743 provider handles are connected by the operator 'AND' or 'OR'.
1746 @param[in] User Handle of a user profile.
1747 @param[out] PolicyType Point to the identity type.
1749 @retval EFI_SUCCESS Get user's identity type successfully.
1750 @retval Others Fail to get user's identity type.
1755 IN EFI_USER_PROFILE_HANDLE User
,
1756 OUT UINT8
*PolicyType
1760 EFI_USER_INFO
*IdentifyInfo
;
1762 EFI_USER_INFO_IDENTITY_POLICY
*Identity
;
1765 // Get user identify policy information.
1767 IdentifyInfo
= NULL
;
1768 Status
= FindUserInfoByType (User
, &IdentifyInfo
, EFI_USER_INFO_IDENTITY_POLICY_RECORD
);
1769 if (EFI_ERROR (Status
)) {
1772 ASSERT (IdentifyInfo
!= NULL
);
1775 // Search the user identify policy according to type.
1778 *PolicyType
= EFI_USER_INFO_IDENTITY_FALSE
;
1779 while (TotalLen
< IdentifyInfo
->InfoSize
- sizeof (EFI_USER_INFO
)) {
1780 Identity
= (EFI_USER_INFO_IDENTITY_POLICY
*) ((UINT8
*) (IdentifyInfo
+ 1) + TotalLen
);
1781 if (Identity
->Type
== EFI_USER_INFO_IDENTITY_AND
) {
1782 *PolicyType
= EFI_USER_INFO_IDENTITY_AND
;
1786 if (Identity
->Type
== EFI_USER_INFO_IDENTITY_OR
) {
1787 *PolicyType
= EFI_USER_INFO_IDENTITY_OR
;
1790 TotalLen
+= Identity
->Length
;
1797 Identify the User by the specfied provider.
1799 @param[in] User Handle of a user profile.
1800 @param[in] Provider Points to the identifier of credential provider.
1802 @retval EFI_INVALID_PARAMETER Provider is NULL.
1803 @retval EFI_NOT_FOUND Fail to identify the specified user.
1804 @retval EFI_SUCCESS User is identified successfully.
1808 IdentifyByProviderId (
1809 IN EFI_USER_PROFILE_HANDLE User
,
1810 IN EFI_GUID
*Provider
1814 EFI_USER_INFO_IDENTIFIER UserId
;
1816 EFI_CREDENTIAL_LOGON_FLAGS AutoLogon
;
1817 EFI_HII_HANDLE HiiHandle
;
1820 EFI_USER_CREDENTIAL2_PROTOCOL
*UserCredential
;
1822 if (Provider
== NULL
) {
1823 return EFI_INVALID_PARAMETER
;
1827 // Check the user ID identified by the specified credential provider.
1829 for (Index
= 0; Index
< mProviderDb
->Count
; Index
++) {
1831 // Check credential provider class.
1833 UserCredential
= mProviderDb
->Provider
[Index
];
1834 if (CompareGuid (&UserCredential
->Identifier
, Provider
)) {
1835 Status
= UserCredential
->Select (UserCredential
, &AutoLogon
);
1836 if (EFI_ERROR (Status
)) {
1840 if ((AutoLogon
& EFI_CREDENTIAL_LOGON_FLAG_AUTO
) == 0) {
1842 // Get credential provider form.
1844 Status
= UserCredential
->Form (
1850 if (!EFI_ERROR (Status
)) {
1852 // Send form to get user input.
1854 Status
= mCallbackInfo
->FormBrowser2
->SendForm (
1855 mCallbackInfo
->FormBrowser2
,
1863 if (EFI_ERROR (Status
)) {
1869 Status
= UserCredential
->User (UserCredential
, User
, &UserId
);
1870 if (EFI_ERROR (Status
)) {
1874 Status
= UserCredential
->Deselect (UserCredential
);
1875 if (EFI_ERROR (Status
)) {
1883 return EFI_NOT_FOUND
;
1888 Update user information when user is logon on successfully.
1890 @param[in] User Points to user profile.
1892 @retval EFI_SUCCESS Update user information successfully.
1893 @retval Others Fail to update user information.
1898 IN USER_PROFILE_ENTRY
*User
1902 EFI_USER_INFO
*Info
;
1903 EFI_USER_INFO
*NewInfo
;
1904 EFI_USER_INFO_CREATE_DATE Date
;
1905 EFI_USER_INFO_USAGE_COUNT UsageCount
;
1909 // Allocate a buffer to update user's date record and usage record.
1911 InfoLen
= MAX (sizeof (EFI_USER_INFO_CREATE_DATE
), sizeof (EFI_USER_INFO_USAGE_COUNT
));
1912 Info
= AllocateZeroPool (sizeof (EFI_USER_INFO
) + InfoLen
);
1914 return EFI_OUT_OF_RESOURCES
;
1918 // Check create date record.
1921 Status
= FindUserInfoByType (User
, &NewInfo
, EFI_USER_INFO_CREATE_DATE_RECORD
);
1922 if (Status
== EFI_NOT_FOUND
) {
1923 Info
->InfoType
= EFI_USER_INFO_CREATE_DATE_RECORD
;
1924 Info
->InfoAttribs
= EFI_USER_INFO_STORAGE_PLATFORM_NV
| EFI_USER_INFO_PUBLIC
| EFI_USER_INFO_EXCLUSIVE
;
1925 Info
->InfoSize
= sizeof (EFI_USER_INFO
) + sizeof (EFI_USER_INFO_CREATE_DATE
);
1926 Status
= gRT
->GetTime (&Date
, NULL
);
1927 if (EFI_ERROR (Status
)) {
1932 CopyMem ((UINT8
*) (Info
+ 1), &Date
, sizeof (EFI_USER_INFO_CREATE_DATE
));
1934 Status
= ModifyUserInfo (User
, &NewInfo
, Info
, Info
->InfoSize
);
1935 if (EFI_ERROR (Status
)) {
1942 // Update usage date record.
1945 Status
= FindUserInfoByType (User
, &NewInfo
, EFI_USER_INFO_USAGE_DATE_RECORD
);
1946 if ((Status
== EFI_SUCCESS
) || (Status
== EFI_NOT_FOUND
)) {
1947 Info
->InfoType
= EFI_USER_INFO_USAGE_DATE_RECORD
;
1948 Info
->InfoAttribs
= EFI_USER_INFO_STORAGE_PLATFORM_NV
| EFI_USER_INFO_PUBLIC
| EFI_USER_INFO_EXCLUSIVE
;
1949 Info
->InfoSize
= sizeof (EFI_USER_INFO
) + sizeof (EFI_USER_INFO_USAGE_DATE
);
1950 Status
= gRT
->GetTime (&Date
, NULL
);
1951 if (EFI_ERROR (Status
)) {
1956 CopyMem ((UINT8
*) (Info
+ 1), &Date
, sizeof (EFI_USER_INFO_USAGE_DATE
));
1957 Status
= ModifyUserInfo (User
, &NewInfo
, Info
, Info
->InfoSize
);
1958 if (EFI_ERROR (Status
)) {
1965 // Update usage count record.
1969 Status
= FindUserInfoByType (User
, &NewInfo
, EFI_USER_INFO_USAGE_COUNT_RECORD
);
1973 if (Status
== EFI_SUCCESS
) {
1974 CopyMem (&UsageCount
, (UINT8
*) (NewInfo
+ 1), sizeof (EFI_USER_INFO_USAGE_COUNT
));
1978 if ((Status
== EFI_SUCCESS
) || (Status
== EFI_NOT_FOUND
)) {
1979 Info
->InfoType
= EFI_USER_INFO_USAGE_COUNT_RECORD
;
1980 Info
->InfoAttribs
= EFI_USER_INFO_STORAGE_PLATFORM_NV
| EFI_USER_INFO_PUBLIC
| EFI_USER_INFO_EXCLUSIVE
;
1981 Info
->InfoSize
= sizeof (EFI_USER_INFO
) + sizeof (EFI_USER_INFO_USAGE_COUNT
);
1982 CopyMem ((UINT8
*) (Info
+ 1), &UsageCount
, sizeof (EFI_USER_INFO_USAGE_COUNT
));
1983 Status
= ModifyUserInfo (User
, &NewInfo
, Info
, Info
->InfoSize
);
1984 if (EFI_ERROR (Status
)) {
1996 Add a credenetial provider item in form.
1998 @param[in] ProviderGuid Points to the identifir of credential provider.
1999 @param[in] OpCodeHandle Points to container for dynamic created opcodes.
2003 AddProviderSelection (
2004 IN EFI_GUID
*ProviderGuid
,
2005 IN VOID
*OpCodeHandle
2008 EFI_HII_HANDLE HiiHandle
;
2009 EFI_STRING_ID ProvID
;
2012 EFI_USER_CREDENTIAL2_PROTOCOL
*UserCredential
;
2014 for (Index
= 0; Index
< mProviderDb
->Count
; Index
++) {
2015 UserCredential
= mProviderDb
->Provider
[Index
];
2016 if (CompareGuid (&UserCredential
->Identifier
, ProviderGuid
)) {
2018 // Add credential provider selection.
2020 UserCredential
->Title (UserCredential
, &HiiHandle
, &ProvID
);
2021 ProvStr
= HiiGetString (HiiHandle
, ProvID
, NULL
);
2022 if (ProvStr
== NULL
) {
2025 ProvID
= HiiSetString (mCallbackInfo
->HiiHandle
, 0, ProvStr
, NULL
);
2027 HiiCreateActionOpCode (
2028 OpCodeHandle
, // Container for dynamic created opcodes
2029 (EFI_QUESTION_ID
)(LABEL_PROVIDER_NAME
+ Index
), // Question ID
2030 ProvID
, // Prompt text
2031 STRING_TOKEN (STR_NULL_STRING
), // Help text
2032 EFI_IFR_FLAG_CALLBACK
, // Question flag
2033 0 // Action String ID
2042 Add a username item in form.
2044 @param[in] Index The index of the user in the user name list.
2045 @param[in] User Points to the user profile whose username is added.
2046 @param[in] OpCodeHandle Points to container for dynamic created opcodes.
2048 @retval EFI_SUCCESS Add a username successfully.
2049 @retval Others Fail to add a username.
2055 IN USER_PROFILE_ENTRY
*User
,
2056 IN VOID
*OpCodeHandle
2059 EFI_STRING_ID UserName
;
2061 EFI_USER_INFO
*UserInfo
;
2064 Status
= FindUserInfoByType (User
, &UserInfo
, EFI_USER_INFO_NAME_RECORD
);
2065 if (EFI_ERROR (Status
)) {
2070 // Add user name selection.
2072 UserName
= HiiSetString (mCallbackInfo
->HiiHandle
, 0, (EFI_STRING
) (UserInfo
+ 1), NULL
);
2073 if (UserName
== 0) {
2074 return EFI_OUT_OF_RESOURCES
;
2077 HiiCreateGotoOpCode (
2078 OpCodeHandle
, // Container for dynamic created opcodes
2079 FORMID_PROVIDER_FORM
, // Target Form ID
2080 UserName
, // Prompt text
2081 STRING_TOKEN (STR_NULL_STRING
), // Help text
2082 EFI_IFR_FLAG_CALLBACK
, // Question flag
2083 (UINT16
) Index
// Question ID
2091 Identify the user whose identity policy does not contain the operator 'OR'.
2093 @param[in] User Points to the user profile.
2095 @retval EFI_SUCCESS The specified user is identified successfully.
2096 @retval Others Fail to identify the user.
2100 IdentifyAndTypeUser (
2101 IN USER_PROFILE_ENTRY
*User
2105 EFI_USER_INFO
*IdentifyInfo
;
2109 EFI_USER_INFO_IDENTITY_POLICY
*Identity
;
2112 // Get user identify policy information.
2114 IdentifyInfo
= NULL
;
2115 Status
= FindUserInfoByType (User
, &IdentifyInfo
, EFI_USER_INFO_IDENTITY_POLICY_RECORD
);
2116 if (EFI_ERROR (Status
)) {
2119 ASSERT (IdentifyInfo
!= NULL
);
2122 // Check each part of identification policy expression.
2126 while (TotalLen
< IdentifyInfo
->InfoSize
- sizeof (EFI_USER_INFO
)) {
2127 Identity
= (EFI_USER_INFO_IDENTITY_POLICY
*) ((UINT8
*) (IdentifyInfo
+ 1) + TotalLen
);
2128 ValueLen
= Identity
->Length
- sizeof (EFI_USER_INFO_IDENTITY_POLICY
);
2129 switch (Identity
->Type
) {
2131 case EFI_USER_INFO_IDENTITY_FALSE
:
2133 // Check False option.
2138 case EFI_USER_INFO_IDENTITY_TRUE
:
2140 // Check True option.
2145 case EFI_USER_INFO_IDENTITY_NOT
:
2147 // Check negative operation.
2151 case EFI_USER_INFO_IDENTITY_AND
:
2153 // Check and operation.
2156 return EFI_NOT_READY
;
2162 case EFI_USER_INFO_IDENTITY_OR
:
2164 // Check or operation.
2171 case EFI_USER_INFO_IDENTITY_CREDENTIAL_TYPE
:
2173 // Check credential provider by type.
2177 case EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER
:
2179 // Check credential provider by ID.
2181 if (ValueLen
!= sizeof (EFI_GUID
)) {
2182 return EFI_INVALID_PARAMETER
;
2185 Status
= IdentifyByProviderId (User
, (EFI_GUID
*) (Identity
+ 1));
2186 if (EFI_ERROR (Status
)) {
2194 return EFI_INVALID_PARAMETER
;
2198 TotalLen
+= Identity
->Length
;
2201 if (TotalLen
!= IdentifyInfo
->InfoSize
- sizeof (EFI_USER_INFO
)) {
2202 return EFI_INVALID_PARAMETER
;
2206 return EFI_NOT_READY
;
2214 Identify the user whose identity policy does not contain the operator 'AND'.
2216 @param[in] User Points to the user profile.
2218 @retval EFI_SUCCESS The specified user is identified successfully.
2219 @retval Others Fail to identify the user.
2223 IdentifyOrTypeUser (
2224 IN USER_PROFILE_ENTRY
*User
2228 EFI_USER_INFO
*IdentifyInfo
;
2231 EFI_USER_INFO_IDENTITY_POLICY
*Identity
;
2232 VOID
*StartOpCodeHandle
;
2233 VOID
*EndOpCodeHandle
;
2234 EFI_IFR_GUID_LABEL
*StartLabel
;
2235 EFI_IFR_GUID_LABEL
*EndLabel
;
2238 // Get user identify policy information.
2240 IdentifyInfo
= NULL
;
2241 Status
= FindUserInfoByType (User
, &IdentifyInfo
, EFI_USER_INFO_IDENTITY_POLICY_RECORD
);
2242 if (EFI_ERROR (Status
)) {
2245 ASSERT (IdentifyInfo
!= NULL
);
2248 // Initialize the container for dynamic opcodes.
2250 StartOpCodeHandle
= HiiAllocateOpCodeHandle ();
2251 ASSERT (StartOpCodeHandle
!= NULL
);
2253 EndOpCodeHandle
= HiiAllocateOpCodeHandle ();
2254 ASSERT (EndOpCodeHandle
!= NULL
);
2257 // Create Hii Extend Label OpCode.
2259 StartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (
2263 sizeof (EFI_IFR_GUID_LABEL
)
2265 StartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
2266 StartLabel
->Number
= LABEL_PROVIDER_NAME
;
2268 EndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (
2272 sizeof (EFI_IFR_GUID_LABEL
)
2274 EndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
2275 EndLabel
->Number
= LABEL_END
;
2278 // Add the providers that exists in the user's policy.
2281 while (TotalLen
< IdentifyInfo
->InfoSize
- sizeof (EFI_USER_INFO
)) {
2282 Identity
= (EFI_USER_INFO_IDENTITY_POLICY
*) ((UINT8
*) (IdentifyInfo
+ 1) + TotalLen
);
2283 ValueLen
= Identity
->Length
- sizeof (EFI_USER_INFO_IDENTITY_POLICY
);
2284 if (Identity
->Type
== EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER
) {
2285 AddProviderSelection ((EFI_GUID
*) (Identity
+ 1), StartOpCodeHandle
);
2288 TotalLen
+= Identity
->Length
;
2292 mCallbackInfo
->HiiHandle
, // HII handle
2293 &gUserIdentifyManagerGuid
,// Formset GUID
2294 FORMID_PROVIDER_FORM
, // Form ID
2295 StartOpCodeHandle
, // Label for where to insert opcodes
2296 EndOpCodeHandle
// Replace data
2299 HiiFreeOpCodeHandle (StartOpCodeHandle
);
2300 HiiFreeOpCodeHandle (EndOpCodeHandle
);
2307 This function processes the results of changes in configuration.
2309 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
2310 @param Action Specifies the type of action taken by the browser.
2311 @param QuestionId A unique value which is sent to the original
2312 exporting driver so that it can identify the type
2314 @param Type The type of value for the question.
2315 @param Value A pointer to the data being sent to the original
2317 @param ActionRequest On return, points to the action requested by the
2320 @retval EFI_SUCCESS The callback successfully handled the action.
2321 @retval Others Fail to handle the action.
2326 UserIdentifyManagerCallback (
2327 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
2328 IN EFI_BROWSER_ACTION Action
,
2329 IN EFI_QUESTION_ID QuestionId
,
2331 IN EFI_IFR_TYPE_VALUE
*Value
,
2332 OUT EFI_BROWSER_ACTION_REQUEST
*ActionRequest
2336 USER_PROFILE_ENTRY
*User
;
2339 VOID
*StartOpCodeHandle
;
2340 VOID
*EndOpCodeHandle
;
2341 EFI_IFR_GUID_LABEL
*StartLabel
;
2342 EFI_IFR_GUID_LABEL
*EndLabel
;
2344 Status
= EFI_SUCCESS
;
2347 case EFI_BROWSER_ACTION_FORM_OPEN
:
2350 // Update user Form when user Form is opened.
2351 // This will be done only in FORM_OPEN CallBack of question with FORM_OPEN_QUESTION_ID from user Form.
2353 if (QuestionId
!= FORM_OPEN_QUESTION_ID
) {
2358 // Initialize the container for dynamic opcodes.
2360 StartOpCodeHandle
= HiiAllocateOpCodeHandle ();
2361 ASSERT (StartOpCodeHandle
!= NULL
);
2363 EndOpCodeHandle
= HiiAllocateOpCodeHandle ();
2364 ASSERT (EndOpCodeHandle
!= NULL
);
2367 // Create Hii Extend Label OpCode.
2369 StartLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (
2373 sizeof (EFI_IFR_GUID_LABEL
)
2375 StartLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
2376 StartLabel
->Number
= LABEL_USER_NAME
;
2378 EndLabel
= (EFI_IFR_GUID_LABEL
*) HiiCreateGuidOpCode (
2382 sizeof (EFI_IFR_GUID_LABEL
)
2384 EndLabel
->ExtendOpCode
= EFI_IFR_EXTEND_OP_LABEL
;
2385 EndLabel
->Number
= LABEL_END
;
2388 // Add all the user profile in the user profile database.
2390 for (Index
= 0; Index
< mUserProfileDb
->UserProfileNum
; Index
++) {
2391 User
= (USER_PROFILE_ENTRY
*) mUserProfileDb
->UserProfile
[Index
];
2392 AddUserSelection ((UINT16
)(LABEL_USER_NAME
+ Index
), User
, StartOpCodeHandle
);
2396 mCallbackInfo
->HiiHandle
, // HII handle
2397 &gUserIdentifyManagerGuid
,// Formset GUID
2398 FORMID_USER_FORM
, // Form ID
2399 StartOpCodeHandle
, // Label for where to insert opcodes
2400 EndOpCodeHandle
// Replace data
2403 HiiFreeOpCodeHandle (StartOpCodeHandle
);
2404 HiiFreeOpCodeHandle (EndOpCodeHandle
);
2410 case EFI_BROWSER_ACTION_FORM_CLOSE
:
2411 Status
= EFI_SUCCESS
;
2414 case EFI_BROWSER_ACTION_CHANGED
:
2415 if (QuestionId
>= LABEL_PROVIDER_NAME
) {
2417 // QuestionId comes from the second Form (Select a Credential Provider if identity
2418 // policy is OR type). Identify the user by the selected provider.
2420 Status
= IdentifyByProviderId (mCurrentUser
, &mProviderDb
->Provider
[QuestionId
& 0xFFF]->Identifier
);
2421 if (Status
== EFI_SUCCESS
) {
2423 *ActionRequest
= EFI_BROWSER_ACTION_REQUEST_EXIT
;
2429 case EFI_BROWSER_ACTION_CHANGING
:
2431 // QuestionId comes from the first Form (Select a user to identify).
2433 if (QuestionId
>= LABEL_PROVIDER_NAME
) {
2437 User
= (USER_PROFILE_ENTRY
*) mUserProfileDb
->UserProfile
[QuestionId
& 0xFFF];
2438 Status
= GetIdentifyType (User
, &PolicyType
);
2439 if (EFI_ERROR (Status
)) {
2443 if (PolicyType
== EFI_USER_INFO_IDENTITY_OR
) {
2445 // Identify the user by "OR" logical.
2447 Status
= IdentifyOrTypeUser (User
);
2448 if (EFI_ERROR (Status
)) {
2452 mCurrentUser
= (EFI_USER_PROFILE_HANDLE
) User
;
2455 // Identify the user by "AND" logical.
2457 Status
= IdentifyAndTypeUser (User
);
2458 if (EFI_ERROR (Status
)) {
2462 mCurrentUser
= (EFI_USER_PROFILE_HANDLE
) User
;
2464 if (Type
== EFI_IFR_TYPE_REF
) {
2465 Value
->ref
.FormId
= FORMID_INVALID_FORM
;
2472 // All other action return unsupported.
2474 Status
= EFI_UNSUPPORTED
;
2484 This function construct user profile database from user data saved in the Flash.
2485 If no user is found in Flash, add one default user "administrator" in the user
2488 @retval EFI_SUCCESS Init user profile database successfully.
2489 @retval Others Fail to init user profile database.
2505 if (mUserProfileDb
!= NULL
) {
2507 // The user profiles had been already initialized.
2513 // Init user profile database structure.
2515 if (!ExpandUsermUserProfileDb ()) {
2516 return EFI_OUT_OF_RESOURCES
;
2519 CurVarSize
= DEFAULT_PROFILE_SIZE
;
2520 VarData
= AllocateZeroPool (CurVarSize
);
2521 if (VarData
== NULL
) {
2522 return EFI_OUT_OF_RESOURCES
;
2526 // Get all user proifle entries.
2531 // Get variable name.
2542 // Get variable value.
2544 VarSize
= CurVarSize
;
2545 Status
= gRT
->GetVariable (VarName
, &gUserIdentifyManagerGuid
, &VarAttr
, &VarSize
, VarData
);
2546 if (Status
== EFI_BUFFER_TOO_SMALL
) {
2548 VarData
= AllocatePool (VarSize
);
2549 if (VarData
== NULL
) {
2550 Status
= EFI_OUT_OF_RESOURCES
;
2554 CurVarSize
= VarSize
;
2555 Status
= gRT
->GetVariable (VarName
, &gUserIdentifyManagerGuid
, &VarAttr
, &VarSize
, VarData
);
2558 if (EFI_ERROR (Status
)) {
2559 if (Status
== EFI_NOT_FOUND
) {
2560 Status
= EFI_SUCCESS
;
2566 // Check variable attributes.
2568 if (VarAttr
!= (EFI_VARIABLE_NON_VOLATILE
| EFI_VARIABLE_BOOTSERVICE_ACCESS
)) {
2569 Status
= gRT
->SetVariable (VarName
, &gUserIdentifyManagerGuid
, VarAttr
, 0, NULL
);
2574 // Add user profile to the user profile database.
2576 Status
= AddUserProfile (NULL
, VarSize
, VarData
, FALSE
);
2577 if (EFI_ERROR (Status
)) {
2578 if (Status
== EFI_SECURITY_VIOLATION
) {
2580 // Delete invalid user profile
2582 gRT
->SetVariable (VarName
, &gUserIdentifyManagerGuid
, VarAttr
, 0, NULL
);
2583 } else if (Status
== EFI_OUT_OF_RESOURCES
) {
2588 // Delete and save the profile again if some invalid profiles are deleted.
2590 if (mUserProfileDb
->UserProfileNum
< Index
) {
2591 gRT
->SetVariable (VarName
, &gUserIdentifyManagerGuid
, VarAttr
, 0, NULL
);
2592 SaveNvUserProfile (mUserProfileDb
->UserProfile
[mUserProfileDb
->UserProfileNum
- 1], FALSE
);
2597 if (VarData
!= NULL
) {
2601 if (EFI_ERROR (Status
)) {
2606 // Check whether the user profile database is empty.
2608 if (mUserProfileDb
->UserProfileNum
== 0) {
2609 Status
= AddDefaultUserProfile ();
2617 This function collects all the credential providers and saves to mProviderDb.
2619 @retval EFI_SUCCESS Collect credential providers successfully.
2620 @retval Others Fail to collect credential providers.
2630 EFI_HANDLE
*HandleBuf
;
2633 if (mProviderDb
!= NULL
) {
2635 // The credential providers had been collected before.
2641 // Try to find all the user credential provider driver.
2645 Status
= gBS
->LocateHandleBuffer (
2647 &gEfiUserCredential2ProtocolGuid
,
2652 if (EFI_ERROR (Status
)) {
2657 // Get provider infomation.
2659 mProviderDb
= AllocateZeroPool (
2660 sizeof (CREDENTIAL_PROVIDER_INFO
) -
2661 sizeof (EFI_USER_CREDENTIAL2_PROTOCOL
*) +
2662 HandleCount
* sizeof (EFI_USER_CREDENTIAL2_PROTOCOL
*)
2664 if (mProviderDb
== NULL
) {
2665 FreePool (HandleBuf
);
2666 return EFI_OUT_OF_RESOURCES
;
2669 mProviderDb
->Count
= HandleCount
;
2670 for (Index
= 0; Index
< HandleCount
; Index
++) {
2671 Status
= gBS
->HandleProtocol (
2673 &gEfiUserCredential2ProtocolGuid
,
2674 (VOID
**) &mProviderDb
->Provider
[Index
]
2676 if (EFI_ERROR (Status
)) {
2677 FreePool (HandleBuf
);
2678 FreePool (mProviderDb
);
2684 FreePool (HandleBuf
);
2690 This function allows a caller to extract the current configuration for one
2691 or more named elements from the target driver.
2694 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
2695 @param Request A null-terminated Unicode string in <ConfigRequest> format.
2696 @param Progress On return, points to a character in the Request string.
2697 Points to the string's null terminator if request was successful.
2698 Points to the most recent '&' before the first failing name/value
2699 pair (or the beginning of the string if the failure is in the
2700 first name/value pair) if the request was not successful.
2701 @param Results A null-terminated Unicode string in <ConfigAltResp> format which
2702 has all values filled in for the names in the Request string.
2703 String to be allocated by the called function.
2705 @retval EFI_SUCCESS The Results is filled with the requested values.
2706 @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
2707 @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
2708 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
2714 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
2715 IN CONST EFI_STRING Request
,
2716 OUT EFI_STRING
*Progress
,
2717 OUT EFI_STRING
*Results
2720 if (Progress
== NULL
|| Results
== NULL
) {
2721 return EFI_INVALID_PARAMETER
;
2723 *Progress
= Request
;
2724 return EFI_NOT_FOUND
;
2728 This function processes the results of changes in configuration.
2731 @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
2732 @param Configuration A null-terminated Unicode string in <ConfigResp> format.
2733 @param Progress A pointer to a string filled in with the offset of the most
2734 recent '&' before the first failing name/value pair (or the
2735 beginning of the string if the failure is in the first
2736 name/value pair) or the terminating NULL if all was successful.
2738 @retval EFI_SUCCESS The Results is processed successfully.
2739 @retval EFI_INVALID_PARAMETER Configuration is NULL.
2740 @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
2746 IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL
*This
,
2747 IN CONST EFI_STRING Configuration
,
2748 OUT EFI_STRING
*Progress
2751 if (Configuration
== NULL
|| Progress
== NULL
) {
2752 return EFI_INVALID_PARAMETER
;
2755 return EFI_NOT_FOUND
;
2760 This function initialize the data mainly used in form browser.
2762 @retval EFI_SUCCESS Initialize form data successfully.
2763 @retval Others Fail to Initialize form data.
2772 USER_MANAGER_CALLBACK_INFO
*CallbackInfo
;
2773 EFI_HII_DATABASE_PROTOCOL
*HiiDatabase
;
2774 EFI_HII_STRING_PROTOCOL
*HiiString
;
2775 EFI_FORM_BROWSER2_PROTOCOL
*FormBrowser2
;
2778 // Initialize driver private data.
2780 CallbackInfo
= AllocateZeroPool (sizeof (USER_MANAGER_CALLBACK_INFO
));
2781 if (CallbackInfo
== NULL
) {
2782 return EFI_OUT_OF_RESOURCES
;
2785 CallbackInfo
->Signature
= USER_MANAGER_SIGNATURE
;
2786 CallbackInfo
->ConfigAccess
.ExtractConfig
= FakeExtractConfig
;
2787 CallbackInfo
->ConfigAccess
.RouteConfig
= FakeRouteConfig
;
2788 CallbackInfo
->ConfigAccess
.Callback
= UserIdentifyManagerCallback
;
2791 // Locate Hii Database protocol.
2793 Status
= gBS
->LocateProtocol (&gEfiHiiDatabaseProtocolGuid
, NULL
, (VOID
**) &HiiDatabase
);
2794 if (EFI_ERROR (Status
)) {
2797 CallbackInfo
->HiiDatabase
= HiiDatabase
;
2800 // Locate HiiString protocol.
2802 Status
= gBS
->LocateProtocol (&gEfiHiiStringProtocolGuid
, NULL
, (VOID
**) &HiiString
);
2803 if (EFI_ERROR (Status
)) {
2806 CallbackInfo
->HiiString
= HiiString
;
2809 // Locate Formbrowser2 protocol.
2811 Status
= gBS
->LocateProtocol (&gEfiFormBrowser2ProtocolGuid
, NULL
, (VOID
**) &FormBrowser2
);
2812 if (EFI_ERROR (Status
)) {
2816 CallbackInfo
->FormBrowser2
= FormBrowser2
;
2817 CallbackInfo
->DriverHandle
= NULL
;
2820 // Install Device Path Protocol and Config Access protocol to driver handle.
2822 Status
= gBS
->InstallMultipleProtocolInterfaces (
2823 &CallbackInfo
->DriverHandle
,
2824 &gEfiDevicePathProtocolGuid
,
2825 &mHiiVendorDevicePath
,
2826 &gEfiHiiConfigAccessProtocolGuid
,
2827 &CallbackInfo
->ConfigAccess
,
2830 ASSERT_EFI_ERROR (Status
);
2833 // Publish HII data.
2835 CallbackInfo
->HiiHandle
= HiiAddPackages (
2836 &gUserIdentifyManagerGuid
,
2837 CallbackInfo
->DriverHandle
,
2838 UserIdentifyManagerStrings
,
2839 UserIdentifyManagerVfrBin
,
2842 if (CallbackInfo
->HiiHandle
== NULL
) {
2843 return EFI_OUT_OF_RESOURCES
;
2846 mCallbackInfo
= CallbackInfo
;
2853 Identify the user whose identification policy supports auto logon.
2855 @param[in] ProviderIndex The provider index in the provider list.
2856 @param[out] User Points to user user profile if a user is identified successfully.
2858 @retval EFI_SUCCESS Identify a user with the specified provider successfully.
2859 @retval Others Fail to identify a user.
2863 IdentifyAutoLogonUser (
2864 IN UINTN ProviderIndex
,
2865 OUT USER_PROFILE_ENTRY
**User
2869 EFI_USER_INFO
*Info
;
2872 Info
= AllocateZeroPool (sizeof (EFI_USER_INFO
) + sizeof (EFI_USER_INFO_IDENTIFIER
));
2874 return EFI_OUT_OF_RESOURCES
;
2877 Info
->InfoType
= EFI_USER_INFO_IDENTIFIER_RECORD
;
2878 Info
->InfoSize
= sizeof (EFI_USER_INFO
) + sizeof (EFI_USER_INFO_IDENTIFIER
);
2881 // Identify the specified credential provider's auto logon user.
2883 Status
= mProviderDb
->Provider
[ProviderIndex
]->User (
2884 mProviderDb
->Provider
[ProviderIndex
],
2886 (EFI_USER_INFO_IDENTIFIER
*) (Info
+ 1)
2888 if (EFI_ERROR (Status
)) {
2894 // Find user with the specified user ID.
2897 Status
= FindUserProfileByInfo (User
, NULL
, Info
, Info
->InfoSize
);
2899 if (EFI_ERROR (Status
)) {
2903 Status
= GetIdentifyType ((EFI_USER_PROFILE_HANDLE
) * User
, &PolicyType
);
2904 if (PolicyType
== EFI_USER_INFO_IDENTITY_AND
) {
2906 // The identified user need also identified by other credential provider.
2907 // This can handle through select user.
2909 return EFI_NOT_READY
;
2917 Check whether the given console is ready.
2919 @param[in] ProtocolGuid Points to the protocol guid of sonsole .
2921 @retval TRUE The given console is ready.
2922 @retval FALSE The given console is not ready.
2927 EFI_GUID
*ProtocolGuid
2932 EFI_HANDLE
*HandleBuf
;
2934 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
2937 // Try to find all the handle driver.
2941 Status
= gBS
->LocateHandleBuffer (
2948 if (EFI_ERROR (Status
)) {
2952 for (Index
= 0; Index
< HandleCount
; Index
++) {
2953 DevicePath
= DevicePathFromHandle (HandleBuf
[Index
]);
2954 if (DevicePath
!= NULL
) {
2955 FreePool (HandleBuf
);
2959 FreePool (HandleBuf
);
2965 Check whether the console is ready.
2967 @retval TRUE The console is ready.
2968 @retval FALSE The console is not ready.
2976 if (!CheckConsole (&gEfiSimpleTextOutProtocolGuid
)) {
2980 if (!CheckConsole (&gEfiSimpleTextInProtocolGuid
)) {
2981 if (!CheckConsole (&gEfiSimpleTextInputExProtocolGuid
)) {
2991 Identify a user to logon.
2993 @param[out] User Points to user user profile if a user is identified successfully.
2995 @retval EFI_SUCCESS Identify a user successfully.
3000 OUT USER_PROFILE_ENTRY
**User
3005 EFI_CREDENTIAL_LOGON_FLAGS AutoLogon
;
3006 EFI_USER_INFO
*IdentifyInfo
;
3007 EFI_USER_INFO_IDENTITY_POLICY
*Identity
;
3008 EFI_USER_CREDENTIAL2_PROTOCOL
*UserCredential
;
3009 USER_PROFILE_ENTRY
*UserEntry
;
3012 // Initialize credential providers.
3014 InitProviderInfo ();
3017 // Initialize user profile database.