+++ /dev/null
-/** @file\r
- GUID used as HII Package list GUID in UsbCredentialProviderDxe driver.\r
-\r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __USB_CREDENTIAL_PROVIDER_HII_H__\r
-#define __USB_CREDENTIAL_PROVIDER_HII_H__\r
-\r
-//\r
-// Used for save password credential and form browser\r
-// And used as provider identifier\r
-//\r
-#define USB_CREDENTIAL_PROVIDER_GUID \\r
- { \\r
- 0xd0849ed1, 0xa88c, 0x4ba6, { 0xb1, 0xd6, 0xab, 0x50, 0xe2, 0x80, 0xb7, 0xa9 }\\r
- }\r
-\r
-extern EFI_GUID gUsbCredentialProviderGuid;\r
-\r
-#endif\r
+++ /dev/null
-/** @file\r
- GUID used as HII FormSet and HII Package list GUID in UserIdentifyManagerDxe driver.\r
-\r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __USER_IDENTIFY_MANAGER_HII_H__\r
-#define __USER_IDENTIFY_MANAGER_HII_H__\r
-\r
-#define USER_IDENTIFY_MANAGER_GUID \\r
- { \\r
- 0x3ccd3dd8, 0x8d45, 0x4fed, { 0x96, 0x2d, 0x2b, 0x38, 0xcd, 0x82, 0xb3, 0xc4 } \\r
- }\r
-\r
-extern EFI_GUID gUserIdentifyManagerGuid;\r
-\r
-#endif\r
+++ /dev/null
-/** @file\r
- GUID used as HII FormSet and HII Package list GUID in UserProfileManagerDxe driver.\r
-\r
-Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __USER_PROFILE_MANAGER_HII_H__\r
-#define __USER_PROFILE_MANAGER_HII_H__\r
-\r
-#define USER_PROFILE_MANAGER_GUID \\r
- { \\r
- 0xc35f272c, 0x97c2, 0x465a, { 0xa2, 0x16, 0x69, 0x6b, 0x66, 0x8a, 0x8c, 0xfe } \\r
- }\r
-\r
-extern EFI_GUID gUserProfileManagerGuid;\r
-\r
-#endif\r
# It also provides the definitions(including PPIs/PROTOCOLs/GUIDs and library classes)\r
# and libraries instances, which are used for those features.\r
#\r
-# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>\r
# (C) Copyright 2015 Hewlett Packard Enterprise Development LP <BR>\r
# Copyright (c) 2017, Microsoft Corporation. All rights reserved. <BR>\r
# This program and the accompanying materials are licensed and made available under\r
# Include/Guid/Tcg2PhysicalPresenceData.h\r
gEfiTcg2PhysicalPresenceGuid = { 0xaeb9c5c1, 0x94f1, 0x4d02, { 0xbf, 0xd9, 0x46, 0x2, 0xdb, 0x2d, 0x3c, 0x54 }}\r
\r
- ## GUID used for form browser, password credential and provider identifier.\r
- # Include/Guid/PwdCredentialProviderHii.h\r
- gPwdCredentialProviderGuid = { 0x78b9ec8b, 0xc000, 0x46c5, { 0xac, 0x93, 0x24, 0xa0, 0xc1, 0xbb, 0x0, 0xce }}\r
-\r
- ## GUID used for form browser, USB credential and provider identifier.\r
- # Include/Guid/UsbCredentialProviderHii.h\r
- gUsbCredentialProviderGuid = { 0xd0849ed1, 0xa88c, 0x4ba6, { 0xb1, 0xd6, 0xab, 0x50, 0xe2, 0x80, 0xb7, 0xa9 }}\r
-\r
## GUID used for FormSet guid and user profile variable.\r
# Include/Guid/UserIdentifyManagerHii.h\r
gUserIdentifyManagerGuid = { 0x3ccd3dd8, 0x8d45, 0x4fed, { 0x96, 0x2d, 0x2b, 0x38, 0xcd, 0x82, 0xb3, 0xc4 }}\r
\r
- ## GUID used for FormSet.\r
- # Include/Guid/UserProfileManagerHii.h\r
- gUserProfileManagerGuid = { 0xc35f272c, 0x97c2, 0x465a, { 0xa2, 0x16, 0x69, 0x6b, 0x66, 0x8a, 0x8c, 0xfe }}\r
-\r
## GUID used for FormSet.\r
# Include/Guid/TcgConfigHii.h\r
gTcgConfigFormSetGuid = { 0xb0f901e4, 0xc424, 0x45de, { 0x90, 0x81, 0x95, 0xe2, 0xb, 0xde, 0x6f, 0xb5 }}\r
## @file\r
# Security Module Package for All Architectures.\r
#\r
-# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.<BR>\r
# (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
# This program and the accompanying materials\r
# are licensed and made available under the terms and conditions of the BSD License\r
SecurityPkg/Library/DxeImageVerificationLib/DxeImageVerificationLib.inf\r
#SecurityPkg/Library/DxeDeferImageLoadLib/DxeDeferImageLoadLib.inf\r
SecurityPkg/Library/DxeImageAuthenticationStatusLib/DxeImageAuthenticationStatusLib.inf\r
- #SecurityPkg/UserIdentification/UserIdentifyManagerDxe/UserIdentifyManagerDxe.inf\r
- #SecurityPkg/UserIdentification/UserProfileManagerDxe/UserProfileManagerDxe.inf\r
\r
#\r
# TPM\r
SecurityPkg/Library/AuthVariableLib/AuthVariableLib.inf\r
\r
[Components.IA32, Components.X64]\r
-# SecurityPkg/UserIdentification/PwdCredentialProviderDxe/PwdCredentialProviderDxe.inf\r
-# SecurityPkg/UserIdentification/UsbCredentialProviderDxe/UsbCredentialProviderDxe.inf\r
SecurityPkg/VariableAuthenticated/SecureBootConfigDxe/SecureBootConfigDxe.inf\r
\r
#\r
+++ /dev/null
-/** @file\r
- Password Credential Provider driver implementation.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-(C) Copyright 2018 Hewlett Packard Enterprise Development LP<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "PwdCredentialProvider.h"\r
-\r
-CREDENTIAL_TABLE *mPwdTable = NULL;\r
-PWD_PROVIDER_CALLBACK_INFO *mCallbackInfo = NULL;\r
-PASSWORD_CREDENTIAL_INFO *mPwdInfoHandle = NULL;\r
-\r
-HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath = {\r
- {\r
- {\r
- HARDWARE_DEVICE_PATH,\r
- HW_VENDOR_DP,\r
- {\r
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
- }\r
- },\r
- PWD_CREDENTIAL_PROVIDER_GUID\r
- },\r
- {\r
- END_DEVICE_PATH_TYPE,\r
- END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
- {\r
- (UINT8) (END_DEVICE_PATH_LENGTH),\r
- (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
- }\r
- }\r
-};\r
-\r
-EFI_USER_CREDENTIAL2_PROTOCOL gPwdCredentialProviderDriver = {\r
- PWD_CREDENTIAL_PROVIDER_GUID,\r
- EFI_USER_CREDENTIAL_CLASS_PASSWORD,\r
- CredentialEnroll,\r
- CredentialForm,\r
- CredentialTile,\r
- CredentialTitle,\r
- CredentialUser,\r
- CredentialSelect,\r
- CredentialDeselect,\r
- CredentialDefault,\r
- CredentialGetInfo,\r
- CredentialGetNextInfo,\r
- EFI_CREDENTIAL_CAPABILITIES_ENROLL,\r
- CredentialDelete\r
-};\r
-\r
-\r
-/**\r
- Get string by string id from HII Interface.\r
-\r
-\r
- @param[in] Id String ID to get the string from.\r
-\r
- @retval CHAR16 * String from ID.\r
- @retval NULL If error occurs.\r
-\r
-**/\r
-CHAR16 *\r
-GetStringById (\r
- IN EFI_STRING_ID Id\r
- )\r
-{\r
- //\r
- // Get the current string for the current Language.\r
- //\r
- return HiiGetString (mCallbackInfo->HiiHandle, Id, NULL);\r
-}\r
-\r
-\r
-/**\r
- Expand password table size.\r
-\r
-**/\r
-VOID\r
-ExpandTableSize (\r
- VOID\r
- )\r
-{\r
- CREDENTIAL_TABLE *NewTable;\r
- UINTN Count;\r
-\r
- Count = mPwdTable->MaxCount + PASSWORD_TABLE_INC;\r
- //\r
- // Create new credential table.\r
- //\r
- NewTable = (CREDENTIAL_TABLE *) AllocateZeroPool (\r
- sizeof (CREDENTIAL_TABLE) +\r
- (Count - 1) * sizeof (PASSWORD_INFO)\r
- );\r
- ASSERT (NewTable != NULL);\r
-\r
- NewTable->MaxCount = Count;\r
- NewTable->Count = mPwdTable->Count;\r
- NewTable->ValidIndex = mPwdTable->ValidIndex;\r
- //\r
- // Copy old entries\r
- //\r
- CopyMem (\r
- &NewTable->UserInfo,\r
- &mPwdTable->UserInfo,\r
- mPwdTable->Count * sizeof (PASSWORD_INFO)\r
- );\r
- FreePool (mPwdTable);\r
- mPwdTable = NewTable;\r
-}\r
-\r
-\r
-/**\r
- Add, update or delete info in table, and sync with NV variable.\r
-\r
- @param[in] Index The index of the password in table. If index is found in\r
- table, update the info, else add the into to table.\r
- @param[in] Info The new password info to add into table.If Info is NULL,\r
- delete the info by Index.\r
-\r
- @retval EFI_INVALID_PARAMETER Info is NULL when save the info.\r
- @retval EFI_SUCCESS Modify the table successfully.\r
- @retval Others Failed to modify the table.\r
-\r
-**/\r
-EFI_STATUS\r
-ModifyTable (\r
- IN UINTN Index,\r
- IN PASSWORD_INFO * Info OPTIONAL\r
- )\r
-{\r
- EFI_STATUS Status;\r
- PASSWORD_INFO *NewPasswordInfo;\r
-\r
- NewPasswordInfo = NULL;\r
-\r
- if (Index < mPwdTable->Count) {\r
- if (Info == NULL) {\r
- //\r
- // Delete the specified entry.\r
- //\r
- mPwdTable->Count--;\r
- if (Index != mPwdTable->Count) {\r
- NewPasswordInfo = &mPwdTable->UserInfo[mPwdTable->Count];\r
- }\r
- } else {\r
- //\r
- // Update the specified entry.\r
- //\r
- NewPasswordInfo = Info;\r
- }\r
- } else {\r
- //\r
- // Add a new password info.\r
- //\r
- if (Info == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (mPwdTable->Count >= mPwdTable->MaxCount) {\r
- ExpandTableSize ();\r
- }\r
-\r
- NewPasswordInfo = Info;\r
- mPwdTable->Count++;\r
- }\r
-\r
- if (NewPasswordInfo != NULL) {\r
- CopyMem (&mPwdTable->UserInfo[Index], NewPasswordInfo, sizeof (PASSWORD_INFO));\r
- }\r
-\r
- //\r
- // Save the credential table.\r
- //\r
- Status = gRT->SetVariable (\r
- L"PwdCredential",\r
- &gPwdCredentialProviderGuid,\r
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
- mPwdTable->Count * sizeof (PASSWORD_INFO),\r
- &mPwdTable->UserInfo\r
- );\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Create a password table.\r
-\r
- @retval EFI_SUCCESS Create a password table successfully.\r
- @retval Others Failed to create a password.\r
-\r
-**/\r
-EFI_STATUS\r
-InitCredentialTable (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINT8 *Var;\r
- UINTN VarSize;\r
-\r
- //\r
- // Get Password credential data from NV variable.\r
- //\r
- VarSize = 0;\r
- Var = NULL;\r
- Status = gRT->GetVariable (\r
- L"PwdCredential",\r
- &gPwdCredentialProviderGuid,\r
- NULL,\r
- &VarSize,\r
- Var\r
- );\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- Var = AllocateZeroPool (VarSize);\r
- if (Var == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- Status = gRT->GetVariable (\r
- L"PwdCredential",\r
- &gPwdCredentialProviderGuid,\r
- NULL,\r
- &VarSize,\r
- Var\r
- );\r
- }\r
- if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Create the password credential table.\r
- //\r
- mPwdTable = AllocateZeroPool (\r
- sizeof (CREDENTIAL_TABLE) - sizeof (PASSWORD_INFO) +\r
- PASSWORD_TABLE_INC * sizeof (PASSWORD_INFO) +\r
- VarSize\r
- );\r
- if (mPwdTable == NULL) {\r
- FreePool (Var);\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- mPwdTable->Count = VarSize / sizeof (PASSWORD_INFO);\r
- mPwdTable->MaxCount = mPwdTable->Count + PASSWORD_TABLE_INC;\r
- mPwdTable->ValidIndex = 0;\r
- if (Var != NULL) {\r
- CopyMem (mPwdTable->UserInfo, Var, VarSize);\r
- FreePool (Var);\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Hash the password to get credential.\r
-\r
- @param[in] Password Points to the input password.\r
- @param[in] PasswordSize The size of password, in bytes.\r
- @param[out] Credential Points to the hashed result.\r
-\r
- @retval TRUE Hash the password successfully.\r
- @retval FALSE Failed to hash the password.\r
-\r
-**/\r
-BOOLEAN\r
-GenerateCredential (\r
- IN CHAR16 *Password,\r
- IN UINTN PasswordSize,\r
- OUT UINT8 *Credential\r
- )\r
-{\r
- BOOLEAN Status;\r
- UINTN HashSize;\r
- VOID *Hash;\r
-\r
- HashSize = Sha1GetContextSize ();\r
- Hash = AllocatePool (HashSize);\r
- ASSERT (Hash != NULL);\r
-\r
- Status = Sha1Init (Hash);\r
- if (!Status) {\r
- goto Done;\r
- }\r
-\r
- Status = Sha1Update (Hash, Password, PasswordSize);\r
- if (!Status) {\r
- goto Done;\r
- }\r
-\r
- Status = Sha1Final (Hash, Credential);\r
-\r
-Done:\r
- FreePool (Hash);\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Get password from user input.\r
-\r
- @param[in] FirstPwd If True, prompt to input the first password.\r
- If False, prompt to input password again.\r
- @param[out] Credential Points to the input password.\r
-\r
-**/\r
-VOID\r
-GetPassword (\r
- IN BOOLEAN FirstPwd,\r
- OUT CHAR8 *Credential\r
- )\r
-{\r
- EFI_INPUT_KEY Key;\r
- CHAR16 PasswordMask[CREDENTIAL_LEN + 1];\r
- CHAR16 Password[CREDENTIAL_LEN];\r
- UINTN PasswordLen;\r
- CHAR16 *QuestionStr;\r
- CHAR16 *LineStr;\r
-\r
- PasswordLen = 0;\r
- while (TRUE) {\r
- PasswordMask[PasswordLen] = L'_';\r
- PasswordMask[PasswordLen + 1] = L'\0';\r
- LineStr = GetStringById (STRING_TOKEN (STR_DRAW_A_LINE));\r
- if (FirstPwd) {\r
- QuestionStr = GetStringById (STRING_TOKEN (STR_INPUT_PASSWORD));\r
- } else {\r
- QuestionStr = GetStringById (STRING_TOKEN (STR_INPUT_PASSWORD_AGAIN));\r
- }\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- QuestionStr,\r
- LineStr,\r
- PasswordMask,\r
- NULL\r
- );\r
- FreePool (QuestionStr);\r
- FreePool (LineStr);\r
-\r
- //\r
- // Check key stroke\r
- //\r
- if (Key.ScanCode == SCAN_NULL) {\r
- if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
- break;\r
- } else if (Key.UnicodeChar == CHAR_BACKSPACE) {\r
- if (PasswordLen > 0) {\r
- PasswordLen--;\r
- }\r
- } else if ((Key.UnicodeChar == CHAR_NULL) ||\r
- (Key.UnicodeChar == CHAR_TAB) ||\r
- (Key.UnicodeChar == CHAR_LINEFEED)) {\r
- continue;\r
- } else {\r
- Password[PasswordLen] = Key.UnicodeChar;\r
- PasswordMask[PasswordLen] = L'*';\r
- PasswordLen++;\r
- if (PasswordLen == CREDENTIAL_LEN) {\r
- break;\r
- }\r
- }\r
- }\r
- }\r
-\r
- PasswordLen = PasswordLen * sizeof (CHAR16);\r
- GenerateCredential (Password, PasswordLen, (UINT8 *)Credential);\r
-}\r
-\r
-/**\r
- Check whether the password can be found on this provider.\r
-\r
- @param[in] Password The password to be found.\r
-\r
- @retval EFI_SUCCESS Found password sucessfully.\r
- @retval EFI_NOT_FOUND Fail to find the password.\r
-\r
-**/\r
-EFI_STATUS\r
-CheckPassword (\r
- IN CHAR8 *Password\r
- )\r
-{\r
- UINTN Index;\r
- CHAR8 *Pwd;\r
-\r
- //\r
- // Check password credential.\r
- //\r
- mPwdTable->ValidIndex = 0;\r
- for (Index = 0; Index < mPwdTable->Count; Index++) {\r
- Pwd = mPwdTable->UserInfo[Index].Password;\r
- if (CompareMem (Pwd, Password, CREDENTIAL_LEN) == 0) {\r
- mPwdTable->ValidIndex = Index + 1;\r
- return EFI_SUCCESS;\r
- }\r
- }\r
-\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
- Find a user infomation record by the information record type.\r
-\r
- This function searches all user information records of User from beginning\r
- until either the information is found, or there are no more user infomation\r
- records. A match occurs when a Info.InfoType field matches the user information\r
- record type.\r
-\r
- @param[in] User Points to the user profile record to search.\r
- @param[in] InfoType The infomation type to be searched.\r
- @param[out] Info Points to the user info found, the caller is responsible\r
- to free.\r
-\r
- @retval EFI_SUCCESS Find the user information successfully.\r
- @retval Others Fail to find the user information.\r
-\r
-**/\r
-EFI_STATUS\r
-FindUserInfoByType (\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN UINT8 InfoType,\r
- OUT EFI_USER_INFO **Info\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *UserInfo;\r
- UINTN UserInfoSize;\r
- EFI_USER_INFO_HANDLE UserInfoHandle;\r
- EFI_USER_MANAGER_PROTOCOL *UserManager;\r
-\r
- //\r
- // Find user information by information type.\r
- //\r
- if (Info == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- Status = gBS->LocateProtocol (\r
- &gEfiUserManagerProtocolGuid,\r
- NULL,\r
- (VOID **) &UserManager\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // Get each user information.\r
- //\r
-\r
- UserInfoHandle = NULL;\r
- UserInfo = NULL;\r
- UserInfoSize = 0;\r
- while (TRUE) {\r
- Status = UserManager->GetNextInfo (UserManager, User, &UserInfoHandle);\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
- //\r
- // Get information.\r
- //\r
- Status = UserManager->GetInfo (\r
- UserManager,\r
- User,\r
- UserInfoHandle,\r
- UserInfo,\r
- &UserInfoSize\r
- );\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- if (UserInfo != NULL) {\r
- FreePool (UserInfo);\r
- }\r
- UserInfo = AllocateZeroPool (UserInfoSize);\r
- if (UserInfo == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- Status = UserManager->GetInfo (\r
- UserManager,\r
- User,\r
- UserInfoHandle,\r
- UserInfo,\r
- &UserInfoSize\r
- );\r
- }\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
-\r
- ASSERT (UserInfo != NULL);\r
- if (UserInfo->InfoType == InfoType) {\r
- *Info = UserInfo;\r
- return EFI_SUCCESS;\r
- }\r
- }\r
-\r
- if (UserInfo != NULL) {\r
- FreePool (UserInfo);\r
- }\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- This function processes the results of changes in configuration.\r
-\r
- @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
- @param Action Specifies the type of action taken by the browser.\r
- @param QuestionId A unique value which is sent to the original\r
- exporting driver so that it can identify the type\r
- of data to expect.\r
- @param Type The type of value for the question.\r
- @param Value A pointer to the data being sent to the original\r
- exporting driver.\r
- @param ActionRequest On return, points to the action requested by the\r
- callback function.\r
-\r
- @retval EFI_SUCCESS The callback successfully handled the action.\r
- @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the\r
- variable and its data.\r
- @retval EFI_DEVICE_ERROR The variable could not be saved.\r
- @retval EFI_UNSUPPORTED The specified Action is not supported by the\r
- callback.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialDriverCallback (\r
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
- IN EFI_BROWSER_ACTION Action,\r
- IN EFI_QUESTION_ID QuestionId,\r
- IN UINT8 Type,\r
- IN EFI_IFR_TYPE_VALUE *Value,\r
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_INPUT_KEY Key;\r
- CHAR8 Password[CREDENTIAL_LEN];\r
- CHAR16 *PromptStr;\r
-\r
- if (Action == EFI_BROWSER_ACTION_CHANGED) {\r
- if (QuestionId == KEY_GET_PASSWORD) {\r
- //\r
- // Get and check password.\r
- //\r
- GetPassword (TRUE, Password);\r
- Status = CheckPassword (Password);\r
- if (EFI_ERROR (Status)) {\r
- PromptStr = GetStringById (STRING_TOKEN (STR_PASSWORD_INCORRECT));\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- L"",\r
- PromptStr,\r
- L"",\r
- NULL\r
- );\r
- FreePool (PromptStr);\r
- return Status;\r
- }\r
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
- }\r
- return EFI_SUCCESS;\r
- }\r
-\r
- //\r
- // All other action return unsupported.\r
- //\r
- return EFI_UNSUPPORTED;\r
-}\r
-\r
-\r
-/**\r
- This function allows a caller to extract the current configuration for one\r
- or more named elements from the target driver.\r
-\r
-\r
- @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
- @param Request A null-terminated Unicode string in <ConfigRequest> format.\r
- @param Progress On return, points to a character in the Request string.\r
- Points to the string's null terminator if request was successful.\r
- Points to the most recent '&' before the first failing name/value\r
- pair (or the beginning of the string if the failure is in the\r
- first name/value pair) if the request was not successful.\r
- @param Results A null-terminated Unicode string in <ConfigAltResp> format which\r
- has all values filled in for the names in the Request string.\r
- String to be allocated by the called function.\r
-\r
- @retval EFI_SUCCESS The Results is filled with the requested values.\r
- @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.\r
- @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.\r
- @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FakeExtractConfig (\r
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
- IN CONST EFI_STRING Request,\r
- OUT EFI_STRING *Progress,\r
- OUT EFI_STRING *Results\r
- )\r
-{\r
- if (Progress == NULL || Results == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- *Progress = Request;\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
- This function processes the results of changes in configuration.\r
-\r
-\r
- @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
- @param Configuration A null-terminated Unicode string in <ConfigResp> format.\r
- @param Progress A pointer to a string filled in with the offset of the most\r
- recent '&' before the first failing name/value pair (or the\r
- beginning of the string if the failure is in the first\r
- name/value pair) or the terminating NULL if all was successful.\r
-\r
- @retval EFI_SUCCESS The Results is processed successfully.\r
- @retval EFI_INVALID_PARAMETER Configuration is NULL.\r
- @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FakeRouteConfig (\r
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
- IN CONST EFI_STRING Configuration,\r
- OUT EFI_STRING *Progress\r
- )\r
-{\r
- if (Configuration == NULL || Progress == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- *Progress = Configuration;\r
-\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
- This function initialize the data mainly used in form browser.\r
-\r
- @retval EFI_SUCCESS Initialize form data successfully.\r
- @retval Others Fail to Initialize form data.\r
-\r
-**/\r
-EFI_STATUS\r
-InitFormBrowser (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- PWD_PROVIDER_CALLBACK_INFO *CallbackInfo;\r
-\r
- //\r
- // Initialize driver private data.\r
- //\r
- CallbackInfo = AllocateZeroPool (sizeof (PWD_PROVIDER_CALLBACK_INFO));\r
- if (CallbackInfo == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- CallbackInfo->Signature = PWD_PROVIDER_SIGNATURE;\r
- CallbackInfo->ConfigAccess.ExtractConfig = FakeExtractConfig;\r
- CallbackInfo->ConfigAccess.RouteConfig = FakeRouteConfig;\r
- CallbackInfo->ConfigAccess.Callback = CredentialDriverCallback;\r
- CallbackInfo->DriverHandle = NULL;\r
-\r
- //\r
- // Install Device Path Protocol and Config Access protocol to driver handle.\r
- //\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &CallbackInfo->DriverHandle,\r
- &gEfiDevicePathProtocolGuid,\r
- &mHiiVendorDevicePath,\r
- &gEfiHiiConfigAccessProtocolGuid,\r
- &CallbackInfo->ConfigAccess,\r
- NULL\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- //\r
- // Publish HII data.\r
- //\r
- CallbackInfo->HiiHandle = HiiAddPackages (\r
- &gPwdCredentialProviderGuid,\r
- CallbackInfo->DriverHandle,\r
- PwdCredentialProviderStrings,\r
- PwdCredentialProviderVfrBin,\r
- NULL\r
- );\r
- if (CallbackInfo->HiiHandle == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- mCallbackInfo = CallbackInfo;\r
-\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Enroll a user on a credential provider.\r
-\r
- This function enrolls a user on this credential provider. If the user exists on\r
- this credential provider, update the user information on this credential provider;\r
- otherwise add the user information on credential provider.\r
-\r
- @param[in] This Points to this instance of EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] User The user profile to enroll.\r
-\r
- @retval EFI_SUCCESS User profile was successfully enrolled.\r
- @retval EFI_ACCESS_DENIED Current user profile does not permit enrollment on the\r
- user profile handle. Either the user profile cannot enroll\r
- on any user profile or cannot enroll on a user profile\r
- other than the current user profile.\r
- @retval EFI_UNSUPPORTED This credential provider does not support enrollment in\r
- the pre-OS.\r
- @retval EFI_DEVICE_ERROR The new credential could not be created because of a device\r
- error.\r
- @retval EFI_INVALID_PARAMETER User does not refer to a valid user profile handle.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialEnroll (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Index;\r
- PASSWORD_INFO PwdInfo;\r
- EFI_USER_INFO *UserInfo;\r
- CHAR8 Password[CREDENTIAL_LEN];\r
- EFI_INPUT_KEY Key;\r
- UINT8 *UserId;\r
- CHAR16 *QuestionStr;\r
- CHAR16 *PromptStr;\r
-\r
- if ((This == NULL) || (User == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Get User Identifier.\r
- //\r
- UserInfo = NULL;\r
- Status = FindUserInfoByType (\r
- User,\r
- EFI_USER_INFO_IDENTIFIER_RECORD,\r
- &UserInfo\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- CopyMem (PwdInfo.UserId, (UINT8 *) (UserInfo + 1), sizeof (EFI_USER_INFO_IDENTIFIER));\r
- FreePool (UserInfo);\r
-\r
- //\r
- // Get password from user.\r
- //\r
- while (TRUE) {\r
- //\r
- // Input password.\r
- //\r
- GetPassword (TRUE, PwdInfo.Password);\r
-\r
- //\r
- // Input password again.\r
- //\r
- GetPassword (FALSE, Password);\r
-\r
- //\r
- // Compare the two password consistency.\r
- //\r
- if (CompareMem (PwdInfo.Password, Password, CREDENTIAL_LEN) == 0) {\r
- break;\r
- }\r
-\r
- QuestionStr = GetStringById (STRING_TOKEN (STR_PASSWORD_MISMATCH));\r
- PromptStr = GetStringById (STRING_TOKEN (STR_INPUT_PASSWORD_AGAIN));\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- QuestionStr,\r
- L"",\r
- PromptStr,\r
- NULL\r
- );\r
- FreePool (QuestionStr);\r
- FreePool (PromptStr);\r
- }\r
-\r
- //\r
- // Check whether User is ever enrolled in the provider.\r
- //\r
- for (Index = 0; Index < mPwdTable->Count; Index++) {\r
- UserId = (UINT8 *) &mPwdTable->UserInfo[Index].UserId;\r
- if (CompareMem (UserId, (UINT8 *) &PwdInfo.UserId, sizeof (EFI_USER_INFO_IDENTIFIER)) == 0) {\r
- //\r
- // User already exists, update the password.\r
- //\r
- break;\r
- }\r
- }\r
-\r
- //\r
- // Enroll the User to the provider.\r
- //\r
- Status = ModifyTable (Index, &PwdInfo);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Returns the user interface information used during user identification.\r
-\r
- This function returns information about the form used when interacting with the\r
- user during user identification. The form is the first enabled form in the form-set\r
- class EFI_HII_USER_CREDENTIAL_FORMSET_GUID installed on the HII handle HiiHandle. If\r
- the user credential provider does not require a form to identify the user, then this\r
- function should return EFI_NOT_FOUND.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] Hii On return, holds the HII database handle.\r
- @param[out] FormSetId On return, holds the identifier of the form set which contains\r
- the form used during user identification.\r
- @param[out] FormId On return, holds the identifier of the form used during user\r
- identification.\r
-\r
- @retval EFI_SUCCESS Form returned successfully.\r
- @retval EFI_NOT_FOUND Form not returned.\r
- @retval EFI_INVALID_PARAMETER Hii is NULL or FormSetId is NULL or FormId is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialForm (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_HII_HANDLE *Hii,\r
- OUT EFI_GUID *FormSetId,\r
- OUT EFI_FORM_ID *FormId\r
- )\r
-{\r
- if ((This == NULL) || (Hii == NULL) ||\r
- (FormSetId == NULL) || (FormId == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- *Hii = mCallbackInfo->HiiHandle;\r
- *FormId = FORMID_GET_PASSWORD_FORM;\r
- CopyGuid (FormSetId, &gPwdCredentialProviderGuid);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Returns bitmap used to describe the credential provider type.\r
-\r
- This optional function returns a bitmap that is less than or equal to the number\r
- of pixels specified by Width and Height. If no such bitmap exists, then EFI_NOT_FOUND\r
- is returned.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in, out] Width On entry, points to the desired bitmap width. If NULL then no\r
- bitmap information will be returned. On exit, points to the\r
- width of the bitmap returned.\r
- @param[in, out] Height On entry, points to the desired bitmap height. If NULL then no\r
- bitmap information will be returned. On exit, points to the\r
- height of the bitmap returned\r
- @param[out] Hii On return, holds the HII database handle.\r
- @param[out] Image On return, holds the HII image identifier.\r
-\r
- @retval EFI_SUCCESS Image identifier returned successfully.\r
- @retval EFI_NOT_FOUND Image identifier not returned.\r
- @retval EFI_INVALID_PARAMETER Hii is NULL or Image is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialTile (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN OUT UINTN *Width,\r
- IN OUT UINTN *Height,\r
- OUT EFI_HII_HANDLE *Hii,\r
- OUT EFI_IMAGE_ID *Image\r
- )\r
-{\r
- if ((This == NULL) || (Hii == NULL) || (Image == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
- Returns string used to describe the credential provider type.\r
-\r
- This function returns a string which describes the credential provider. If no\r
- such string exists, then EFI_NOT_FOUND is returned.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] Hii On return, holds the HII database handle.\r
- @param[out] String On return, holds the HII string identifier.\r
-\r
- @retval EFI_SUCCESS String identifier returned successfully.\r
- @retval EFI_NOT_FOUND String identifier not returned.\r
- @retval EFI_INVALID_PARAMETER Hii is NULL or String is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialTitle (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_HII_HANDLE *Hii,\r
- OUT EFI_STRING_ID *String\r
- )\r
-{\r
- if ((This == NULL) || (Hii == NULL) || (String == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Set Hii handle and String ID.\r
- //\r
- *Hii = mCallbackInfo->HiiHandle;\r
- *String = STRING_TOKEN (STR_CREDENTIAL_TITLE);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Return the user identifier associated with the currently authenticated user.\r
-\r
- This function returns the user identifier of the user authenticated by this credential\r
- provider. This function is called after the credential-related information has been\r
- submitted on a form, OR after a call to Default() has returned that this credential is\r
- ready to log on.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] User The user profile handle of the user profile currently being\r
- considered by the user identity manager. If NULL, then no user\r
- profile is currently under consideration.\r
- @param[out] Identifier On return, points to the user identifier.\r
-\r
- @retval EFI_SUCCESS User identifier returned successfully.\r
- @retval EFI_NOT_READY No user identifier can be returned.\r
- @retval EFI_ACCESS_DENIED The user has been locked out of this user credential.\r
- @retval EFI_INVALID_PARAMETER This is NULL, or Identifier is NULL.\r
- @retval EFI_NOT_FOUND User is not NULL, and the specified user handle can't be\r
- found in user profile database\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialUser (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- OUT EFI_USER_INFO_IDENTIFIER *Identifier\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Index;\r
- EFI_USER_INFO *UserInfo;\r
- UINT8 *UserId;\r
- UINT8 *NewUserId;\r
- CHAR8 *Pwd;\r
- CHAR8 *NewPwd;\r
-\r
- if ((This == NULL) || (Identifier == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (mPwdTable->ValidIndex == 0) {\r
- //\r
- // No password input, or the input password doesn't match\r
- // anyone in PwdTable.\r
- //\r
- return EFI_NOT_READY;\r
- }\r
-\r
- if (User == NULL) {\r
- //\r
- // Return the user ID whose password matches the input password.\r
- //\r
- CopyMem (\r
- Identifier,\r
- &mPwdTable->UserInfo[mPwdTable->ValidIndex - 1].UserId,\r
- sizeof (EFI_USER_INFO_IDENTIFIER)\r
- );\r
- return EFI_SUCCESS;\r
- }\r
-\r
- //\r
- // Get the User's ID.\r
- //\r
- Status = FindUserInfoByType (\r
- User,\r
- EFI_USER_INFO_IDENTIFIER_RECORD,\r
- &UserInfo\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // Check whether the input password matches one in PwdTable.\r
- //\r
- for (Index = 0; Index < mPwdTable->Count; Index++) {\r
- UserId = (UINT8 *) &mPwdTable->UserInfo[Index].UserId;\r
- NewUserId = (UINT8 *) (UserInfo + 1);\r
- if (CompareMem (UserId, NewUserId, sizeof (EFI_USER_INFO_IDENTIFIER)) == 0) {\r
- Pwd = mPwdTable->UserInfo[Index].Password;\r
- NewPwd = mPwdTable->UserInfo[mPwdTable->ValidIndex - 1].Password;\r
- if (CompareMem (Pwd, NewPwd, CREDENTIAL_LEN) == 0) {\r
- CopyMem (Identifier, UserId, sizeof (EFI_USER_INFO_IDENTIFIER));\r
- FreePool (UserInfo);\r
- return EFI_SUCCESS;\r
- }\r
- }\r
- }\r
-\r
- FreePool (UserInfo);\r
- return EFI_NOT_READY;\r
-}\r
-\r
-\r
-/**\r
- Indicate that user interface interaction has begun for the specified credential.\r
-\r
- This function is called when a credential provider is selected by the user. If\r
- AutoLogon returns FALSE, then the user interface will be constructed by the User\r
- Identity Manager.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] AutoLogon On return, points to the credential provider's capabilities\r
- after the credential provider has been selected by the user.\r
-\r
- @retval EFI_SUCCESS Credential provider successfully selected.\r
- @retval EFI_INVALID_PARAMETER AutoLogon is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialSelect (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_CREDENTIAL_LOGON_FLAGS *AutoLogon\r
- )\r
-{\r
- if ((This == NULL) || (AutoLogon == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- *AutoLogon = 0;\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Indicate that user interface interaction has ended for the specified credential.\r
-\r
- This function is called when a credential provider is deselected by the user.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
-\r
- @retval EFI_SUCCESS Credential provider successfully deselected.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialDeselect (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This\r
- )\r
-{\r
- if (This == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Return the default logon behavior for this user credential.\r
-\r
- This function reports the default login behavior regarding this credential provider.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] AutoLogon On return, holds whether the credential provider should be used\r
- by default to automatically log on the user.\r
-\r
- @retval EFI_SUCCESS Default information successfully returned.\r
- @retval EFI_INVALID_PARAMETER AutoLogon is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialDefault (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_CREDENTIAL_LOGON_FLAGS *AutoLogon\r
- )\r
-{\r
- if ((This == NULL) || (AutoLogon == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- *AutoLogon = 0;\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Return information attached to the credential provider.\r
-\r
- This function returns user information.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] UserInfo Handle of the user information data record.\r
- @param[out] Info On entry, points to a buffer of at least *InfoSize bytes. On\r
- exit, holds the user information. If the buffer is too small\r
- to hold the information, then EFI_BUFFER_TOO_SMALL is returned\r
- and InfoSize is updated to contain the number of bytes actually\r
- required.\r
- @param[in, out] InfoSize On entry, points to the size of Info. On return, points to the\r
- size of the user information.\r
-\r
- @retval EFI_SUCCESS Information returned successfully.\r
- @retval EFI_BUFFER_TOO_SMALL The size specified by InfoSize is too small to hold all of the\r
- user information. The size required is returned in *InfoSize.\r
- @retval EFI_INVALID_PARAMETER Info is NULL or InfoSize is NULL.\r
- @retval EFI_NOT_FOUND The specified UserInfo does not refer to a valid user info handle.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialGetInfo (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_INFO_HANDLE UserInfo,\r
- OUT EFI_USER_INFO *Info,\r
- IN OUT UINTN *InfoSize\r
- )\r
-{\r
- EFI_USER_INFO *CredentialInfo;\r
- UINTN Index;\r
-\r
- if ((This == NULL) || (InfoSize == NULL) || (Info == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if ((UserInfo == NULL) || (mPwdInfoHandle == NULL)) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // Find information handle in credential info table.\r
- //\r
- for (Index = 0; Index < mPwdInfoHandle->Count; Index++) {\r
- CredentialInfo = mPwdInfoHandle->Info[Index];\r
- if (UserInfo == (EFI_USER_INFO_HANDLE)CredentialInfo) {\r
- //\r
- // The handle is found, copy the user info.\r
- //\r
- if (CredentialInfo->InfoSize > *InfoSize) {\r
- *InfoSize = CredentialInfo->InfoSize;\r
- return EFI_BUFFER_TOO_SMALL;\r
- }\r
- CopyMem (Info, CredentialInfo, CredentialInfo->InfoSize);\r
- return EFI_SUCCESS;\r
- }\r
- }\r
-\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
- Enumerate all of the user informations on the credential provider.\r
-\r
- This function returns the next user information record. To retrieve the first user\r
- information record handle, point UserInfo at a NULL. Each subsequent call will retrieve\r
- another user information record handle until there are no more, at which point UserInfo\r
- will point to NULL.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in, out] UserInfo On entry, points to the previous user information handle or NULL\r
- to start enumeration. On exit, points to the next user information\r
- handle or NULL if there is no more user information.\r
-\r
- @retval EFI_SUCCESS User information returned.\r
- @retval EFI_NOT_FOUND No more user information found.\r
- @retval EFI_INVALID_PARAMETER UserInfo is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialGetNextInfo (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN OUT EFI_USER_INFO_HANDLE *UserInfo\r
- )\r
-{\r
- EFI_USER_INFO *Info;\r
- CHAR16 *ProvNameStr;\r
- UINTN InfoLen;\r
- UINTN Index;\r
- UINTN ProvStrLen;\r
-\r
- if ((This == NULL) || (UserInfo == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (mPwdInfoHandle == NULL) {\r
- //\r
- // Initilized user info table. There are 4 user info records in the table.\r
- //\r
- InfoLen = sizeof (PASSWORD_CREDENTIAL_INFO) + (4 - 1) * sizeof (EFI_USER_INFO *);\r
- mPwdInfoHandle = AllocateZeroPool (InfoLen);\r
- if (mPwdInfoHandle == NULL) {\r
- *UserInfo = NULL;\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // The first information, Credential Provider info.\r
- //\r
- InfoLen = sizeof (EFI_USER_INFO) + sizeof (EFI_GUID);\r
- Info = AllocateZeroPool (InfoLen);\r
- ASSERT (Info != NULL);\r
-\r
- Info->InfoType = EFI_USER_INFO_CREDENTIAL_PROVIDER_RECORD;\r
- Info->InfoSize = (UINT32) InfoLen;\r
- Info->InfoAttribs = EFI_USER_INFO_PROTECTED;\r
- CopyGuid (&Info->Credential, &gPwdCredentialProviderGuid);\r
- CopyGuid ((EFI_GUID *)(Info + 1), &gPwdCredentialProviderGuid);\r
-\r
- mPwdInfoHandle->Info[0] = Info;\r
- mPwdInfoHandle->Count++;\r
-\r
- //\r
- // The second information, Credential Provider name info.\r
- //\r
- ProvNameStr = GetStringById (STRING_TOKEN (STR_PROVIDER_NAME));\r
- ProvStrLen = StrSize (ProvNameStr);\r
- InfoLen = sizeof (EFI_USER_INFO) + ProvStrLen;\r
- Info = AllocateZeroPool (InfoLen);\r
- ASSERT (Info != NULL);\r
-\r
- Info->InfoType = EFI_USER_INFO_CREDENTIAL_PROVIDER_NAME_RECORD;\r
- Info->InfoSize = (UINT32) InfoLen;\r
- Info->InfoAttribs = EFI_USER_INFO_PROTECTED;\r
- CopyGuid (&Info->Credential, &gPwdCredentialProviderGuid);\r
- CopyMem ((UINT8*)(Info + 1), ProvNameStr, ProvStrLen);\r
- FreePool (ProvNameStr);\r
-\r
- mPwdInfoHandle->Info[1] = Info;\r
- mPwdInfoHandle->Count++;\r
-\r
- //\r
- // The third information, Credential Provider type info.\r
- //\r
- InfoLen = sizeof (EFI_USER_INFO) + sizeof (EFI_GUID);\r
- Info = AllocateZeroPool (InfoLen);\r
- ASSERT (Info != NULL);\r
-\r
- Info->InfoType = EFI_USER_INFO_CREDENTIAL_TYPE_RECORD;\r
- Info->InfoSize = (UINT32) InfoLen;\r
- Info->InfoAttribs = EFI_USER_INFO_PROTECTED;\r
- CopyGuid (&Info->Credential, &gPwdCredentialProviderGuid);\r
- CopyGuid ((EFI_GUID *)(Info + 1), &gEfiUserCredentialClassPasswordGuid);\r
-\r
- mPwdInfoHandle->Info[2] = Info;\r
- mPwdInfoHandle->Count++;\r
-\r
- //\r
- // The fourth information, Credential Provider type name info.\r
- //\r
- ProvNameStr = GetStringById (STRING_TOKEN (STR_PROVIDER_TYPE_NAME));\r
- ProvStrLen = StrSize (ProvNameStr);\r
- InfoLen = sizeof (EFI_USER_INFO) + ProvStrLen;\r
- Info = AllocateZeroPool (InfoLen);\r
- ASSERT (Info != NULL);\r
-\r
- Info->InfoType = EFI_USER_INFO_CREDENTIAL_PROVIDER_NAME_RECORD;\r
- Info->InfoSize = (UINT32) InfoLen;\r
- Info->InfoAttribs = EFI_USER_INFO_PROTECTED;\r
- CopyGuid (&Info->Credential, &gPwdCredentialProviderGuid);\r
- CopyMem ((UINT8*)(Info + 1), ProvNameStr, ProvStrLen);\r
- FreePool (ProvNameStr);\r
-\r
- mPwdInfoHandle->Info[3] = Info;\r
- mPwdInfoHandle->Count++;\r
- }\r
-\r
- if (*UserInfo == NULL) {\r
- //\r
- // Return the first info handle.\r
- //\r
- *UserInfo = (EFI_USER_INFO_HANDLE) mPwdInfoHandle->Info[0];\r
- return EFI_SUCCESS;\r
- }\r
-\r
- //\r
- // Find information handle in credential info table.\r
- //\r
- for (Index = 0; Index < mPwdInfoHandle->Count; Index++) {\r
- Info = mPwdInfoHandle->Info[Index];\r
- if (*UserInfo == (EFI_USER_INFO_HANDLE)Info) {\r
- //\r
- // The handle is found, get the next one.\r
- //\r
- if (Index == mPwdInfoHandle->Count - 1) {\r
- //\r
- // Already last one.\r
- //\r
- *UserInfo = NULL;\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- Index++;\r
- *UserInfo = (EFI_USER_INFO_HANDLE)mPwdInfoHandle->Info[Index];\r
- return EFI_SUCCESS;\r
- }\r
- }\r
-\r
- *UserInfo = NULL;\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
- Delete a user on this credential provider.\r
-\r
- This function deletes a user on this credential provider.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] User The user profile handle to delete.\r
-\r
- @retval EFI_SUCCESS User profile was successfully deleted.\r
- @retval EFI_ACCESS_DENIED Current user profile does not permit deletion on the user profile handle.\r
- Either the user profile cannot delete on any user profile or cannot delete\r
- on a user profile other than the current user profile.\r
- @retval EFI_UNSUPPORTED This credential provider does not support deletion in the pre-OS.\r
- @retval EFI_DEVICE_ERROR The new credential could not be deleted because of a device error.\r
- @retval EFI_INVALID_PARAMETER User does not refer to a valid user profile handle.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialDelete (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *UserInfo;\r
- UINT8 *UserId;\r
- UINT8 *NewUserId;\r
- UINTN Index;\r
-\r
- if ((This == NULL) || (User == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Get User Identifier.\r
- //\r
- UserInfo = NULL;\r
- Status = FindUserInfoByType (\r
- User,\r
- EFI_USER_INFO_IDENTIFIER_RECORD,\r
- &UserInfo\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Find the user by user identifier in mPwdTable.\r
- //\r
- for (Index = 0; Index < mPwdTable->Count; Index++) {\r
- UserId = (UINT8 *) &mPwdTable->UserInfo[Index].UserId;\r
- NewUserId = (UINT8 *) (UserInfo + 1);\r
- if (CompareMem (UserId, NewUserId, sizeof (EFI_USER_INFO_IDENTIFIER)) == 0) {\r
- //\r
- // Found the user, delete it.\r
- //\r
- ModifyTable (Index, NULL);\r
- break;\r
- }\r
- }\r
-\r
- FreePool (UserInfo);\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Main entry for this driver.\r
-\r
- @param ImageHandle Image handle this driver.\r
- @param SystemTable Pointer to SystemTable.\r
-\r
- @retval EFI_SUCESS This function always complete successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-PasswordProviderInit (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- //\r
- // It is NOT robust enough to be included in production.\r
- //\r
- #error "This implementation is just a sample, please comment this line if you really want to use this driver."\r
-\r
- //\r
- // Init credential table.\r
- //\r
- Status = InitCredentialTable ();\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Init Form Browser.\r
- //\r
- Status = InitFormBrowser ();\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Install protocol interfaces for the password credential provider.\r
- //\r
- Status = gBS->InstallProtocolInterface (\r
- &mCallbackInfo->DriverHandle,\r
- &gEfiUserCredential2ProtocolGuid,\r
- EFI_NATIVE_INTERFACE,\r
- &gPwdCredentialProviderDriver\r
- );\r
- return Status;\r
-}\r
+++ /dev/null
-/** @file\r
- Password Credential Provider driver header file.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _PASSWORD_CREDENTIAL_PROVIDER_H_\r
-#define _PASSWORD_CREDENTIAL_PROVIDER_H_\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Guid/GlobalVariable.h>\r
-\r
-#include <Protocol/HiiConfigAccess.h>\r
-#include <Protocol/UserCredential2.h>\r
-#include <Protocol/UserManager.h>\r
-\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/HiiLib.h>\r
-#include <Library/BaseCryptLib.h>\r
-\r
-#include "PwdCredentialProviderData.h"\r
-\r
-extern UINT8 PwdCredentialProviderStrings[];\r
-extern UINT8 PwdCredentialProviderVfrBin[];\r
-\r
-#define PASSWORD_TABLE_INC 16\r
-#define CREDENTIAL_LEN 20\r
-\r
-//\r
-// Password credential information.\r
-//\r
-typedef struct {\r
- EFI_USER_INFO_IDENTIFIER UserId;\r
- CHAR8 Password[CREDENTIAL_LEN];\r
-} PASSWORD_INFO;\r
-\r
-//\r
-// Password credential table.\r
-//\r
-typedef struct {\r
- UINTN Count;\r
- UINTN MaxCount;\r
- UINTN ValidIndex;\r
- PASSWORD_INFO UserInfo[1];\r
-} CREDENTIAL_TABLE;\r
-\r
-//\r
-// The user information on the password provider.\r
-//\r
-typedef struct {\r
- UINTN Count;\r
- EFI_USER_INFO *Info[1];\r
-} PASSWORD_CREDENTIAL_INFO;\r
-\r
-///\r
-/// HII specific Vendor Device Path definition.\r
-///\r
-typedef struct {\r
- VENDOR_DEVICE_PATH VendorDevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL End;\r
-} HII_VENDOR_DEVICE_PATH;\r
-\r
-#define PWD_PROVIDER_SIGNATURE SIGNATURE_32 ('P', 'W', 'D', 'P')\r
-\r
-typedef struct {\r
- UINTN Signature;\r
- EFI_HANDLE DriverHandle;\r
- EFI_HII_HANDLE HiiHandle;\r
- //\r
- // Produced protocol.\r
- //\r
- EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;\r
-} PWD_PROVIDER_CALLBACK_INFO;\r
-\r
-\r
-/**\r
- Enroll a user on a credential provider.\r
-\r
- This function enrolls a user on this credential provider. If the user exists on\r
- this credential provider, update the user information on this credential provider;\r
- otherwise delete the user information on credential provider.\r
-\r
- @param[in] This Points to this instance of EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] User The user profile to enroll.\r
-\r
- @retval EFI_SUCCESS User profile was successfully enrolled.\r
- @retval EFI_ACCESS_DENIED Current user profile does not permit enrollment on the\r
- user profile handle. Either the user profile cannot enroll\r
- on any user profile or cannot enroll on a user profile\r
- other than the current user profile.\r
- @retval EFI_UNSUPPORTED This credential provider does not support enrollment in\r
- the pre-OS.\r
- @retval EFI_DEVICE_ERROR The new credential could not be created because of a device\r
- error.\r
- @retval EFI_INVALID_PARAMETER User does not refer to a valid user profile handle.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialEnroll (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User\r
- );\r
-\r
-/**\r
- Returns the user interface information used during user identification.\r
-\r
- This function returns information about the form used when interacting with the\r
- user during user identification. The form is the first enabled form in the form-set\r
- class EFI_HII_USER_CREDENTIAL_FORMSET_GUID installed on the HII handle HiiHandle. If\r
- the user credential provider does not require a form to identify the user, then this\r
- function should return EFI_NOT_FOUND.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] Hii On return, holds the HII database handle.\r
- @param[out] FormSetId On return, holds the identifier of the form set which contains\r
- the form used during user identification.\r
- @param[out] FormId On return, holds the identifier of the form used during user\r
- identification.\r
-\r
- @retval EFI_SUCCESS Form returned successfully.\r
- @retval EFI_NOT_FOUND Form not returned.\r
- @retval EFI_INVALID_PARAMETER Hii is NULL or FormSetId is NULL or FormId is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialForm (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_HII_HANDLE *Hii,\r
- OUT EFI_GUID *FormSetId,\r
- OUT EFI_FORM_ID *FormId\r
- );\r
-\r
-/**\r
- Returns bitmap used to describe the credential provider type.\r
-\r
- This optional function returns a bitmap which is less than or equal to the number\r
- of pixels specified by Width and Height. If no such bitmap exists, then EFI_NOT_FOUND\r
- is returned.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in, out] Width On entry, points to the desired bitmap width. If NULL then no\r
- bitmap information will be returned. On exit, points to the\r
- width of the bitmap returned.\r
- @param[in, out] Height On entry, points to the desired bitmap height. If NULL then no\r
- bitmap information will be returned. On exit, points to the\r
- height of the bitmap returned\r
- @param[out] Hii On return, holds the HII database handle.\r
- @param[out] Image On return, holds the HII image identifier.\r
-\r
- @retval EFI_SUCCESS Image identifier returned successfully.\r
- @retval EFI_NOT_FOUND Image identifier not returned.\r
- @retval EFI_INVALID_PARAMETER Hii is NULL or Image is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialTile (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN OUT UINTN *Width,\r
- IN OUT UINTN *Height,\r
- OUT EFI_HII_HANDLE *Hii,\r
- OUT EFI_IMAGE_ID *Image\r
- );\r
-\r
-/**\r
- Returns string used to describe the credential provider type.\r
-\r
- This function returns a string which describes the credential provider. If no\r
- such string exists, then EFI_NOT_FOUND is returned.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] Hii On return, holds the HII database handle.\r
- @param[out] String On return, holds the HII string identifier.\r
-\r
- @retval EFI_SUCCESS String identifier returned successfully.\r
- @retval EFI_NOT_FOUND String identifier not returned.\r
- @retval EFI_INVALID_PARAMETER Hii is NULL or String is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialTitle (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_HII_HANDLE *Hii,\r
- OUT EFI_STRING_ID *String\r
- );\r
-\r
-/**\r
- Return the user identifier associated with the currently authenticated user.\r
-\r
- This function returns the user identifier of the user authenticated by this credential\r
- provider. This function is called after the credential-related information has been\r
- submitted on a form OR after a call to Default() has returned that this credential is\r
- ready to log on.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] User The user profile handle of the user profile currently being\r
- considered by the user identity manager. If NULL, then no user\r
- profile is currently under consideration.\r
- @param[out] Identifier On return, points to the user identifier.\r
-\r
- @retval EFI_SUCCESS User identifier returned successfully.\r
- @retval EFI_NOT_READY No user identifier can be returned.\r
- @retval EFI_ACCESS_DENIED The user has been locked out of this user credential.\r
- @retval EFI_INVALID_PARAMETER This is NULL, or Identifier is NULL.\r
- @retval EFI_NOT_FOUND User is not NULL, and the specified user handle can't be\r
- found in user profile database\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialUser (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- OUT EFI_USER_INFO_IDENTIFIER *Identifier\r
- );\r
-\r
-/**\r
- Indicate that user interface interaction has begun for the specified credential.\r
-\r
- This function is called when a credential provider is selected by the user. If\r
- AutoLogon returns FALSE, then the user interface will be constructed by the User\r
- Identity Manager.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] AutoLogon On return, points to the credential provider's capabilities\r
- after the credential provider has been selected by the user.\r
-\r
- @retval EFI_SUCCESS Credential provider successfully selected.\r
- @retval EFI_INVALID_PARAMETER AutoLogon is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialSelect (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_CREDENTIAL_LOGON_FLAGS *AutoLogon\r
- );\r
-\r
-/**\r
- Indicate that user interface interaction has ended for the specified credential.\r
-\r
- This function is called when a credential provider is deselected by the user.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
-\r
- @retval EFI_SUCCESS Credential provider successfully deselected.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialDeselect (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This\r
- );\r
-\r
-/**\r
- Return the default logon behavior for this user credential.\r
-\r
- This function reports the default login behavior regarding this credential provider.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] AutoLogon On return, holds whether the credential provider should be used\r
- by default to automatically log on the user.\r
-\r
- @retval EFI_SUCCESS Default information successfully returned.\r
- @retval EFI_INVALID_PARAMETER AutoLogon is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialDefault (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_CREDENTIAL_LOGON_FLAGS *AutoLogon\r
- );\r
-\r
-/**\r
- Return information attached to the credential provider.\r
-\r
- This function returns user information.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] UserInfo Handle of the user information data record.\r
- @param[out] Info On entry, points to a buffer of at least *InfoSize bytes. On\r
- exit, holds the user information. If the buffer is too small\r
- to hold the information, then EFI_BUFFER_TOO_SMALL is returned\r
- and InfoSize is updated to contain the number of bytes actually\r
- required.\r
- @param[in, out] InfoSize On entry, points to the size of Info. On return, points to the\r
- size of the user information.\r
-\r
- @retval EFI_SUCCESS Information returned successfully.\r
- @retval EFI_BUFFER_TOO_SMALL The size specified by InfoSize is too small to hold all of the\r
- user information. The size required is returned in *InfoSize.\r
- @retval EFI_INVALID_PARAMETER Info is NULL or InfoSize is NULL.\r
- @retval EFI_NOT_FOUND The specified UserInfo does not refer to a valid user info handle.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialGetInfo (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_INFO_HANDLE UserInfo,\r
- OUT EFI_USER_INFO *Info,\r
- IN OUT UINTN *InfoSize\r
- );\r
-\r
-\r
-/**\r
- Enumerate all of the user informations on the credential provider.\r
-\r
- This function returns the next user information record. To retrieve the first user\r
- information record handle, point UserInfo at a NULL. Each subsequent call will retrieve\r
- another user information record handle until there are no more, at which point UserInfo\r
- will point to NULL.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in, out] UserInfo On entry, points to the previous user information handle or NULL\r
- to start enumeration. On exit, points to the next user information\r
- handle or NULL if there is no more user information.\r
-\r
- @retval EFI_SUCCESS User information returned.\r
- @retval EFI_NOT_FOUND No more user information found.\r
- @retval EFI_INVALID_PARAMETER UserInfo is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialGetNextInfo (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN OUT EFI_USER_INFO_HANDLE *UserInfo\r
- );\r
-\r
-/**\r
- Delete a user on this credential provider.\r
-\r
- This function deletes a user on this credential provider.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] User The user profile handle to delete.\r
-\r
- @retval EFI_SUCCESS User profile was successfully deleted.\r
- @retval EFI_ACCESS_DENIED Current user profile does not permit deletion on the user profile handle.\r
- Either the user profile cannot delete on any user profile or cannot delete\r
- on a user profile other than the current user profile.\r
- @retval EFI_UNSUPPORTED This credential provider does not support deletion in the pre-OS.\r
- @retval EFI_DEVICE_ERROR The new credential could not be deleted because of a device error.\r
- @retval EFI_INVALID_PARAMETER User does not refer to a valid user profile handle.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialDelete (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User\r
- );\r
-\r
-#endif\r
+++ /dev/null
-// /** @file\r
-// Provides a password credential provider implementation\r
-//\r
-// This module provides a password credential provider implementation.\r
-//\r
-// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// This program and the accompanying materials\r
-// are licensed and made available under the terms and conditions of the BSD License\r
-// which accompanies this distribution. The full text of the license may be found at\r
-// http://opensource.org/licenses/bsd-license.php\r
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT #language en-US "Provides a password credential provider implementation"\r
-\r
-#string STR_MODULE_DESCRIPTION #language en-US "This module provides a password credential provider implementation."\r
-\r
+++ /dev/null
-/** @file\r
- Data structure used by the Password Credential Provider driver.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _PWD_CREDENTIAL_PROVIDER_DATA_H_\r
-#define _PWD_CREDENTIAL_PROVIDER_DATA_H_\r
-\r
-#include <Guid/PwdCredentialProviderHii.h>\r
-\r
-//\r
-// Forms definition\r
-//\r
-#define FORMID_GET_PASSWORD_FORM 1\r
-\r
-//\r
-// Key defination\r
-//\r
-#define KEY_GET_PASSWORD 0x1000\r
-\r
-#endif\r
+++ /dev/null
-## @file\r
-# Provides a password credential provider implementation\r
-# This module provides a password credential provider implementation.\r
-#\r
-# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-##\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = PwdCredentialProvider\r
- MODULE_UNI_FILE = PwdCredentialProvider.uni\r
- FILE_GUID = D6C589EA-DD29-49ef-97F6-1A9FE19A04E0\r
- MODULE_TYPE = UEFI_DRIVER\r
- VERSION_STRING = 1.0\r
- ENTRY_POINT = PasswordProviderInit\r
-\r
-[Sources]\r
- PwdCredentialProvider.c\r
- PwdCredentialProvider.h\r
- PwdCredentialProviderData.h\r
- PwdCredentialProviderVfr.Vfr\r
- PwdCredentialProviderStrings.uni\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- MdeModulePkg/MdeModulePkg.dec\r
- CryptoPkg/CryptoPkg.dec\r
- SecurityPkg/SecurityPkg.dec\r
-\r
-[LibraryClasses]\r
- UefiRuntimeServicesTableLib\r
- UefiBootServicesTableLib\r
- UefiDriverEntryPoint\r
- MemoryAllocationLib\r
- BaseMemoryLib\r
- DebugLib\r
- HiiLib\r
- UefiLib\r
- BaseCryptLib\r
-\r
-[Guids]\r
- gEfiUserCredentialClassPasswordGuid ## SOMETIMES_CONSUMES ## GUID\r
-\r
- ## PRODUCES ## Variable:L"PwdCredential"\r
- ## CONSUMES ## Variable:L"PwdCredential"\r
- ## CONSUMES ## HII\r
- ## SOMETIMES_CONSUMES ## GUID # The credential provider identifier\r
- gPwdCredentialProviderGuid\r
-\r
-[Protocols]\r
- gEfiDevicePathProtocolGuid ## PRODUCES\r
- gEfiHiiConfigAccessProtocolGuid ## PRODUCES\r
- gEfiUserCredential2ProtocolGuid ## PRODUCES\r
- gEfiUserManagerProtocolGuid ## SOMETIMES_CONSUMES\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
- PwdCredentialProviderExtra.uni\r
-\r
+++ /dev/null
-// /** @file\r
-// PwdCredentialProvider Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// This program and the accompanying materials\r
-// are licensed and made available under the terms and conditions of the BSD License\r
-// which accompanies this distribution. The full text of the license may be found at\r
-// http://opensource.org/licenses/bsd-license.php\r
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"Password Credential Provider"\r
-\r
-\r
+++ /dev/null
-/** @file\r
- String definitions for the Password Credential Provider.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php.\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#langdef en-US "English"\r
-#langdef fr-FR "Francais"\r
-\r
-#string STR_CREDENTIAL_TITLE #language en-US "Password Credential Provider"\r
- #language fr-FR "Password Credential Provider (French)"\r
-#string STR_FORM_TITLE #language en-US "Get Password"\r
- #language fr-FR "Get Password(French)"\r
-#string STR_NULL_STRING #language en-US ""\r
- #language fr-FR ""\r
-#string STR_INPUT_PASSWORD #language en-US "Please Input Password"\r
- #language fr-FR "Please Input Password(French)"\r
-#string STR_PROVIDER_NAME #language en-US "INTEL Password Credential Provider"\r
- #language fr-FR "INTEL Password Credential Provider(French)"\r
-#string STR_PROVIDER_TYPE_NAME #language en-US "Password Credential Provider"\r
- #language fr-FR "Password Credential Provider(French)"\r
-#string STR_INPUT_PASSWORD_AGAIN #language en-US "Input Password Again"\r
- #language fr-FR "Input Password Again (French)"\r
-#string STR_DRAW_A_LINE #language en-US "-----------------------------"\r
- #language fr-FR "------------------------------------"\r
-#string STR_PASSWORD_INCORRECT #language en-US " Incorrect Password! "\r
- #language fr-FR " Incorrect Password! (French) "\r
-#string STR_PASSWORD_MISMATCH #language en-US " The Password Mismatch! "\r
- #language fr-FR " The Password Mismatch! (French) "\r
-\r
+++ /dev/null
-/** @file\r
- Password Credential Provider formset.\r
-\r
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "PwdCredentialProviderData.h"\r
-\r
-formset \r
- guid = PWD_CREDENTIAL_PROVIDER_GUID,\r
- title = STRING_TOKEN(STR_CREDENTIAL_TITLE), \r
- help = STRING_TOKEN(STR_NULL_STRING), \r
- classguid = PWD_CREDENTIAL_PROVIDER_GUID,\r
- \r
- form formid = FORMID_GET_PASSWORD_FORM, \r
- title = STRING_TOKEN(STR_FORM_TITLE);\r
- \r
- text \r
- help = STRING_TOKEN(STR_NULL_STRING), \r
- text = STRING_TOKEN(STR_INPUT_PASSWORD),\r
- flags = INTERACTIVE,\r
- key = KEY_GET_PASSWORD;\r
-\r
- endform;\r
- \r
-endformset;
\ No newline at end of file
+++ /dev/null
-/** @file\r
- Usb Credential Provider driver implemenetation.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "UsbCredentialProvider.h"\r
-\r
-CREDENTIAL_TABLE *mUsbTable = NULL;\r
-USB_PROVIDER_CALLBACK_INFO *mCallbackInfo = NULL;\r
-USB_CREDENTIAL_INFO *mUsbInfoHandle = NULL;\r
-\r
-EFI_USER_CREDENTIAL2_PROTOCOL gUsbCredentialProviderDriver = {\r
- USB_CREDENTIAL_PROVIDER_GUID,\r
- EFI_USER_CREDENTIAL_CLASS_SECURE_CARD,\r
- CredentialEnroll,\r
- CredentialForm,\r
- CredentialTile,\r
- CredentialTitle,\r
- CredentialUser,\r
- CredentialSelect,\r
- CredentialDeselect,\r
- CredentialDefault,\r
- CredentialGetInfo,\r
- CredentialGetNextInfo,\r
- EFI_CREDENTIAL_CAPABILITIES_ENROLL,\r
- CredentialDelete\r
-};\r
-\r
-\r
-/**\r
- Get string by string id from HII Interface.\r
-\r
-\r
- @param[in] Id String ID to get the string from.\r
-\r
- @retval CHAR16 * String from ID.\r
- @retval NULL If error occurs.\r
-\r
-**/\r
-CHAR16 *\r
-GetStringById (\r
- IN EFI_STRING_ID Id\r
- )\r
-{\r
- //\r
- // Get the current string for the current Language\r
- //\r
- return HiiGetString (mCallbackInfo->HiiHandle, Id, NULL);\r
-}\r
-\r
-\r
-/**\r
- Expand password table size.\r
-\r
-**/\r
-VOID\r
-ExpandTableSize (\r
- VOID\r
- )\r
-{\r
- CREDENTIAL_TABLE *NewTable;\r
- UINTN Count;\r
-\r
- Count = mUsbTable->MaxCount + USB_TABLE_INC;\r
- //\r
- // Create new credential table.\r
- //\r
- NewTable = AllocateZeroPool (\r
- sizeof (CREDENTIAL_TABLE) - sizeof (USB_INFO) +\r
- Count * sizeof (USB_INFO)\r
- );\r
- ASSERT (NewTable != NULL);\r
-\r
- NewTable->MaxCount = Count;\r
- NewTable->Count = mUsbTable->Count;\r
-\r
- //\r
- // Copy old entries.\r
- //\r
- CopyMem (\r
- &NewTable->UserInfo,\r
- &mUsbTable->UserInfo,\r
- mUsbTable->Count * sizeof (USB_INFO)\r
- );\r
- FreePool (mUsbTable);\r
- mUsbTable = NewTable;\r
-}\r
-\r
-\r
-/**\r
- Add, update or delete info in table, and sync with NV variable.\r
-\r
- @param[in] Index The index of the password in table. If index is found in\r
- table, update the info, else add the into to table.\r
- @param[in] Info The new credential info to add into table. If Info is NULL,\r
- delete the info by Index.\r
-\r
- @retval EFI_INVALID_PARAMETER Info is NULL when save the info.\r
- @retval EFI_SUCCESS Modify the table successfully.\r
- @retval Others Failed to modify the table.\r
-\r
-**/\r
-EFI_STATUS\r
-ModifyTable (\r
- IN UINTN Index,\r
- IN USB_INFO * Info OPTIONAL\r
- )\r
-{\r
- EFI_STATUS Status;\r
- USB_INFO *NewUsbInfo;\r
-\r
- NewUsbInfo = NULL;\r
- if (Index < mUsbTable->Count) {\r
- if (Info == NULL) {\r
- //\r
- // Delete the specified entry.\r
- //\r
- mUsbTable->Count--;\r
- if (Index != mUsbTable->Count) {\r
- NewUsbInfo = &mUsbTable->UserInfo[mUsbTable->Count];\r
- }\r
- } else {\r
- //\r
- // Update the specified entry.\r
- //\r
- NewUsbInfo = Info;\r
- }\r
- } else {\r
- //\r
- // Add a new entry\r
- //\r
- if (Info == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (mUsbTable->Count >= mUsbTable->MaxCount) {\r
- ExpandTableSize ();\r
- }\r
-\r
- NewUsbInfo = Info;\r
- mUsbTable->Count++;\r
- }\r
-\r
- if (NewUsbInfo != NULL) {\r
- CopyMem (&mUsbTable->UserInfo[Index], NewUsbInfo, sizeof (USB_INFO));\r
- }\r
-\r
- //\r
- // Save the credential table.\r
- //\r
- Status = gRT->SetVariable (\r
- L"UsbCredential",\r
- &gUsbCredentialProviderGuid,\r
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
- mUsbTable->Count * sizeof (USB_INFO),\r
- &mUsbTable->UserInfo\r
- );\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Create a credential table\r
-\r
- @retval EFI_SUCCESS Create a credential table successfully.\r
- @retval Others Failed to create a password.\r
-\r
-**/\r
-EFI_STATUS\r
-InitCredentialTable (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINT8 *Var;\r
- UINTN VarSize;\r
-\r
- //\r
- // Get Usb credential data from NV variable.\r
- //\r
- VarSize = 0;\r
- Var = NULL;\r
- Status = gRT->GetVariable (\r
- L"UsbCredential",\r
- &gUsbCredentialProviderGuid,\r
- NULL,\r
- &VarSize,\r
- Var\r
- );\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- Var = AllocateZeroPool (VarSize);\r
- if (Var == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- Status = gRT->GetVariable (\r
- L"UsbCredential",\r
- &gUsbCredentialProviderGuid,\r
- NULL,\r
- &VarSize,\r
- Var\r
- );\r
- }\r
- if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Init Usb credential table.\r
- //\r
- mUsbTable = AllocateZeroPool (\r
- sizeof (CREDENTIAL_TABLE) - sizeof (USB_INFO) +\r
- USB_TABLE_INC * sizeof (USB_INFO) +\r
- VarSize\r
- );\r
- if (mUsbTable == NULL) {\r
- FreePool (Var);\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- mUsbTable->Count = VarSize / sizeof (USB_INFO);\r
- mUsbTable->MaxCount = mUsbTable->Count + USB_TABLE_INC;\r
- if (Var != NULL) {\r
- CopyMem (mUsbTable->UserInfo, Var, VarSize);\r
- FreePool (Var);\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Read the specified file by FileName in the Usb key and return the file size in BufferSize\r
- and file content in Buffer.\r
- Note: the caller is responsible to free the buffer memory.\r
-\r
- @param FileName File to read.\r
- @param Buffer Returned with data read from the file.\r
- @param BufferSize Size of the data buffer.\r
-\r
- @retval EFI_SUCCESS The command completed successfully.\r
- @retval EFI_OUT_OF_RESOURCES Resource allocation failed.\r
- @retval EFI_NOT_FOUND File not found.\r
- @retval EFI_DEVICE_ERROR Device I/O error.\r
-\r
-**/\r
-EFI_STATUS\r
-GetFileData (\r
- IN CHAR16 *FileName,\r
- OUT VOID **Buffer,\r
- OUT UINTN *BufferSize\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Index;\r
- UINTN HandleCount;\r
- UINTN ScratchBufferSize;\r
- EFI_HANDLE *HandleBuffer;\r
- EFI_FILE *RootFs;\r
- EFI_FILE *FileHandle;\r
- EFI_FILE_INFO *FileInfo;\r
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFileSystem;\r
- EFI_BLOCK_IO_PROTOCOL *BlkIo;\r
-\r
- FileInfo = NULL;\r
- FileHandle = NULL;\r
-\r
- Status = gBS->LocateHandleBuffer (\r
- ByProtocol,\r
- &gEfiSimpleFileSystemProtocolGuid,\r
- NULL,\r
- &HandleCount,\r
- &HandleBuffer\r
- );\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((DEBUG_ERROR, "Can not Locate SimpleFileSystemProtocol\n"));\r
- goto Done;\r
- }\r
-\r
- //\r
- // Find and open the file in removable media disk.\r
- //\r
- for (Index = 0; Index < HandleCount; Index++) {\r
- Status = gBS->HandleProtocol (\r
- HandleBuffer[Index],\r
- &gEfiBlockIoProtocolGuid,\r
- (VOID **) &BlkIo\r
- );\r
- if (EFI_ERROR (Status)) {\r
- continue;\r
- }\r
-\r
- if (BlkIo->Media->RemovableMedia) {\r
- Status = gBS->HandleProtocol (\r
- HandleBuffer[Index],\r
- &gEfiSimpleFileSystemProtocolGuid,\r
- (VOID **) &SimpleFileSystem\r
- );\r
- if (EFI_ERROR (Status)) {\r
- continue;\r
- }\r
-\r
- Status = SimpleFileSystem->OpenVolume (\r
- SimpleFileSystem,\r
- &RootFs\r
- );\r
- if (EFI_ERROR (Status)) {\r
- continue;\r
- }\r
-\r
- Status = RootFs->Open (\r
- RootFs,\r
- &FileHandle,\r
- FileName,\r
- EFI_FILE_MODE_READ,\r
- 0\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- break;\r
- }\r
- }\r
- }\r
-\r
- FreePool (HandleBuffer);\r
-\r
- if (Index >= HandleCount) {\r
- DEBUG ((DEBUG_ERROR, "Can not found the token file!\n"));\r
- Status = EFI_NOT_FOUND;\r
- goto Done;\r
- }\r
-\r
- //\r
- // Figure out how big the file is.\r
- //\r
- ScratchBufferSize = 0;\r
- Status = FileHandle->GetInfo (\r
- FileHandle,\r
- &gEfiFileInfoGuid,\r
- &ScratchBufferSize,\r
- NULL\r
- );\r
- if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {\r
- DEBUG ((DEBUG_ERROR, "Can not obtain file size info!\n"));\r
- Status = EFI_DEVICE_ERROR;\r
- goto Done;\r
- }\r
-\r
- FileInfo = AllocateZeroPool (ScratchBufferSize);\r
- if (FileInfo == NULL) {\r
- DEBUG ((DEBUG_ERROR, "Can not allocate enough memory for the token file!\n"));\r
- Status = EFI_OUT_OF_RESOURCES;\r
- goto Done;\r
- }\r
-\r
- Status = FileHandle->GetInfo (\r
- FileHandle,\r
- &gEfiFileInfoGuid,\r
- &ScratchBufferSize,\r
- FileInfo\r
- );\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((DEBUG_ERROR, "Can not obtain file info from the token file!\n"));\r
- Status = EFI_DEVICE_ERROR;\r
- goto Done;\r
- }\r
-\r
- //\r
- // Allocate a buffer for the file.\r
- //\r
- *BufferSize = (UINT32) FileInfo->FileSize;\r
- *Buffer = AllocateZeroPool (*BufferSize);\r
- if (*Buffer == NULL) {\r
- DEBUG ((DEBUG_ERROR, "Can not allocate a buffer for the file!\n"));\r
- Status = EFI_OUT_OF_RESOURCES;\r
- goto Done;\r
- }\r
-\r
- //\r
- // Load file into the allocated memory.\r
- //\r
- Status = FileHandle->Read (FileHandle, BufferSize, *Buffer);\r
- if (EFI_ERROR (Status)) {\r
- FreePool (*Buffer);\r
- DEBUG ((DEBUG_ERROR, "Can not read the token file!\n"));\r
- Status = EFI_DEVICE_ERROR;\r
- goto Done;\r
- }\r
-\r
- //\r
- // Close file.\r
- //\r
- Status = FileHandle->Close (FileHandle);\r
- if (EFI_ERROR (Status)) {\r
- FreePool (*Buffer);\r
- DEBUG ((DEBUG_ERROR, "Can not close the token file !\n"));\r
- Status = EFI_DEVICE_ERROR;\r
- }\r
-\r
-Done:\r
-\r
- if (FileInfo != NULL) {\r
- FreePool (FileInfo);\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Hash the data to get credential.\r
-\r
- @param[in] Buffer Points to the data buffer\r
- @param[in] BufferSize The size of data in buffer, in bytes.\r
- @param[out] Credential Points to the hashed result\r
-\r
- @retval TRUE Hash the data successfully.\r
- @retval FALSE Failed to hash the data.\r
-\r
-**/\r
-BOOLEAN\r
-GenerateCredential (\r
- IN UINT8 *Buffer,\r
- IN UINTN BufferSize,\r
- OUT UINT8 *Credential\r
- )\r
-{\r
- BOOLEAN Status;\r
- UINTN HashSize;\r
- VOID *Hash;\r
-\r
- HashSize = Sha1GetContextSize ();\r
- Hash = AllocatePool (HashSize);\r
- ASSERT (Hash != NULL);\r
-\r
- Status = Sha1Init (Hash);\r
- if (!Status) {\r
- goto Done;\r
- }\r
-\r
- Status = Sha1Update (Hash, Buffer, BufferSize);\r
- if (!Status) {\r
- goto Done;\r
- }\r
-\r
- Status = Sha1Final (Hash, Credential);\r
-\r
-Done:\r
- FreePool (Hash);\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Read the token file, and default the Token is saved at the begining of the file.\r
-\r
- @param[out] Token Token read from a Token file.\r
-\r
- @retval EFI_SUCCESS Read a Token successfully.\r
- @retval Others Fails to read a Token.\r
-\r
-**/\r
-EFI_STATUS\r
-GetToken (\r
- OUT UINT8 *Token\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINT8 *Buffer;\r
- UINTN BufSize;\r
- CHAR16 *TokenFile;\r
-\r
- BufSize = 0;\r
- Buffer = NULL;\r
- TokenFile = PcdGetPtr (PcdFixedUsbCredentialProviderTokenFileName);\r
- Status = GetFileData (TokenFile, (VOID *)&Buffer, &BufSize);\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((DEBUG_ERROR, "Read file %s from USB error! Status=(%r)\n", TokenFile, Status));\r
- return Status;\r
- }\r
-\r
- if (!GenerateCredential (Buffer, BufSize, Token)) {\r
- DEBUG ((DEBUG_ERROR, "Generate credential from read data failed!\n"));\r
- FreePool (Buffer);\r
- return EFI_SECURITY_VIOLATION;\r
- }\r
-\r
- FreePool (Buffer);\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Find a user infomation record by the information record type.\r
-\r
- This function searches all user information records of User from beginning\r
- until either the information is found or there are no more user infomation\r
- record. A match occurs when a Info.InfoType field matches the user information\r
- record type.\r
-\r
- @param[in] User Points to the user profile record to search.\r
- @param[in] InfoType The infomation type to be searched.\r
- @param[out] Info Points to the user info found, the caller is responsible\r
- to free.\r
-\r
- @retval EFI_SUCCESS Find the user information successfully.\r
- @retval Others Fail to find the user information.\r
-\r
-**/\r
-EFI_STATUS\r
-FindUserInfoByType (\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN UINT8 InfoType,\r
- OUT EFI_USER_INFO **Info\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *UserInfo;\r
- UINTN UserInfoSize;\r
- EFI_USER_INFO_HANDLE UserInfoHandle;\r
- EFI_USER_MANAGER_PROTOCOL *UserManager;\r
-\r
- //\r
- // Find user information by information type.\r
- //\r
- if (Info == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- Status = gBS->LocateProtocol (\r
- &gEfiUserManagerProtocolGuid,\r
- NULL,\r
- (VOID **) &UserManager\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // Get each user information.\r
- //\r
-\r
- UserInfoHandle = NULL;\r
- UserInfo = NULL;\r
- UserInfoSize = 0;\r
- while (TRUE) {\r
- Status = UserManager->GetNextInfo (UserManager, User, &UserInfoHandle);\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
- //\r
- // Get information.\r
- //\r
- Status = UserManager->GetInfo (\r
- UserManager,\r
- User,\r
- UserInfoHandle,\r
- UserInfo,\r
- &UserInfoSize\r
- );\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- if (UserInfo != NULL) {\r
- FreePool (UserInfo);\r
- }\r
- UserInfo = AllocateZeroPool (UserInfoSize);\r
- if (UserInfo == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- Status = UserManager->GetInfo (\r
- UserManager,\r
- User,\r
- UserInfoHandle,\r
- UserInfo,\r
- &UserInfoSize\r
- );\r
- }\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
-\r
- ASSERT (UserInfo != NULL);\r
- if (UserInfo->InfoType == InfoType) {\r
- *Info = UserInfo;\r
- return EFI_SUCCESS;\r
- }\r
- }\r
-\r
- if (UserInfo != NULL) {\r
- FreePool (UserInfo);\r
- }\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- This function initialize the data mainly used in form browser.\r
-\r
- @retval EFI_SUCCESS Initialize form data successfully.\r
- @retval Others Fail to Initialize form data.\r
-\r
-**/\r
-EFI_STATUS\r
-InitFormBrowser (\r
- VOID\r
- )\r
-{\r
- USB_PROVIDER_CALLBACK_INFO *CallbackInfo;\r
-\r
- //\r
- // Initialize driver private data.\r
- //\r
- CallbackInfo = AllocateZeroPool (sizeof (USB_PROVIDER_CALLBACK_INFO));\r
- if (CallbackInfo == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- CallbackInfo->DriverHandle = NULL;\r
-\r
- //\r
- // Publish HII data.\r
- //\r
- CallbackInfo->HiiHandle = HiiAddPackages (\r
- &gUsbCredentialProviderGuid,\r
- CallbackInfo->DriverHandle,\r
- UsbCredentialProviderStrings,\r
- NULL\r
- );\r
- if (CallbackInfo->HiiHandle == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- mCallbackInfo = CallbackInfo;\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Enroll a user on a credential provider.\r
-\r
- This function enrolls a user on this credential provider. If the user exists on\r
- this credential provider, update the user information on this credential provider;\r
- otherwise add the user information on credential provider.\r
-\r
- @param[in] This Points to this instance of EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] User The user profile to enroll.\r
-\r
- @retval EFI_SUCCESS User profile was successfully enrolled.\r
- @retval EFI_ACCESS_DENIED Current user profile does not permit enrollment on the\r
- user profile handle. Either the user profile cannot enroll\r
- on any user profile or cannot enroll on a user profile\r
- other than the current user profile.\r
- @retval EFI_UNSUPPORTED This credential provider does not support enrollment in\r
- the pre-OS.\r
- @retval EFI_DEVICE_ERROR The new credential could not be created because of a device\r
- error.\r
- @retval EFI_INVALID_PARAMETER User does not refer to a valid user profile handle.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialEnroll (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Index;\r
- USB_INFO UsbInfo;\r
- EFI_USER_INFO *UserInfo;\r
- EFI_INPUT_KEY Key;\r
- UINT8 *UserId;\r
- CHAR16 *QuestionStr;\r
- CHAR16 *PromptStr;\r
-\r
- if ((This == NULL) || (User == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Get User Identifier\r
- //\r
- UserInfo = NULL;\r
- Status = FindUserInfoByType (\r
- User,\r
- EFI_USER_INFO_IDENTIFIER_RECORD,\r
- &UserInfo\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- CopyMem (UsbInfo.UserId, (UINT8 *) (UserInfo + 1), sizeof (EFI_USER_INFO_IDENTIFIER));\r
- FreePool (UserInfo);\r
-\r
- //\r
- // Get Token and User ID to UsbInfo.\r
- //\r
- Status = GetToken (UsbInfo.Token);\r
- if (EFI_ERROR (Status)) {\r
- QuestionStr = GetStringById (STRING_TOKEN (STR_READ_USB_TOKEN_ERROR));\r
- PromptStr = GetStringById (STRING_TOKEN (STR_INSERT_USB_TOKEN));\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- QuestionStr,\r
- L"",\r
- PromptStr,\r
- NULL\r
- );\r
- FreePool (QuestionStr);\r
- FreePool (PromptStr);\r
- return Status;\r
- }\r
-\r
- //\r
- // Check whether User is ever enrolled in the provider.\r
- //\r
- for (Index = 0; Index < mUsbTable->Count; Index++) {\r
- UserId = (UINT8 *) &mUsbTable->UserInfo[Index].UserId;\r
- if (CompareMem (UserId, (UINT8 *) &UsbInfo.UserId, sizeof (EFI_USER_INFO_IDENTIFIER)) == 0) {\r
- //\r
- // User already exists, update the password.\r
- //\r
- break;\r
- }\r
- }\r
-\r
- //\r
- // Enroll the User to the provider.\r
- //\r
- Status = ModifyTable (Index, &UsbInfo);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Returns the user interface information used during user identification.\r
-\r
- This function returns information about the form used when interacting with the\r
- user during user identification. The form is the first enabled form in the form-set\r
- class EFI_HII_USER_CREDENTIAL_FORMSET_GUID installed on the HII handle HiiHandle. If\r
- the user credential provider does not require a form to identify the user, then this\r
- function should return EFI_NOT_FOUND.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] Hii On return, holds the HII database handle.\r
- @param[out] FormSetId On return, holds the identifier of the form set which contains\r
- the form used during user identification.\r
- @param[out] FormId On return, holds the identifier of the form used during user\r
- identification.\r
-\r
- @retval EFI_SUCCESS Form returned successfully.\r
- @retval EFI_NOT_FOUND Form not returned.\r
- @retval EFI_INVALID_PARAMETER Hii is NULL or FormSetId is NULL or FormId is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialForm (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_HII_HANDLE *Hii,\r
- OUT EFI_GUID *FormSetId,\r
- OUT EFI_FORM_ID *FormId\r
- )\r
-{\r
- if ((This == NULL) || (Hii == NULL) ||\r
- (FormSetId == NULL) || (FormId == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
- Returns bitmap used to describe the credential provider type.\r
-\r
- This optional function returns a bitmap which is less than or equal to the number\r
- of pixels specified by Width and Height. If no such bitmap exists, then EFI_NOT_FOUND\r
- is returned.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in, out] Width On entry, points to the desired bitmap width. If NULL then no\r
- bitmap information will be returned. On exit, points to the\r
- width of the bitmap returned.\r
- @param[in, out] Height On entry, points to the desired bitmap height. If NULL then no\r
- bitmap information will be returned. On exit, points to the\r
- height of the bitmap returned.\r
- @param[out] Hii On return, holds the HII database handle.\r
- @param[out] Image On return, holds the HII image identifier.\r
-\r
- @retval EFI_SUCCESS Image identifier returned successfully.\r
- @retval EFI_NOT_FOUND Image identifier not returned.\r
- @retval EFI_INVALID_PARAMETER Hii is NULL or Image is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialTile (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN OUT UINTN *Width,\r
- IN OUT UINTN *Height,\r
- OUT EFI_HII_HANDLE *Hii,\r
- OUT EFI_IMAGE_ID *Image\r
- )\r
-{\r
- if ((This == NULL) || (Hii == NULL) || (Image == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
- Returns string used to describe the credential provider type.\r
-\r
- This function returns a string which describes the credential provider. If no\r
- such string exists, then EFI_NOT_FOUND is returned.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] Hii On return, holds the HII database handle.\r
- @param[out] String On return, holds the HII string identifier.\r
-\r
- @retval EFI_SUCCESS String identifier returned successfully.\r
- @retval EFI_NOT_FOUND String identifier not returned.\r
- @retval EFI_INVALID_PARAMETER Hii is NULL or String is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialTitle (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_HII_HANDLE *Hii,\r
- OUT EFI_STRING_ID *String\r
- )\r
-{\r
- if ((This == NULL) || (Hii == NULL) || (String == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- //\r
- // Set Hii handle and String ID.\r
- //\r
- *Hii = mCallbackInfo->HiiHandle;\r
- *String = STRING_TOKEN (STR_CREDENTIAL_TITLE);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Return the user identifier associated with the currently authenticated user.\r
-\r
- This function returns the user identifier of the user authenticated by this credential\r
- provider. This function is called after the credential-related information has been\r
- submitted on a form OR after a call to Default() has returned that this credential is\r
- ready to log on.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] User The user profile handle of the user profile currently being\r
- considered by the user identity manager. If NULL, then no user\r
- profile is currently under consideration.\r
- @param[out] Identifier On return, points to the user identifier.\r
-\r
- @retval EFI_SUCCESS User identifier returned successfully.\r
- @retval EFI_NOT_READY No user identifier can be returned.\r
- @retval EFI_ACCESS_DENIED The user has been locked out of this user credential.\r
- @retval EFI_INVALID_PARAMETER This is NULL, or Identifier is NULL.\r
- @retval EFI_NOT_FOUND User is not NULL, and the specified user handle can't be\r
- found in user profile database.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialUser (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- OUT EFI_USER_INFO_IDENTIFIER *Identifier\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Index;\r
- EFI_USER_INFO *UserInfo;\r
- UINT8 *UserId;\r
- UINT8 *NewUserId;\r
- UINT8 *UserToken;\r
- UINT8 ReadToken[HASHED_CREDENTIAL_LEN];\r
- EFI_INPUT_KEY Key;\r
- CHAR16 *QuestionStr;\r
- CHAR16 *PromptStr;\r
-\r
- if ((This == NULL) || (Identifier == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (User == NULL) {\r
- //\r
- // Verify the auto logon user, get user id by matched token.\r
- //\r
- if (mUsbTable->Count == 0) {\r
- return EFI_NOT_READY;\r
- }\r
-\r
- //\r
- // No user selected, get token first and verify the user existed in user database.\r
- //\r
- Status = GetToken (ReadToken);\r
- if (EFI_ERROR (Status)) {\r
- return EFI_NOT_READY;\r
- }\r
-\r
- for (Index = 0; Index < mUsbTable->Count; Index++) {\r
- //\r
- // find the specified credential in the Usb credential database.\r
- //\r
- UserToken = mUsbTable->UserInfo[Index].Token;\r
- if (CompareMem (UserToken, ReadToken, HASHED_CREDENTIAL_LEN) == 0) {\r
- UserId = (UINT8 *) &mUsbTable->UserInfo[Index].UserId;\r
- CopyMem (Identifier, UserId, sizeof (EFI_USER_INFO_IDENTIFIER));\r
- return EFI_SUCCESS;\r
- }\r
- }\r
-\r
- return EFI_NOT_READY;\r
- }\r
-\r
- //\r
- // User is not NULL here. Read a token, and check whether the token matches with\r
- // the selected user's Token. If not, try to find a token in token DB to matches\r
- // with read token.\r
- //\r
-\r
- Status = GetToken (ReadToken);\r
- if (EFI_ERROR (Status)) {\r
- QuestionStr = GetStringById (STRING_TOKEN (STR_READ_USB_TOKEN_ERROR));\r
- PromptStr = GetStringById (STRING_TOKEN (STR_INSERT_USB_TOKEN));\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- QuestionStr,\r
- L"",\r
- PromptStr,\r
- NULL\r
- );\r
- FreePool (QuestionStr);\r
- FreePool (PromptStr);\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // Get the selected user's identifier.\r
- //\r
- Status = FindUserInfoByType (User, EFI_USER_INFO_IDENTIFIER_RECORD, &UserInfo);\r
- if (EFI_ERROR (Status)) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // Check the selected user's Token with the read token.\r
- //\r
- for (Index = 0; Index < mUsbTable->Count; Index++) {\r
- UserId = (UINT8 *) &mUsbTable->UserInfo[Index].UserId;\r
- NewUserId = (UINT8 *) (UserInfo + 1);\r
- if (CompareMem (UserId, NewUserId, sizeof (EFI_USER_INFO_IDENTIFIER)) == 0) {\r
- //\r
- // The user's ID is found in the UsbTable.\r
- //\r
- UserToken = mUsbTable->UserInfo[Index].Token;\r
- if (CompareMem (UserToken, ReadToken, HASHED_CREDENTIAL_LEN) == 0) {\r
- //\r
- // The read token matches with the one in UsbTable.\r
- //\r
- CopyMem (Identifier, UserId, sizeof (EFI_USER_INFO_IDENTIFIER));\r
- FreePool (UserInfo);\r
- return EFI_SUCCESS;\r
- }\r
- }\r
- }\r
-\r
- FreePool (UserInfo);\r
-\r
- return EFI_NOT_READY;\r
-}\r
-\r
-\r
-/**\r
- Indicate that user interface interaction has begun for the specified credential.\r
-\r
- This function is called when a credential provider is selected by the user. If\r
- AutoLogon returns FALSE, then the user interface will be constructed by the User\r
- Identity Manager.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] AutoLogon On return, points to the credential provider's capabilities\r
- after the credential provider has been selected by the user.\r
-\r
- @retval EFI_SUCCESS Credential provider successfully selected.\r
- @retval EFI_INVALID_PARAMETER AutoLogon is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialSelect (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_CREDENTIAL_LOGON_FLAGS *AutoLogon\r
- )\r
-{\r
- if ((This == NULL) || (AutoLogon == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- *AutoLogon = EFI_CREDENTIAL_LOGON_FLAG_DEFAULT | EFI_CREDENTIAL_LOGON_FLAG_AUTO;\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Indicate that user interface interaction has ended for the specified credential.\r
-\r
- This function is called when a credential provider is deselected by the user.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
-\r
- @retval EFI_SUCCESS Credential provider successfully deselected.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialDeselect (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This\r
- )\r
-{\r
- if (This == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Return the default logon behavior for this user credential.\r
-\r
- This function reports the default login behavior regarding this credential provider.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] AutoLogon On return, holds whether the credential provider should be used\r
- by default to automatically log on the user.\r
-\r
- @retval EFI_SUCCESS Default information successfully returned.\r
- @retval EFI_INVALID_PARAMETER AutoLogon is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialDefault (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_CREDENTIAL_LOGON_FLAGS *AutoLogon\r
- )\r
-{\r
- if ((This == NULL) || (AutoLogon == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- *AutoLogon = EFI_CREDENTIAL_LOGON_FLAG_DEFAULT | EFI_CREDENTIAL_LOGON_FLAG_AUTO;\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Return information attached to the credential provider.\r
-\r
- This function returns user information.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] UserInfo Handle of the user information data record.\r
- @param[out] Info On entry, points to a buffer of at least *InfoSize bytes. On\r
- exit, holds the user information. If the buffer is too small\r
- to hold the information, then EFI_BUFFER_TOO_SMALL is returned\r
- and InfoSize is updated to contain the number of bytes actually\r
- required.\r
- @param[in, out] InfoSize On entry, points to the size of Info. On return, points to the\r
- size of the user information.\r
-\r
- @retval EFI_SUCCESS Information returned successfully.\r
- @retval EFI_BUFFER_TOO_SMALL The size specified by InfoSize is too small to hold all of the\r
- user information. The size required is returned in *InfoSize.\r
- @retval EFI_INVALID_PARAMETER Info is NULL or InfoSize is NULL.\r
- @retval EFI_NOT_FOUND The specified UserInfo does not refer to a valid user info handle.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialGetInfo (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_INFO_HANDLE UserInfo,\r
- OUT EFI_USER_INFO *Info,\r
- IN OUT UINTN *InfoSize\r
- )\r
-{\r
- EFI_USER_INFO *CredentialInfo;\r
- UINTN Index;\r
-\r
- if ((This == NULL) || (InfoSize == NULL) || (Info == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if ((UserInfo == NULL) || (mUsbInfoHandle == NULL)) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // Find information handle in credential info table.\r
- //\r
- for (Index = 0; Index < mUsbInfoHandle->Count; Index++) {\r
- CredentialInfo = mUsbInfoHandle->Info[Index];\r
- if (UserInfo == (EFI_USER_INFO_HANDLE)CredentialInfo) {\r
- //\r
- // The handle is found, copy the user info.\r
- //\r
- if (CredentialInfo->InfoSize > *InfoSize) {\r
- *InfoSize = CredentialInfo->InfoSize;\r
- return EFI_BUFFER_TOO_SMALL;\r
- }\r
-\r
- CopyMem (Info, CredentialInfo, CredentialInfo->InfoSize);\r
- return EFI_SUCCESS;\r
- }\r
- }\r
-\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
- Enumerate all of the user informations on the credential provider.\r
-\r
- This function returns the next user information record. To retrieve the first user\r
- information record handle, point UserInfo at a NULL. Each subsequent call will retrieve\r
- another user information record handle until there are no more, at which point UserInfo\r
- will point to NULL.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in, out] UserInfo On entry, points to the previous user information handle or NULL\r
- to start enumeration. On exit, points to the next user information\r
- handle or NULL if there is no more user information.\r
-\r
- @retval EFI_SUCCESS User information returned.\r
- @retval EFI_NOT_FOUND No more user information found.\r
- @retval EFI_INVALID_PARAMETER UserInfo is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialGetNextInfo (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN OUT EFI_USER_INFO_HANDLE *UserInfo\r
- )\r
-{\r
- EFI_USER_INFO *Info;\r
- CHAR16 *ProvNameStr;\r
- UINTN InfoLen;\r
- UINTN Index;\r
- UINTN ProvStrLen;\r
-\r
- if ((This == NULL) || (UserInfo == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (mUsbInfoHandle == NULL) {\r
- //\r
- // Initilized user info table. There are 4 user info records in the table.\r
- //\r
- InfoLen = sizeof (USB_CREDENTIAL_INFO) + (4 - 1) * sizeof (EFI_USER_INFO *);\r
- mUsbInfoHandle = AllocateZeroPool (InfoLen);\r
- if (mUsbInfoHandle == NULL) {\r
- *UserInfo = NULL;\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // The first information, Credential Provider info.\r
- //\r
- InfoLen = sizeof (EFI_USER_INFO) + sizeof (EFI_GUID);\r
- Info = AllocateZeroPool (InfoLen);\r
- ASSERT (Info != NULL);\r
-\r
- Info->InfoType = EFI_USER_INFO_CREDENTIAL_PROVIDER_RECORD;\r
- Info->InfoSize = (UINT32) InfoLen;\r
- Info->InfoAttribs = EFI_USER_INFO_PROTECTED;\r
- CopyGuid (&Info->Credential, &gUsbCredentialProviderGuid);\r
- CopyGuid ((EFI_GUID *)(Info + 1), &gUsbCredentialProviderGuid);\r
-\r
- mUsbInfoHandle->Info[0] = Info;\r
- mUsbInfoHandle->Count++;\r
-\r
- //\r
- // The second information, Credential Provider name info.\r
- //\r
- ProvNameStr = GetStringById (STRING_TOKEN (STR_PROVIDER_NAME));\r
- ProvStrLen = StrSize (ProvNameStr);\r
- InfoLen = sizeof (EFI_USER_INFO) + ProvStrLen;\r
- Info = AllocateZeroPool (InfoLen);\r
- ASSERT (Info != NULL);\r
-\r
- Info->InfoType = EFI_USER_INFO_CREDENTIAL_PROVIDER_NAME_RECORD;\r
- Info->InfoSize = (UINT32) InfoLen;\r
- Info->InfoAttribs = EFI_USER_INFO_PROTECTED;\r
- CopyGuid (&Info->Credential, &gUsbCredentialProviderGuid);\r
- CopyMem ((UINT8*)(Info + 1), ProvNameStr, ProvStrLen);\r
- FreePool (ProvNameStr);\r
-\r
- mUsbInfoHandle->Info[1] = Info;\r
- mUsbInfoHandle->Count++;\r
-\r
- //\r
- // The third information, Credential Provider type info.\r
- //\r
- InfoLen = sizeof (EFI_USER_INFO) + sizeof (EFI_GUID);\r
- Info = AllocateZeroPool (InfoLen);\r
- ASSERT (Info != NULL);\r
-\r
- Info->InfoType = EFI_USER_INFO_CREDENTIAL_TYPE_RECORD;\r
- Info->InfoSize = (UINT32) InfoLen;\r
- Info->InfoAttribs = EFI_USER_INFO_PROTECTED;\r
- CopyGuid (&Info->Credential, &gUsbCredentialProviderGuid);\r
- CopyGuid ((EFI_GUID *)(Info + 1), &gEfiUserCredentialClassSecureCardGuid);\r
-\r
- mUsbInfoHandle->Info[2] = Info;\r
- mUsbInfoHandle->Count++;\r
-\r
- //\r
- // The fourth information, Credential Provider type name info.\r
- //\r
- ProvNameStr = GetStringById (STRING_TOKEN (STR_PROVIDER_TYPE_NAME));\r
- ProvStrLen = StrSize (ProvNameStr);\r
- InfoLen = sizeof (EFI_USER_INFO) + ProvStrLen;\r
- Info = AllocateZeroPool (InfoLen);\r
- ASSERT (Info != NULL);\r
-\r
- Info->InfoType = EFI_USER_INFO_CREDENTIAL_PROVIDER_NAME_RECORD;\r
- Info->InfoSize = (UINT32) InfoLen;\r
- Info->InfoAttribs = EFI_USER_INFO_PROTECTED;\r
- CopyGuid (&Info->Credential, &gUsbCredentialProviderGuid);\r
- CopyMem ((UINT8*)(Info + 1), ProvNameStr, ProvStrLen);\r
- FreePool (ProvNameStr);\r
-\r
- mUsbInfoHandle->Info[3] = Info;\r
- mUsbInfoHandle->Count++;\r
- }\r
-\r
- if (*UserInfo == NULL) {\r
- //\r
- // Return the first info handle.\r
- //\r
- *UserInfo = (EFI_USER_INFO_HANDLE) mUsbInfoHandle->Info[0];\r
- return EFI_SUCCESS;\r
- }\r
-\r
- //\r
- // Find information handle in credential info table.\r
- //\r
- for (Index = 0; Index < mUsbInfoHandle->Count; Index++) {\r
- Info = mUsbInfoHandle->Info[Index];\r
- if (*UserInfo == (EFI_USER_INFO_HANDLE)Info) {\r
- //\r
- // The handle is found, get the next one.\r
- //\r
- if (Index == mUsbInfoHandle->Count - 1) {\r
- //\r
- // Already last one.\r
- //\r
- *UserInfo = NULL;\r
- return EFI_NOT_FOUND;\r
- }\r
- Index++;\r
- *UserInfo = (EFI_USER_INFO_HANDLE)mUsbInfoHandle->Info[Index];\r
- return EFI_SUCCESS;\r
- }\r
- }\r
-\r
- *UserInfo = NULL;\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
- Delete a user on this credential provider.\r
-\r
- This function deletes a user on this credential provider.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] User The user profile handle to delete.\r
-\r
- @retval EFI_SUCCESS User profile was successfully deleted.\r
- @retval EFI_ACCESS_DENIED Current user profile does not permit deletion on the user profile handle.\r
- Either the user profile cannot delete on any user profile or cannot delete\r
- on a user profile other than the current user profile.\r
- @retval EFI_UNSUPPORTED This credential provider does not support deletion in the pre-OS.\r
- @retval EFI_DEVICE_ERROR The new credential could not be deleted because of a device error.\r
- @retval EFI_INVALID_PARAMETER User does not refer to a valid user profile handle.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialDelete (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *UserInfo;\r
- UINT8 *UserId;\r
- UINT8 *NewUserId;\r
- UINTN Index;\r
-\r
- if ((This == NULL) || (User == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Get User Identifier.\r
- //\r
- UserInfo = NULL;\r
- Status = FindUserInfoByType (\r
- User,\r
- EFI_USER_INFO_IDENTIFIER_RECORD,\r
- &UserInfo\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Find the user by user identifier in mPwdTable.\r
- //\r
- for (Index = 0; Index < mUsbTable->Count; Index++) {\r
- UserId = (UINT8 *) &mUsbTable->UserInfo[Index].UserId;\r
- NewUserId = (UINT8 *) (UserInfo + 1);\r
- if (CompareMem (UserId, NewUserId, sizeof (EFI_USER_INFO_IDENTIFIER)) == 0) {\r
- //\r
- // Found the user, delete it.\r
- //\r
- ModifyTable (Index, NULL);\r
- break;\r
- }\r
- }\r
-\r
- FreePool (UserInfo);\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Main entry for this driver.\r
-\r
- @param ImageHandle Image handle this driver.\r
- @param SystemTable Pointer to SystemTable.\r
-\r
- @retval EFI_SUCESS This function always complete successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UsbProviderInit (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- //\r
- // It is NOT robust enough to be included in production.\r
- //\r
- #error "This implementation is just a sample, please comment this line if you really want to use this driver."\r
-\r
- //\r
- // Init credential table.\r
- //\r
- Status = InitCredentialTable ();\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Init Form Browser\r
- //\r
- Status = InitFormBrowser ();\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Install protocol interfaces for the Usb Credential Provider.\r
- //\r
- Status = gBS->InstallProtocolInterface (\r
- &mCallbackInfo->DriverHandle,\r
- &gEfiUserCredential2ProtocolGuid,\r
- EFI_NATIVE_INTERFACE,\r
- &gUsbCredentialProviderDriver\r
- );\r
- return Status;\r
-}\r
+++ /dev/null
-/** @file\r
- Usb Credential Provider driver header file.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _USB_CREDENTIAL_PROVIDER_H_\r
-#define _USB_CREDENTIAL_PROVIDER_H_\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Guid/GlobalVariable.h>\r
-#include <Guid/FileInfo.h>\r
-#include <Guid/SecurityPkgTokenSpace.h>\r
-#include <Guid/UsbCredentialProviderHii.h>\r
-\r
-#include <Protocol/SimpleFileSystem.h>\r
-#include <Protocol/BlockIo.h>\r
-#include <Protocol/UserCredential2.h>\r
-#include <Protocol/UserManager.h>\r
-\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/BaseCryptLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/HiiLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-extern UINT8 UsbCredentialProviderStrings[];\r
-\r
-#define USB_TABLE_INC 16\r
-#define HASHED_CREDENTIAL_LEN 20\r
-\r
-//\r
-// Save the enroll user credential Information.\r
-//\r
-typedef struct {\r
- EFI_USER_INFO_IDENTIFIER UserId;\r
- UINT8 Token[HASHED_CREDENTIAL_LEN];\r
-} USB_INFO;\r
-\r
-//\r
-// USB Credential Table.\r
-//\r
-typedef struct {\r
- UINTN Count;\r
- UINTN MaxCount;\r
- USB_INFO UserInfo[1];\r
-} CREDENTIAL_TABLE;\r
-\r
-//\r
-// The user information on the USB provider.\r
-//\r
-typedef struct {\r
- UINTN Count;\r
- EFI_USER_INFO *Info[1];\r
-} USB_CREDENTIAL_INFO;\r
-\r
-#define USB_PROVIDER_SIGNATURE SIGNATURE_32 ('U', 'S', 'B', 'P')\r
-\r
-typedef struct {\r
- UINTN Signature;\r
- EFI_HANDLE DriverHandle;\r
- EFI_HII_HANDLE HiiHandle;\r
-} USB_PROVIDER_CALLBACK_INFO;\r
-\r
-/**\r
- Enroll a user on a credential provider.\r
-\r
- This function enrolls and deletes a user profile using this credential provider.\r
- If a user profile is successfully enrolled, it calls the User Manager Protocol\r
- function Notify() to notify the user manager driver that credential information\r
- has changed. If an enrolled user does exist, delete the user on the credential\r
- provider.\r
-\r
- @param[in] This Points to this instance of EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] User The user profile to enroll.\r
-\r
- @retval EFI_SUCCESS User profile was successfully enrolled.\r
- @retval EFI_ACCESS_DENIED Current user profile does not permit enrollment on the\r
- user profile handle. Either the user profile cannot enroll\r
- on any user profile or cannot enroll on a user profile\r
- other than the current user profile.\r
- @retval EFI_UNSUPPORTED This credential provider does not support enrollment in\r
- the pre-OS.\r
- @retval EFI_DEVICE_ERROR The new credential could not be created because of a device\r
- error.\r
- @retval EFI_INVALID_PARAMETER User does not refer to a valid user profile handle.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialEnroll (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User\r
- );\r
-\r
-/**\r
- Returns the user interface information used during user identification.\r
-\r
- This function enrolls a user on this credential provider. If the user exists on\r
- this credential provider, update the user information on this credential provider;\r
- otherwise delete the user information on credential provider.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] Hii On return, holds the HII database handle.\r
- @param[out] FormSetId On return, holds the identifier of the form set which contains\r
- the form used during user identification.\r
- @param[out] FormId On return, holds the identifier of the form used during user\r
- identification.\r
-\r
- @retval EFI_SUCCESS Form returned successfully.\r
- @retval EFI_NOT_FOUND Form not returned.\r
- @retval EFI_INVALID_PARAMETER Hii is NULL or FormSetId is NULL or FormId is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialForm (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_HII_HANDLE *Hii,\r
- OUT EFI_GUID *FormSetId,\r
- OUT EFI_FORM_ID *FormId\r
- );\r
-\r
-/**\r
- Returns bitmap used to describe the credential provider type.\r
-\r
- This optional function returns a bitmap which is less than or equal to the number\r
- of pixels specified by Width and Height. If no such bitmap exists, then EFI_NOT_FOUND\r
- is returned.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in, out] Width On entry, points to the desired bitmap width. If NULL then no\r
- bitmap information will be returned. On exit, points to the\r
- width of the bitmap returned.\r
- @param[in, out] Height On entry, points to the desired bitmap height. If NULL then no\r
- bitmap information will be returned. On exit, points to the\r
- height of the bitmap returned.\r
- @param[out] Hii On return, holds the HII database handle.\r
- @param[out] Image On return, holds the HII image identifier.\r
-\r
- @retval EFI_SUCCESS Image identifier returned successfully.\r
- @retval EFI_NOT_FOUND Image identifier not returned.\r
- @retval EFI_INVALID_PARAMETER Hii is NULL or Image is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialTile (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN OUT UINTN *Width,\r
- IN OUT UINTN *Height,\r
- OUT EFI_HII_HANDLE *Hii,\r
- OUT EFI_IMAGE_ID *Image\r
- );\r
-\r
-/**\r
- Returns string used to describe the credential provider type.\r
-\r
- This function returns a string which describes the credential provider. If no\r
- such string exists, then EFI_NOT_FOUND is returned.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] Hii On return, holds the HII database handle.\r
- @param[out] String On return, holds the HII string identifier.\r
-\r
- @retval EFI_SUCCESS String identifier returned successfully.\r
- @retval EFI_NOT_FOUND String identifier not returned.\r
- @retval EFI_INVALID_PARAMETER Hii is NULL or String is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialTitle (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_HII_HANDLE *Hii,\r
- OUT EFI_STRING_ID *String\r
- );\r
-\r
-/**\r
- Return the user identifier associated with the currently authenticated user.\r
-\r
- This function returns the user identifier of the user authenticated by this credential\r
- provider. This function is called after the credential-related information has been\r
- submitted on a form OR after a call to Default() has returned that this credential is\r
- ready to log on.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] User The user profile handle of the user profile currently being\r
- considered by the user identity manager. If NULL, then no user\r
- profile is currently under consideration.\r
- @param[out] Identifier On return, points to the user identifier.\r
-\r
- @retval EFI_SUCCESS User identifier returned successfully.\r
- @retval EFI_NOT_READY No user identifier can be returned.\r
- @retval EFI_ACCESS_DENIED The user has been locked out of this user credential.\r
- @retval EFI_INVALID_PARAMETER This is NULL, or Identifier is NULL.\r
- @retval EFI_NOT_FOUND User is not NULL, and the specified user handle can't be\r
- found in user profile database.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialUser (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- OUT EFI_USER_INFO_IDENTIFIER *Identifier\r
- );\r
-\r
-/**\r
- Indicate that user interface interaction has begun for the specified credential.\r
-\r
- This function is called when a credential provider is selected by the user. If\r
- AutoLogon returns FALSE, then the user interface will be constructed by the User\r
- Identity Manager.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] AutoLogon On return, points to the credential provider's capabilities\r
- after the credential provider has been selected by the user.\r
-\r
- @retval EFI_SUCCESS Credential provider successfully selected.\r
- @retval EFI_INVALID_PARAMETER AutoLogon is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialSelect (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_CREDENTIAL_LOGON_FLAGS *AutoLogon\r
- );\r
-\r
-/**\r
- Indicate that user interface interaction has ended for the specified credential.\r
-\r
- This function is called when a credential provider is deselected by the user.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
-\r
- @retval EFI_SUCCESS Credential provider successfully deselected.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialDeselect (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This\r
- );\r
-\r
-/**\r
- Return the default logon behavior for this user credential.\r
-\r
- This function reports the default login behavior regarding this credential provider.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[out] AutoLogon On return, holds whether the credential provider should be used\r
- by default to automatically log on the user.\r
-\r
- @retval EFI_SUCCESS Default information successfully returned.\r
- @retval EFI_INVALID_PARAMETER AutoLogon is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialDefault (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- OUT EFI_CREDENTIAL_LOGON_FLAGS *AutoLogon\r
- );\r
-\r
-/**\r
- Return information attached to the credential provider.\r
-\r
- This function returns user information.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] UserInfo Handle of the user information data record.\r
- @param[out] Info On entry, points to a buffer of at least *InfoSize bytes. On\r
- exit, holds the user information. If the buffer is too small\r
- to hold the information, then EFI_BUFFER_TOO_SMALL is returned\r
- and InfoSize is updated to contain the number of bytes actually\r
- required.\r
- @param[in, out] InfoSize On entry, points to the size of Info. On return, points to the\r
- size of the user information.\r
-\r
- @retval EFI_SUCCESS Information returned successfully.\r
- @retval EFI_BUFFER_TOO_SMALL The size specified by InfoSize is too small to hold all of the\r
- user information. The size required is returned in *InfoSize.\r
- @retval EFI_INVALID_PARAMETER Info is NULL or InfoSize is NULL.\r
- @retval EFI_NOT_FOUND The specified UserInfo does not refer to a valid user info handle.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialGetInfo (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_INFO_HANDLE UserInfo,\r
- OUT EFI_USER_INFO *Info,\r
- IN OUT UINTN *InfoSize\r
- );\r
-\r
-/**\r
- Enumerate all of the user informations on the credential provider.\r
-\r
- This function returns the next user information record. To retrieve the first user\r
- information record handle, point UserInfo at a NULL. Each subsequent call will retrieve\r
- another user information record handle until there are no more, at which point UserInfo\r
- will point to NULL.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in, out] UserInfo On entry, points to the previous user information handle or NULL\r
- to start enumeration. On exit, points to the next user information\r
- handle or NULL if there is no more user information.\r
-\r
- @retval EFI_SUCCESS User information returned.\r
- @retval EFI_NOT_FOUND No more user information found.\r
- @retval EFI_INVALID_PARAMETER UserInfo is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialGetNextInfo (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN OUT EFI_USER_INFO_HANDLE *UserInfo\r
- );\r
-\r
-/**\r
- Delete a user on this credential provider.\r
-\r
- This function deletes a user on this credential provider.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
- @param[in] User The user profile handle to delete.\r
-\r
- @retval EFI_SUCCESS User profile was successfully deleted.\r
- @retval EFI_ACCESS_DENIED Current user profile does not permit deletion on the user profile handle.\r
- Either the user profile cannot delete on any user profile or cannot delete\r
- on a user profile other than the current user profile.\r
- @retval EFI_UNSUPPORTED This credential provider does not support deletion in the pre-OS.\r
- @retval EFI_DEVICE_ERROR The new credential could not be deleted because of a device error.\r
- @retval EFI_INVALID_PARAMETER User does not refer to a valid user profile handle.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-CredentialDelete (\r
- IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User\r
- );\r
-\r
-#endif\r
+++ /dev/null
-// /** @file\r
-// Provides a USB credential provider implementation\r
-//\r
-// This module reads a token from a token file that is saved in the root\r
-// folder of a USB stick. The token file name can be specified by the PCD\r
-// PcdFixedUsbCredentialProviderTokenFileName.\r
-//\r
-// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// This program and the accompanying materials\r
-// are licensed and made available under the terms and conditions of the BSD License\r
-// which accompanies this distribution. The full text of the license may be found at\r
-// http://opensource.org/licenses/bsd-license.php\r
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT #language en-US "Provides a USB credential provider implementation"\r
-\r
-#string STR_MODULE_DESCRIPTION #language en-US "This module reads a token from a token file that is saved in the root folder of a USB stick. The token file name can be specified by the PCD PcdFixedUsbCredentialProviderTokenFileName."\r
-\r
+++ /dev/null
-## @file\r
-# Provides a USB credential provider implementation\r
-#\r
-# This module reads a token from a token file that is saved in the root\r
-# folder of a USB stick. The token file name can be specified by the PCD\r
-# PcdFixedUsbCredentialProviderTokenFileName.\r
-#\r
-# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-##\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = UsbCredentialProvider\r
- MODULE_UNI_FILE = UsbCredentialProvider.uni\r
- FILE_GUID = 672A0C68-2BF0-46f9-93C3-C4E7DC0FA555\r
- MODULE_TYPE = UEFI_DRIVER\r
- VERSION_STRING = 1.0\r
- ENTRY_POINT = UsbProviderInit\r
-\r
-[Sources]\r
- UsbCredentialProvider.c\r
- UsbCredentialProvider.h\r
- UsbCredentialProviderStrings.uni\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- MdeModulePkg/MdeModulePkg.dec\r
- CryptoPkg/CryptoPkg.dec\r
- SecurityPkg/SecurityPkg.dec\r
-\r
-[LibraryClasses]\r
- UefiRuntimeServicesTableLib\r
- UefiBootServicesTableLib\r
- UefiDriverEntryPoint\r
- MemoryAllocationLib\r
- BaseMemoryLib\r
- DebugLib\r
- HiiLib\r
- UefiLib\r
- BaseCryptLib\r
-\r
-[Guids]\r
- ## PRODUCES ## Variable:L"UsbCredential"\r
- ## CONSUMES ## Variable:L"UsbCredential"\r
- ## CONSUMES ## HII\r
- ## SOMETIMES_CONSUMES ## GUID # The credential provider identifier\r
- gUsbCredentialProviderGuid\r
-\r
- gEfiFileInfoGuid ## SOMETIMES_CONSUMES ## GUID\r
- gEfiUserCredentialClassSecureCardGuid ## SOMETIMES_CONSUMES ## GUID\r
-\r
-[Pcd]\r
- gEfiSecurityPkgTokenSpaceGuid.PcdFixedUsbCredentialProviderTokenFileName ## SOMETIMES_CONSUMES\r
-\r
-[Protocols]\r
- gEfiUserCredential2ProtocolGuid ## PRODUCES\r
- gEfiUserManagerProtocolGuid ## SOMETIMES_CONSUMES\r
- gEfiBlockIoProtocolGuid ## SOMETIMES_CONSUMES\r
- gEfiSimpleFileSystemProtocolGuid ## SOMETIMES_CONSUMES\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
- UsbCredentialProviderExtra.uni\r
-\r
+++ /dev/null
-// /** @file\r
-// UsbCredentialProvider Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// This program and the accompanying materials\r
-// are licensed and made available under the terms and conditions of the BSD License\r
-// which accompanies this distribution. The full text of the license may be found at\r
-// http://opensource.org/licenses/bsd-license.php\r
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"USB Credential Provider"\r
-\r
-\r
+++ /dev/null
-/** @file\r
- String definitions for the USB Credential Provider.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php.\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#langdef en-US "English"\r
-#langdef fr-FR "Francais"\r
-\r
-#string STR_CREDENTIAL_TITLE #language en-US "USB Credential Provider"\r
- #language fr-FR "USB Credential Provider (French)"\r
-#string STR_NULL_STRING #language en-US ""\r
- #language fr-FR ""\r
-#string STR_PROVIDER_NAME #language en-US "INTEL USB Credential Provider"\r
- #language fr-FR "INTEL USB Credential Provider (French)"\r
-#string STR_PROVIDER_TYPE_NAME #language en-US "Secure Card Credential Provider"\r
- #language fr-FR "Secure Card Credential Provider (French)"\r
-#string STR_READ_USB_TOKEN_ERROR #language en-US "Read USB Token File Error!"\r
- #language fr-FR "Read USB Token File Error! (French)"\r
-#string STR_INSERT_USB_TOKEN #language en-US "Please insert USB key with Token"\r
- #language fr-FR "Please insert USB key with Token (French)"\r
+++ /dev/null
-/** @file\r
- Load the deferred images after user is identified.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "UserIdentifyManager.h"\r
-\r
-EFI_HANDLE mDeferredImageHandle;\r
-\r
-/**\r
- The function will load all the deferred images again. If the deferred image is loaded\r
- successfully, try to start it.\r
-\r
- @param Event Event whose notification function is being invoked.\r
- @param Context Pointer to the notification function's context\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-LoadDeferredImage (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_DEFERRED_IMAGE_LOAD_PROTOCOL *DeferredImage;\r
- UINTN HandleCount;\r
- EFI_HANDLE *HandleBuf;\r
- UINTN Index;\r
- UINTN DriverIndex;\r
- EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;\r
- VOID *DriverImage;\r
- UINTN ImageSize;\r
- BOOLEAN BootOption;\r
- EFI_HANDLE ImageHandle;\r
- UINTN ExitDataSize;\r
- CHAR16 *ExitData;\r
-\r
- //\r
- // Find all the deferred image load protocols.\r
- //\r
- HandleCount = 0;\r
- HandleBuf = NULL;\r
- Status = gBS->LocateHandleBuffer (\r
- ByProtocol,\r
- &gEfiDeferredImageLoadProtocolGuid,\r
- NULL,\r
- &HandleCount,\r
- &HandleBuf\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return ;\r
- }\r
-\r
- for (Index = 0; Index < HandleCount; Index++) {\r
- Status = gBS->HandleProtocol (\r
- HandleBuf[Index],\r
- &gEfiDeferredImageLoadProtocolGuid,\r
- (VOID **) &DeferredImage\r
- );\r
- if (EFI_ERROR (Status)) {\r
- continue ;\r
- }\r
-\r
- DriverIndex = 0;\r
- do {\r
- //\r
- // Load all the deferred images in this protocol instance.\r
- //\r
- Status = DeferredImage->GetImageInfo(\r
- DeferredImage,\r
- DriverIndex,\r
- &ImageDevicePath,\r
- (VOID **) &DriverImage,\r
- &ImageSize,\r
- &BootOption\r
- );\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
-\r
- //\r
- // Load and start the image.\r
- //\r
- Status = gBS->LoadImage (\r
- BootOption,\r
- mDeferredImageHandle,\r
- ImageDevicePath,\r
- NULL,\r
- 0,\r
- &ImageHandle\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- //\r
- // Before calling the image, enable the Watchdog Timer for\r
- // a 5 Minute period\r
- //\r
- gBS->SetWatchdogTimer (5 * 60, 0x0000, 0x00, NULL);\r
- Status = gBS->StartImage (ImageHandle, &ExitDataSize, &ExitData);\r
-\r
- //\r
- // Clear the Watchdog Timer after the image returns.\r
- //\r
- gBS->SetWatchdogTimer (0x0000, 0x0000, 0x0000, NULL);\r
- }\r
- DriverIndex++;\r
- } while (TRUE);\r
- }\r
- FreePool (HandleBuf);\r
-}\r
-\r
-\r
-/**\r
- Register an event notification function for user profile changed.\r
-\r
- @param[in] ImageHandle Image handle this driver.\r
-\r
-**/\r
-VOID\r
-LoadDeferredImageInit (\r
- IN EFI_HANDLE ImageHandle\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_EVENT Event;\r
-\r
- mDeferredImageHandle = ImageHandle;\r
-\r
- Status = gBS->CreateEventEx (\r
- EVT_NOTIFY_SIGNAL,\r
- TPL_CALLBACK,\r
- LoadDeferredImage,\r
- NULL,\r
- &gEfiEventUserProfileChangedGuid,\r
- &Event\r
- );\r
-\r
- ASSERT (Status == EFI_SUCCESS);\r
-}\r
+++ /dev/null
-/** @file\r
- This driver manages user information and produces user manager protocol.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-(C) Copyright 2018 Hewlett Packard Enterprise Development LP<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "UserIdentifyManager.h"\r
-\r
-//\r
-// Default user name.\r
-//\r
-CHAR16 mUserName[] = L"Administrator";\r
-\r
-//\r
-// Points to the user profile database.\r
-//\r
-USER_PROFILE_DB *mUserProfileDb = NULL;\r
-\r
-//\r
-// Points to the credential providers found in system.\r
-//\r
-CREDENTIAL_PROVIDER_INFO *mProviderDb = NULL;\r
-\r
-//\r
-// Current user shared in multi function.\r
-//\r
-EFI_USER_PROFILE_HANDLE mCurrentUser = NULL;\r
-\r
-//\r
-// Flag indicates a user is identified.\r
-//\r
-BOOLEAN mIdentified = FALSE;\r
-USER_MANAGER_CALLBACK_INFO *mCallbackInfo = NULL;\r
-HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath = {\r
- {\r
- {\r
- HARDWARE_DEVICE_PATH,\r
- HW_VENDOR_DP,\r
- {\r
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
- }\r
- },\r
- USER_IDENTIFY_MANAGER_GUID\r
- },\r
- {\r
- END_DEVICE_PATH_TYPE,\r
- END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
- {\r
- (UINT8) (END_DEVICE_PATH_LENGTH),\r
- (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
- }\r
- }\r
-};\r
-\r
-\r
-EFI_USER_MANAGER_PROTOCOL gUserIdentifyManager = {\r
- UserProfileCreate,\r
- UserProfileDelete,\r
- UserProfileGetNext,\r
- UserProfileCurrent,\r
- UserProfileIdentify,\r
- UserProfileFind,\r
- UserProfileNotify,\r
- UserProfileGetInfo,\r
- UserProfileSetInfo,\r
- UserProfileDeleteInfo,\r
- UserProfileGetNextInfo,\r
-};\r
-\r
-\r
-/**\r
- Find the specified user in the user database.\r
-\r
- This function searches the specified user from the beginning of the user database.\r
- And if NextUser is TRUE, return the next User in the user database.\r
-\r
- @param[in, out] User On entry, points to the user profile entry to search.\r
- On return, points to the user profile entry or NULL if not found.\r
- @param[in] NextUser If FALSE, find the user in user profile database specifyed by User\r
- If TRUE, find the next user in user profile database specifyed\r
- by User.\r
- @param[out] ProfileIndex A pointer to the index of user profile database that matches the\r
- user specifyed by User.\r
-\r
- @retval EFI_NOT_FOUND User was NULL, or User was not found, or the next user was not found.\r
- @retval EFI_SUCCESS User or the next user are found in user profile database\r
-\r
-**/\r
-EFI_STATUS\r
-FindUserProfile (\r
- IN OUT USER_PROFILE_ENTRY **User,\r
- IN BOOLEAN NextUser,\r
- OUT UINTN *ProfileIndex OPTIONAL\r
- )\r
-{\r
- UINTN Index;\r
-\r
- //\r
- // Check parameters\r
- //\r
- if ((mUserProfileDb == NULL) || (User == NULL)) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- //\r
- // Check whether the user profile is in the user profile database.\r
- //\r
- for (Index = 0; Index < mUserProfileDb->UserProfileNum; Index++) {\r
- if (mUserProfileDb->UserProfile[Index] == *User) {\r
- if (ProfileIndex != NULL) {\r
- *ProfileIndex = Index;\r
- }\r
- break;\r
- }\r
- }\r
-\r
- if (NextUser) {\r
- //\r
- // Find the next user profile.\r
- //\r
- Index++;\r
- if (Index < mUserProfileDb->UserProfileNum) {\r
- *User = mUserProfileDb->UserProfile[Index];\r
- } else if (Index == mUserProfileDb->UserProfileNum) {\r
- *User = NULL;\r
- return EFI_NOT_FOUND;\r
- } else {\r
- if ((mUserProfileDb->UserProfileNum > 0) && (*User == NULL)) {\r
- *User = mUserProfileDb->UserProfile[0];\r
- } else {\r
- *User = NULL;\r
- return EFI_NOT_FOUND;\r
- }\r
- }\r
- } else if (Index == mUserProfileDb->UserProfileNum) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- Find the specified user information record in the specified User profile.\r
-\r
- This function searches the specified user information record from the beginning of the user\r
- profile. And if NextInfo is TRUE, return the next info in the user profile.\r
-\r
- @param[in] User Points to the user profile entry.\r
- @param[in, out] Info On entry, points to the user information record or NULL to start\r
- searching with the first user information record.\r
- On return, points to the user information record or NULL if not found.\r
- @param[in] NextInfo If FALSE, find the user information record in profile specifyed by User.\r
- If TRUE, find the next user information record in profile specifyed\r
- by User.\r
- @param[out] Offset A pointer to the offset of the information record in the user profile.\r
-\r
- @retval EFI_INVALID_PARAMETER Info is NULL\r
- @retval EFI_NOT_FOUND Info was not found, or the next Info was not found.\r
- @retval EFI_SUCCESS Info or the next info are found in user profile.\r
-\r
-**/\r
-EFI_STATUS\r
-FindUserInfo (\r
- IN USER_PROFILE_ENTRY * User,\r
- IN OUT EFI_USER_INFO **Info,\r
- IN BOOLEAN NextInfo,\r
- OUT UINTN *Offset OPTIONAL\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *UserInfo;\r
- UINTN InfoLen;\r
-\r
- if (Info == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Check user profile entry\r
- //\r
- Status = FindUserProfile (&User, FALSE, NULL);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Find user information in the specified user record.\r
- //\r
- InfoLen = 0;\r
- while (InfoLen < User->UserProfileSize) {\r
- UserInfo = (EFI_USER_INFO *) (User->ProfileInfo + InfoLen);\r
- if (UserInfo == *Info) {\r
- if (Offset != NULL) {\r
- *Offset = InfoLen;\r
- }\r
- break;\r
- }\r
- InfoLen += ALIGN_VARIABLE (UserInfo->InfoSize);\r
- }\r
-\r
- //\r
- // Check whether to find the next user information.\r
- //\r
- if (NextInfo) {\r
- if (InfoLen < User->UserProfileSize) {\r
- UserInfo = (EFI_USER_INFO *) (User->ProfileInfo + InfoLen);\r
- InfoLen += ALIGN_VARIABLE (UserInfo->InfoSize);\r
- if (InfoLen < User->UserProfileSize) {\r
- *Info = (EFI_USER_INFO *) (User->ProfileInfo + InfoLen);\r
- if (Offset != NULL) {\r
- *Offset = InfoLen;\r
- }\r
- } else if (InfoLen == User->UserProfileSize) {\r
- *Info = NULL;\r
- return EFI_NOT_FOUND;\r
- }\r
- } else {\r
- if (*Info == NULL) {\r
- *Info = (EFI_USER_INFO *) User->ProfileInfo;\r
- if (Offset != NULL) {\r
- *Offset = 0;\r
- }\r
- } else {\r
- *Info = NULL;\r
- return EFI_NOT_FOUND;\r
- }\r
- }\r
- } else if (InfoLen == User->UserProfileSize) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- Find a user infomation record by the information record type.\r
-\r
- This function searches all user information records of User. The search starts with the\r
- user information record following Info and continues until either the information is found\r
- or there are no more user infomation record.\r
- A match occurs when a Info.InfoType field matches the user information record type.\r
-\r
- @param[in] User Points to the user profile record to search.\r
- @param[in, out] Info On entry, points to the user information record or NULL to start\r
- searching with the first user information record.\r
- On return, points to the user information record or NULL if not found.\r
- @param[in] InfoType The infomation type to be searched.\r
-\r
- @retval EFI_SUCCESS User information was found. Info points to the user information record.\r
- @retval EFI_NOT_FOUND User information was not found.\r
- @retval EFI_INVALID_PARAMETER User is NULL or Info is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-FindUserInfoByType (\r
- IN USER_PROFILE_ENTRY *User,\r
- IN OUT EFI_USER_INFO **Info,\r
- IN UINT8 InfoType\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *UserInfo;\r
- UINTN InfoLen;\r
-\r
- if (Info == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Check whether the user has the specified user information.\r
- //\r
- InfoLen = 0;\r
- if (*Info == NULL) {\r
- Status = FindUserProfile (&User, FALSE, NULL);\r
- } else {\r
- Status = FindUserInfo (User, Info, TRUE, &InfoLen);\r
- }\r
-\r
- if (EFI_ERROR (Status)) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- while (InfoLen < User->UserProfileSize) {\r
- UserInfo = (EFI_USER_INFO *) (User->ProfileInfo + InfoLen);\r
- if (UserInfo->InfoType == InfoType) {\r
- if (UserInfo != *Info) {\r
- *Info = UserInfo;\r
- return EFI_SUCCESS;\r
- }\r
- }\r
-\r
- InfoLen += ALIGN_VARIABLE (UserInfo->InfoSize);\r
- }\r
-\r
- *Info = NULL;\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
- Find a user using a user information record.\r
-\r
- This function searches all user profiles for the specified user information record. The\r
- search starts with the user information record handle following UserInfo and continues\r
- until either the information is found or there are no more user profiles.\r
- A match occurs when the Info.InfoType field matches the user information record type and the\r
- user information record data matches the portion of Info passed the EFI_USER_INFO header.\r
-\r
- @param[in, out] User On entry, points to the previously returned user profile record,\r
- or NULL to start searching with the first user profile.\r
- On return, points to the user profile entry, or NULL if not found.\r
- @param[in, out] UserInfo On entry, points to the previously returned user information record,\r
- or NULL to start searching with the first.\r
- On return, points to the user information record, or NULL if not found.\r
- @param[in] Info Points to the buffer containing the user information to be compared\r
- to the user information record.\r
- @param[in] InfoSize The size of Info, in bytes. Same as Info->InfoSize.\r
-\r
- @retval EFI_SUCCESS User information was found. User points to the user profile record,\r
- and UserInfo points to the user information record.\r
- @retval EFI_NOT_FOUND User information was not found.\r
- @retval EFI_INVALID_PARAMETER User is NULL; Info is NULL; or, InfoSize is too small.\r
-\r
-**/\r
-EFI_STATUS\r
-FindUserProfileByInfo (\r
- IN OUT USER_PROFILE_ENTRY **User,\r
- IN OUT EFI_USER_INFO **UserInfo, OPTIONAL\r
- IN EFI_USER_INFO *Info,\r
- IN UINTN InfoSize\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *InfoEntry;\r
-\r
-\r
- if ((User == NULL) || (Info == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (InfoSize < sizeof (EFI_USER_INFO)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (UserInfo != NULL) {\r
- InfoEntry = *UserInfo;\r
- } else {\r
- InfoEntry = NULL;\r
- }\r
- //\r
- // Find user profile according to information.\r
- //\r
- if (*User == NULL) {\r
- *User = mUserProfileDb->UserProfile[0];\r
- }\r
-\r
- //\r
- // Check user profile handle.\r
- //\r
- Status = FindUserProfile (User, FALSE, NULL);\r
-\r
- while (!EFI_ERROR (Status)) {\r
- //\r
- // Find the user information in a user profile.\r
- //\r
- while (TRUE) {\r
- Status = FindUserInfoByType (*User, &InfoEntry, Info->InfoType);\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
-\r
- if (InfoSize == Info->InfoSize) {\r
- if (CompareMem ((UINT8 *) (InfoEntry + 1), (UINT8 *) (Info + 1), InfoSize - sizeof (EFI_USER_INFO)) == 0) {\r
- //\r
- // Found the infomation record.\r
- //\r
- if (UserInfo != NULL) {\r
- *UserInfo = InfoEntry;\r
- }\r
- return EFI_SUCCESS;\r
- }\r
- }\r
- }\r
-\r
- //\r
- // Get next user profile.\r
- //\r
- InfoEntry = NULL;\r
- Status = FindUserProfile (User, TRUE, NULL);\r
- }\r
-\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
- Check whether the access policy is valid.\r
-\r
- @param[in] PolicyInfo Point to the access policy.\r
- @param[in] InfoLen The policy length.\r
-\r
- @retval TRUE The policy is a valid access policy.\r
- @retval FALSE The access policy is not a valid access policy.\r
-\r
-**/\r
-BOOLEAN\r
-CheckAccessPolicy (\r
- IN UINT8 *PolicyInfo,\r
- IN UINTN InfoLen\r
- )\r
-{\r
- UINTN TotalLen;\r
- UINTN ValueLen;\r
- UINTN OffSet;\r
- EFI_USER_INFO_ACCESS_CONTROL Access;\r
- EFI_DEVICE_PATH_PROTOCOL *Path;\r
- UINTN PathSize;\r
-\r
- TotalLen = 0;\r
- while (TotalLen < InfoLen) {\r
- //\r
- // Check access policy according to type.\r
- //\r
- CopyMem (&Access, PolicyInfo + TotalLen, sizeof (Access));\r
- ValueLen = Access.Size - sizeof (EFI_USER_INFO_ACCESS_CONTROL);\r
- switch (Access.Type) {\r
- case EFI_USER_INFO_ACCESS_FORBID_LOAD:\r
- case EFI_USER_INFO_ACCESS_PERMIT_LOAD:\r
- case EFI_USER_INFO_ACCESS_FORBID_CONNECT:\r
- case EFI_USER_INFO_ACCESS_PERMIT_CONNECT:\r
- OffSet = 0;\r
- while (OffSet < ValueLen) {\r
- Path = (EFI_DEVICE_PATH_PROTOCOL *) (PolicyInfo + TotalLen + sizeof (Access) + OffSet);\r
- PathSize = GetDevicePathSize (Path);\r
- OffSet += PathSize;\r
- }\r
- if (OffSet != ValueLen) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_ACCESS_SETUP:\r
- if (ValueLen % sizeof (EFI_GUID) != 0) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_ACCESS_BOOT_ORDER:\r
- if (ValueLen % sizeof (EFI_USER_INFO_ACCESS_BOOT_ORDER_HDR) != 0) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_ACCESS_ENROLL_SELF:\r
- case EFI_USER_INFO_ACCESS_ENROLL_OTHERS:\r
- case EFI_USER_INFO_ACCESS_MANAGE:\r
- if (ValueLen != 0) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- default:\r
- return FALSE;\r
- break;\r
- }\r
-\r
- TotalLen += Access.Size;\r
- }\r
-\r
- if (TotalLen != InfoLen) {\r
- return FALSE;\r
- }\r
-\r
- return TRUE;\r
-}\r
-\r
-\r
-/**\r
- Check whether the identity policy is valid.\r
-\r
- @param[in] PolicyInfo Point to the identity policy.\r
- @param[in] InfoLen The policy length.\r
-\r
- @retval TRUE The policy is a valid identity policy.\r
- @retval FALSE The access policy is not a valid identity policy.\r
-\r
-**/\r
-BOOLEAN\r
-CheckIdentityPolicy (\r
- IN UINT8 *PolicyInfo,\r
- IN UINTN InfoLen\r
- )\r
-{\r
- UINTN TotalLen;\r
- UINTN ValueLen;\r
- EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
-\r
- TotalLen = 0;\r
-\r
- //\r
- // Check each part of policy expression.\r
- //\r
- while (TotalLen < InfoLen) {\r
- //\r
- // Check access polisy according to type.\r
- //\r
- Identity = (EFI_USER_INFO_IDENTITY_POLICY *) (PolicyInfo + TotalLen);\r
- ValueLen = Identity->Length - sizeof (EFI_USER_INFO_IDENTITY_POLICY);\r
- switch (Identity->Type) {\r
- //\r
- // Check False option.\r
- //\r
- case EFI_USER_INFO_IDENTITY_FALSE:\r
- if (ValueLen != 0) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- //\r
- // Check True option.\r
- //\r
- case EFI_USER_INFO_IDENTITY_TRUE:\r
- if (ValueLen != 0) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- //\r
- // Check negative operation.\r
- //\r
- case EFI_USER_INFO_IDENTITY_NOT:\r
- if (ValueLen != 0) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- //\r
- // Check and operation.\r
- //\r
- case EFI_USER_INFO_IDENTITY_AND:\r
- if (ValueLen != 0) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- //\r
- // Check or operation.\r
- //\r
- case EFI_USER_INFO_IDENTITY_OR:\r
- if (ValueLen != 0) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- //\r
- // Check credential provider by type.\r
- //\r
- case EFI_USER_INFO_IDENTITY_CREDENTIAL_TYPE:\r
- if (ValueLen != sizeof (EFI_GUID)) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- //\r
- // Check credential provider by ID.\r
- //\r
- case EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER:\r
- if (ValueLen != sizeof (EFI_GUID)) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- default:\r
- return FALSE;\r
- break;\r
- }\r
-\r
- TotalLen += Identity->Length;\r
- }\r
-\r
- if (TotalLen != InfoLen) {\r
- return FALSE;\r
- }\r
-\r
- return TRUE;\r
-}\r
-\r
-\r
-/**\r
- Check whether the user information is a valid user information record.\r
-\r
- @param[in] Info points to the user information.\r
-\r
- @retval TRUE The info is a valid user information record.\r
- @retval FALSE The info is not a valid user information record.\r
-\r
-**/\r
-BOOLEAN\r
-CheckUserInfo (\r
- IN CONST EFI_USER_INFO *Info\r
- )\r
-{\r
- UINTN InfoLen;\r
-\r
- if (Info == NULL) {\r
- return FALSE;\r
- }\r
- //\r
- // Check user information according to information type.\r
- //\r
- InfoLen = Info->InfoSize - sizeof (EFI_USER_INFO);\r
- switch (Info->InfoType) {\r
- case EFI_USER_INFO_EMPTY_RECORD:\r
- if (InfoLen != 0) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_NAME_RECORD:\r
- case EFI_USER_INFO_CREDENTIAL_TYPE_NAME_RECORD:\r
- case EFI_USER_INFO_CREDENTIAL_PROVIDER_NAME_RECORD:\r
- break;\r
-\r
- case EFI_USER_INFO_CREATE_DATE_RECORD:\r
- case EFI_USER_INFO_USAGE_DATE_RECORD:\r
- if (InfoLen != sizeof (EFI_TIME)) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_USAGE_COUNT_RECORD:\r
- if (InfoLen != sizeof (UINT64)) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTIFIER_RECORD:\r
- if (InfoLen != 16) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_CREDENTIAL_TYPE_RECORD:\r
- case EFI_USER_INFO_CREDENTIAL_PROVIDER_RECORD:\r
- case EFI_USER_INFO_GUID_RECORD:\r
- if (InfoLen != sizeof (EFI_GUID)) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_PKCS11_RECORD:\r
- case EFI_USER_INFO_CBEFF_RECORD:\r
- break;\r
-\r
- case EFI_USER_INFO_FAR_RECORD:\r
- case EFI_USER_INFO_RETRY_RECORD:\r
- if (InfoLen != 1) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_ACCESS_POLICY_RECORD:\r
- if(!CheckAccessPolicy ((UINT8 *) (Info + 1), InfoLen)) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_POLICY_RECORD:\r
- if (!CheckIdentityPolicy ((UINT8 *) (Info + 1), InfoLen)) {\r
- return FALSE;\r
- }\r
- break;\r
-\r
- default:\r
- return FALSE;\r
- break;\r
- }\r
-\r
- return TRUE;\r
-}\r
-\r
-\r
-/**\r
- Check the user profile data format to be added.\r
-\r
- @param[in] UserProfileInfo Points to the user profile data.\r
- @param[in] UserProfileSize The length of user profile data.\r
-\r
- @retval TRUE It is a valid user profile.\r
- @retval FALSE It is not a valid user profile.\r
-\r
-**/\r
-BOOLEAN\r
-CheckProfileInfo (\r
- IN UINT8 *UserProfileInfo,\r
- IN UINTN UserProfileSize\r
- )\r
-{\r
- UINTN ChkLen;\r
- EFI_USER_INFO *Info;\r
-\r
- if (UserProfileInfo == NULL) {\r
- return FALSE;\r
- }\r
-\r
- //\r
- // Check user profile information length.\r
- //\r
- ChkLen = 0;\r
- while (ChkLen < UserProfileSize) {\r
- Info = (EFI_USER_INFO *) (UserProfileInfo + ChkLen);\r
- //\r
- // Check user information format.\r
- //\r
- if (!CheckUserInfo (Info)) {\r
- return FALSE;\r
- }\r
-\r
- ChkLen += ALIGN_VARIABLE (Info->InfoSize);\r
- }\r
-\r
- if (ChkLen != UserProfileSize) {\r
- return FALSE;\r
- }\r
-\r
- return TRUE;\r
-}\r
-\r
-\r
-/**\r
- Find the specified RightType in current user profile.\r
-\r
- @param[in] RightType Could be EFI_USER_INFO_ACCESS_MANAGE,\r
- EFI_USER_INFO_ACCESS_ENROLL_OTHERS or\r
- EFI_USER_INFO_ACCESS_ENROLL_SELF.\r
-\r
- @retval TRUE Find the specified RightType in current user profile.\r
- @retval FALSE Can't find the right in the profile.\r
-\r
-**/\r
-BOOLEAN\r
-CheckCurrentUserAccessRight (\r
- IN UINT32 RightType\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *Info;\r
- UINTN TotalLen;\r
- UINTN CheckLen;\r
- EFI_USER_INFO_ACCESS_CONTROL Access;\r
-\r
- //\r
- // Get user access right information.\r
- //\r
- Info = NULL;\r
- Status = FindUserInfoByType (\r
- (USER_PROFILE_ENTRY *) mCurrentUser,\r
- &Info,\r
- EFI_USER_INFO_ACCESS_POLICY_RECORD\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return FALSE;\r
- }\r
-\r
- ASSERT (Info != NULL);\r
- TotalLen = Info->InfoSize - sizeof (EFI_USER_INFO);\r
- CheckLen = 0;\r
- while (CheckLen < TotalLen) {\r
- //\r
- // Check right according to access type.\r
- //\r
- CopyMem (&Access, (UINT8 *) (Info + 1) + CheckLen, sizeof (Access));\r
- if (Access.Type == RightType) {\r
- return TRUE;;\r
- }\r
-\r
- CheckLen += Access.Size;\r
- }\r
-\r
- return FALSE;\r
-}\r
-\r
-\r
-/**\r
- Create a unique user identifier.\r
-\r
- @param[out] Identifier This points to the identifier.\r
-\r
-**/\r
-VOID\r
-GenerateIdentifier (\r
- OUT UINT8 *Identifier\r
- )\r
-{\r
- EFI_TIME Time;\r
- UINT64 MonotonicCount;\r
- UINT32 *MonotonicPointer;\r
- UINTN Index;\r
-\r
- //\r
- // Create a unique user identifier.\r
- //\r
- gRT->GetTime (&Time, NULL);\r
- CopyMem (Identifier, &Time, sizeof (EFI_TIME));\r
- //\r
- // Remove zeros.\r
- //\r
- for (Index = 0; Index < sizeof (EFI_TIME); Index++) {\r
- if (Identifier[Index] == 0) {\r
- Identifier[Index] = 0x5a;\r
- }\r
- }\r
-\r
- MonotonicPointer = (UINT32 *) Identifier;\r
- gBS->GetNextMonotonicCount (&MonotonicCount);\r
- MonotonicPointer[0] += (UINT32) MonotonicCount;\r
- MonotonicPointer[1] += (UINT32) MonotonicCount;\r
- MonotonicPointer[2] += (UINT32) MonotonicCount;\r
- MonotonicPointer[3] += (UINT32) MonotonicCount;\r
-}\r
-\r
-\r
-/**\r
- Generate unique user ID.\r
-\r
- @param[out] UserId Points to the user identifer.\r
-\r
-**/\r
-VOID\r
-GenerateUserId (\r
- OUT UINT8 *UserId\r
- )\r
-{\r
- EFI_STATUS Status;\r
- USER_PROFILE_ENTRY *UserProfile;\r
- EFI_USER_INFO *UserInfo;\r
- UINTN Index;\r
-\r
- //\r
- // Generate unique user ID\r
- //\r
- while (TRUE) {\r
- GenerateIdentifier (UserId);\r
- //\r
- // Check whether it's unique in user profile database.\r
- //\r
- if (mUserProfileDb == NULL) {\r
- return ;\r
- }\r
-\r
- for (Index = 0; Index < mUserProfileDb->UserProfileNum; Index++) {\r
- UserProfile = (USER_PROFILE_ENTRY *) (mUserProfileDb->UserProfile[Index]);\r
- UserInfo = NULL;\r
- Status = FindUserInfoByType (UserProfile, &UserInfo, EFI_USER_INFO_IDENTIFIER_RECORD);\r
- if (EFI_ERROR (Status)) {\r
- continue;\r
- }\r
-\r
- if (CompareMem ((UINT8 *) (UserInfo + 1), UserId, sizeof (EFI_USER_INFO_IDENTIFIER)) == 0) {\r
- break;\r
- }\r
- }\r
-\r
- if (Index == mUserProfileDb->UserProfileNum) {\r
- return ;\r
- }\r
- }\r
-}\r
-\r
-\r
-/**\r
- Expand user profile database.\r
-\r
- @retval TRUE Success to expand user profile database.\r
- @retval FALSE Fail to expand user profile database.\r
-\r
-**/\r
-BOOLEAN\r
-ExpandUsermUserProfileDb (\r
- VOID\r
- )\r
-{\r
- UINTN MaxNum;\r
- USER_PROFILE_DB *NewDataBase;\r
-\r
- //\r
- // Create new user profile database.\r
- //\r
- if (mUserProfileDb == NULL) {\r
- MaxNum = USER_NUMBER_INC;\r
- } else {\r
- MaxNum = mUserProfileDb->MaxProfileNum + USER_NUMBER_INC;\r
- }\r
-\r
- NewDataBase = AllocateZeroPool (\r
- sizeof (USER_PROFILE_DB) - sizeof (EFI_USER_PROFILE_HANDLE) +\r
- MaxNum * sizeof (EFI_USER_PROFILE_HANDLE)\r
- );\r
- if (NewDataBase == NULL) {\r
- return FALSE;\r
- }\r
-\r
- NewDataBase->MaxProfileNum = MaxNum;\r
-\r
- //\r
- // Copy old user profile database value\r
- //\r
- if (mUserProfileDb == NULL) {\r
- NewDataBase->UserProfileNum = 0;\r
- } else {\r
- NewDataBase->UserProfileNum = mUserProfileDb->UserProfileNum;\r
- CopyMem (\r
- NewDataBase->UserProfile,\r
- mUserProfileDb->UserProfile,\r
- NewDataBase->UserProfileNum * sizeof (EFI_USER_PROFILE_HANDLE)\r
- );\r
- FreePool (mUserProfileDb);\r
- }\r
-\r
- mUserProfileDb = NewDataBase;\r
- return TRUE;\r
-}\r
-\r
-\r
-/**\r
- Expand user profile\r
-\r
- @param[in] User Points to user profile.\r
- @param[in] ExpandSize The size of user profile.\r
-\r
- @retval TRUE Success to expand user profile size.\r
- @retval FALSE Fail to expand user profile size.\r
-\r
-**/\r
-BOOLEAN\r
-ExpandUserProfile (\r
- IN USER_PROFILE_ENTRY *User,\r
- IN UINTN ExpandSize\r
- )\r
-{\r
- UINT8 *Info;\r
- UINTN InfoSizeInc;\r
-\r
- //\r
- // Allocate new memory.\r
- //\r
- InfoSizeInc = 128;\r
- User->MaxProfileSize += ((ExpandSize + InfoSizeInc - 1) / InfoSizeInc) * InfoSizeInc;\r
- Info = AllocateZeroPool (User->MaxProfileSize);\r
- if (Info == NULL) {\r
- return FALSE;\r
- }\r
-\r
- //\r
- // Copy exist information.\r
- //\r
- if (User->UserProfileSize > 0) {\r
- CopyMem (Info, User->ProfileInfo, User->UserProfileSize);\r
- FreePool (User->ProfileInfo);\r
- }\r
-\r
- User->ProfileInfo = Info;\r
- return TRUE;\r
-}\r
-\r
-\r
-/**\r
- Save the user profile to non-volatile memory, or delete it from non-volatile memory.\r
-\r
- @param[in] User Point to the user profile\r
- @param[in] Delete If TRUE, delete the found user profile.\r
- If FALSE, save the user profile.\r
- @retval EFI_SUCCESS Save or delete user profile successfully.\r
- @retval Others Fail to change the profile.\r
-\r
-**/\r
-EFI_STATUS\r
-SaveNvUserProfile (\r
- IN USER_PROFILE_ENTRY *User,\r
- IN BOOLEAN Delete\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- //\r
- // Check user profile entry.\r
- //\r
- Status = FindUserProfile (&User, FALSE, NULL);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Save the user profile to non-volatile memory.\r
- //\r
- Status = gRT->SetVariable (\r
- User->UserVarName,\r
- &gUserIdentifyManagerGuid,\r
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
- Delete ? 0 : User->UserProfileSize,\r
- User->ProfileInfo\r
- );\r
- return Status;\r
-}\r
-\r
-/**\r
- Add one new user info into the user's profile.\r
-\r
- @param[in] User point to the user profile\r
- @param[in] Info Points to the user information payload.\r
- @param[in] InfoSize The size of the user information payload, in bytes.\r
- @param[out] UserInfo Point to the new info in user profile\r
- @param[in] Save If TRUE, save the profile to NV flash.\r
- If FALSE, don't need to save the profile to NV flash.\r
-\r
- @retval EFI_SUCCESS Add user info to user profile successfully.\r
- @retval Others Fail to add user info to user profile.\r
-\r
-**/\r
-EFI_STATUS\r
-AddUserInfo (\r
- IN USER_PROFILE_ENTRY *User,\r
- IN UINT8 *Info,\r
- IN UINTN InfoSize,\r
- OUT EFI_USER_INFO **UserInfo, OPTIONAL\r
- IN BOOLEAN Save\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- if ((Info == NULL) || (User == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Check user profile handle.\r
- //\r
- Status = FindUserProfile (&User, FALSE, NULL);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Check user information memory size.\r
- //\r
- if (User->MaxProfileSize - User->UserProfileSize < ALIGN_VARIABLE (InfoSize)) {\r
- if (!ExpandUserProfile (User, ALIGN_VARIABLE (InfoSize))) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- }\r
-\r
- //\r
- // Add new user information.\r
- //\r
- CopyMem (User->ProfileInfo + User->UserProfileSize, Info, InfoSize);\r
- if (UserInfo != NULL) {\r
- *UserInfo = (EFI_USER_INFO *) (User->ProfileInfo + User->UserProfileSize);\r
- }\r
- User->UserProfileSize += ALIGN_VARIABLE (InfoSize);\r
-\r
- //\r
- // Save user profile information.\r
- //\r
- if (Save) {\r
- Status = SaveNvUserProfile (User, FALSE);\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Get the user info from the specified user info handle.\r
-\r
- @param[in] User Point to the user profile.\r
- @param[in] UserInfo Point to the user information record to get.\r
- @param[out] Info On entry, points to a buffer of at least *InfoSize bytes.\r
- On exit, holds the user information.\r
- @param[in, out] InfoSize On entry, points to the size of Info.\r
- On return, points to the size of the user information.\r
- @param[in] ChkRight If TRUE, check the user info attribute.\r
- If FALSE, don't check the user info attribute.\r
-\r
-\r
- @retval EFI_ACCESS_DENIED The information cannot be accessed by the current user.\r
- @retval EFI_INVALID_PARAMETER InfoSize is NULL or UserInfo is NULL.\r
- @retval EFI_BUFFER_TOO_SMALL The number of bytes specified by *InfoSize is too small to hold the\r
- returned data. The actual size required is returned in *InfoSize.\r
- @retval EFI_SUCCESS Information returned successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-GetUserInfo (\r
- IN USER_PROFILE_ENTRY *User,\r
- IN EFI_USER_INFO *UserInfo,\r
- OUT EFI_USER_INFO *Info,\r
- IN OUT UINTN *InfoSize,\r
- IN BOOLEAN ChkRight\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- if ((InfoSize == NULL) || (UserInfo == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if ((*InfoSize != 0) && (Info == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Find the user information to get.\r
- //\r
- Status = FindUserInfo (User, &UserInfo, FALSE, NULL);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Check information attributes.\r
- //\r
- if (ChkRight) {\r
- switch (UserInfo->InfoAttribs & EFI_USER_INFO_ACCESS) {\r
- case EFI_USER_INFO_PRIVATE:\r
- case EFI_USER_INFO_PROTECTED:\r
- if (User != mCurrentUser) {\r
- return EFI_ACCESS_DENIED;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_PUBLIC:\r
- break;\r
-\r
- default:\r
- return EFI_INVALID_PARAMETER;\r
- break;\r
- }\r
- }\r
-\r
- //\r
- // Get user information.\r
- //\r
- if (UserInfo->InfoSize > *InfoSize) {\r
- *InfoSize = UserInfo->InfoSize;\r
- return EFI_BUFFER_TOO_SMALL;\r
- }\r
-\r
- *InfoSize = UserInfo->InfoSize;\r
- if (Info != NULL) {\r
- CopyMem (Info, UserInfo, *InfoSize);\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Delete the specified user information from user profile.\r
-\r
- @param[in] User Point to the user profile.\r
- @param[in] Info Point to the user information record to delete.\r
- @param[in] Save If TRUE, save the profile to NV flash.\r
- If FALSE, don't need to save the profile to NV flash.\r
-\r
- @retval EFI_SUCCESS Delete user info from user profile successfully.\r
- @retval Others Fail to delete user info from user profile.\r
-\r
-**/\r
-EFI_STATUS\r
-DelUserInfo (\r
- IN USER_PROFILE_ENTRY *User,\r
- IN EFI_USER_INFO *Info,\r
- IN BOOLEAN Save\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Offset;\r
- UINTN NextOffset;\r
-\r
- //\r
- // Check user information handle.\r
- //\r
- Status = FindUserInfo (User, &Info, FALSE, &Offset);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- if (Info->InfoType == EFI_USER_INFO_IDENTIFIER_RECORD) {\r
- return EFI_ACCESS_DENIED;\r
- }\r
-\r
- //\r
- // Delete the specified user information.\r
- //\r
- NextOffset = Offset + ALIGN_VARIABLE (Info->InfoSize);\r
- User->UserProfileSize -= ALIGN_VARIABLE (Info->InfoSize);\r
- if (Offset < User->UserProfileSize) {\r
- CopyMem (User->ProfileInfo + Offset, User->ProfileInfo + NextOffset, User->UserProfileSize - Offset);\r
- }\r
-\r
- if (Save) {\r
- Status = SaveNvUserProfile (User, FALSE);\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Add or update user information.\r
-\r
- @param[in] User Point to the user profile.\r
- @param[in, out] UserInfo On entry, points to the user information to modify,\r
- or NULL to add a new UserInfo.\r
- On return, points to the modified user information.\r
- @param[in] Info Points to the new user information.\r
- @param[in] InfoSize The size of Info,in bytes.\r
-\r
- @retval EFI_INVALID_PARAMETER UserInfo is NULL or Info is NULL.\r
- @retval EFI_ACCESS_DENIED The record is exclusive.\r
- @retval EFI_SUCCESS User information was successfully changed/added.\r
-\r
-**/\r
-EFI_STATUS\r
-ModifyUserInfo (\r
- IN USER_PROFILE_ENTRY *User,\r
- IN OUT EFI_USER_INFO **UserInfo,\r
- IN CONST EFI_USER_INFO *Info,\r
- IN UINTN InfoSize\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN PayloadLen;\r
- EFI_USER_INFO *OldInfo;\r
-\r
- if ((UserInfo == NULL) || (Info == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (InfoSize < sizeof (EFI_USER_INFO) || InfoSize != Info->InfoSize) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Check user information.\r
- //\r
- if (Info->InfoType == EFI_USER_INFO_IDENTIFIER_RECORD) {\r
- return EFI_ACCESS_DENIED;\r
- }\r
-\r
- if (!CheckUserInfo (Info)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
-\r
- if (*UserInfo == NULL) {\r
- //\r
- // Add new user information.\r
- //\r
- OldInfo = NULL;\r
- do {\r
- Status = FindUserInfoByType (User, &OldInfo, Info->InfoType);\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
- ASSERT (OldInfo != NULL);\r
-\r
- if (((OldInfo->InfoAttribs & EFI_USER_INFO_EXCLUSIVE) != 0) ||\r
- ((Info->InfoAttribs & EFI_USER_INFO_EXCLUSIVE) != 0)) {\r
- //\r
- // Same type can not co-exist for exclusive information.\r
- //\r
- return EFI_ACCESS_DENIED;\r
- }\r
-\r
- //\r
- // Check whether it exists in DB.\r
- //\r
- if (Info->InfoSize != OldInfo->InfoSize) {\r
- continue;\r
- }\r
-\r
- if (!CompareGuid (&OldInfo->Credential, &Info->Credential)) {\r
- continue;\r
- }\r
-\r
- PayloadLen = Info->InfoSize - sizeof (EFI_USER_INFO);\r
- if (PayloadLen == 0) {\r
- continue;\r
- }\r
-\r
- if (CompareMem ((UINT8 *)(OldInfo + 1), (UINT8 *)(Info + 1), PayloadLen) != 0) {\r
- continue;\r
- }\r
-\r
- //\r
- // Yes. The new info is as same as the one in profile.\r
- //\r
- return EFI_SUCCESS;\r
- } while (!EFI_ERROR (Status));\r
-\r
- Status = AddUserInfo (User, (UINT8 *) Info, InfoSize, UserInfo, TRUE);\r
- return Status;\r
- }\r
-\r
- //\r
- // Modify existing user information.\r
- //\r
- OldInfo = *UserInfo;\r
- if (OldInfo->InfoType != Info->InfoType) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (((Info->InfoAttribs & EFI_USER_INFO_EXCLUSIVE) != 0) &&\r
- (OldInfo->InfoAttribs & EFI_USER_INFO_EXCLUSIVE) == 0) {\r
- //\r
- // Try to add exclusive attrib in new info.\r
- // Check whether there is another information with the same type in profile.\r
- //\r
- OldInfo = NULL;\r
- do {\r
- Status = FindUserInfoByType (User, &OldInfo, Info->InfoType);\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
- if (OldInfo != *UserInfo) {\r
- //\r
- // There is another information with the same type in profile.\r
- // Therefore, can't modify existing user information to add exclusive attribute.\r
- //\r
- return EFI_ACCESS_DENIED;\r
- }\r
- } while (TRUE);\r
- }\r
-\r
- Status = DelUserInfo (User, *UserInfo, FALSE);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- return AddUserInfo (User, (UINT8 *) Info, InfoSize, UserInfo, TRUE);\r
-}\r
-\r
-\r
-/**\r
- Delete the user profile from non-volatile memory and database.\r
-\r
- @param[in] User Points to the user profile.\r
-\r
- @retval EFI_SUCCESS Delete user from the user profile successfully.\r
- @retval Others Fail to delete user from user profile\r
-\r
-**/\r
-EFI_STATUS\r
-DelUserProfile (\r
- IN USER_PROFILE_ENTRY *User\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Index;\r
-\r
- //\r
- // Check whether it is in the user profile database.\r
- //\r
- Status = FindUserProfile (&User, FALSE, &Index);\r
- if (EFI_ERROR (Status)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Check whether it is the current user.\r
- //\r
- if (User == mCurrentUser) {\r
- return EFI_ACCESS_DENIED;\r
- }\r
-\r
- //\r
- // Delete user profile from the non-volatile memory.\r
- //\r
- Status = SaveNvUserProfile (mUserProfileDb->UserProfile[mUserProfileDb->UserProfileNum - 1], TRUE);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- mUserProfileDb->UserProfileNum--;\r
-\r
- //\r
- // Modify user profile database.\r
- //\r
- if (Index != mUserProfileDb->UserProfileNum) {\r
- mUserProfileDb->UserProfile[Index] = mUserProfileDb->UserProfile[mUserProfileDb->UserProfileNum];\r
- CopyMem (\r
- ((USER_PROFILE_ENTRY *) mUserProfileDb->UserProfile[Index])->UserVarName,\r
- User->UserVarName,\r
- sizeof (User->UserVarName)\r
- );\r
- Status = SaveNvUserProfile (mUserProfileDb->UserProfile[Index], FALSE);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- }\r
- //\r
- // Delete user profile information.\r
- //\r
- if (User->ProfileInfo != NULL) {\r
- FreePool (User->ProfileInfo);\r
- }\r
-\r
- FreePool (User);\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Add user profile to user profile database.\r
-\r
- @param[out] UserProfile Point to the newly added user profile.\r
- @param[in] ProfileSize The size of the user profile.\r
- @param[in] ProfileInfo Point to the user profie data.\r
- @param[in] Save If TRUE, save the new added profile to NV flash.\r
- If FALSE, don't save the profile to NV flash.\r
-\r
- @retval EFI_SUCCESS Add user profile to user profile database successfully.\r
- @retval Others Fail to add user profile to user profile database.\r
-\r
-**/\r
-EFI_STATUS\r
-AddUserProfile (\r
- OUT USER_PROFILE_ENTRY **UserProfile, OPTIONAL\r
- IN UINTN ProfileSize,\r
- IN UINT8 *ProfileInfo,\r
- IN BOOLEAN Save\r
- )\r
-{\r
- EFI_STATUS Status;\r
- USER_PROFILE_ENTRY *User;\r
-\r
- //\r
- // Check the data format to be added.\r
- //\r
- if (!CheckProfileInfo (ProfileInfo, ProfileSize)) {\r
- return EFI_SECURITY_VIOLATION;\r
- }\r
-\r
- //\r
- // Create user profile entry.\r
- //\r
- User = AllocateZeroPool (sizeof (USER_PROFILE_ENTRY));\r
- if (User == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- //\r
- // Add the entry to the user profile database.\r
- //\r
- if (mUserProfileDb->UserProfileNum == mUserProfileDb->MaxProfileNum) {\r
- if (!ExpandUsermUserProfileDb ()) {\r
- FreePool (User);\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- }\r
-\r
- UnicodeSPrint (\r
- User->UserVarName,\r
- sizeof (User->UserVarName),\r
- L"User%04x",\r
- mUserProfileDb->UserProfileNum\r
- );\r
- User->UserProfileSize = 0;\r
- User->MaxProfileSize = 0;\r
- User->ProfileInfo = NULL;\r
- mUserProfileDb->UserProfile[mUserProfileDb->UserProfileNum] = (EFI_USER_PROFILE_HANDLE) User;\r
- mUserProfileDb->UserProfileNum++;\r
-\r
- //\r
- // Add user profile information.\r
- //\r
- Status = AddUserInfo (User, ProfileInfo, ProfileSize, NULL, Save);\r
- if (EFI_ERROR (Status)) {\r
- DelUserProfile (User);\r
- return Status;\r
- }\r
- //\r
- // Set new user profile handle.\r
- //\r
- if (UserProfile != NULL) {\r
- *UserProfile = User;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- This function creates a new user profile with only a new user identifier\r
- attached and returns its handle. The user profile is non-volatile, but the\r
- handle User can change across reboots.\r
-\r
- @param[out] User Handle of a new user profile.\r
-\r
- @retval EFI_SUCCESS User profile was successfully created.\r
- @retval Others Fail to create user profile\r
-\r
-**/\r
-EFI_STATUS\r
-CreateUserProfile (\r
- OUT USER_PROFILE_ENTRY **User\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *UserInfo;\r
-\r
- if (User == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- //\r
- // Generate user id information.\r
- //\r
- UserInfo = AllocateZeroPool (sizeof (EFI_USER_INFO) + sizeof (EFI_USER_INFO_IDENTIFIER));\r
- if (UserInfo == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- UserInfo->InfoType = EFI_USER_INFO_IDENTIFIER_RECORD;\r
- UserInfo->InfoSize = sizeof (EFI_USER_INFO) + sizeof (EFI_USER_INFO_IDENTIFIER);\r
- UserInfo->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;\r
- GenerateUserId ((UINT8 *) (UserInfo + 1));\r
-\r
- //\r
- // Add user profile to the user profile database.\r
- //\r
- Status = AddUserProfile (User, UserInfo->InfoSize, (UINT8 *) UserInfo, TRUE);\r
- FreePool (UserInfo);\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Add a default user profile to user profile database.\r
-\r
- @retval EFI_SUCCESS A default user profile is added successfully.\r
- @retval Others Fail to add a default user profile\r
-\r
-**/\r
-EFI_STATUS\r
-AddDefaultUserProfile (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- USER_PROFILE_ENTRY *User;\r
- EFI_USER_INFO *Info;\r
- EFI_USER_INFO *NewInfo;\r
- EFI_USER_INFO_CREATE_DATE CreateDate;\r
- EFI_USER_INFO_USAGE_COUNT UsageCount;\r
- EFI_USER_INFO_ACCESS_CONTROL *Access;\r
- EFI_USER_INFO_IDENTITY_POLICY *Policy;\r
-\r
- //\r
- // Create a user profile.\r
- //\r
- Status = CreateUserProfile (&User);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Allocate a buffer to add all default user information.\r
- //\r
- Info = AllocateZeroPool (sizeof (EFI_USER_INFO) + INFO_PAYLOAD_SIZE);\r
- if (Info == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- //\r
- // Add user name.\r
- //\r
- Info->InfoType = EFI_USER_INFO_NAME_RECORD;\r
- Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;\r
- Info->InfoSize = sizeof (EFI_USER_INFO) + sizeof (mUserName);\r
- CopyMem ((UINT8 *) (Info + 1), mUserName, sizeof (mUserName));\r
- NewInfo = NULL;\r
- Status = ModifyUserInfo (User, &NewInfo, Info, Info->InfoSize);\r
- if (EFI_ERROR (Status)) {\r
- goto Done;\r
- }\r
-\r
- //\r
- // Add user profile create date record.\r
- //\r
- Info->InfoType = EFI_USER_INFO_CREATE_DATE_RECORD;\r
- Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;\r
- Info->InfoSize = sizeof (EFI_USER_INFO) + sizeof (EFI_USER_INFO_CREATE_DATE);\r
- Status = gRT->GetTime (&CreateDate, NULL);\r
- if (EFI_ERROR (Status)) {\r
- goto Done;\r
- }\r
-\r
- CopyMem ((UINT8 *) (Info + 1), &CreateDate, sizeof (EFI_USER_INFO_CREATE_DATE));\r
- NewInfo = NULL;\r
- Status = ModifyUserInfo (User, &NewInfo, Info, Info->InfoSize);\r
- if (EFI_ERROR (Status)) {\r
- goto Done;\r
- }\r
-\r
- //\r
- // Add user profile usage count record.\r
- //\r
- Info->InfoType = EFI_USER_INFO_USAGE_COUNT_RECORD;\r
- Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;\r
- Info->InfoSize = sizeof (EFI_USER_INFO) + sizeof (EFI_USER_INFO_USAGE_COUNT);\r
- UsageCount = 0;\r
- CopyMem ((UINT8 *) (Info + 1), &UsageCount, sizeof (EFI_USER_INFO_USAGE_COUNT));\r
- NewInfo = NULL;\r
- Status = ModifyUserInfo (User, &NewInfo, Info, Info->InfoSize);\r
- if (EFI_ERROR (Status)) {\r
- goto Done;\r
- }\r
-\r
- //\r
- // Add user access right.\r
- //\r
- Info->InfoType = EFI_USER_INFO_ACCESS_POLICY_RECORD;\r
- Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;\r
- Access = (EFI_USER_INFO_ACCESS_CONTROL *) (Info + 1);\r
- Access->Type = EFI_USER_INFO_ACCESS_MANAGE;\r
- Access->Size = sizeof (EFI_USER_INFO_ACCESS_CONTROL);\r
- Info->InfoSize = sizeof (EFI_USER_INFO) + Access->Size;\r
- NewInfo = NULL;\r
- Status = ModifyUserInfo (User, &NewInfo, Info, Info->InfoSize);\r
- if (EFI_ERROR (Status)) {\r
- goto Done;\r
- }\r
-\r
- //\r
- // Add user identity policy.\r
- //\r
- Info->InfoType = EFI_USER_INFO_IDENTITY_POLICY_RECORD;\r
- Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PRIVATE | EFI_USER_INFO_EXCLUSIVE;\r
- Policy = (EFI_USER_INFO_IDENTITY_POLICY *) (Info + 1);\r
- Policy->Type = EFI_USER_INFO_IDENTITY_TRUE;\r
- Policy->Length = sizeof (EFI_USER_INFO_IDENTITY_POLICY);\r
- Info->InfoSize = sizeof (EFI_USER_INFO) + Policy->Length;\r
- NewInfo = NULL;\r
- Status = ModifyUserInfo (User, &NewInfo, Info, Info->InfoSize);\r
-\r
-Done:\r
- FreePool (Info);\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Publish current user information into EFI System Configuration Table.\r
-\r
- By UEFI spec, the User Identity Manager will publish the current user profile\r
- into the EFI System Configuration Table. Currently, only the user identifier and user\r
- name are published.\r
-\r
- @retval EFI_SUCCESS Current user information is published successfully.\r
- @retval Others Fail to publish current user information\r
-\r
-**/\r
-EFI_STATUS\r
-PublishUserTable (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_CONFIGURATION_TABLE *EfiConfigurationTable;\r
- EFI_USER_INFO_TABLE *UserInfoTable;\r
- EFI_USER_INFO *IdInfo;\r
- EFI_USER_INFO *NameInfo;\r
-\r
- Status = EfiGetSystemConfigurationTable (\r
- &gEfiUserManagerProtocolGuid,\r
- (VOID **) &EfiConfigurationTable\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- //\r
- // The table existed!\r
- //\r
- return EFI_SUCCESS;\r
- }\r
-\r
- //\r
- // Get user ID information.\r
- //\r
- IdInfo = NULL;\r
- Status = FindUserInfoByType (mCurrentUser, &IdInfo, EFI_USER_INFO_IDENTIFIER_RECORD);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
-\r
- }\r
- //\r
- // Get user name information.\r
- //\r
- NameInfo = NULL;\r
- Status = FindUserInfoByType (mCurrentUser, &NameInfo, EFI_USER_INFO_NAME_RECORD);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Allocate a buffer for user information table.\r
- //\r
- UserInfoTable = (EFI_USER_INFO_TABLE *) AllocateRuntimePool (\r
- sizeof (EFI_USER_INFO_TABLE) +\r
- IdInfo->InfoSize +\r
- NameInfo->InfoSize\r
- );\r
- if (UserInfoTable == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- return Status;\r
- }\r
-\r
- UserInfoTable->Size = sizeof (EFI_USER_INFO_TABLE);\r
-\r
- //\r
- // Append the user information to the user info table\r
- //\r
- CopyMem ((UINT8 *) UserInfoTable + UserInfoTable->Size, (UINT8 *) IdInfo, IdInfo->InfoSize);\r
- UserInfoTable->Size += IdInfo->InfoSize;\r
-\r
- CopyMem ((UINT8 *) UserInfoTable + UserInfoTable->Size, (UINT8 *) NameInfo, NameInfo->InfoSize);\r
- UserInfoTable->Size += NameInfo->InfoSize;\r
-\r
- Status = gBS->InstallConfigurationTable (&gEfiUserManagerProtocolGuid, (VOID *) UserInfoTable);\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Get the user's identity type.\r
-\r
- The identify manager only supports the identity policy in which the credential\r
- provider handles are connected by the operator 'AND' or 'OR'.\r
-\r
-\r
- @param[in] User Handle of a user profile.\r
- @param[out] PolicyType Point to the identity type.\r
-\r
- @retval EFI_SUCCESS Get user's identity type successfully.\r
- @retval Others Fail to get user's identity type.\r
-\r
-**/\r
-EFI_STATUS\r
-GetIdentifyType (\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- OUT UINT8 *PolicyType\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *IdentifyInfo;\r
- UINTN TotalLen;\r
- EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
-\r
- //\r
- // Get user identify policy information.\r
- //\r
- IdentifyInfo = NULL;\r
- Status = FindUserInfoByType (User, &IdentifyInfo, EFI_USER_INFO_IDENTITY_POLICY_RECORD);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- ASSERT (IdentifyInfo != NULL);\r
-\r
- //\r
- // Search the user identify policy according to type.\r
- //\r
- TotalLen = 0;\r
- *PolicyType = EFI_USER_INFO_IDENTITY_FALSE;\r
- while (TotalLen < IdentifyInfo->InfoSize - sizeof (EFI_USER_INFO)) {\r
- Identity = (EFI_USER_INFO_IDENTITY_POLICY *) ((UINT8 *) (IdentifyInfo + 1) + TotalLen);\r
- if (Identity->Type == EFI_USER_INFO_IDENTITY_AND) {\r
- *PolicyType = EFI_USER_INFO_IDENTITY_AND;\r
- break;\r
- }\r
-\r
- if (Identity->Type == EFI_USER_INFO_IDENTITY_OR) {\r
- *PolicyType = EFI_USER_INFO_IDENTITY_OR;\r
- break;\r
- }\r
- TotalLen += Identity->Length;\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Identify the User by the specfied provider.\r
-\r
- @param[in] User Handle of a user profile.\r
- @param[in] Provider Points to the identifier of credential provider.\r
-\r
- @retval EFI_INVALID_PARAMETER Provider is NULL.\r
- @retval EFI_NOT_FOUND Fail to identify the specified user.\r
- @retval EFI_SUCCESS User is identified successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-IdentifyByProviderId (\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN EFI_GUID *Provider\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO_IDENTIFIER UserId;\r
- UINTN Index;\r
- EFI_CREDENTIAL_LOGON_FLAGS AutoLogon;\r
- EFI_HII_HANDLE HiiHandle;\r
- EFI_GUID FormSetId;\r
- EFI_FORM_ID FormId;\r
- EFI_USER_CREDENTIAL2_PROTOCOL *UserCredential;\r
-\r
- if (Provider == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Check the user ID identified by the specified credential provider.\r
- //\r
- for (Index = 0; Index < mProviderDb->Count; Index++) {\r
- //\r
- // Check credential provider class.\r
- //\r
- UserCredential = mProviderDb->Provider[Index];\r
- if (CompareGuid (&UserCredential->Identifier, Provider)) {\r
- Status = UserCredential->Select (UserCredential, &AutoLogon);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- if ((AutoLogon & EFI_CREDENTIAL_LOGON_FLAG_AUTO) == 0) {\r
- //\r
- // Get credential provider form.\r
- //\r
- Status = UserCredential->Form (\r
- UserCredential,\r
- &HiiHandle,\r
- &FormSetId,\r
- &FormId\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- //\r
- // Send form to get user input.\r
- //\r
- Status = mCallbackInfo->FormBrowser2->SendForm (\r
- mCallbackInfo->FormBrowser2,\r
- &HiiHandle,\r
- 1,\r
- &FormSetId,\r
- FormId,\r
- NULL,\r
- NULL\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- }\r
- }\r
-\r
- Status = UserCredential->User (UserCredential, User, &UserId);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- Status = UserCredential->Deselect (UserCredential);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- return EFI_SUCCESS;\r
- }\r
- }\r
-\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
- Update user information when user is logon on successfully.\r
-\r
- @param[in] User Points to user profile.\r
-\r
- @retval EFI_SUCCESS Update user information successfully.\r
- @retval Others Fail to update user information.\r
-\r
-**/\r
-EFI_STATUS\r
-UpdateUserInfo (\r
- IN USER_PROFILE_ENTRY *User\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *Info;\r
- EFI_USER_INFO *NewInfo;\r
- EFI_USER_INFO_CREATE_DATE Date;\r
- EFI_USER_INFO_USAGE_COUNT UsageCount;\r
- UINTN InfoLen;\r
-\r
- //\r
- // Allocate a buffer to update user's date record and usage record.\r
- //\r
- InfoLen = MAX (sizeof (EFI_USER_INFO_CREATE_DATE), sizeof (EFI_USER_INFO_USAGE_COUNT));\r
- Info = AllocateZeroPool (sizeof (EFI_USER_INFO) + InfoLen);\r
- if (Info == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- //\r
- // Check create date record.\r
- //\r
- NewInfo = NULL;\r
- Status = FindUserInfoByType (User, &NewInfo, EFI_USER_INFO_CREATE_DATE_RECORD);\r
- if (Status == EFI_NOT_FOUND) {\r
- Info->InfoType = EFI_USER_INFO_CREATE_DATE_RECORD;\r
- Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;\r
- Info->InfoSize = sizeof (EFI_USER_INFO) + sizeof (EFI_USER_INFO_CREATE_DATE);\r
- Status = gRT->GetTime (&Date, NULL);\r
- if (EFI_ERROR (Status)) {\r
- FreePool (Info);\r
- return Status;\r
- }\r
-\r
- CopyMem ((UINT8 *) (Info + 1), &Date, sizeof (EFI_USER_INFO_CREATE_DATE));\r
- NewInfo = NULL;\r
- Status = ModifyUserInfo (User, &NewInfo, Info, Info->InfoSize);\r
- if (EFI_ERROR (Status)) {\r
- FreePool (Info);\r
- return Status;\r
- }\r
- }\r
-\r
- //\r
- // Update usage date record.\r
- //\r
- NewInfo = NULL;\r
- Status = FindUserInfoByType (User, &NewInfo, EFI_USER_INFO_USAGE_DATE_RECORD);\r
- if ((Status == EFI_SUCCESS) || (Status == EFI_NOT_FOUND)) {\r
- Info->InfoType = EFI_USER_INFO_USAGE_DATE_RECORD;\r
- Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;\r
- Info->InfoSize = sizeof (EFI_USER_INFO) + sizeof (EFI_USER_INFO_USAGE_DATE);\r
- Status = gRT->GetTime (&Date, NULL);\r
- if (EFI_ERROR (Status)) {\r
- FreePool (Info);\r
- return Status;\r
- }\r
-\r
- CopyMem ((UINT8 *) (Info + 1), &Date, sizeof (EFI_USER_INFO_USAGE_DATE));\r
- Status = ModifyUserInfo (User, &NewInfo, Info, Info->InfoSize);\r
- if (EFI_ERROR (Status)) {\r
- FreePool (Info);\r
- return Status;\r
- }\r
- }\r
-\r
- //\r
- // Update usage count record.\r
- //\r
- UsageCount = 0;\r
- NewInfo = NULL;\r
- Status = FindUserInfoByType (User, &NewInfo, EFI_USER_INFO_USAGE_COUNT_RECORD);\r
- //\r
- // Get usage count.\r
- //\r
- if (Status == EFI_SUCCESS) {\r
- CopyMem (&UsageCount, (UINT8 *) (NewInfo + 1), sizeof (EFI_USER_INFO_USAGE_COUNT));\r
- }\r
-\r
- UsageCount++;\r
- if ((Status == EFI_SUCCESS) || (Status == EFI_NOT_FOUND)) {\r
- Info->InfoType = EFI_USER_INFO_USAGE_COUNT_RECORD;\r
- Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;\r
- Info->InfoSize = sizeof (EFI_USER_INFO) + sizeof (EFI_USER_INFO_USAGE_COUNT);\r
- CopyMem ((UINT8 *) (Info + 1), &UsageCount, sizeof (EFI_USER_INFO_USAGE_COUNT));\r
- Status = ModifyUserInfo (User, &NewInfo, Info, Info->InfoSize);\r
- if (EFI_ERROR (Status)) {\r
- FreePool (Info);\r
- return Status;\r
- }\r
- }\r
-\r
- FreePool (Info);\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Add a credenetial provider item in form.\r
-\r
- @param[in] ProviderGuid Points to the identifir of credential provider.\r
- @param[in] OpCodeHandle Points to container for dynamic created opcodes.\r
-\r
-**/\r
-VOID\r
-AddProviderSelection (\r
- IN EFI_GUID *ProviderGuid,\r
- IN VOID *OpCodeHandle\r
- )\r
-{\r
- EFI_HII_HANDLE HiiHandle;\r
- EFI_STRING_ID ProvID;\r
- CHAR16 *ProvStr;\r
- UINTN Index;\r
- EFI_USER_CREDENTIAL2_PROTOCOL *UserCredential;\r
-\r
- for (Index = 0; Index < mProviderDb->Count; Index++) {\r
- UserCredential = mProviderDb->Provider[Index];\r
- if (CompareGuid (&UserCredential->Identifier, ProviderGuid)) {\r
- //\r
- // Add credential provider selection.\r
- //\r
- UserCredential->Title (UserCredential, &HiiHandle, &ProvID);\r
- ProvStr = HiiGetString (HiiHandle, ProvID, NULL);\r
- if (ProvStr == NULL) {\r
- continue ;\r
- }\r
- ProvID = HiiSetString (mCallbackInfo->HiiHandle, 0, ProvStr, NULL);\r
- FreePool (ProvStr);\r
- HiiCreateActionOpCode (\r
- OpCodeHandle, // Container for dynamic created opcodes\r
- (EFI_QUESTION_ID)(LABEL_PROVIDER_NAME + Index), // Question ID\r
- ProvID, // Prompt text\r
- STRING_TOKEN (STR_NULL_STRING), // Help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- 0 // Action String ID\r
- );\r
- break;\r
- }\r
- }\r
-}\r
-\r
-\r
-/**\r
- Add a username item in form.\r
-\r
- @param[in] Index The index of the user in the user name list.\r
- @param[in] User Points to the user profile whose username is added.\r
- @param[in] OpCodeHandle Points to container for dynamic created opcodes.\r
-\r
- @retval EFI_SUCCESS Add a username successfully.\r
- @retval Others Fail to add a username.\r
-\r
-**/\r
-EFI_STATUS\r
-AddUserSelection (\r
- IN UINT16 Index,\r
- IN USER_PROFILE_ENTRY *User,\r
- IN VOID *OpCodeHandle\r
- )\r
-{\r
- EFI_STRING_ID UserName;\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *UserInfo;\r
-\r
- UserInfo = NULL;\r
- Status = FindUserInfoByType (User, &UserInfo, EFI_USER_INFO_NAME_RECORD);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Add user name selection.\r
- //\r
- UserName = HiiSetString (mCallbackInfo->HiiHandle, 0, (EFI_STRING) (UserInfo + 1), NULL);\r
- if (UserName == 0) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- HiiCreateGotoOpCode (\r
- OpCodeHandle, // Container for dynamic created opcodes\r
- FORMID_PROVIDER_FORM, // Target Form ID\r
- UserName, // Prompt text\r
- STRING_TOKEN (STR_NULL_STRING), // Help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- (UINT16) Index // Question ID\r
- );\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Identify the user whose identity policy does not contain the operator 'OR'.\r
-\r
- @param[in] User Points to the user profile.\r
-\r
- @retval EFI_SUCCESS The specified user is identified successfully.\r
- @retval Others Fail to identify the user.\r
-\r
-**/\r
-EFI_STATUS\r
-IdentifyAndTypeUser (\r
- IN USER_PROFILE_ENTRY *User\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *IdentifyInfo;\r
- BOOLEAN Success;\r
- UINTN TotalLen;\r
- UINTN ValueLen;\r
- EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
-\r
- //\r
- // Get user identify policy information.\r
- //\r
- IdentifyInfo = NULL;\r
- Status = FindUserInfoByType (User, &IdentifyInfo, EFI_USER_INFO_IDENTITY_POLICY_RECORD);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- ASSERT (IdentifyInfo != NULL);\r
-\r
- //\r
- // Check each part of identification policy expression.\r
- //\r
- Success = FALSE;\r
- TotalLen = 0;\r
- while (TotalLen < IdentifyInfo->InfoSize - sizeof (EFI_USER_INFO)) {\r
- Identity = (EFI_USER_INFO_IDENTITY_POLICY *) ((UINT8 *) (IdentifyInfo + 1) + TotalLen);\r
- ValueLen = Identity->Length - sizeof (EFI_USER_INFO_IDENTITY_POLICY);\r
- switch (Identity->Type) {\r
-\r
- case EFI_USER_INFO_IDENTITY_FALSE:\r
- //\r
- // Check False option.\r
- //\r
- Success = FALSE;\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_TRUE:\r
- //\r
- // Check True option.\r
- //\r
- Success = TRUE;\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_NOT:\r
- //\r
- // Check negative operation.\r
- //\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_AND:\r
- //\r
- // Check and operation.\r
- //\r
- if (!Success) {\r
- return EFI_NOT_READY;\r
- }\r
-\r
- Success = FALSE;\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_OR:\r
- //\r
- // Check or operation.\r
- //\r
- if (Success) {\r
- return EFI_SUCCESS;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_CREDENTIAL_TYPE:\r
- //\r
- // Check credential provider by type.\r
- //\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER:\r
- //\r
- // Check credential provider by ID.\r
- //\r
- if (ValueLen != sizeof (EFI_GUID)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- Status = IdentifyByProviderId (User, (EFI_GUID *) (Identity + 1));\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- Success = TRUE;\r
- break;\r
-\r
- default:\r
- return EFI_INVALID_PARAMETER;\r
- break;\r
- }\r
-\r
- TotalLen += Identity->Length;\r
- }\r
-\r
- if (TotalLen != IdentifyInfo->InfoSize - sizeof (EFI_USER_INFO)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (!Success) {\r
- return EFI_NOT_READY;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Identify the user whose identity policy does not contain the operator 'AND'.\r
-\r
- @param[in] User Points to the user profile.\r
-\r
- @retval EFI_SUCCESS The specified user is identified successfully.\r
- @retval Others Fail to identify the user.\r
-\r
-**/\r
-EFI_STATUS\r
-IdentifyOrTypeUser (\r
- IN USER_PROFILE_ENTRY *User\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *IdentifyInfo;\r
- UINTN TotalLen;\r
- UINTN ValueLen;\r
- EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
- VOID *StartOpCodeHandle;\r
- VOID *EndOpCodeHandle;\r
- EFI_IFR_GUID_LABEL *StartLabel;\r
- EFI_IFR_GUID_LABEL *EndLabel;\r
-\r
- //\r
- // Get user identify policy information.\r
- //\r
- IdentifyInfo = NULL;\r
- Status = FindUserInfoByType (User, &IdentifyInfo, EFI_USER_INFO_IDENTITY_POLICY_RECORD);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- ASSERT (IdentifyInfo != NULL);\r
-\r
- //\r
- // Initialize the container for dynamic opcodes.\r
- //\r
- StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (StartOpCodeHandle != NULL);\r
-\r
- EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (EndOpCodeHandle != NULL);\r
-\r
- //\r
- // Create Hii Extend Label OpCode.\r
- //\r
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- StartOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- StartLabel->Number = LABEL_PROVIDER_NAME;\r
-\r
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- EndOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- EndLabel->Number = LABEL_END;\r
-\r
- //\r
- // Add the providers that exists in the user's policy.\r
- //\r
- TotalLen = 0;\r
- while (TotalLen < IdentifyInfo->InfoSize - sizeof (EFI_USER_INFO)) {\r
- Identity = (EFI_USER_INFO_IDENTITY_POLICY *) ((UINT8 *) (IdentifyInfo + 1) + TotalLen);\r
- ValueLen = Identity->Length - sizeof (EFI_USER_INFO_IDENTITY_POLICY);\r
- if (Identity->Type == EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER) {\r
- AddProviderSelection ((EFI_GUID *) (Identity + 1), StartOpCodeHandle);\r
- }\r
-\r
- TotalLen += Identity->Length;\r
- }\r
-\r
- HiiUpdateForm (\r
- mCallbackInfo->HiiHandle, // HII handle\r
- &gUserIdentifyManagerGuid,// Formset GUID\r
- FORMID_PROVIDER_FORM, // Form ID\r
- StartOpCodeHandle, // Label for where to insert opcodes\r
- EndOpCodeHandle // Replace data\r
- );\r
-\r
- HiiFreeOpCodeHandle (StartOpCodeHandle);\r
- HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- This function processes the results of changes in configuration.\r
-\r
- @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
- @param Action Specifies the type of action taken by the browser.\r
- @param QuestionId A unique value which is sent to the original\r
- exporting driver so that it can identify the type\r
- of data to expect.\r
- @param Type The type of value for the question.\r
- @param Value A pointer to the data being sent to the original\r
- exporting driver.\r
- @param ActionRequest On return, points to the action requested by the\r
- callback function.\r
-\r
- @retval EFI_SUCCESS The callback successfully handled the action.\r
- @retval Others Fail to handle the action.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserIdentifyManagerCallback (\r
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
- IN EFI_BROWSER_ACTION Action,\r
- IN EFI_QUESTION_ID QuestionId,\r
- IN UINT8 Type,\r
- IN EFI_IFR_TYPE_VALUE *Value,\r
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r
- )\r
-{\r
- EFI_STATUS Status;\r
- USER_PROFILE_ENTRY *User;\r
- UINT8 PolicyType;\r
- UINT16 Index;\r
- VOID *StartOpCodeHandle;\r
- VOID *EndOpCodeHandle;\r
- EFI_IFR_GUID_LABEL *StartLabel;\r
- EFI_IFR_GUID_LABEL *EndLabel;\r
-\r
- Status = EFI_SUCCESS;\r
-\r
- switch (Action) {\r
- case EFI_BROWSER_ACTION_FORM_OPEN:\r
- {\r
- //\r
- // Update user Form when user Form is opened.\r
- // This will be done only in FORM_OPEN CallBack of question with FORM_OPEN_QUESTION_ID from user Form.\r
- //\r
- if (QuestionId != FORM_OPEN_QUESTION_ID) {\r
- return EFI_SUCCESS;\r
- }\r
-\r
- //\r
- // Initialize the container for dynamic opcodes.\r
- //\r
- StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (StartOpCodeHandle != NULL);\r
-\r
- EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (EndOpCodeHandle != NULL);\r
-\r
- //\r
- // Create Hii Extend Label OpCode.\r
- //\r
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- StartOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- StartLabel->Number = LABEL_USER_NAME;\r
-\r
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- EndOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- EndLabel->Number = LABEL_END;\r
-\r
- //\r
- // Add all the user profile in the user profile database.\r
- //\r
- for (Index = 0; Index < mUserProfileDb->UserProfileNum; Index++) {\r
- User = (USER_PROFILE_ENTRY *) mUserProfileDb->UserProfile[Index];\r
- AddUserSelection ((UINT16)(LABEL_USER_NAME + Index), User, StartOpCodeHandle);\r
- }\r
-\r
- HiiUpdateForm (\r
- mCallbackInfo->HiiHandle, // HII handle\r
- &gUserIdentifyManagerGuid,// Formset GUID\r
- FORMID_USER_FORM, // Form ID\r
- StartOpCodeHandle, // Label for where to insert opcodes\r
- EndOpCodeHandle // Replace data\r
- );\r
-\r
- HiiFreeOpCodeHandle (StartOpCodeHandle);\r
- HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-\r
- return EFI_SUCCESS;\r
- }\r
- break;\r
-\r
- case EFI_BROWSER_ACTION_FORM_CLOSE:\r
- Status = EFI_SUCCESS;\r
- break;\r
-\r
- case EFI_BROWSER_ACTION_CHANGED:\r
- if (QuestionId >= LABEL_PROVIDER_NAME) {\r
- //\r
- // QuestionId comes from the second Form (Select a Credential Provider if identity\r
- // policy is OR type). Identify the user by the selected provider.\r
- //\r
- Status = IdentifyByProviderId (mCurrentUser, &mProviderDb->Provider[QuestionId & 0xFFF]->Identifier);\r
- if (Status == EFI_SUCCESS) {\r
- mIdentified = TRUE;\r
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;\r
- }\r
- return EFI_SUCCESS;\r
- }\r
- break;\r
-\r
- case EFI_BROWSER_ACTION_CHANGING:\r
- //\r
- // QuestionId comes from the first Form (Select a user to identify).\r
- //\r
- if (QuestionId >= LABEL_PROVIDER_NAME) {\r
- return EFI_SUCCESS;\r
- }\r
-\r
- User = (USER_PROFILE_ENTRY *) mUserProfileDb->UserProfile[QuestionId & 0xFFF];\r
- Status = GetIdentifyType (User, &PolicyType);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- if (PolicyType == EFI_USER_INFO_IDENTITY_OR) {\r
- //\r
- // Identify the user by "OR" logical.\r
- //\r
- Status = IdentifyOrTypeUser (User);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- mCurrentUser = (EFI_USER_PROFILE_HANDLE) User;\r
- } else {\r
- //\r
- // Identify the user by "AND" logical.\r
- //\r
- Status = IdentifyAndTypeUser (User);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- mCurrentUser = (EFI_USER_PROFILE_HANDLE) User;\r
- mIdentified = TRUE;\r
- if (Type == EFI_IFR_TYPE_REF) {\r
- Value->ref.FormId = FORMID_INVALID_FORM;\r
- }\r
- }\r
- break;\r
-\r
- default:\r
- //\r
- // All other action return unsupported.\r
- //\r
- Status = EFI_UNSUPPORTED;\r
- break;\r
- }\r
-\r
-\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- This function construct user profile database from user data saved in the Flash.\r
- If no user is found in Flash, add one default user "administrator" in the user\r
- profile database.\r
-\r
- @retval EFI_SUCCESS Init user profile database successfully.\r
- @retval Others Fail to init user profile database.\r
-\r
-**/\r
-EFI_STATUS\r
-InitUserProfileDb (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINT8 *VarData;\r
- UINTN VarSize;\r
- UINTN CurVarSize;\r
- CHAR16 VarName[10];\r
- UINTN Index;\r
- UINT32 VarAttr;\r
-\r
- if (mUserProfileDb != NULL) {\r
- //\r
- // The user profiles had been already initialized.\r
- //\r
- return EFI_SUCCESS;\r
- }\r
-\r
- //\r
- // Init user profile database structure.\r
- //\r
- if (!ExpandUsermUserProfileDb ()) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- CurVarSize = DEFAULT_PROFILE_SIZE;\r
- VarData = AllocateZeroPool (CurVarSize);\r
- if (VarData == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- //\r
- // Get all user proifle entries.\r
- //\r
- Index = 0;\r
- while (TRUE) {\r
- //\r
- // Get variable name.\r
- //\r
- UnicodeSPrint (\r
- VarName,\r
- sizeof (VarName),\r
- L"User%04x",\r
- Index\r
- );\r
- Index++;\r
-\r
- //\r
- // Get variable value.\r
- //\r
- VarSize = CurVarSize;\r
- Status = gRT->GetVariable (VarName, &gUserIdentifyManagerGuid, &VarAttr, &VarSize, VarData);\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- FreePool (VarData);\r
- VarData = AllocatePool (VarSize);\r
- if (VarData == NULL) {\r
- Status = EFI_OUT_OF_RESOURCES;\r
- break;\r
- }\r
-\r
- CurVarSize = VarSize;\r
- Status = gRT->GetVariable (VarName, &gUserIdentifyManagerGuid, &VarAttr, &VarSize, VarData);\r
- }\r
-\r
- if (EFI_ERROR (Status)) {\r
- if (Status == EFI_NOT_FOUND) {\r
- Status = EFI_SUCCESS;\r
- }\r
- break;\r
- }\r
-\r
- //\r
- // Check variable attributes.\r
- //\r
- if (VarAttr != (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)) {\r
- Status = gRT->SetVariable (VarName, &gUserIdentifyManagerGuid, VarAttr, 0, NULL);\r
- continue;\r
- }\r
-\r
- //\r
- // Add user profile to the user profile database.\r
- //\r
- Status = AddUserProfile (NULL, VarSize, VarData, FALSE);\r
- if (EFI_ERROR (Status)) {\r
- if (Status == EFI_SECURITY_VIOLATION) {\r
- //\r
- // Delete invalid user profile\r
- //\r
- gRT->SetVariable (VarName, &gUserIdentifyManagerGuid, VarAttr, 0, NULL);\r
- } else if (Status == EFI_OUT_OF_RESOURCES) {\r
- break;\r
- }\r
- } else {\r
- //\r
- // Delete and save the profile again if some invalid profiles are deleted.\r
- //\r
- if (mUserProfileDb->UserProfileNum < Index) {\r
- gRT->SetVariable (VarName, &gUserIdentifyManagerGuid, VarAttr, 0, NULL);\r
- SaveNvUserProfile (mUserProfileDb->UserProfile[mUserProfileDb->UserProfileNum - 1], FALSE);\r
- }\r
- }\r
- }\r
-\r
- if (VarData != NULL) {\r
- FreePool (VarData);\r
- }\r
-\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Check whether the user profile database is empty.\r
- //\r
- if (mUserProfileDb->UserProfileNum == 0) {\r
- Status = AddDefaultUserProfile ();\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- This function collects all the credential providers and saves to mProviderDb.\r
-\r
- @retval EFI_SUCCESS Collect credential providers successfully.\r
- @retval Others Fail to collect credential providers.\r
-\r
-**/\r
-EFI_STATUS\r
-InitProviderInfo (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN HandleCount;\r
- EFI_HANDLE *HandleBuf;\r
- UINTN Index;\r
-\r
- if (mProviderDb != NULL) {\r
- //\r
- // The credential providers had been collected before.\r
- //\r
- return EFI_SUCCESS;\r
- }\r
-\r
- //\r
- // Try to find all the user credential provider driver.\r
- //\r
- HandleCount = 0;\r
- HandleBuf = NULL;\r
- Status = gBS->LocateHandleBuffer (\r
- ByProtocol,\r
- &gEfiUserCredential2ProtocolGuid,\r
- NULL,\r
- &HandleCount,\r
- &HandleBuf\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Get provider infomation.\r
- //\r
- mProviderDb = AllocateZeroPool (\r
- sizeof (CREDENTIAL_PROVIDER_INFO) -\r
- sizeof (EFI_USER_CREDENTIAL2_PROTOCOL *) +\r
- HandleCount * sizeof (EFI_USER_CREDENTIAL2_PROTOCOL *)\r
- );\r
- if (mProviderDb == NULL) {\r
- FreePool (HandleBuf);\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- mProviderDb->Count = HandleCount;\r
- for (Index = 0; Index < HandleCount; Index++) {\r
- Status = gBS->HandleProtocol (\r
- HandleBuf[Index],\r
- &gEfiUserCredential2ProtocolGuid,\r
- (VOID **) &mProviderDb->Provider[Index]\r
- );\r
- if (EFI_ERROR (Status)) {\r
- FreePool (HandleBuf);\r
- FreePool (mProviderDb);\r
- mProviderDb = NULL;\r
- return Status;\r
- }\r
- }\r
-\r
- FreePool (HandleBuf);\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- This function allows a caller to extract the current configuration for one\r
- or more named elements from the target driver.\r
-\r
-\r
- @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
- @param Request A null-terminated Unicode string in <ConfigRequest> format.\r
- @param Progress On return, points to a character in the Request string.\r
- Points to the string's null terminator if request was successful.\r
- Points to the most recent '&' before the first failing name/value\r
- pair (or the beginning of the string if the failure is in the\r
- first name/value pair) if the request was not successful.\r
- @param Results A null-terminated Unicode string in <ConfigAltResp> format which\r
- has all values filled in for the names in the Request string.\r
- String to be allocated by the called function.\r
-\r
- @retval EFI_SUCCESS The Results is filled with the requested values.\r
- @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.\r
- @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.\r
- @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FakeExtractConfig (\r
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
- IN CONST EFI_STRING Request,\r
- OUT EFI_STRING *Progress,\r
- OUT EFI_STRING *Results\r
- )\r
-{\r
- if (Progress == NULL || Results == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- *Progress = Request;\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
- This function processes the results of changes in configuration.\r
-\r
-\r
- @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
- @param Configuration A null-terminated Unicode string in <ConfigResp> format.\r
- @param Progress A pointer to a string filled in with the offset of the most\r
- recent '&' before the first failing name/value pair (or the\r
- beginning of the string if the failure is in the first\r
- name/value pair) or the terminating NULL if all was successful.\r
-\r
- @retval EFI_SUCCESS The Results is processed successfully.\r
- @retval EFI_INVALID_PARAMETER Configuration is NULL.\r
- @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FakeRouteConfig (\r
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
- IN CONST EFI_STRING Configuration,\r
- OUT EFI_STRING *Progress\r
- )\r
-{\r
- if (Configuration == NULL || Progress == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- *Progress = Configuration;\r
-\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
- This function initialize the data mainly used in form browser.\r
-\r
- @retval EFI_SUCCESS Initialize form data successfully.\r
- @retval Others Fail to Initialize form data.\r
-\r
-**/\r
-EFI_STATUS\r
-InitFormBrowser (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- USER_MANAGER_CALLBACK_INFO *CallbackInfo;\r
- EFI_HII_DATABASE_PROTOCOL *HiiDatabase;\r
- EFI_HII_STRING_PROTOCOL *HiiString;\r
- EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;\r
-\r
- //\r
- // Initialize driver private data.\r
- //\r
- CallbackInfo = AllocateZeroPool (sizeof (USER_MANAGER_CALLBACK_INFO));\r
- if (CallbackInfo == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- CallbackInfo->Signature = USER_MANAGER_SIGNATURE;\r
- CallbackInfo->ConfigAccess.ExtractConfig = FakeExtractConfig;\r
- CallbackInfo->ConfigAccess.RouteConfig = FakeRouteConfig;\r
- CallbackInfo->ConfigAccess.Callback = UserIdentifyManagerCallback;\r
-\r
- //\r
- // Locate Hii Database protocol.\r
- //\r
- Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID **) &HiiDatabase);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- CallbackInfo->HiiDatabase = HiiDatabase;\r
-\r
- //\r
- // Locate HiiString protocol.\r
- //\r
- Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **) &HiiString);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- CallbackInfo->HiiString = HiiString;\r
-\r
- //\r
- // Locate Formbrowser2 protocol.\r
- //\r
- Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, (VOID **) &FormBrowser2);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- CallbackInfo->FormBrowser2 = FormBrowser2;\r
- CallbackInfo->DriverHandle = NULL;\r
-\r
- //\r
- // Install Device Path Protocol and Config Access protocol to driver handle.\r
- //\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &CallbackInfo->DriverHandle,\r
- &gEfiDevicePathProtocolGuid,\r
- &mHiiVendorDevicePath,\r
- &gEfiHiiConfigAccessProtocolGuid,\r
- &CallbackInfo->ConfigAccess,\r
- NULL\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- //\r
- // Publish HII data.\r
- //\r
- CallbackInfo->HiiHandle = HiiAddPackages (\r
- &gUserIdentifyManagerGuid,\r
- CallbackInfo->DriverHandle,\r
- UserIdentifyManagerStrings,\r
- UserIdentifyManagerVfrBin,\r
- NULL\r
- );\r
- if (CallbackInfo->HiiHandle == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- mCallbackInfo = CallbackInfo;\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Identify the user whose identification policy supports auto logon.\r
-\r
- @param[in] ProviderIndex The provider index in the provider list.\r
- @param[out] User Points to user user profile if a user is identified successfully.\r
-\r
- @retval EFI_SUCCESS Identify a user with the specified provider successfully.\r
- @retval Others Fail to identify a user.\r
-\r
-**/\r
-EFI_STATUS\r
-IdentifyAutoLogonUser (\r
- IN UINTN ProviderIndex,\r
- OUT USER_PROFILE_ENTRY **User\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *Info;\r
- UINT8 PolicyType;\r
-\r
- Info = AllocateZeroPool (sizeof (EFI_USER_INFO) + sizeof (EFI_USER_INFO_IDENTIFIER));\r
- if (Info == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- Info->InfoType = EFI_USER_INFO_IDENTIFIER_RECORD;\r
- Info->InfoSize = sizeof (EFI_USER_INFO) + sizeof (EFI_USER_INFO_IDENTIFIER);\r
-\r
- //\r
- // Identify the specified credential provider's auto logon user.\r
- //\r
- Status = mProviderDb->Provider[ProviderIndex]->User (\r
- mProviderDb->Provider[ProviderIndex],\r
- NULL,\r
- (EFI_USER_INFO_IDENTIFIER *) (Info + 1)\r
- );\r
- if (EFI_ERROR (Status)) {\r
- FreePool (Info);\r
- return Status;\r
- }\r
-\r
- //\r
- // Find user with the specified user ID.\r
- //\r
- *User = NULL;\r
- Status = FindUserProfileByInfo (User, NULL, Info, Info->InfoSize);\r
- FreePool (Info);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- Status = GetIdentifyType ((EFI_USER_PROFILE_HANDLE) * User, &PolicyType);\r
- if (PolicyType == EFI_USER_INFO_IDENTITY_AND) {\r
- //\r
- // The identified user need also identified by other credential provider.\r
- // This can handle through select user.\r
- //\r
- return EFI_NOT_READY;\r
- }\r
-\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Check whether the given console is ready.\r
-\r
- @param[in] ProtocolGuid Points to the protocol guid of sonsole .\r
-\r
- @retval TRUE The given console is ready.\r
- @retval FALSE The given console is not ready.\r
-\r
-**/\r
-BOOLEAN\r
-CheckConsole (\r
- EFI_GUID *ProtocolGuid\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN HandleCount;\r
- EFI_HANDLE *HandleBuf;\r
- UINTN Index;\r
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
-\r
- //\r
- // Try to find all the handle driver.\r
- //\r
- HandleCount = 0;\r
- HandleBuf = NULL;\r
- Status = gBS->LocateHandleBuffer (\r
- ByProtocol,\r
- ProtocolGuid,\r
- NULL,\r
- &HandleCount,\r
- &HandleBuf\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return FALSE;\r
- }\r
-\r
- for (Index = 0; Index < HandleCount; Index++) {\r
- DevicePath = DevicePathFromHandle (HandleBuf[Index]);\r
- if (DevicePath != NULL) {\r
- FreePool (HandleBuf);\r
- return TRUE;\r
- }\r
- }\r
- FreePool (HandleBuf);\r
- return FALSE;\r
-}\r
-\r
-\r
-/**\r
- Check whether the console is ready.\r
-\r
- @retval TRUE The console is ready.\r
- @retval FALSE The console is not ready.\r
-\r
-**/\r
-BOOLEAN\r
-IsConsoleReady (\r
- VOID\r
- )\r
-{\r
- if (!CheckConsole (&gEfiSimpleTextOutProtocolGuid)) {\r
- return FALSE;\r
- }\r
-\r
- if (!CheckConsole (&gEfiSimpleTextInProtocolGuid)) {\r
- if (!CheckConsole (&gEfiSimpleTextInputExProtocolGuid)) {\r
- return FALSE;\r
- }\r
- }\r
-\r
- return TRUE;\r
-}\r
-\r
-\r
-/**\r
- Identify a user to logon.\r
-\r
- @param[out] User Points to user user profile if a user is identified successfully.\r
-\r
- @retval EFI_SUCCESS Identify a user successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-IdentifyUser (\r
- OUT USER_PROFILE_ENTRY **User\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Index;\r
- EFI_CREDENTIAL_LOGON_FLAGS AutoLogon;\r
- EFI_USER_INFO *IdentifyInfo;\r
- EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
- EFI_USER_CREDENTIAL2_PROTOCOL *UserCredential;\r
- USER_PROFILE_ENTRY *UserEntry;\r
-\r
- //\r
- // Initialize credential providers.\r
- //\r
- InitProviderInfo ();\r
-\r
- //\r
- // Initialize user profile database.\r
- //\r
- InitUserProfileDb ();\r
-\r
- //\r
- // If only one user in system, and its identify policy is TRUE, then auto logon.\r
- //\r
- if (mUserProfileDb->UserProfileNum == 1) {\r
- UserEntry = (USER_PROFILE_ENTRY *) mUserProfileDb->UserProfile[0];\r
- IdentifyInfo = NULL;\r
- Status = FindUserInfoByType (UserEntry, &IdentifyInfo, EFI_USER_INFO_IDENTITY_POLICY_RECORD);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- ASSERT (IdentifyInfo != NULL);\r
-\r
- Identity = (EFI_USER_INFO_IDENTITY_POLICY *) ((UINT8 *) (IdentifyInfo + 1));\r
- if (Identity->Type == EFI_USER_INFO_IDENTITY_TRUE) {\r
- mCurrentUser = (EFI_USER_PROFILE_HANDLE) UserEntry;\r
- UpdateUserInfo (UserEntry);\r
- *User = UserEntry;\r
- return EFI_SUCCESS;\r
- }\r
- }\r
-\r
- //\r
- // Find and login the default & AutoLogon user.\r
- //\r
- for (Index = 0; Index < mProviderDb->Count; Index++) {\r
- UserCredential = mProviderDb->Provider[Index];\r
- Status = UserCredential->Default (UserCredential, &AutoLogon);\r
- if (EFI_ERROR (Status)) {\r
- continue;\r
- }\r
-\r
- if ((AutoLogon & (EFI_CREDENTIAL_LOGON_FLAG_DEFAULT | EFI_CREDENTIAL_LOGON_FLAG_AUTO)) != 0) {\r
- Status = IdentifyAutoLogonUser (Index, &UserEntry);\r
- if (Status == EFI_SUCCESS) {\r
- mCurrentUser = (EFI_USER_PROFILE_HANDLE) UserEntry;\r
- UpdateUserInfo (UserEntry);\r
- *User = UserEntry;\r
- return EFI_SUCCESS;\r
- }\r
- }\r
- }\r
-\r
- if (!IsConsoleReady ()) {\r
- //\r
- // The console is still not ready for user selection.\r
- //\r
- return EFI_ACCESS_DENIED;\r
- }\r
-\r
- //\r
- // Select a user and identify it.\r
- //\r
- mCallbackInfo->FormBrowser2->SendForm (\r
- mCallbackInfo->FormBrowser2,\r
- &mCallbackInfo->HiiHandle,\r
- 1,\r
- &gUserIdentifyManagerGuid,\r
- 0,\r
- NULL,\r
- NULL\r
- );\r
-\r
- if (mIdentified) {\r
- *User = (USER_PROFILE_ENTRY *) mCurrentUser;\r
- UpdateUserInfo (*User);\r
- return EFI_SUCCESS;\r
- }\r
-\r
- return EFI_ACCESS_DENIED;\r
-}\r
-\r
-\r
-/**\r
- An empty function to pass error checking of CreateEventEx ().\r
-\r
- @param Event Event whose notification function is being invoked.\r
- @param Context Pointer to the notification function's context,\r
- which is implementation-dependent.\r
-\r
-**/\r
-VOID\r
-EFIAPI\r
-InternalEmptyFuntion (\r
- IN EFI_EVENT Event,\r
- IN VOID *Context\r
- )\r
-{\r
-}\r
-\r
-\r
-/**\r
- Create, Signal, and Close the User Profile Changed event.\r
-\r
-**/\r
-VOID\r
-SignalEventUserProfileChanged (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_EVENT Event;\r
-\r
- Status = gBS->CreateEventEx (\r
- EVT_NOTIFY_SIGNAL,\r
- TPL_CALLBACK,\r
- InternalEmptyFuntion,\r
- NULL,\r
- &gEfiEventUserProfileChangedGuid,\r
- &Event\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
- gBS->SignalEvent (Event);\r
- gBS->CloseEvent (Event);\r
-}\r
-\r
-\r
-/**\r
- Create a new user profile.\r
-\r
- This function creates a new user profile with only a new user identifier attached and returns\r
- its handle. The user profile is non-volatile, but the handle User can change across reboots.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.\r
- @param[out] User On return, points to the new user profile handle.\r
- The user profile handle is unique only during this boot.\r
-\r
- @retval EFI_SUCCESS User profile was successfully created.\r
- @retval EFI_ACCESS_DENIED Current user does not have sufficient permissions to create a\r
- user profile.\r
- @retval EFI_UNSUPPORTED Creation of new user profiles is not supported.\r
- @retval EFI_INVALID_PARAMETER The User parameter is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileCreate (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- OUT EFI_USER_PROFILE_HANDLE *User\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- if ((This == NULL) || (User == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Check the right of the current user.\r
- //\r
- if (!CheckCurrentUserAccessRight (EFI_USER_INFO_ACCESS_MANAGE)) {\r
- if (!CheckCurrentUserAccessRight (EFI_USER_INFO_ACCESS_ENROLL_OTHERS)) {\r
- return EFI_ACCESS_DENIED;\r
- }\r
- }\r
-\r
- //\r
- // Create new user profile\r
- //\r
- Status = CreateUserProfile ((USER_PROFILE_ENTRY **) User);\r
- if (EFI_ERROR (Status)) {\r
- return EFI_ACCESS_DENIED;\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Delete an existing user profile.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.\r
- @param[in] User User profile handle.\r
-\r
- @retval EFI_SUCCESS User profile was successfully deleted.\r
- @retval EFI_ACCESS_DENIED Current user does not have sufficient permissions to delete a user\r
- profile or there is only one user profile.\r
- @retval EFI_UNSUPPORTED Deletion of new user profiles is not supported.\r
- @retval EFI_INVALID_PARAMETER User does not refer to a valid user profile.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileDelete (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- if (This == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Check the right of the current user.\r
- //\r
- if (!CheckCurrentUserAccessRight (EFI_USER_INFO_ACCESS_MANAGE)) {\r
- return EFI_ACCESS_DENIED;\r
- }\r
-\r
- //\r
- // Delete user profile.\r
- //\r
- Status = DelUserProfile (User);\r
- if (EFI_ERROR (Status)) {\r
- if (Status != EFI_INVALID_PARAMETER) {\r
- return EFI_ACCESS_DENIED;\r
- }\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Enumerate all of the enrolled users on the platform.\r
-\r
- This function returns the next enrolled user profile. To retrieve the first user profile handle,\r
- point User at a NULL. Each subsequent call will retrieve another user profile handle until there\r
- are no more, at which point User will point to NULL.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.\r
- @param[in, out] User On entry, points to the previous user profile handle or NULL to\r
- start enumeration. On exit, points to the next user profile handle\r
- or NULL if there are no more user profiles.\r
-\r
- @retval EFI_SUCCESS Next enrolled user profile successfully returned.\r
- @retval EFI_ACCESS_DENIED Next enrolled user profile was not successfully returned.\r
- @retval EFI_INVALID_PARAMETER The User parameter is NULL.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileGetNext (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN OUT EFI_USER_PROFILE_HANDLE *User\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- if ((This == NULL) || (User == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- Status = FindUserProfile ((USER_PROFILE_ENTRY **) User, TRUE, NULL);\r
- if (EFI_ERROR (Status)) {\r
- return EFI_ACCESS_DENIED;\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Return the current user profile handle.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.\r
- @param[out] CurrentUser On return, points to the current user profile handle.\r
-\r
- @retval EFI_SUCCESS Current user profile handle returned successfully.\r
- @retval EFI_INVALID_PARAMETER The CurrentUser parameter is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileCurrent (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- OUT EFI_USER_PROFILE_HANDLE *CurrentUser\r
- )\r
-{\r
- //\r
- // Get current user profile.\r
- //\r
- if ((This == NULL) || (CurrentUser == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- *CurrentUser = mCurrentUser;\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Identify a user.\r
-\r
- Identify the user and, if authenticated, returns the user handle and changes the current\r
- user profile. All user information marked as private in a previously selected profile\r
- is no longer available for inspection.\r
- Whenever the current user profile is changed then the an event with the GUID\r
- EFI_EVENT_GROUP_USER_PROFILE_CHANGED is signaled.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.\r
- @param[out] User On return, points to the user profile handle for the current\r
- user profile.\r
-\r
- @retval EFI_SUCCESS User was successfully identified.\r
- @retval EFI_ACCESS_DENIED User was not successfully identified.\r
- @retval EFI_INVALID_PARAMETER The User parameter is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileIdentify (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- OUT EFI_USER_PROFILE_HANDLE *User\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- if ((This == NULL) || (User == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (mCurrentUser != NULL) {\r
- *User = mCurrentUser;\r
- return EFI_SUCCESS;\r
- }\r
-\r
- //\r
- // Identify user\r
- //\r
- Status = IdentifyUser ((USER_PROFILE_ENTRY **) User);\r
- if (EFI_ERROR (Status)) {\r
- return EFI_ACCESS_DENIED;\r
- }\r
-\r
- //\r
- // Publish the user info into the EFI system configuration table.\r
- //\r
- PublishUserTable ();\r
-\r
- //\r
- // Signal User Profile Changed event.\r
- //\r
- SignalEventUserProfileChanged ();\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- Find a user using a user information record.\r
-\r
- This function searches all user profiles for the specified user information record.\r
- The search starts with the user information record handle following UserInfo and\r
- continues until either the information is found or there are no more user profiles.\r
- A match occurs when the Info.InfoType field matches the user information record\r
- type and the user information record data matches the portion of Info.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.\r
- @param[in, out] User On entry, points to the previously returned user profile\r
- handle, or NULL to start searching with the first user profile.\r
- On return, points to the user profile handle, or NULL if not\r
- found.\r
- @param[in, out] UserInfo On entry, points to the previously returned user information\r
- handle, or NULL to start searching with the first. On return,\r
- points to the user information handle of the user information\r
- record, or NULL if not found. Can be NULL, in which case only\r
- one user information record per user can be returned.\r
- @param[in] Info Points to the buffer containing the user information to be\r
- compared to the user information record. If the user information\r
- record data is empty, then only the user information record type\r
- is compared. If InfoSize is 0, then the user information record\r
- must be empty.\r
-\r
- @param[in] InfoSize The size of Info, in bytes.\r
-\r
- @retval EFI_SUCCESS User information was found. User points to the user profile\r
- handle, and UserInfo points to the user information handle.\r
- @retval EFI_NOT_FOUND User information was not found. User points to NULL, and\r
- UserInfo points to NULL.\r
- @retval EFI_INVALID_PARAMETER User is NULL. Or Info is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileFind (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN OUT EFI_USER_PROFILE_HANDLE *User,\r
- IN OUT EFI_USER_INFO_HANDLE *UserInfo OPTIONAL,\r
- IN CONST EFI_USER_INFO *Info,\r
- IN UINTN InfoSize\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN Size;\r
-\r
- if ((This == NULL) || (User == NULL) || (Info == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if (InfoSize == 0) {\r
- //\r
- // If InfoSize is 0, then the user information record must be empty.\r
- //\r
- if (Info->InfoSize != sizeof (EFI_USER_INFO)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- } else {\r
- if (InfoSize != Info->InfoSize) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- }\r
- Size = Info->InfoSize;\r
-\r
- //\r
- // Find user profile accdoring to user information.\r
- //\r
- Status = FindUserProfileByInfo (\r
- (USER_PROFILE_ENTRY **) User,\r
- (EFI_USER_INFO **) UserInfo,\r
- (EFI_USER_INFO *) Info,\r
- Size\r
- );\r
- if (EFI_ERROR (Status)) {\r
- *User = NULL;\r
- if (UserInfo != NULL) {\r
- *UserInfo = NULL;\r
- }\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Return information attached to the user.\r
-\r
- This function returns user information. The format of the information is described in User\r
- Information. The function may return EFI_ACCESS_DENIED if the information is marked private\r
- and the handle specified by User is not the current user profile. The function may return\r
- EFI_ACCESS_DENIED if the information is marked protected and the information is associated\r
- with a credential provider for which the user has not been authenticated.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.\r
- @param[in] User Handle of the user whose profile will be retrieved.\r
- @param[in] UserInfo Handle of the user information data record.\r
- @param[out] Info On entry, points to a buffer of at least *InfoSize bytes. On exit,\r
- holds the user information. If the buffer is too small to hold the\r
- information, then EFI_BUFFER_TOO_SMALL is returned and InfoSize is\r
- updated to contain the number of bytes actually required.\r
- @param[in, out] InfoSize On entry, points to the size of Info. On return, points to the size\r
- of the user information.\r
-\r
- @retval EFI_SUCCESS Information returned successfully.\r
- @retval EFI_ACCESS_DENIED The information about the specified user cannot be accessed by the\r
- current user.\r
- @retval EFI_BUFFER_TOO_SMALL The number of bytes specified by *InfoSize is too small to hold the\r
- returned data. The actual size required is returned in *InfoSize.\r
- @retval EFI_NOT_FOUND User does not refer to a valid user profile or UserInfo does not refer\r
- to a valid user info handle.\r
- @retval EFI_INVALID_PARAMETER Info is NULL or InfoSize is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileGetInfo (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN EFI_USER_INFO_HANDLE UserInfo,\r
- OUT EFI_USER_INFO *Info,\r
- IN OUT UINTN *InfoSize\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- if ((This == NULL) || (InfoSize == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if ((*InfoSize != 0) && (Info == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- if ((User == NULL) || (UserInfo == NULL)) {\r
- return EFI_NOT_FOUND;\r
- }\r
-\r
- Status = GetUserInfo (User, UserInfo, Info, InfoSize, TRUE);\r
- if (EFI_ERROR (Status)) {\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- return EFI_BUFFER_TOO_SMALL;\r
- }\r
- return EFI_ACCESS_DENIED;\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Add or update user information.\r
-\r
- This function changes user information. If NULL is pointed to by UserInfo, then a new user\r
- information record is created and its handle is returned in UserInfo. Otherwise, the existing\r
- one is replaced.\r
- If EFI_USER_INFO_IDENITTY_POLICY_RECORD is changed, it is the caller's responsibility to keep\r
- it to be synced with the information on credential providers.\r
- If EFI_USER_INFO_EXCLUSIVE is specified in Info and a user information record of the same\r
- type already exists in the user profile, then EFI_ACCESS_DENIED will be returned and UserInfo\r
- will point to the handle of the existing record.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.\r
- @param[in] User Handle of the user whose profile will be retrieved.\r
- @param[in, out] UserInfo Handle of the user information data record.\r
- @param[in] Info On entry, points to a buffer of at least *InfoSize bytes. On exit,\r
- holds the user information. If the buffer is too small to hold the\r
- information, then EFI_BUFFER_TOO_SMALL is returned and InfoSize is\r
- updated to contain the number of bytes actually required.\r
- @param[in] InfoSize On entry, points to the size of Info. On return, points to the size\r
- of the user information.\r
-\r
- @retval EFI_SUCCESS Information returned successfully.\r
- @retval EFI_ACCESS_DENIED The record is exclusive.\r
- @retval EFI_SECURITY_VIOLATION The current user does not have permission to change the specified\r
- user profile or user information record.\r
- @retval EFI_NOT_FOUND User does not refer to a valid user profile or UserInfo does not\r
- refer to a valid user info handle.\r
- @retval EFI_INVALID_PARAMETER UserInfo is NULL or Info is NULL.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileSetInfo (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN OUT EFI_USER_INFO_HANDLE *UserInfo,\r
- IN CONST EFI_USER_INFO *Info,\r
- IN UINTN InfoSize\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- if ((This == NULL) || (User == NULL) || (UserInfo == NULL) || (Info == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Check the right of the current user.\r
- //\r
- if (User != mCurrentUser) {\r
- if (!CheckCurrentUserAccessRight (EFI_USER_INFO_ACCESS_MANAGE)) {\r
- if (*UserInfo != NULL) {\r
- //\r
- // Can't update info in other profiles without MANAGE right.\r
- //\r
- return EFI_SECURITY_VIOLATION;\r
- }\r
-\r
- if (!CheckCurrentUserAccessRight (EFI_USER_INFO_ACCESS_ENROLL_OTHERS)) {\r
- //\r
- // Can't add info into other profiles.\r
- //\r
- return EFI_SECURITY_VIOLATION;\r
- }\r
- }\r
- }\r
-\r
- if (User == mCurrentUser) {\r
- if (CheckCurrentUserAccessRight (EFI_USER_INFO_ACCESS_ENROLL_SELF)) {\r
- //\r
- // Only identify policy can be added/updated.\r
- //\r
- if (Info->InfoType != EFI_USER_INFO_IDENTITY_POLICY_RECORD) {\r
- return EFI_SECURITY_VIOLATION;\r
- }\r
- }\r
- }\r
-\r
- //\r
- // Modify user information.\r
- //\r
- Status = ModifyUserInfo (User, (EFI_USER_INFO **) UserInfo, Info, InfoSize);\r
- if (EFI_ERROR (Status)) {\r
- if (Status == EFI_ACCESS_DENIED) {\r
- return EFI_ACCESS_DENIED;\r
- }\r
- return EFI_SECURITY_VIOLATION;\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Called by credential provider to notify of information change.\r
-\r
- This function allows the credential provider to notify the User Identity Manager when user status\r
- has changed.\r
- If the User Identity Manager doesn't support asynchronous changes in credentials, then this function\r
- should return EFI_UNSUPPORTED.\r
- If current user does not exist, and the credential provider can identify a user, then make the user\r
- to be current user and signal the EFI_EVENT_GROUP_USER_PROFILE_CHANGED event.\r
- If current user already exists, and the credential provider can identify another user, then switch\r
- current user to the newly identified user, and signal the EFI_EVENT_GROUP_USER_PROFILE_CHANGED event.\r
- If current user was identified by this credential provider and now the credential provider cannot identify\r
- current user, then logout current user and signal the EFI_EVENT_GROUP_USER_PROFILE_CHANGED event.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.\r
- @param[in] Changed Handle on which is installed an instance of the EFI_USER_CREDENTIAL2_PROTOCOL\r
- where the user has changed.\r
-\r
- @retval EFI_SUCCESS The User Identity Manager has handled the notification.\r
- @retval EFI_NOT_READY The function was called while the specified credential provider was not selected.\r
- @retval EFI_UNSUPPORTED The User Identity Manager doesn't support asynchronous notifications.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileNotify (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN EFI_HANDLE Changed\r
- )\r
-{\r
- return EFI_UNSUPPORTED;\r
-}\r
-\r
-\r
-/**\r
- Delete user information.\r
-\r
- Delete the user information attached to the user profile specified by the UserInfo.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.\r
- @param[in] User Handle of the user whose information will be deleted.\r
- @param[in] UserInfo Handle of the user information to remove.\r
-\r
- @retval EFI_SUCCESS User information deleted successfully.\r
- @retval EFI_NOT_FOUND User information record UserInfo does not exist in the user profile.\r
- @retval EFI_ACCESS_DENIED The current user does not have permission to delete this user information.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileDeleteInfo (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN EFI_USER_INFO_HANDLE UserInfo\r
- )\r
-{\r
- EFI_STATUS Status;\r
-\r
- if (This == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Check the right of the current user.\r
- //\r
- if (User != mCurrentUser) {\r
- if (!CheckCurrentUserAccessRight (EFI_USER_INFO_ACCESS_MANAGE)) {\r
- return EFI_ACCESS_DENIED;\r
- }\r
- }\r
-\r
- //\r
- // Delete user information.\r
- //\r
- Status = DelUserInfo (User, UserInfo, TRUE);\r
- if (EFI_ERROR (Status)) {\r
- if (Status == EFI_NOT_FOUND) {\r
- return EFI_NOT_FOUND;\r
- }\r
- return EFI_ACCESS_DENIED;\r
- }\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Enumerate user information of all the enrolled users on the platform.\r
-\r
- This function returns the next user information record. To retrieve the first user\r
- information record handle, point UserInfo at a NULL. Each subsequent call will retrieve\r
- another user information record handle until there are no more, at which point UserInfo\r
- will point to NULL.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.\r
- @param[in] User Handle of the user whose information will be deleted.\r
- @param[in, out] UserInfo Handle of the user information to remove.\r
-\r
- @retval EFI_SUCCESS User information returned.\r
- @retval EFI_NOT_FOUND No more user information found.\r
- @retval EFI_INVALID_PARAMETER UserInfo is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileGetNextInfo (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN OUT EFI_USER_INFO_HANDLE *UserInfo\r
- )\r
-{\r
- if ((This == NULL) || (UserInfo == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- //\r
- // Get next user information entry.\r
- //\r
- return FindUserInfo (User, (EFI_USER_INFO **) UserInfo, TRUE, NULL);\r
-}\r
-\r
-\r
-/**\r
- Main entry for this driver.\r
-\r
- @param[in] ImageHandle Image handle this driver.\r
- @param[in] SystemTable Pointer to SystemTable.\r
-\r
- @retval EFI_SUCESS This function always complete successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserIdentifyManagerInit (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
-\r
- EFI_STATUS Status;\r
-\r
- //\r
- // It is NOT robust enough to be included in production.\r
- //\r
- #error "This implementation is just a sample, please comment this line if you really want to use this driver."\r
-\r
- //\r
- // Initiate form browser.\r
- //\r
- InitFormBrowser ();\r
-\r
- //\r
- // Install protocol interfaces for the User Identity Manager.\r
- //\r
- Status = gBS->InstallProtocolInterface (\r
- &mCallbackInfo->DriverHandle,\r
- &gEfiUserManagerProtocolGuid,\r
- EFI_NATIVE_INTERFACE,\r
- &gUserIdentifyManager\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- LoadDeferredImageInit (ImageHandle);\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
+++ /dev/null
-/** @file\r
- The header file for User identify Manager driver.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _USER_IDENTIFY_MANAGER_H_\r
-#define _USER_IDENTIFY_MANAGER_H_\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Guid/GlobalVariable.h>\r
-#include <Guid/MdeModuleHii.h>\r
-\r
-#include <Protocol/FormBrowser2.h>\r
-#include <Protocol/HiiDatabase.h>\r
-#include <Protocol/HiiConfigAccess.h>\r
-#include <Protocol/HiiString.h>\r
-#include <Protocol/HiiConfigRouting.h>\r
-#include <Protocol/UserCredential2.h>\r
-#include <Protocol/UserManager.h>\r
-#include <Protocol/DeferredImageLoad.h>\r
-#include <Protocol/SimpleTextOut.h>\r
-#include <Protocol/SimpleTextIn.h>\r
-#include <Protocol/SimpleTextInEx.h>\r
-\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/HiiLib.h>\r
-\r
-#include "UserIdentifyManagerData.h"\r
-\r
-//\r
-// This is the generated IFR binary data for each formset defined in VFR.\r
-// This data array is ready to be used as input of HiiAddPackages() to\r
-// create a packagelist.\r
-//\r
-extern UINT8 UserIdentifyManagerVfrBin[];\r
-\r
-//\r
-// This is the generated String package data for all .UNI files.\r
-// This data array is ready to be used as input of HiiAddPackages() to\r
-// create a packagelist.\r
-//\r
-extern UINT8 UserIdentifyManagerStrings[];\r
-\r
-#define USER_NUMBER_INC 32\r
-#define DEFAULT_PROFILE_SIZE 512\r
-#define INFO_PAYLOAD_SIZE 64\r
-\r
-//\r
-// Credential Provider Information.\r
-//\r
-typedef struct {\r
- UINTN Count;\r
- EFI_USER_CREDENTIAL2_PROTOCOL *Provider[1];\r
-} CREDENTIAL_PROVIDER_INFO;\r
-\r
-//\r
-// Internal user profile entry.\r
-//\r
-typedef struct {\r
- UINTN MaxProfileSize;\r
- UINTN UserProfileSize;\r
- CHAR16 UserVarName[9];\r
- UINT8 *ProfileInfo;\r
-} USER_PROFILE_ENTRY;\r
-\r
-//\r
-// Internal user profile database.\r
-//\r
-typedef struct {\r
- UINTN UserProfileNum;\r
- UINTN MaxProfileNum;\r
- EFI_USER_PROFILE_HANDLE UserProfile[1];\r
-} USER_PROFILE_DB;\r
-\r
-#define USER_MANAGER_SIGNATURE SIGNATURE_32 ('U', 'I', 'M', 'S')\r
-\r
-typedef struct {\r
- UINTN Signature;\r
- EFI_HANDLE DriverHandle;\r
- EFI_HII_HANDLE HiiHandle;\r
-\r
- //\r
- // Consumed protocol.\r
- //\r
- EFI_HII_DATABASE_PROTOCOL *HiiDatabase;\r
- EFI_HII_STRING_PROTOCOL *HiiString;\r
- EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;\r
- EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;\r
-\r
- //\r
- // Produced protocol.\r
- //\r
- EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;\r
-} USER_MANAGER_CALLBACK_INFO;\r
-\r
-///\r
-/// HII specific Vendor Device Path definition.\r
-///\r
-typedef struct {\r
- VENDOR_DEVICE_PATH VendorDevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL End;\r
-} HII_VENDOR_DEVICE_PATH;\r
-\r
-/**\r
- Register an event notification function for the user profile changed.\r
-\r
- @param[in] ImageHandle Image handle this driver.\r
-\r
-**/\r
-VOID\r
-LoadDeferredImageInit (\r
- IN EFI_HANDLE ImageHandle\r
- );\r
-\r
-\r
-/**\r
- This function creates a new user profile with only\r
- a new user identifier attached and returns its handle.\r
- The user profile is non-volatile, but the handle User\r
- can change across reboots.\r
-\r
- @param[in] This Protocol EFI_USER_MANAGER_PROTOCOL instance\r
- pointer.\r
- @param[out] User Handle of a new user profile.\r
-\r
- @retval EFI_SUCCESS User profile was successfully created.\r
- @retval EFI_ACCESS_DENIED Current user does not have sufficient permissions\r
- to create a user profile.\r
- @retval EFI_UNSUPPORTED Creation of new user profiles is not supported.\r
- @retval EFI_INVALID_PARAMETER User is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileCreate (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- OUT EFI_USER_PROFILE_HANDLE *User\r
- );\r
-\r
-\r
-/**\r
- Delete an existing user profile.\r
-\r
- @param This Protocol EFI_USER_MANAGER_PROTOCOL instance\r
- pointer.\r
- @param User User profile handle.\r
-\r
- @retval EFI_SUCCESS User profile was successfully deleted.\r
- @retval EFI_ACCESS_DENIED Current user does not have sufficient permissions\r
- to delete a user profile or there is only one\r
- user profile.\r
- @retval EFI_UNSUPPORTED Deletion of new user profiles is not supported.\r
- @retval EFI_INVALID_PARAMETER User does not refer to a valid user profile.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileDelete (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User\r
- );\r
-\r
-\r
-/**\r
- Get next user profile from the user profile database.\r
-\r
- @param[in] This Protocol EFI_USER_MANAGER_PROTOCOL instance\r
- pointer.\r
- @param[in, out] User User profile handle.\r
-\r
- @retval EFI_SUCCESS Next enrolled user profile successfully returned.\r
- @retval EFI_INVALID_PARAMETER User is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileGetNext (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN OUT EFI_USER_PROFILE_HANDLE *User\r
- );\r
-\r
-\r
-/**\r
- This function returns the current user profile handle.\r
-\r
- @param[in] This Protocol EFI_USER_MANAGER_PROTOCOL instance pointer.\r
- @param[out] CurrentUser User profile handle.\r
-\r
- @retval EFI_SUCCESS Current user profile handle returned successfully.\r
- @retval EFI_INVALID_PARAMETER CurrentUser is NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileCurrent (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- OUT EFI_USER_PROFILE_HANDLE *CurrentUser\r
- );\r
-\r
-\r
-/**\r
- Identify the user and, if authenticated, returns the user handle and changes\r
- the current user profile.\r
-\r
- @param This Protocol EFI_USER_MANAGER_PROTOCOL instance pointer.\r
- @param CurrentUser User profile handle.\r
-\r
- @retval EFI_SUCCESS User was successfully identified.\r
- @retval EFI_INVALID_PARAMETER User is NULL.\r
- @retval EFI_ACCESS_DENIED User was not successfully identified.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileIdentify (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- OUT EFI_USER_PROFILE_HANDLE *User\r
- );\r
-\r
-\r
-/**\r
- Find a user using a user information record.\r
-\r
- This function searches all user profiles for the specified user information record.\r
- The search starts with the user information record handle following UserInfo and\r
- continues until either the information is found or there are no more user profiles.\r
- A match occurs when the Info.InfoType field matches the user information record\r
- type and the user information record data matches the portion of Info passed the\r
- EFI_USER_INFO header.\r
-\r
- @param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.\r
- @param[in, out] User On entry, points to the previously returned user profile\r
- handle, or NULL to start searching with the first user profile.\r
- On return, points to the user profile handle, or NULL if not\r
- found.\r
- @param[in, out] UserInfo On entry, points to the previously returned user information\r
- handle, or NULL to start searching with the first. On return,\r
- points to the user information handle of the user information\r
- record, or NULL if not found. Can be NULL, in which case only\r
- one user information record per user can be returned.\r
- @param[in] Info Points to the buffer containing the user information to be\r
- compared to the user information record. If NULL, then only\r
- the user information record type is compared. If InfoSize is 0,\r
- then the user information record must be empty.\r
-\r
- @param[in] InfoSize The size of Info, in bytes.\r
-\r
- @retval EFI_SUCCESS User information was found. User points to the user profile handle,\r
- and UserInfo points to the user information handle.\r
- @retval EFI_NOT_FOUND User information was not found. User points to NULL and UserInfo\r
- points to NULL.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileFind (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN OUT EFI_USER_PROFILE_HANDLE *User,\r
- IN OUT EFI_USER_INFO_HANDLE *UserInfo OPTIONAL,\r
- IN CONST EFI_USER_INFO *Info,\r
- IN UINTN InfoSize\r
- );\r
-\r
-\r
-/**\r
- This function returns user information.\r
-\r
- @param This Protocol EFI_USER_MANAGER_PROTOCOL instance\r
- pointer.\r
- @param User Handle of the user whose profile will be\r
- retrieved.\r
- @param UserInfo Handle of the user information data record.\r
- @param Info On entry, points to a buffer of at least\r
- *InfoSize bytes. On exit, holds the user\r
- information.\r
- @param InfoSize On entry, points to the size of Info. On return,\r
- points to the size of the user information.\r
-\r
- @retval EFI_SUCCESS Information returned successfully.\r
- @retval EFI_ACCESS_DENIED The information about the specified user cannot\r
- be accessed by the current user.\r
- EFI_BUFFER_TOO_SMALL- The number of bytes\r
- specified by *InfoSize is too small to hold the\r
- returned data.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileGetInfo (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN EFI_USER_INFO_HANDLE UserInfo,\r
- OUT EFI_USER_INFO *Info,\r
- IN OUT UINTN *InfoSize\r
- );\r
-\r
-\r
-/**\r
- This function changes user information.\r
-\r
- @param This Protocol EFI_USER_MANAGER_PROTOCOL instance\r
- pointer.\r
- @param User Handle of the user whose profile will be\r
- retrieved.\r
- @param UserInfo Handle of the user information data record.\r
- @param Info Points to the user information.\r
- @param InfoSize The size of Info, in bytes.\r
-\r
- @retval EFI_SUCCESS User profile information was successfully\r
- changed/added.\r
- @retval EFI_ACCESS_DENIED The record is exclusive.\r
- @retval EFI_SECURITY_VIOLATION The current user does not have permission to\r
- change the specified user profile or user\r
- information record.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileSetInfo (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN OUT EFI_USER_INFO_HANDLE *UserInfo,\r
- IN CONST EFI_USER_INFO *Info,\r
- IN UINTN InfoSize\r
- );\r
-\r
-\r
-/**\r
- This function allows the credential provider to notify the User Identity Manager\r
- when user status has changed while deselected.\r
-\r
- @param This Protocol EFI_USER_MANAGER_PROTOCOL instance\r
- pointer.\r
- @param Changed Points to the instance of the\r
- EFI_USER_CREDENTIAL_PROTOCOL where the user has\r
- changed.\r
-\r
- @retval EFI_SUCCESS The User Identity Manager has handled the\r
- notification.\r
- @retval EFI_NOT_READY The function was called while the specified\r
- credential provider was not selected.\r
- @retval EFI_UNSUPPORTED The User Identity Manager doesn't support\r
- asynchronous notifications.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileNotify (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN EFI_HANDLE Changed\r
- );\r
-\r
-\r
-/**\r
- Delete the user information attached to the user profile specified by the UserInfo.\r
-\r
- @param This Protocol EFI_USER_MANAGER_PROTOCOL instance pointer.\r
- @param User Handle of the user whose profile will be retrieved.\r
- @param UserInfo Handle of the user information data record.\r
-\r
- @retval EFI_SUCCESS User information deleted successfully.\r
- @retval EFI_ACCESS_DENIED The current user does not have permission to\r
- delete this user in-formation.\r
- @retval EFI_NOT_FOUND User information record UserInfo does not exist\r
- in the user pro-file.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileDeleteInfo (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN EFI_USER_INFO_HANDLE UserInfo\r
- );\r
-\r
-\r
-/**\r
- This function returns the next user information record.\r
-\r
- @param This Protocol EFI_USER_MANAGER_PROTOCOL instance pointer.\r
- @param User Handle of the user whose profile will be retrieved.\r
- @param UserInfo Handle of the user information data record.\r
-\r
- @retval EFI_SUCCESS User information returned.\r
- @retval EFI_NOT_FOUND No more user information found.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileGetNextInfo (\r
- IN CONST EFI_USER_MANAGER_PROTOCOL *This,\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN OUT EFI_USER_INFO_HANDLE *UserInfo\r
- );\r
-\r
-#endif\r
+++ /dev/null
-// /** @file\r
-// Produces user manager protocol\r
-//\r
-// This module manages user information and produces user manager protocol.\r
-//\r
-// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// This program and the accompanying materials\r
-// are licensed and made available under the terms and conditions of the BSD License\r
-// which accompanies this distribution. The full text of the license may be found at\r
-// http://opensource.org/licenses/bsd-license.php\r
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT #language en-US "Produces user manager protocol"\r
-\r
-#string STR_MODULE_DESCRIPTION #language en-US "This module manages user information and produces user manager protocol."\r
-\r
+++ /dev/null
-/** @file\r
- Data structure used by the user identify manager driver.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef _USER_IDENTIFY_MANAGER_DATA_H_\r
-#define _USER_IDENTIFY_MANAGER_DATA_H_\r
-\r
-#include <Guid/UserIdentifyManagerHii.h>\r
-\r
-//\r
-// Forms definition.\r
-//\r
-#define FORMID_USER_FORM 1\r
-#define FORMID_PROVIDER_FORM 2\r
-#define FORMID_INVALID_FORM 0x0FFF\r
-\r
-//\r
-// Labels definition.\r
-//\r
-#define LABEL_USER_NAME 0x1000\r
-#define LABEL_PROVIDER_NAME 0x3000\r
-#define LABEL_END 0xffff\r
-#define FORM_OPEN_QUESTION_ID 0xfffe\r
-\r
-#endif\r
+++ /dev/null
-## @file\r
-# Produces user manager protocol\r
-#\r
-# This module manages user information and produces user manager protocol.\r
-#\r
-# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-##\r
-\r
-[defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = UserIdentifyManager\r
- MODULE_UNI_FILE = UserIdentifyManager.uni\r
- FILE_GUID = C5D3191B-27D5-4873-8DF2-628136991A21\r
- MODULE_TYPE = DXE_DRIVER\r
- VERSION_STRING = 1.0\r
- ENTRY_POINT = UserIdentifyManagerInit\r
-\r
-[sources]\r
- UserIdentifyManager.c\r
- LoadDeferredImage.c\r
- UserIdentifyManager.h\r
- UserIdentifyManagerData.h\r
- UserIdentifyManagerStrings.uni\r
- UserIdentifyManagerVfr.Vfr\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- MdeModulePkg/MdeModulePkg.dec\r
- SecurityPkg/SecurityPkg.dec\r
-\r
-[LibraryClasses]\r
- UefiRuntimeServicesTableLib\r
- UefiBootServicesTableLib\r
- UefiDriverEntryPoint\r
- MemoryAllocationLib\r
- BaseMemoryLib\r
- DebugLib\r
- HiiLib\r
- UefiLib\r
-\r
-[Guids]\r
- gEfiIfrTianoGuid ## SOMETIMES_CONSUMES ## GUID\r
- gEfiEventUserProfileChangedGuid ## SOMETIMES_PRODUCES ## Event\r
-\r
- ## SOMETIMES_PRODUCES ## Variable:L"Userxxxx"\r
- ## SOMETIMES_CONSUMES ## Variable:L"Userxxxx"\r
- ## CONSUMES ## HII\r
- gUserIdentifyManagerGuid\r
-\r
-[Protocols]\r
- gEfiFormBrowser2ProtocolGuid ## CONSUMES\r
- gEfiHiiDatabaseProtocolGuid ## CONSUMES\r
- gEfiUserCredential2ProtocolGuid ## SOMETIMES_CONSUMES\r
- gEfiDeferredImageLoadProtocolGuid ## SOMETIMES_CONSUMES\r
- gEfiSimpleTextOutProtocolGuid ## SOMETIMES_CONSUMES\r
- gEfiSimpleTextInProtocolGuid ## SOMETIMES_CONSUMES\r
- gEfiSimpleTextInputExProtocolGuid ## SOMETIMES_CONSUMES\r
- gEfiHiiConfigAccessProtocolGuid ## PRODUCES\r
- gEfiDevicePathProtocolGuid ## PRODUCES\r
-\r
- ## PRODUCES\r
- ## SOMETIMES_PRODUCES ## SystemTable\r
- gEfiUserManagerProtocolGuid\r
-\r
-[Depex]\r
- gEfiHiiDatabaseProtocolGuid AND\r
- gEfiHiiStringProtocolGuid AND\r
- gEfiFormBrowser2ProtocolGuid\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
- UserIdentifyManagerExtra.uni\r
-\r
+++ /dev/null
-// /** @file\r
-// UserIdentifyManager Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// This program and the accompanying materials\r
-// are licensed and made available under the terms and conditions of the BSD License\r
-// which accompanies this distribution. The full text of the license may be found at\r
-// http://opensource.org/licenses/bsd-license.php\r
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"User Identify Manager"\r
-\r
-\r
+++ /dev/null
-/** @file\r
- String definitions for the User Identify Manager driver.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php.\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#langdef en-US "English"\r
-#langdef fr-FR "Francais"\r
-\r
-#string STR_TITLE #language en-US "User Identity Manager"\r
- #language fr-FR "User Identity Manager(French)"\r
-#string STR_USER_SELECT #language en-US "User Selection"\r
- #language fr-FR "User Selection(French)"\r
-#string STR_PROVIDER_SELECT #language en-US "Provider Selection"\r
- #language fr-FR "User Selection(French)"\r
-#string STR_NULL_STRING #language en-US ""\r
- #language fr-FR ""\r
-\r
-\r
+++ /dev/null
-/** @file\r
- User identify manager formset.\r
-\r
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "UserIdentifyManagerData.h"\r
-\r
-formset \r
- guid = USER_IDENTIFY_MANAGER_GUID,\r
- title = STRING_TOKEN(STR_TITLE), \r
- help = STRING_TOKEN(STR_NULL_STRING), \r
- classguid = USER_IDENTIFY_MANAGER_GUID,\r
- \r
- form formid = FORMID_USER_FORM,\r
- title = STRING_TOKEN(STR_USER_SELECT); \r
-\r
- suppressif TRUE;\r
- text\r
- help = STRING_TOKEN(STR_NULL_STRING),\r
- text = STRING_TOKEN(STR_NULL_STRING),\r
- flags = INTERACTIVE,\r
- key = FORM_OPEN_QUESTION_ID;\r
- endif;\r
-\r
- label LABEL_USER_NAME;\r
- label LABEL_END; \r
- endform;\r
- \r
- form formid = FORMID_PROVIDER_FORM,\r
- title = STRING_TOKEN(STR_PROVIDER_SELECT);\r
- label LABEL_PROVIDER_NAME;\r
- label LABEL_END;\r
- endform; \r
-endformset;
\ No newline at end of file
+++ /dev/null
-/** @file\r
- The functions for access policy modification.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "UserProfileManager.h"\r
-\r
-/**\r
- Collect all the access policy data to mUserInfo.AccessPolicy,\r
- and save it to user profile.\r
-\r
-**/\r
-VOID\r
-SaveAccessPolicy (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN OffSet;\r
- UINTN Size;\r
- EFI_USER_INFO_ACCESS_CONTROL Control;\r
- EFI_USER_INFO_HANDLE UserInfo;\r
- EFI_USER_INFO *Info;\r
-\r
- if (mUserInfo.AccessPolicy != NULL) {\r
- FreePool (mUserInfo.AccessPolicy);\r
- }\r
- mUserInfo.AccessPolicy = NULL;\r
- mUserInfo.AccessPolicyLen = 0;\r
- mUserInfo.AccessPolicyModified = TRUE;\r
- OffSet = 0;\r
-\r
- //\r
- // Save access right.\r
- //\r
- Size = sizeof (EFI_USER_INFO_ACCESS_CONTROL);\r
- if (mUserInfo.AccessPolicyLen - OffSet < Size) {\r
- ExpandMemory (OffSet, Size);\r
- }\r
-\r
- Control.Type = mAccessInfo.AccessRight;\r
- Control.Size = (UINT32) Size;\r
- CopyMem (mUserInfo.AccessPolicy + OffSet, &Control, sizeof (Control));\r
- OffSet += sizeof (Control);\r
-\r
- //\r
- // Save access setup.\r
- //\r
- Size = sizeof (EFI_USER_INFO_ACCESS_CONTROL) + sizeof (EFI_GUID);\r
- if (mUserInfo.AccessPolicyLen - OffSet < Size) {\r
- ExpandMemory (OffSet, Size);\r
- }\r
-\r
- Control.Type = EFI_USER_INFO_ACCESS_SETUP;\r
- Control.Size = (UINT32) Size;\r
- CopyMem (mUserInfo.AccessPolicy + OffSet, &Control, sizeof (Control));\r
- OffSet += sizeof (Control);\r
-\r
- if (mAccessInfo.AccessSetup == ACCESS_SETUP_NORMAL) {\r
- CopyGuid ((EFI_GUID *) (mUserInfo.AccessPolicy + OffSet), &gEfiUserInfoAccessSetupNormalGuid);\r
- } else if (mAccessInfo.AccessSetup == ACCESS_SETUP_RESTRICTED) {\r
- CopyGuid ((EFI_GUID *) (mUserInfo.AccessPolicy + OffSet), &gEfiUserInfoAccessSetupRestrictedGuid);\r
- } else if (mAccessInfo.AccessSetup == ACCESS_SETUP_ADMIN) {\r
- CopyGuid ((EFI_GUID *) (mUserInfo.AccessPolicy + OffSet), &gEfiUserInfoAccessSetupAdminGuid);\r
- }\r
- OffSet += sizeof (EFI_GUID);\r
-\r
- //\r
- // Save access of boot order.\r
- //\r
- Size = sizeof (EFI_USER_INFO_ACCESS_CONTROL) + sizeof (UINT32);\r
- if (mUserInfo.AccessPolicyLen - OffSet < Size) {\r
- ExpandMemory (OffSet, Size);\r
- }\r
-\r
- Control.Type = EFI_USER_INFO_ACCESS_BOOT_ORDER;\r
- Control.Size = (UINT32) Size;\r
- CopyMem (mUserInfo.AccessPolicy + OffSet, &Control, sizeof (Control));\r
- OffSet += sizeof (Control);\r
-\r
- CopyMem ((UINT8 *) (mUserInfo.AccessPolicy + OffSet), &mAccessInfo.AccessBootOrder, sizeof (UINT32));\r
- OffSet += sizeof (UINT32);\r
-\r
- //\r
- // Save permit load.\r
- //\r
- if (mAccessInfo.LoadPermitLen > 0) {\r
- Size = sizeof (EFI_USER_INFO_ACCESS_CONTROL) + mAccessInfo.LoadPermitLen;\r
- if (mUserInfo.AccessPolicyLen - OffSet < Size) {\r
- ExpandMemory (OffSet, Size);\r
- }\r
-\r
- Control.Type = EFI_USER_INFO_ACCESS_PERMIT_LOAD;\r
- Control.Size = (UINT32) Size;\r
- CopyMem (mUserInfo.AccessPolicy + OffSet, &Control, sizeof (Control));\r
- OffSet += sizeof (Control);\r
-\r
- CopyMem (mUserInfo.AccessPolicy + OffSet, mAccessInfo.LoadPermit, mAccessInfo.LoadPermitLen);\r
- OffSet += mAccessInfo.LoadPermitLen;\r
- }\r
-\r
- //\r
- // Save forbid load.\r
- //\r
- if (mAccessInfo.LoadForbidLen > 0) {\r
- Size = sizeof (EFI_USER_INFO_ACCESS_CONTROL) + mAccessInfo.LoadForbidLen;\r
- if (mUserInfo.AccessPolicyLen - OffSet < Size) {\r
- ExpandMemory (OffSet, Size);\r
- }\r
-\r
- Control.Type = EFI_USER_INFO_ACCESS_FORBID_LOAD;\r
- Control.Size = (UINT32) Size;\r
- CopyMem (mUserInfo.AccessPolicy + OffSet, &Control, sizeof (Control));\r
- OffSet += sizeof (Control);\r
-\r
- CopyMem (mUserInfo.AccessPolicy + OffSet, mAccessInfo.LoadForbid, mAccessInfo.LoadForbidLen);\r
- OffSet += mAccessInfo.LoadForbidLen;\r
- }\r
-\r
- //\r
- // Save permit connect.\r
- //\r
- if (mAccessInfo.ConnectPermitLen > 0) {\r
- Size = sizeof (EFI_USER_INFO_ACCESS_CONTROL) + mAccessInfo.ConnectPermitLen;\r
- if (mUserInfo.AccessPolicyLen - OffSet < Size) {\r
- ExpandMemory (OffSet, Size);\r
- }\r
-\r
- Control.Type = EFI_USER_INFO_ACCESS_PERMIT_CONNECT;\r
- Control.Size = (UINT32) Size;\r
- CopyMem (mUserInfo.AccessPolicy + OffSet, &Control, sizeof (Control));\r
- OffSet += sizeof (Control);\r
-\r
- CopyMem (mUserInfo.AccessPolicy + OffSet, mAccessInfo.ConnectPermit, mAccessInfo.ConnectPermitLen);\r
- OffSet += mAccessInfo.ConnectPermitLen;\r
- }\r
-\r
- //\r
- // Save forbid connect.\r
- //\r
- if (mAccessInfo.ConnectForbidLen > 0) {\r
- Size = sizeof (EFI_USER_INFO_ACCESS_CONTROL) + mAccessInfo.ConnectForbidLen;\r
- if (mUserInfo.AccessPolicyLen - OffSet < Size) {\r
- ExpandMemory (OffSet, Size);\r
- }\r
-\r
- Control.Type = EFI_USER_INFO_ACCESS_FORBID_CONNECT;\r
- Control.Size = (UINT32) Size;\r
- CopyMem (mUserInfo.AccessPolicy + OffSet, &Control, sizeof (Control));\r
- OffSet += sizeof (Control);\r
-\r
- CopyMem (mUserInfo.AccessPolicy + OffSet, mAccessInfo.ConnectForbid, mAccessInfo.ConnectForbidLen);\r
- OffSet += mAccessInfo.ConnectForbidLen;\r
- }\r
-\r
- mUserInfo.AccessPolicyLen = OffSet;\r
-\r
- //\r
- // Save access policy.\r
- //\r
- if (mUserInfo.AccessPolicyModified && (mUserInfo.AccessPolicyLen > 0) && (mUserInfo.AccessPolicy != NULL)) {\r
- Info = AllocateZeroPool (sizeof (EFI_USER_INFO) + mUserInfo.AccessPolicyLen);\r
- if (Info == NULL) {\r
- return ;\r
- }\r
-\r
- Status = FindInfoByType (mModifyUser, EFI_USER_INFO_ACCESS_POLICY_RECORD, &UserInfo);\r
- if (!EFI_ERROR (Status)) {\r
- Info->InfoType = EFI_USER_INFO_ACCESS_POLICY_RECORD;\r
- Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV |\r
- EFI_USER_INFO_PUBLIC |\r
- EFI_USER_INFO_EXCLUSIVE;\r
- Info->InfoSize = (UINT32) (sizeof (EFI_USER_INFO) + mUserInfo.AccessPolicyLen);\r
- CopyMem ((UINT8 *) (Info + 1), mUserInfo.AccessPolicy, mUserInfo.AccessPolicyLen);\r
- Status = mUserManager->SetInfo (\r
- mUserManager,\r
- mModifyUser,\r
- &UserInfo,\r
- Info,\r
- Info->InfoSize\r
- );\r
- mUserInfo.AccessPolicyModified = FALSE;\r
- }\r
- FreePool (Info);\r
- }\r
-\r
- if (mAccessInfo.ConnectForbid != NULL) {\r
- FreePool (mAccessInfo.ConnectForbid);\r
- mAccessInfo.ConnectForbid = NULL;\r
- }\r
-\r
- if (mAccessInfo.ConnectPermit != NULL) {\r
- FreePool (mAccessInfo.ConnectPermit);\r
- mAccessInfo.ConnectPermit = NULL;\r
- }\r
-\r
- if (mAccessInfo.LoadForbid != NULL) {\r
- FreePool (mAccessInfo.LoadForbid);\r
- mAccessInfo.LoadForbid = NULL;\r
- }\r
-\r
- if (mAccessInfo.LoadPermit != NULL) {\r
- FreePool (mAccessInfo.LoadPermit);\r
- mAccessInfo.LoadPermit = NULL;\r
- }\r
-}\r
-\r
-/**\r
- Create an action OpCode with QuestionID and DevicePath on a given OpCodeHandle.\r
-\r
- @param[in] QuestionID The question ID.\r
- @param[in] DevicePath Points to device path.\r
- @param[in] OpCodeHandle Points to container for dynamic created opcodes.\r
-\r
-**/\r
-VOID\r
-AddDevicePath (\r
- IN UINTN QuestionID,\r
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
- IN VOID *OpCodeHandle\r
- )\r
-{\r
- EFI_DEVICE_PATH_PROTOCOL *Next;\r
- EFI_STRING_ID NameID;\r
- EFI_STRING DriverName;\r
-\r
- //\r
- // Get driver file name node.\r
- //\r
- Next = DevicePath;\r
- while (!IsDevicePathEnd (Next)) {\r
- DevicePath = Next;\r
- Next = NextDevicePathNode (Next);\r
- }\r
-\r
- //\r
- // Display the device path in form.\r
- //\r
- DriverName = ConvertDevicePathToText (DevicePath, FALSE, FALSE);\r
- NameID = HiiSetString (mCallbackInfo->HiiHandle, 0, DriverName, NULL);\r
- FreePool (DriverName);\r
- if (NameID == 0) {\r
- return ;\r
- }\r
-\r
- HiiCreateActionOpCode (\r
- OpCodeHandle, // Container for dynamic created opcodes\r
- (UINT16) QuestionID, // Question ID\r
- NameID, // Prompt text\r
- STRING_TOKEN (STR_NULL_STRING), // Help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- 0 // Action String ID\r
- );\r
-}\r
-\r
-\r
-/**\r
- Check whether the DevicePath is in the device path forbid list\r
- (mAccessInfo.LoadForbid).\r
-\r
- @param[in] DevicePath Points to device path.\r
-\r
- @retval TRUE The DevicePath is in the device path forbid list.\r
- @retval FALSE The DevicePath is not in the device path forbid list.\r
-\r
-**/\r
-BOOLEAN\r
-IsLoadForbidden (\r
- IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
- )\r
-{\r
- UINTN OffSet;\r
- UINTN DPSize;\r
- UINTN Size;\r
- EFI_DEVICE_PATH_PROTOCOL *Dp;\r
-\r
- OffSet = 0;\r
- Size = GetDevicePathSize (DevicePath);\r
- //\r
- // Check each device path.\r
- //\r
- while (OffSet < mAccessInfo.LoadForbidLen) {\r
- Dp = (EFI_DEVICE_PATH_PROTOCOL *) (mAccessInfo.LoadForbid + OffSet);\r
- DPSize = GetDevicePathSize (Dp);\r
- //\r
- // Compare device path.\r
- //\r
- if ((DPSize == Size) && (CompareMem (DevicePath, Dp, Size) == 0)) {\r
- return TRUE;\r
- }\r
- OffSet += DPSize;\r
- }\r
- return FALSE;\r
-}\r
-\r
-\r
-/**\r
- Display the permit load device path in the loadable device path list.\r
-\r
-**/\r
-VOID\r
-DisplayLoadPermit(\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- CHAR16 *Order;\r
- UINTN OrderSize;\r
- UINTN ListCount;\r
- UINTN Index;\r
- UINT8 *Var;\r
- UINT8 *VarPtr;\r
- CHAR16 VarName[12];\r
- VOID *StartOpCodeHandle;\r
- VOID *EndOpCodeHandle;\r
- EFI_IFR_GUID_LABEL *StartLabel;\r
- EFI_IFR_GUID_LABEL *EndLabel;\r
-\r
- //\r
- // Get DriverOrder.\r
- //\r
- OrderSize = 0;\r
- Status = gRT->GetVariable (\r
- L"DriverOrder",\r
- &gEfiGlobalVariableGuid,\r
- NULL,\r
- &OrderSize,\r
- NULL\r
- );\r
- if (Status != EFI_BUFFER_TOO_SMALL) {\r
- return ;\r
- }\r
-\r
- Order = AllocateZeroPool (OrderSize);\r
- if (Order == NULL) {\r
- return ;\r
- }\r
-\r
- Status = gRT->GetVariable (\r
- L"DriverOrder",\r
- &gEfiGlobalVariableGuid,\r
- NULL,\r
- &OrderSize,\r
- Order\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return ;\r
- }\r
-\r
- //\r
- // Initialize the container for dynamic opcodes.\r
- //\r
- StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (StartOpCodeHandle != NULL);\r
-\r
- EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (EndOpCodeHandle != NULL);\r
-\r
- //\r
- // Create Hii Extend Label OpCode.\r
- //\r
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- StartOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- StartLabel->Number = LABEL_PERMIT_LOAD_FUNC;\r
-\r
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- EndOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- EndLabel->Number = LABEL_END;\r
-\r
- //\r
- // Add each driver option.\r
- //\r
- Var = NULL;\r
- ListCount = OrderSize / sizeof (UINT16);\r
- for (Index = 0; Index < ListCount; Index++) {\r
- //\r
- // Get driver device path.\r
- //\r
- UnicodeSPrint (VarName, sizeof (VarName), L"Driver%04x", Order[Index]);\r
- GetEfiGlobalVariable2 (VarName, (VOID**)&Var, NULL);\r
- if (Var == NULL) {\r
- continue;\r
- }\r
-\r
- //\r
- // Check whether the driver is already forbidden.\r
- //\r
-\r
- VarPtr = Var;\r
- //\r
- // Skip attribute.\r
- //\r
- VarPtr += sizeof (UINT32);\r
-\r
- //\r
- // Skip device path lenth.\r
- //\r
- VarPtr += sizeof (UINT16);\r
-\r
- //\r
- // Skip descript string.\r
- //\r
- VarPtr += StrSize ((UINT16 *) VarPtr);\r
-\r
- if (IsLoadForbidden ((EFI_DEVICE_PATH_PROTOCOL *) VarPtr)) {\r
- FreePool (Var);\r
- Var = NULL;\r
- continue;\r
- }\r
-\r
- AddDevicePath (\r
- KEY_MODIFY_USER | KEY_MODIFY_AP_DP | KEY_LOAD_PERMIT_MODIFY | Order[Index],\r
- (EFI_DEVICE_PATH_PROTOCOL *) VarPtr,\r
- StartOpCodeHandle\r
- );\r
- FreePool (Var);\r
- Var = NULL;\r
- }\r
-\r
- HiiUpdateForm (\r
- mCallbackInfo->HiiHandle, // HII handle\r
- &gUserProfileManagerGuid, // Formset GUID\r
- FORMID_PERMIT_LOAD_DP, // Form ID\r
- StartOpCodeHandle, // Label for where to insert opcodes\r
- EndOpCodeHandle // Replace data\r
- );\r
-\r
- HiiFreeOpCodeHandle (StartOpCodeHandle);\r
- HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-\r
- //\r
- // Clear Environment.\r
- //\r
- if (Var != NULL) {\r
- FreePool (Var);\r
- }\r
- FreePool (Order);\r
-}\r
-\r
-\r
-/**\r
- Display the forbid load device path list (mAccessInfo.LoadForbid).\r
-\r
-**/\r
-VOID\r
-DisplayLoadForbid (\r
- VOID\r
- )\r
-{\r
- UINTN Offset;\r
- UINTN DPSize;\r
- UINTN Index;\r
- EFI_DEVICE_PATH_PROTOCOL *Dp;\r
- VOID *StartOpCodeHandle;\r
- VOID *EndOpCodeHandle;\r
- EFI_IFR_GUID_LABEL *StartLabel;\r
- EFI_IFR_GUID_LABEL *EndLabel;\r
-\r
- //\r
- // Initialize the container for dynamic opcodes.\r
- //\r
- StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (StartOpCodeHandle != NULL);\r
-\r
- EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (EndOpCodeHandle != NULL);\r
-\r
- //\r
- // Create Hii Extend Label OpCode.\r
- //\r
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- StartOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- StartLabel->Number = LABLE_FORBID_LOAD_FUNC;\r
-\r
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- EndOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- EndLabel->Number = LABEL_END;\r
-\r
- //\r
- // Add each forbid load drivers.\r
- //\r
- Offset = 0;\r
- Index = 0;\r
- while (Offset < mAccessInfo.LoadForbidLen) {\r
- Dp = (EFI_DEVICE_PATH_PROTOCOL *) (mAccessInfo.LoadForbid + Offset);\r
- DPSize = GetDevicePathSize (Dp);\r
- AddDevicePath (\r
- KEY_MODIFY_USER | KEY_MODIFY_AP_DP | KEY_LOAD_FORBID_MODIFY | Index,\r
- Dp,\r
- StartOpCodeHandle\r
- );\r
- Index++;\r
- Offset += DPSize;\r
- }\r
-\r
- HiiUpdateForm (\r
- mCallbackInfo->HiiHandle, // HII handle\r
- &gUserProfileManagerGuid, // Formset GUID\r
- FORMID_FORBID_LOAD_DP, // Form ID\r
- StartOpCodeHandle, // Label for where to insert opcodes\r
- EndOpCodeHandle // Replace data\r
- );\r
-\r
- HiiFreeOpCodeHandle (StartOpCodeHandle);\r
- HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-}\r
-\r
-\r
-/**\r
- Display the permit connect device path.\r
-\r
-**/\r
-VOID\r
-DisplayConnectPermit (\r
- VOID\r
- )\r
-{\r
- //\r
- // Note:\r
- // As no architect protocol/interface to be called in ConnectController()\r
- // to verify the device path, just add a place holder for permitted connect\r
- // device path.\r
- //\r
-}\r
-\r
-\r
-/**\r
- Display the forbid connect device path list.\r
-\r
-**/\r
-VOID\r
-DisplayConnectForbid (\r
- VOID\r
- )\r
-{\r
- //\r
- // Note:\r
- // As no architect protocol/interface to be called in ConnectController()\r
- // to verify the device path, just add a place holder for forbidden connect\r
- // device path.\r
- //\r
-}\r
-\r
-\r
-/**\r
- Delete the specified device path by DriverIndex from the forbid device path\r
- list (mAccessInfo.LoadForbid).\r
-\r
- @param[in] DriverIndex The index of driver in forbidden device path list.\r
-\r
-**/\r
-VOID\r
-DeleteFromForbidLoad (\r
- IN UINT16 DriverIndex\r
- )\r
-{\r
- UINTN OffSet;\r
- UINTN DPSize;\r
- UINTN OffLen;\r
- EFI_DEVICE_PATH_PROTOCOL *Dp;\r
-\r
- OffSet = 0;\r
- //\r
- // Find the specified device path.\r
- //\r
- while ((OffSet < mAccessInfo.LoadForbidLen) && (DriverIndex > 0)) {\r
- Dp = (EFI_DEVICE_PATH_PROTOCOL *) (mAccessInfo.LoadForbid + OffSet);\r
- DPSize = GetDevicePathSize (Dp);\r
- OffSet += DPSize;\r
- DriverIndex--;\r
- }\r
-\r
- //\r
- // Specified device path found.\r
- //\r
- if (DriverIndex == 0) {\r
- Dp = (EFI_DEVICE_PATH_PROTOCOL *) (mAccessInfo.LoadForbid + OffSet);\r
- DPSize = GetDevicePathSize (Dp);\r
- OffLen = mAccessInfo.LoadForbidLen - OffSet - DPSize;\r
- if (OffLen > 0) {\r
- CopyMem (\r
- mAccessInfo.LoadForbid + OffSet,\r
- mAccessInfo.LoadForbid + OffSet + DPSize,\r
- OffLen\r
- );\r
- }\r
- mAccessInfo.LoadForbidLen -= DPSize;\r
- }\r
-}\r
-\r
-\r
-/**\r
- Add the specified device path by DriverIndex to the forbid device path\r
- list (mAccessInfo.LoadForbid).\r
-\r
- @param[in] DriverIndex The index of driver saved in driver options.\r
-\r
-**/\r
-VOID\r
-AddToForbidLoad (\r
- IN UINT16 DriverIndex\r
- )\r
-{\r
- UINTN DevicePathLen;\r
- UINT8 *Var;\r
- UINT8 *VarPtr;\r
- UINTN NewLen;\r
- UINT8 *NewFL;\r
- CHAR16 VarName[13];\r
-\r
- //\r
- // Get loadable driver device path.\r
- //\r
- UnicodeSPrint (VarName, sizeof (VarName), L"Driver%04x", DriverIndex);\r
- GetEfiGlobalVariable2 (VarName, (VOID**)&Var, NULL);\r
- if (Var == NULL) {\r
- return;\r
- }\r
-\r
- //\r
- // Save forbid load driver.\r
- //\r
-\r
- VarPtr = Var;\r
- //\r
- // Skip attribute.\r
- //\r
- VarPtr += sizeof (UINT32);\r
-\r
- DevicePathLen = *(UINT16 *) VarPtr;\r
- //\r
- // Skip device path length.\r
- //\r
- VarPtr += sizeof (UINT16);\r
-\r
- //\r
- // Skip description string.\r
- //\r
- VarPtr += StrSize ((UINT16 *) VarPtr);\r
-\r
- NewLen = mAccessInfo.LoadForbidLen + DevicePathLen;\r
- NewFL = AllocateZeroPool (NewLen);\r
- if (NewFL == NULL) {\r
- FreePool (Var);\r
- return ;\r
- }\r
-\r
- if (mAccessInfo.LoadForbidLen > 0) {\r
- CopyMem (NewFL, mAccessInfo.LoadForbid, mAccessInfo.LoadForbidLen);\r
- FreePool (mAccessInfo.LoadForbid);\r
- }\r
-\r
- CopyMem (NewFL + mAccessInfo.LoadForbidLen, VarPtr, DevicePathLen);\r
- mAccessInfo.LoadForbidLen = NewLen;\r
- mAccessInfo.LoadForbid = NewFL;\r
- FreePool (Var);\r
-}\r
-\r
-\r
+++ /dev/null
-/** @file\r
- The functions for identification policy modification.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "UserProfileManager.h"\r
-\r
-\r
-/**\r
- Verify the new identity policy in the current implementation. The same credential\r
- provider can't appear twice in one identity policy.\r
-\r
- @param[in] NewGuid Points to the credential provider guid.\r
-\r
- @retval TRUE The NewGuid was found in the identity policy.\r
- @retval FALSE The NewGuid was not found.\r
-\r
-**/\r
-BOOLEAN\r
-ProviderAlreadyInPolicy (\r
- IN EFI_GUID *NewGuid\r
- )\r
-{\r
- UINTN Offset;\r
- EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
- EFI_INPUT_KEY Key;\r
-\r
- Offset = 0;\r
- while (Offset < mUserInfo.NewIdentityPolicyLen) {\r
- Identity = (EFI_USER_INFO_IDENTITY_POLICY *) (mUserInfo.NewIdentityPolicy + Offset);\r
- if (Identity->Type == EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER) {\r
- if (CompareGuid (NewGuid, (EFI_GUID *) (Identity + 1))) {\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- L"This Credential Provider Are Already Used!",\r
- L"",\r
- L"Press Any Key to Continue ...",\r
- NULL\r
- );\r
- return TRUE;\r
- }\r
- }\r
- Offset += Identity->Length;\r
- }\r
-\r
- return FALSE;\r
-}\r
-\r
-\r
-/**\r
- Add the user's credential record in the provider.\r
-\r
- @param[in] Identity Identity policy item including credential provider.\r
- @param[in] User Points to user profile.\r
-\r
- @retval EFI_SUCCESS Add or delete record successfully.\r
- @retval Others Fail to add or delete record.\r
-\r
-**/\r
-EFI_STATUS\r
-EnrollUserOnProvider (\r
- IN EFI_USER_INFO_IDENTITY_POLICY *Identity,\r
- IN EFI_USER_PROFILE_HANDLE User\r
- )\r
-{\r
- UINTN Index;\r
- EFI_USER_CREDENTIAL2_PROTOCOL *UserCredential;\r
-\r
- //\r
- // Find the specified credential provider.\r
- //\r
- for (Index = 0; Index < mProviderInfo->Count; Index++) {\r
- UserCredential = mProviderInfo->Provider[Index];\r
- if (CompareGuid ((EFI_GUID *)(Identity + 1), &UserCredential->Identifier)) {\r
- return UserCredential->Enroll (UserCredential, User);\r
- }\r
- }\r
-\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
- Delete the User's credential record on the provider.\r
-\r
- @param[in] Identity Point to EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER user info.\r
- @param[in] User Points to user profile.\r
-\r
- @retval EFI_SUCCESS Delete User's credential record successfully.\r
- @retval Others Fail to add or delete record.\r
-\r
-**/\r
-EFI_STATUS\r
-DeleteUserOnProvider (\r
- IN EFI_USER_INFO_IDENTITY_POLICY *Identity,\r
- IN EFI_USER_PROFILE_HANDLE User\r
- )\r
-{\r
- UINTN Index;\r
- EFI_USER_CREDENTIAL2_PROTOCOL *UserCredential;\r
-\r
- //\r
- // Find the specified credential provider.\r
- //\r
- for (Index = 0; Index < mProviderInfo->Count; Index++) {\r
- UserCredential = mProviderInfo->Provider[Index];\r
- if (CompareGuid ((EFI_GUID *)(Identity + 1), &UserCredential->Identifier)) {\r
- return UserCredential->Delete (UserCredential, User);\r
- }\r
- }\r
-\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
- Delete User's credental from all the providers that exist in User's identity policy.\r
-\r
- @param[in] IdentityPolicy Point to User's identity policy.\r
- @param[in] IdentityPolicyLen The length of the identity policy.\r
- @param[in] User Points to user profile.\r
-\r
-**/\r
-VOID\r
-DeleteCredentialFromProviders (\r
- IN UINT8 *IdentityPolicy,\r
- IN UINTN IdentityPolicyLen,\r
- IN EFI_USER_PROFILE_HANDLE User\r
- )\r
-{\r
- EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
- UINTN Offset;\r
-\r
- Offset = 0;\r
- while (Offset < IdentityPolicyLen) {\r
- Identity = (EFI_USER_INFO_IDENTITY_POLICY *) (IdentityPolicy + Offset);\r
- if (Identity->Type == EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER) {\r
- //\r
- // Delete the user on this provider.\r
- //\r
- DeleteUserOnProvider (Identity, User);\r
- }\r
- Offset += Identity->Length;\r
- }\r
-\r
-}\r
-\r
-\r
-/**\r
- Remove the provider specified by Offset from the new user identification record.\r
-\r
- @param[in] IdentityPolicy Point to user identity item in new identification policy.\r
- @param[in] Offset The item offset in the new identification policy.\r
-\r
-**/\r
-VOID\r
-DeleteProviderFromPolicy (\r
- IN EFI_USER_INFO_IDENTITY_POLICY *IdentityPolicy,\r
- IN UINTN Offset\r
- )\r
-{\r
- UINTN RemainingLen;\r
- UINTN DeleteLen;\r
-\r
- if (IdentityPolicy->Length == mUserInfo.NewIdentityPolicyLen) {\r
- //\r
- // Only one credential provider in the identification policy.\r
- // Set the new policy to be TRUE after removed the provider.\r
- //\r
- IdentityPolicy->Type = EFI_USER_INFO_IDENTITY_TRUE;\r
- IdentityPolicy->Length = sizeof (EFI_USER_INFO_IDENTITY_POLICY);\r
- mUserInfo.NewIdentityPolicyLen = IdentityPolicy->Length;\r
- return ;\r
- }\r
-\r
- DeleteLen = IdentityPolicy->Length + sizeof(EFI_USER_INFO_IDENTITY_POLICY);\r
- if ((Offset + IdentityPolicy->Length) != mUserInfo.NewIdentityPolicyLen) {\r
- //\r
- // This provider is not the last item in the identification policy, delete it and the connector.\r
- //\r
- RemainingLen = mUserInfo.NewIdentityPolicyLen - Offset - DeleteLen;\r
- CopyMem ((UINT8 *) IdentityPolicy, (UINT8 *) IdentityPolicy + DeleteLen, RemainingLen);\r
- }\r
- mUserInfo.NewIdentityPolicyLen -= DeleteLen;\r
-}\r
-\r
-\r
-/**\r
- Add a new provider to the mUserInfo.NewIdentityPolicy.\r
-\r
- It is invoked when 'add option' in UI is pressed.\r
-\r
- @param[in] NewGuid Points to the credential provider guid.\r
-\r
-**/\r
-VOID\r
-AddProviderToPolicy (\r
- IN EFI_GUID *NewGuid\r
- )\r
-{\r
- UINT8 *NewPolicyInfo;\r
- UINTN NewPolicyInfoLen;\r
- EFI_USER_INFO_IDENTITY_POLICY *Policy;\r
-\r
- //\r
- // Allocate memory for the new identity policy.\r
- //\r
- NewPolicyInfoLen = mUserInfo.NewIdentityPolicyLen + sizeof (EFI_USER_INFO_IDENTITY_POLICY) + sizeof (EFI_GUID);\r
- if (mUserInfo.NewIdentityPolicyLen > 0) {\r
- //\r
- // It is not the first provider in the policy. Add a connector before provider.\r
- //\r
- NewPolicyInfoLen += sizeof (EFI_USER_INFO_IDENTITY_POLICY);\r
- }\r
- NewPolicyInfo = AllocateZeroPool (NewPolicyInfoLen);\r
- if (NewPolicyInfo == NULL) {\r
- return ;\r
- }\r
-\r
- NewPolicyInfoLen = 0;\r
- if (mUserInfo.NewIdentityPolicyLen > 0) {\r
- //\r
- // Save orginal policy.\r
- //\r
- CopyMem (NewPolicyInfo, mUserInfo.NewIdentityPolicy, mUserInfo.NewIdentityPolicyLen);\r
-\r
- //\r
- // Save logical connector.\r
- //\r
- Policy = (EFI_USER_INFO_IDENTITY_POLICY *) (NewPolicyInfo + mUserInfo.NewIdentityPolicyLen);\r
- if (mConncetLogical == 0) {\r
- Policy->Type = EFI_USER_INFO_IDENTITY_AND;\r
- } else {\r
- Policy->Type = EFI_USER_INFO_IDENTITY_OR;\r
- }\r
-\r
- Policy->Length = sizeof (EFI_USER_INFO_IDENTITY_POLICY);\r
- NewPolicyInfoLen = mUserInfo.NewIdentityPolicyLen + Policy->Length;\r
- FreePool (mUserInfo.NewIdentityPolicy);\r
- }\r
-\r
- //\r
- // Save credential provider.\r
- //\r
- Policy = (EFI_USER_INFO_IDENTITY_POLICY *) (NewPolicyInfo + NewPolicyInfoLen);\r
- Policy->Length = sizeof (EFI_USER_INFO_IDENTITY_POLICY) + sizeof (EFI_GUID);\r
- Policy->Type = EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER;\r
- CopyGuid ((EFI_GUID *) (Policy + 1), NewGuid);\r
- NewPolicyInfoLen += Policy->Length;\r
-\r
- //\r
- // Update identity policy choice.\r
- //\r
- mUserInfo.NewIdentityPolicy = NewPolicyInfo;\r
- mUserInfo.NewIdentityPolicyLen = NewPolicyInfoLen;\r
- mUserInfo.NewIdentityPolicyModified = TRUE;\r
-}\r
-\r
-\r
-/**\r
- This function replaces the old identity policy with a new identity policy.\r
-\r
- This function delete the user identity policy information.\r
- If enroll new credential failed, recover the old identity policy.\r
-\r
- @retval EFI_SUCCESS Modify user identity policy successfully.\r
- @retval Others Fail to modify user identity policy.\r
-\r
-**/\r
-EFI_STATUS\r
-UpdateCredentialProvider (\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
- UINTN Offset;\r
-\r
- //\r
- // Delete the old identification policy.\r
- //\r
- DeleteCredentialFromProviders (mUserInfo.IdentityPolicy, mUserInfo.IdentityPolicyLen, mModifyUser);\r
-\r
- //\r
- // Add the new identification policy.\r
- //\r
- Offset = 0;\r
- while (Offset < mUserInfo.NewIdentityPolicyLen) {\r
- Identity = (EFI_USER_INFO_IDENTITY_POLICY *) (mUserInfo.NewIdentityPolicy + Offset);\r
- if (Identity->Type == EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER) {\r
- //\r
- // Enroll the user on this provider\r
- //\r
- Status = EnrollUserOnProvider (Identity, mModifyUser);\r
- if (EFI_ERROR (Status)) {\r
- //\r
- // Failed to enroll the user by new identification policy.\r
- // So removed the credential provider from the identification policy\r
- //\r
- DeleteProviderFromPolicy (Identity, Offset);\r
- continue;\r
- }\r
- }\r
- Offset += Identity->Length;\r
- }\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Check whether the identity policy is valid.\r
-\r
- @param[in] PolicyInfo Point to the identity policy.\r
- @param[in] PolicyInfoLen The policy length.\r
-\r
- @retval TRUE The policy is a valid identity policy.\r
- @retval FALSE The policy is not a valid identity policy.\r
-\r
-**/\r
-BOOLEAN\r
-CheckNewIdentityPolicy (\r
- IN UINT8 *PolicyInfo,\r
- IN UINTN PolicyInfoLen\r
- )\r
-{\r
- EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
- EFI_INPUT_KEY Key;\r
- UINTN Offset;\r
- UINT32 OpCode;\r
-\r
- //\r
- // Check policy expression.\r
- //\r
- OpCode = EFI_USER_INFO_IDENTITY_FALSE;\r
- Offset = 0;\r
- while (Offset < PolicyInfoLen) {\r
- //\r
- // Check identification policy according to type\r
- //\r
- Identity = (EFI_USER_INFO_IDENTITY_POLICY *) (PolicyInfo + Offset);\r
- switch (Identity->Type) {\r
-\r
- case EFI_USER_INFO_IDENTITY_TRUE:\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_OR:\r
- if (OpCode == EFI_USER_INFO_IDENTITY_AND) {\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- L"Invalid Identity Policy, Mixed Connector Unsupport!",\r
- L"",\r
- L"Press Any Key to Continue ...",\r
- NULL\r
- );\r
- return FALSE;\r
- }\r
-\r
- OpCode = EFI_USER_INFO_IDENTITY_OR;\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_AND:\r
- if (OpCode == EFI_USER_INFO_IDENTITY_OR) {\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- L"Invalid Identity Policy, Mixed Connector Unsupport!",\r
- L"",\r
- L"Press Any Key to Continue ...",\r
- NULL\r
- );\r
- return FALSE;\r
- }\r
-\r
- OpCode = EFI_USER_INFO_IDENTITY_AND;\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER:\r
- break;\r
-\r
- default:\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- L"Unsupport parameter",\r
- L"",\r
- L"Press Any Key to Continue ...",\r
- NULL\r
- );\r
- return FALSE;\r
- }\r
- Offset += Identity->Length;\r
- }\r
-\r
- return TRUE;\r
-}\r
-\r
-\r
-/**\r
- Save the identity policy and update UI with it.\r
-\r
- This function will verify the new identity policy, in current implementation,\r
- the identity policy can be: T, P & P & P & ..., P | P | P | ...\r
- Here, "T" means "True", "P" means "Credential Provider", "&" means "and", "|" means "or".\r
- Other identity policies are not supported.\r
-\r
-**/\r
-VOID\r
-SaveIdentityPolicy (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO_HANDLE UserInfo;\r
- EFI_USER_INFO *Info;\r
-\r
- if (!mUserInfo.NewIdentityPolicyModified || (mUserInfo.NewIdentityPolicyLen == 0)) {\r
- return;\r
- }\r
-\r
- //\r
- // Check policy expression.\r
- //\r
- if (!CheckNewIdentityPolicy (mUserInfo.NewIdentityPolicy, mUserInfo.NewIdentityPolicyLen)) {\r
- return;\r
- }\r
-\r
- Status = FindInfoByType (mModifyUser, EFI_USER_INFO_IDENTITY_POLICY_RECORD, &UserInfo);\r
- if (EFI_ERROR (Status)) {\r
- return ;\r
- }\r
-\r
- //\r
- // Update the informantion on credential provider.\r
- //\r
- Status = UpdateCredentialProvider ();\r
- if (EFI_ERROR (Status)) {\r
- return ;\r
- }\r
-\r
- //\r
- // Save new identification policy.\r
- //\r
- Info = AllocateZeroPool (sizeof (EFI_USER_INFO) + mUserInfo.NewIdentityPolicyLen);\r
- ASSERT (Info != NULL);\r
-\r
- Info->InfoType = EFI_USER_INFO_IDENTITY_POLICY_RECORD;\r
- Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;\r
- Info->InfoSize = (UINT32) (sizeof (EFI_USER_INFO) + mUserInfo.NewIdentityPolicyLen);\r
- CopyMem ((UINT8 *) (Info + 1), mUserInfo.NewIdentityPolicy, mUserInfo.NewIdentityPolicyLen);\r
-\r
- Status = mUserManager->SetInfo (mUserManager, mModifyUser, &UserInfo, Info, Info->InfoSize);\r
- FreePool (Info);\r
-\r
- //\r
- // Update the mUserInfo.IdentityPolicy by mUserInfo.NewIdentityPolicy\r
- //\r
- if (mUserInfo.IdentityPolicy != NULL) {\r
- FreePool (mUserInfo.IdentityPolicy);\r
- }\r
- mUserInfo.IdentityPolicy = mUserInfo.NewIdentityPolicy;\r
- mUserInfo.IdentityPolicyLen = mUserInfo.NewIdentityPolicyLen;\r
-\r
- mUserInfo.NewIdentityPolicy = NULL;\r
- mUserInfo.NewIdentityPolicyLen = 0;\r
- mUserInfo.NewIdentityPolicyModified = FALSE;\r
-\r
- //\r
- // Update identity policy choice.\r
- //\r
- ResolveIdentityPolicy (mUserInfo.IdentityPolicy, mUserInfo.IdentityPolicyLen, STRING_TOKEN (STR_IDENTIFY_POLICY_VAL));\r
-}\r
-\r
-\r
-/**\r
- Update the mUserInfo.NewIdentityPolicy, and UI when 'add option' is pressed.\r
-\r
-**/\r
-VOID\r
-AddIdentityPolicyItem (\r
- VOID\r
- )\r
-{\r
- if (mProviderInfo->Count == 0) {\r
- return ;\r
- }\r
-\r
- //\r
- // Check the identity policy.\r
- //\r
- if (ProviderAlreadyInPolicy (&mProviderInfo->Provider[mProviderChoice]->Identifier)) {\r
- return;\r
- }\r
-\r
- //\r
- // Add it to identification policy\r
- //\r
- AddProviderToPolicy (&mProviderInfo->Provider[mProviderChoice]->Identifier);\r
-\r
- //\r
- // Update identity policy choice.\r
- //\r
- ResolveIdentityPolicy (mUserInfo.NewIdentityPolicy, mUserInfo.NewIdentityPolicyLen, STRING_TOKEN (STR_IDENTIFY_POLICY_VALUE));\r
-}\r
-\r
-\r
+++ /dev/null
-/** @file\r
- The functions to add a user profile.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "UserProfileManager.h"\r
-\r
-\r
-/**\r
- Get user name from the popup windows.\r
-\r
- @param[in, out] UserNameLen On entry, point to UserName buffer lengh, in bytes.\r
- On exit, point to input user name length, in bytes.\r
- @param[out] UserName The buffer to hold the input user name.\r
-\r
- @retval EFI_ABORTED It is given up by pressing 'ESC' key.\r
- @retval EFI_NOT_READY Not a valid input at all.\r
- @retval EFI_SUCCESS Get a user name successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-GetUserNameInput (\r
- IN OUT UINTN *UserNameLen,\r
- OUT CHAR16 *UserName\r
- )\r
-{\r
- EFI_INPUT_KEY Key;\r
- UINTN NameLen;\r
- CHAR16 Name[USER_NAME_LENGTH];\r
-\r
- NameLen = 0;\r
- while (TRUE) {\r
- Name[NameLen] = L'_';\r
- Name[NameLen + 1] = L'\0';\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- L"Input User Name",\r
- L"---------------------",\r
- Name,\r
- NULL\r
- );\r
- //\r
- // Check key.\r
- //\r
- if (Key.ScanCode == SCAN_NULL) {\r
- if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {\r
- //\r
- // Add the null terminator.\r
- //\r
- Name[NameLen] = 0;\r
- NameLen++;\r
- break;\r
- } else if ((Key.UnicodeChar == CHAR_NULL) ||\r
- (Key.UnicodeChar == CHAR_TAB) ||\r
- (Key.UnicodeChar == CHAR_LINEFEED)\r
- ) {\r
- continue;\r
- } else {\r
- if (Key.UnicodeChar == CHAR_BACKSPACE) {\r
- if (NameLen > 0) {\r
- NameLen--;\r
- }\r
- } else {\r
- Name[NameLen] = Key.UnicodeChar;\r
- NameLen++;\r
- if (NameLen + 1 == USER_NAME_LENGTH) {\r
- //\r
- // Add the null terminator.\r
- //\r
- Name[NameLen] = 0;\r
- NameLen++;\r
- break;\r
- }\r
- }\r
- }\r
- }\r
-\r
- if (Key.ScanCode == SCAN_ESC) {\r
- return EFI_ABORTED;\r
- }\r
- }\r
-\r
- if (NameLen <= 1) {\r
- return EFI_NOT_READY;\r
- }\r
-\r
- if (*UserNameLen < NameLen * sizeof (CHAR16)) {\r
- return EFI_NOT_READY;\r
- }\r
-\r
- *UserNameLen = NameLen * sizeof (CHAR16);\r
- CopyMem (UserName, Name, *UserNameLen);\r
-\r
- return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
- Set a user's username.\r
-\r
- @param[in] User Handle of a user profile .\r
- @param[in] UserNameLen The lengh of UserName.\r
- @param[in] UserName Point to the buffer of user name.\r
-\r
- @retval EFI_NOT_READY The usernme in mAddUserName had been used.\r
- @retval EFI_SUCCESS Change the user's username successfully with\r
- username in mAddUserName.\r
-\r
-**/\r
-EFI_STATUS\r
-SetUserName (\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN UINTN UserNameLen,\r
- IN CHAR16 *UserName\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO_HANDLE UserInfo;\r
- EFI_USER_PROFILE_HANDLE TempUser;\r
- EFI_USER_INFO *NewUserInfo;\r
-\r
- NewUserInfo = AllocateZeroPool (sizeof (EFI_USER_INFO) + UserNameLen);\r
- ASSERT (NewUserInfo != NULL);\r
-\r
- NewUserInfo->InfoType = EFI_USER_INFO_NAME_RECORD;\r
- NewUserInfo->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV |\r
- EFI_USER_INFO_PUBLIC |\r
- EFI_USER_INFO_EXCLUSIVE;\r
- NewUserInfo->InfoSize = (UINT32) (sizeof (EFI_USER_INFO) + UserNameLen);\r
- CopyMem ((UINT8 *) (NewUserInfo + 1), UserName, UserNameLen);\r
- TempUser = NULL;\r
- Status = mUserManager->Find (\r
- mUserManager,\r
- &TempUser,\r
- NULL,\r
- NewUserInfo,\r
- NewUserInfo->InfoSize\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- //\r
- // The user name had been used, return error.\r
- //\r
- FreePool (NewUserInfo);\r
- return EFI_NOT_READY;\r
- }\r
-\r
- UserInfo = NULL;\r
- mUserManager->SetInfo (\r
- mUserManager,\r
- User,\r
- &UserInfo,\r
- NewUserInfo,\r
- NewUserInfo->InfoSize\r
- );\r
- FreePool (NewUserInfo);\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- Set create date of the specified user.\r
-\r
- @param[in] User Handle of a user profile.\r
-\r
-**/\r
-VOID\r
-SetCreateDate (\r
- IN EFI_USER_PROFILE_HANDLE User\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO_HANDLE UserInfo;\r
- EFI_USER_INFO_CREATE_DATE Date;\r
- EFI_USER_INFO *NewUserInfo;\r
-\r
- NewUserInfo = AllocateZeroPool (\r
- sizeof (EFI_USER_INFO) +\r
- sizeof (EFI_USER_INFO_CREATE_DATE)\r
- );\r
- ASSERT (NewUserInfo != NULL);\r
-\r
- NewUserInfo->InfoType = EFI_USER_INFO_CREATE_DATE_RECORD;\r
- NewUserInfo->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV |\r
- EFI_USER_INFO_PUBLIC |\r
- EFI_USER_INFO_EXCLUSIVE;\r
- NewUserInfo->InfoSize = sizeof (EFI_USER_INFO) + sizeof (EFI_USER_INFO_CREATE_DATE);\r
- Status = gRT->GetTime (&Date, NULL);\r
- if (EFI_ERROR (Status)) {\r
- FreePool (NewUserInfo);\r
- return ;\r
- }\r
-\r
- CopyMem ((UINT8 *) (NewUserInfo + 1), &Date, sizeof (EFI_USER_INFO_CREATE_DATE));\r
- UserInfo = NULL;\r
- mUserManager->SetInfo (\r
- mUserManager,\r
- User,\r
- &UserInfo,\r
- NewUserInfo,\r
- NewUserInfo->InfoSize\r
- );\r
- FreePool (NewUserInfo);\r
-}\r
-\r
-\r
-/**\r
- Set the default identity policy of the specified user.\r
-\r
- @param[in] User Handle of a user profile.\r
-\r
-**/\r
-VOID\r
-SetIdentityPolicy (\r
- IN EFI_USER_PROFILE_HANDLE User\r
- )\r
-{\r
- EFI_USER_INFO_IDENTITY_POLICY *Policy;\r
- EFI_USER_INFO_HANDLE UserInfo;\r
- EFI_USER_INFO *NewUserInfo;\r
-\r
- NewUserInfo = AllocateZeroPool (\r
- sizeof (EFI_USER_INFO) +\r
- sizeof (EFI_USER_INFO_IDENTITY_POLICY)\r
- );\r
- ASSERT (NewUserInfo != NULL);\r
-\r
- Policy = (EFI_USER_INFO_IDENTITY_POLICY *) (NewUserInfo + 1);\r
- Policy->Type = EFI_USER_INFO_IDENTITY_TRUE;\r
- Policy->Length = sizeof (EFI_USER_INFO_IDENTITY_POLICY);\r
-\r
- NewUserInfo->InfoType = EFI_USER_INFO_IDENTITY_POLICY_RECORD;\r
- NewUserInfo->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV |\r
- EFI_USER_INFO_PUBLIC |\r
- EFI_USER_INFO_EXCLUSIVE;\r
- NewUserInfo->InfoSize = sizeof (EFI_USER_INFO) + Policy->Length;\r
- UserInfo = NULL;\r
- mUserManager->SetInfo (\r
- mUserManager,\r
- User,\r
- &UserInfo,\r
- NewUserInfo,\r
- NewUserInfo->InfoSize\r
- );\r
- FreePool (NewUserInfo);\r
-}\r
-\r
-\r
-/**\r
- Set the default access policy of the specified user.\r
-\r
- @param[in] User Handle of a user profile.\r
-\r
-**/\r
-VOID\r
-SetAccessPolicy (\r
- IN EFI_USER_PROFILE_HANDLE User\r
- )\r
-{\r
- EFI_USER_INFO_ACCESS_CONTROL *Control;\r
- EFI_USER_INFO_HANDLE UserInfo;\r
- EFI_USER_INFO *NewUserInfo;\r
-\r
- NewUserInfo = AllocateZeroPool (\r
- sizeof (EFI_USER_INFO) +\r
- sizeof (EFI_USER_INFO_ACCESS_CONTROL)\r
- );\r
- ASSERT (NewUserInfo != NULL);\r
-\r
- Control = (EFI_USER_INFO_ACCESS_CONTROL *) (NewUserInfo + 1);\r
- Control->Type = EFI_USER_INFO_ACCESS_ENROLL_SELF;\r
- Control->Size = sizeof (EFI_USER_INFO_ACCESS_CONTROL);\r
-\r
- NewUserInfo->InfoType = EFI_USER_INFO_ACCESS_POLICY_RECORD;\r
- NewUserInfo->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV |\r
- EFI_USER_INFO_PUBLIC |\r
- EFI_USER_INFO_EXCLUSIVE;\r
- NewUserInfo->InfoSize = sizeof (EFI_USER_INFO) + Control->Size;\r
- UserInfo = NULL;\r
- mUserManager->SetInfo (\r
- mUserManager,\r
- User,\r
- &UserInfo,\r
- NewUserInfo,\r
- NewUserInfo->InfoSize\r
- );\r
- FreePool (NewUserInfo);\r
-}\r
-\r
-\r
-/**\r
- Add a new user profile into the user profile database.\r
-\r
-**/\r
-VOID\r
-CallAddUser (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_INPUT_KEY Key;\r
- EFI_USER_PROFILE_HANDLE User;\r
- UINTN UserNameLen;\r
- CHAR16 UserName[USER_NAME_LENGTH];\r
- CHAR16 *QuestionStr;\r
- CHAR16 *PromptStr;\r
-\r
- QuestionStr = NULL;\r
- PromptStr = NULL;\r
-\r
- //\r
- // Get user name to add.\r
- //\r
- UserNameLen = sizeof (UserName);\r
- Status = GetUserNameInput (&UserNameLen, UserName);\r
- if (EFI_ERROR (Status)) {\r
- if (Status != EFI_ABORTED) {\r
- QuestionStr = GetStringById (STRING_TOKEN (STR_GET_USERNAME_FAILED));\r
- PromptStr = GetStringById (STRING_TOKEN (STR_STROKE_KEY_CONTINUE));\r
- goto Done;\r
- }\r
- return ;\r
- }\r
-\r
- //\r
- // Create a new user profile.\r
- //\r
- User = NULL;\r
- Status = mUserManager->Create (mUserManager, &User);\r
- if (EFI_ERROR (Status)) {\r
- QuestionStr = GetStringById (STRING_TOKEN (STR_CREATE_PROFILE_FAILED));\r
- PromptStr = GetStringById (STRING_TOKEN (STR_STROKE_KEY_CONTINUE));\r
- } else {\r
- //\r
- // Add default user information.\r
- //\r
- Status = SetUserName (User, UserNameLen, UserName);\r
- if (EFI_ERROR (Status)) {\r
- QuestionStr = GetStringById (STRING_TOKEN (STR_USER_ALREADY_EXISTED));\r
- PromptStr = GetStringById (STRING_TOKEN (STR_STROKE_KEY_CONTINUE));\r
- goto Done;\r
- }\r
-\r
- SetCreateDate (User);\r
- SetIdentityPolicy (User);\r
- SetAccessPolicy (User);\r
-\r
- QuestionStr = GetStringById (STRING_TOKEN (STR_CREATE_PROFILE_SUCCESS));\r
- PromptStr = GetStringById (STRING_TOKEN (STR_STROKE_KEY_CONTINUE));\r
- }\r
-\r
-Done:\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- QuestionStr,\r
- L"",\r
- PromptStr,\r
- NULL\r
- );\r
- FreePool (QuestionStr);\r
- FreePool (PromptStr);\r
-}\r
-\r
+++ /dev/null
-/** @file\r
- The functions to delete a user profile.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "UserProfileManager.h"\r
-\r
-/**\r
- Get the username from the specified user.\r
-\r
- @param[in] User Handle of a user profile.\r
-\r
- @retval EFI_STRING_ID The String Id of the user's username.\r
-\r
-**/\r
-EFI_STRING_ID\r
-GetUserName (\r
- IN EFI_USER_PROFILE_HANDLE User\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO_HANDLE UserInfo;\r
- EFI_USER_INFO *Info;\r
- UINTN InfoSize;\r
- UINTN MemSize;\r
- UINTN NameLen;\r
- CHAR16 UserName[USER_NAME_LENGTH];\r
- EFI_STRING_ID UserId;\r
-\r
- //\r
- // Allocate user information memory.\r
- //\r
- MemSize = sizeof (EFI_USER_INFO) + 63;\r
- Info = AllocateZeroPool (MemSize);\r
- ASSERT (Info != NULL);\r
-\r
- //\r
- // Get user name information.\r
- //\r
- UserInfo = NULL;\r
- while (TRUE) {\r
- InfoSize = MemSize;\r
- //\r
- // Get next user information.\r
- //\r
- Status = mUserManager->GetNextInfo (\r
- mUserManager,\r
- User,\r
- &UserInfo\r
- );\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
-\r
- Status = mUserManager->GetInfo (\r
- mUserManager,\r
- User,\r
- UserInfo,\r
- Info,\r
- &InfoSize\r
- );\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- MemSize = InfoSize;\r
- FreePool (Info);\r
- Info = AllocateZeroPool (MemSize);\r
- ASSERT (Info != NULL);\r
-\r
- Status = mUserManager->GetInfo (\r
- mUserManager,\r
- User,\r
- UserInfo,\r
- Info,\r
- &InfoSize\r
- );\r
- }\r
- //\r
- // Check user information.\r
- //\r
- if (Status == EFI_SUCCESS) {\r
- if (Info->InfoType == EFI_USER_INFO_NAME_RECORD) {\r
- NameLen = Info->InfoSize - sizeof (EFI_USER_INFO);\r
- if (NameLen > USER_NAME_LENGTH * sizeof (CHAR16)) {\r
- NameLen = USER_NAME_LENGTH * sizeof (CHAR16);\r
- }\r
- ASSERT (NameLen >= sizeof (CHAR16));\r
- CopyMem (UserName, (UINT8 *) (Info + 1), NameLen);\r
- UserName[NameLen / sizeof (CHAR16) - 1] = 0;\r
- UserId = HiiSetString (\r
- mCallbackInfo->HiiHandle,\r
- 0,\r
- UserName,\r
- NULL\r
- );\r
- if (UserId != 0) {\r
- FreePool (Info);\r
- return UserId;\r
- }\r
- }\r
- }\r
- }\r
-\r
- FreePool (Info);\r
- return 0;\r
-}\r
-\r
-\r
-/**\r
- Add a username item in form.\r
-\r
- @param[in] User Points to the user profile whose username is added.\r
- @param[in] Index The index of the user in the user name list\r
- @param[in] OpCodeHandle Points to container for dynamic created opcodes.\r
-\r
-**/\r
-VOID\r
-AddUserToForm (\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN UINT16 Index,\r
- IN VOID *OpCodeHandle\r
- )\r
-{\r
- EFI_STRING_ID NameId;\r
-\r
- //\r
- // Get user name\r
- //\r
- NameId = GetUserName (User);\r
- if (NameId == 0) {\r
- return ;\r
- }\r
-\r
- //\r
- // Create user name option.\r
- //\r
- switch (Index & KEY_FIRST_FORM_MASK) {\r
- case KEY_MODIFY_USER:\r
- HiiCreateGotoOpCode (\r
- OpCodeHandle, // Container for dynamic created opcodes\r
- FORMID_USER_INFO, // Target Form ID\r
- NameId, // Prompt text\r
- STRING_TOKEN (STR_NULL_STRING), // Help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- Index // Question ID\r
- );\r
- break;\r
-\r
- case KEY_DEL_USER:\r
- HiiCreateActionOpCode (\r
- OpCodeHandle, // Container for dynamic created opcodes\r
- Index, // Question ID\r
- NameId, // Prompt text\r
- STRING_TOKEN (STR_NULL_STRING), // Help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- 0 // Action String ID\r
- );\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
-}\r
-\r
-\r
-/**\r
- Delete the user specified by UserIndex in user profile database.\r
-\r
- @param[in] UserIndex The index of user in the user name list\r
- to be deleted.\r
-\r
-**/\r
-VOID\r
-DeleteUser (\r
- IN UINT8 UserIndex\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_PROFILE_HANDLE User;\r
- EFI_INPUT_KEY Key;\r
- EFI_USER_INFO_HANDLE UserInfo;\r
- EFI_USER_INFO *Info;\r
- UINTN InfoSize;\r
-\r
- //\r
- // Find specified user profile and delete it.\r
- //\r
- User = NULL;\r
- Status = mUserManager->GetNext (mUserManager, &User);\r
- if (EFI_ERROR (Status)) {\r
- goto Done;\r
- }\r
-\r
- while (UserIndex > 1) {\r
- Status = mUserManager->GetNext (mUserManager, &User);\r
- if (EFI_ERROR (Status)) {\r
- goto Done;\r
- }\r
- UserIndex--;\r
- }\r
-\r
- if (UserIndex == 1) {\r
- //\r
- // Get the identification policy.\r
- //\r
- Status = FindInfoByType (User, EFI_USER_INFO_IDENTITY_POLICY_RECORD, &UserInfo);\r
- if (EFI_ERROR (Status)) {\r
- goto Done;\r
- }\r
-\r
- InfoSize = 0;\r
- Info = NULL;\r
- Status = mUserManager->GetInfo (mUserManager, User, UserInfo, Info, &InfoSize);\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- Info = AllocateZeroPool (InfoSize);\r
- if (Info == NULL) {\r
- goto Done;\r
- }\r
- Status = mUserManager->GetInfo (mUserManager, User, UserInfo, Info, &InfoSize);\r
- }\r
-\r
- //\r
- // Delete the user on the credential providers by its identification policy.\r
- //\r
- ASSERT (Info != NULL);\r
- DeleteCredentialFromProviders ((UINT8 *)(Info + 1), Info->InfoSize - sizeof (EFI_USER_INFO), User);\r
- FreePool (Info);\r
-\r
- Status = mUserManager->Delete (mUserManager, User);\r
- if (EFI_ERROR (Status)) {\r
- goto Done;\r
- }\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- L"Delete User Succeed!",\r
- L"",\r
- L"Please Press Any Key to Continue ...",\r
- NULL\r
- );\r
- return ;\r
- }\r
-\r
-Done:\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- L"Delete User Failed!",\r
- L"",\r
- L"Please Press Any Key to Continue ...",\r
- NULL\r
- );\r
-}\r
-\r
-\r
-/**\r
- Display user select form, cab select a user to delete.\r
-\r
-**/\r
-VOID\r
-SelectUserToDelete (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINT8 Index;\r
- EFI_USER_PROFILE_HANDLE User;\r
- EFI_USER_PROFILE_HANDLE CurrentUser;\r
- VOID *StartOpCodeHandle;\r
- VOID *EndOpCodeHandle;\r
- EFI_IFR_GUID_LABEL *StartLabel;\r
- EFI_IFR_GUID_LABEL *EndLabel;\r
-\r
- //\r
- // Initialize the container for dynamic opcodes.\r
- //\r
- StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (StartOpCodeHandle != NULL);\r
-\r
- EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (EndOpCodeHandle != NULL);\r
-\r
- //\r
- // Create Hii Extend Label OpCode.\r
- //\r
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- StartOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- StartLabel->Number = LABEL_USER_DEL_FUNC;\r
-\r
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- EndOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- EndLabel->Number = LABEL_END;\r
-\r
- //\r
- // Add each user can be deleted.\r
- //\r
- User = NULL;\r
- Index = 1;\r
- mUserManager->Current (mUserManager, &CurrentUser);\r
- while (TRUE) {\r
- Status = mUserManager->GetNext (mUserManager, &User);\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
-\r
- if (User != CurrentUser) {\r
- AddUserToForm (\r
- User,\r
- (UINT16)(KEY_DEL_USER | KEY_SELECT_USER | Index),\r
- StartOpCodeHandle\r
- );\r
- }\r
- Index++;\r
- }\r
-\r
- HiiUpdateForm (\r
- mCallbackInfo->HiiHandle, // HII handle\r
- &gUserProfileManagerGuid, // Formset GUID\r
- FORMID_DEL_USER, // Form ID\r
- StartOpCodeHandle, // Label for where to insert opcodes\r
- EndOpCodeHandle // Replace data\r
- );\r
-\r
- HiiFreeOpCodeHandle (StartOpCodeHandle);\r
- HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-}\r
+++ /dev/null
-/** @file\r
- This driver is a configuration tool for adding, deleting or modifying user\r
- profiles, including gathering the necessary information to ascertain their\r
- identity in the future, updating user access policy and identification\r
- policy, etc.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-(C) Copyright 2018 Hewlett Packard Enterprise Development LP<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "UserProfileManager.h"\r
-\r
-EFI_USER_MANAGER_PROTOCOL *mUserManager = NULL;\r
-CREDENTIAL_PROVIDER_INFO *mProviderInfo = NULL;\r
-UINT8 mProviderChoice;\r
-UINT8 mConncetLogical;\r
-USER_INFO_ACCESS mAccessInfo;\r
-USER_INFO mUserInfo;\r
-USER_PROFILE_MANAGER_CALLBACK_INFO *mCallbackInfo;\r
-HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath = {\r
- {\r
- {\r
- HARDWARE_DEVICE_PATH,\r
- HW_VENDOR_DP,\r
- {\r
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),\r
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
- }\r
- },\r
- USER_PROFILE_MANAGER_GUID\r
- },\r
- {\r
- END_DEVICE_PATH_TYPE,\r
- END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
- {\r
- (UINT8) (END_DEVICE_PATH_LENGTH),\r
- (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
- }\r
- }\r
-};\r
-\r
-\r
-/**\r
- Get string by string id from HII Interface.\r
-\r
-\r
- @param[in] Id String ID to get the string from.\r
-\r
- @retval CHAR16 * String from ID.\r
- @retval NULL If error occurs.\r
-\r
-**/\r
-CHAR16 *\r
-GetStringById (\r
- IN EFI_STRING_ID Id\r
- )\r
-{\r
- //\r
- // Get the current string for the current Language.\r
- //\r
- return HiiGetString (mCallbackInfo->HiiHandle, Id, NULL);\r
-}\r
-\r
-\r
-/**\r
- This function gets all the credential providers in the system and saved them\r
- to mProviderInfo.\r
-\r
- @retval EFI_SUCESS Init credential provider database successfully.\r
- @retval Others Fail to init credential provider database.\r
-\r
-**/\r
-EFI_STATUS\r
-InitProviderInfo (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN HandleCount;\r
- EFI_HANDLE *HandleBuf;\r
- UINTN Index;\r
-\r
- //\r
- // Try to find all the user credential provider driver.\r
- //\r
- HandleCount = 0;\r
- HandleBuf = NULL;\r
- Status = gBS->LocateHandleBuffer (\r
- ByProtocol,\r
- &gEfiUserCredential2ProtocolGuid,\r
- NULL,\r
- &HandleCount,\r
- &HandleBuf\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Get provider infomation.\r
- //\r
- if (mProviderInfo != NULL) {\r
- FreePool (mProviderInfo);\r
- }\r
- mProviderInfo = AllocateZeroPool (\r
- sizeof (CREDENTIAL_PROVIDER_INFO) -\r
- sizeof (EFI_USER_CREDENTIAL2_PROTOCOL *) +\r
- HandleCount * sizeof (EFI_USER_CREDENTIAL2_PROTOCOL *)\r
- );\r
- if (mProviderInfo == NULL) {\r
- FreePool (HandleBuf);\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- mProviderInfo->Count = HandleCount;\r
- for (Index = 0; Index < HandleCount; Index++) {\r
- Status = gBS->HandleProtocol (\r
- HandleBuf[Index],\r
- &gEfiUserCredential2ProtocolGuid,\r
- (VOID **) &mProviderInfo->Provider[Index]\r
- );\r
- if (EFI_ERROR (Status)) {\r
- FreePool (HandleBuf);\r
- FreePool (mProviderInfo);\r
- mProviderInfo = NULL;\r
- return Status;\r
- }\r
- }\r
-\r
- FreePool (HandleBuf);\r
- return EFI_SUCCESS;\r
-}\r
-\r
-\r
-/**\r
- This function processes changes in user profile configuration.\r
-\r
- @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
- @param Action Specifies the type of action taken by the browser.\r
- @param QuestionId A unique value which is sent to the original\r
- exporting driver so that it can identify the type\r
- of data to expect.\r
- @param Type The type of value for the question.\r
- @param Value A pointer to the data being sent to the original\r
- exporting driver.\r
- @param ActionRequest On return, points to the action requested by the\r
- callback function.\r
-\r
- @retval EFI_SUCCESS The callback successfully handled the action.\r
- @retval Others Fail to handle the action.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileManagerCallback (\r
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
- IN EFI_BROWSER_ACTION Action,\r
- IN EFI_QUESTION_ID QuestionId,\r
- IN UINT8 Type,\r
- IN EFI_IFR_TYPE_VALUE *Value,\r
- OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_INPUT_KEY Key;\r
- UINT32 CurrentAccessRight;\r
- CHAR16 *QuestionStr;\r
- CHAR16 *PromptStr;\r
- VOID *StartOpCodeHandle;\r
- VOID *EndOpCodeHandle;\r
- EFI_IFR_GUID_LABEL *StartLabel;\r
- EFI_IFR_GUID_LABEL *EndLabel;\r
- EFI_USER_PROFILE_HANDLE CurrentUser;\r
-\r
- Status = EFI_SUCCESS;\r
-\r
- switch (Action) {\r
- case EFI_BROWSER_ACTION_FORM_OPEN:\r
- {\r
- //\r
- // Update user manage Form when user manage Form is opened.\r
- // This will be done only in FORM_OPEN CallBack of question with QUESTIONID_USER_MANAGE from user manage Form.\r
- //\r
- if (QuestionId != QUESTIONID_USER_MANAGE) {\r
- return EFI_SUCCESS;\r
- }\r
-\r
- //\r
- // Get current user\r
- //\r
- CurrentUser = NULL;\r
- mUserManager->Current (mUserManager, &CurrentUser);\r
- if (CurrentUser == NULL) {\r
- DEBUG ((DEBUG_ERROR, "Error: current user does not exist!\n"));\r
- return EFI_NOT_READY;\r
- }\r
-\r
- //\r
- // Get current user's right information.\r
- //\r
- Status = GetAccessRight (&CurrentAccessRight);\r
- if (EFI_ERROR (Status)) {\r
- CurrentAccessRight = EFI_USER_INFO_ACCESS_ENROLL_SELF;\r
- }\r
-\r
- //\r
- // Init credential provider information.\r
- //\r
- Status = InitProviderInfo ();\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
- //\r
- // Initialize the container for dynamic opcodes.\r
- //\r
- StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (StartOpCodeHandle != NULL);\r
-\r
- EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (EndOpCodeHandle != NULL);\r
-\r
- //\r
- // Create Hii Extend Label OpCode.\r
- //\r
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- StartOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- StartLabel->Number = LABEL_USER_MANAGE_FUNC;\r
-\r
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- EndOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- EndLabel->Number = LABEL_END;\r
-\r
- //\r
- // Add user profile option.\r
- //\r
- if ((CurrentAccessRight == EFI_USER_INFO_ACCESS_MANAGE) ||\r
- (CurrentAccessRight == EFI_USER_INFO_ACCESS_ENROLL_OTHERS)\r
- ) {\r
- HiiCreateActionOpCode (\r
- StartOpCodeHandle, // Container for dynamic created opcodes\r
- KEY_ADD_USER, // Question ID\r
- STRING_TOKEN (STR_ADD_USER_TITLE), // Prompt text\r
- STRING_TOKEN (STR_ADD_USER_HELP), // Help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- 0 // Action String ID\r
- );\r
- }\r
-\r
- //\r
- // Add modify user profile option.\r
- //\r
- HiiCreateGotoOpCode (\r
- StartOpCodeHandle, // Container for dynamic created opcodes\r
- FORMID_MODIFY_USER, // Target Form ID\r
- STRING_TOKEN (STR_MODIFY_USER_TITLE), // Prompt text\r
- STRING_TOKEN (STR_MODIFY_USER_HELP), // Help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- KEY_MODIFY_USER // Question ID\r
- );\r
-\r
- //\r
- // Add delete user profile option\r
- //\r
- if (CurrentAccessRight == EFI_USER_INFO_ACCESS_MANAGE) {\r
- HiiCreateGotoOpCode (\r
- StartOpCodeHandle, // Container for dynamic created opcodes\r
- FORMID_DEL_USER, // Target Form ID\r
- STRING_TOKEN (STR_DELETE_USER_TITLE), // Prompt text\r
- STRING_TOKEN (STR_DELETE_USER_HELP), // Help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- KEY_DEL_USER // Question ID\r
- );\r
- }\r
-\r
- HiiUpdateForm (\r
- mCallbackInfo->HiiHandle, // HII handle\r
- &gUserProfileManagerGuid, // Formset GUID\r
- FORMID_USER_MANAGE, // Form ID\r
- StartOpCodeHandle, // Label for where to insert opcodes\r
- EndOpCodeHandle // Replace data\r
- );\r
-\r
- HiiFreeOpCodeHandle (StartOpCodeHandle);\r
- HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-\r
- return EFI_SUCCESS;\r
- }\r
- break;\r
-\r
- case EFI_BROWSER_ACTION_FORM_CLOSE:\r
- Status = EFI_SUCCESS;\r
- break;\r
-\r
- case EFI_BROWSER_ACTION_CHANGED:\r
- {\r
- //\r
- // Handle the request from form.\r
- //\r
- if ((Value == NULL) || (ActionRequest == NULL)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Judge first 2 bits.\r
- //\r
- switch (QuestionId & KEY_FIRST_FORM_MASK) {\r
- //\r
- // Add user profile operation.\r
- //\r
- case KEY_ADD_USER:\r
- CallAddUser ();\r
- break;\r
-\r
- //\r
- // Delete user profile operation.\r
- //\r
- case KEY_DEL_USER:\r
- //\r
- // Judge next 2 bits.\r
- //\r
- switch (QuestionId & KEY_SECOND_FORM_MASK) {\r
- //\r
- // Delete specified user profile.\r
- //\r
- case KEY_SELECT_USER:\r
- DeleteUser ((UINT8) QuestionId);\r
- //\r
- // Update select user form after delete a user.\r
- //\r
- SelectUserToDelete ();\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- break;\r
-\r
- //\r
- // Modify user profile operation.\r
- //\r
- case KEY_MODIFY_USER:\r
- //\r
- // Judge next 2 bits.\r
- //\r
- switch (QuestionId & KEY_SECOND_FORM_MASK) {\r
- //\r
- // Enter user profile information form.\r
- //\r
- case KEY_SELECT_USER:\r
- //\r
- // Judge next 3 bits.\r
- //\r
- switch (QuestionId & KEY_MODIFY_INFO_MASK) {\r
- //\r
- // Modify user name.\r
- //\r
- case KEY_MODIFY_NAME:\r
- ModifyUserName ();\r
- //\r
- // Update username in parent form.\r
- //\r
- SelectUserToModify ();\r
- break;\r
-\r
- //\r
- // Modify identity policy.\r
- //\r
- case KEY_MODIFY_IP:\r
- //\r
- // Judge next 3 bits\r
- //\r
- switch (QuestionId & KEY_MODIFY_IP_MASK) {\r
- //\r
- // Change credential provider option.\r
- //\r
- case KEY_MODIFY_PROV:\r
- mProviderChoice = Value->u8;\r
- break;\r
-\r
- //\r
- // Change logical connector.\r
- //\r
- case KEY_MODIFY_CONN:\r
- mConncetLogical = Value->u8;\r
- break;\r
-\r
- //\r
- // Save option.\r
- //\r
- case KEY_ADD_IP_OP:\r
- AddIdentityPolicyItem ();\r
- break;\r
-\r
- //\r
- // Return to user profile information form.\r
- //\r
- case KEY_IP_RETURN_UIF:\r
- SaveIdentityPolicy ();\r
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- break;\r
-\r
- //\r
- // Modify access policy.\r
- //\r
- case KEY_MODIFY_AP:\r
- //\r
- // Judge next 3 bits.\r
- //\r
- switch (QuestionId & KEY_MODIFY_AP_MASK) {\r
- //\r
- // Change access right choice.\r
- //\r
- case KEY_MODIFY_RIGHT:\r
- mAccessInfo.AccessRight = Value->u8;\r
- break;\r
-\r
- //\r
- // Change setup choice.\r
- //\r
- case KEY_MODIFY_SETUP:\r
- mAccessInfo.AccessSetup= Value->u8;\r
- break;\r
-\r
- //\r
- // Change boot order choice.\r
- //\r
- case KEY_MODIFY_BOOT:\r
- mAccessInfo.AccessBootOrder = Value->u32;\r
- break;\r
-\r
- //\r
- // Return to user profile information form.\r
- //\r
- case KEY_AP_RETURN_UIF:\r
- SaveAccessPolicy ();\r
- *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- break;\r
-\r
- //\r
- // Access policy device path modified.\r
- //\r
- case KEY_MODIFY_AP_DP:\r
- //\r
- // Judge next 2 bits.\r
- //\r
- switch (QuestionId & KEY_MODIFY_DP_MASK) {\r
- //\r
- // Load permit device path modified.\r
- //\r
- case KEY_LOAD_PERMIT_MODIFY:\r
- QuestionStr = GetStringById (STRING_TOKEN (STR_MOVE_TO_FORBID_LIST));\r
- PromptStr = GetStringById (STRING_TOKEN (STR_PRESS_KEY_CONTINUE));\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- QuestionStr,\r
- L"",\r
- PromptStr,\r
- NULL\r
- );\r
- FreePool (QuestionStr);\r
- FreePool (PromptStr);\r
- if (Key.UnicodeChar != CHAR_CARRIAGE_RETURN) {\r
- break;\r
- }\r
-\r
- AddToForbidLoad ((UINT16)(QuestionId & (KEY_MODIFY_DP_MASK - 1)));\r
- DisplayLoadPermit ();\r
- break;\r
-\r
- //\r
- // Load forbid device path modified.\r
- //\r
- case KEY_LOAD_FORBID_MODIFY:\r
- QuestionStr = GetStringById (STRING_TOKEN (STR_MOVE_TO_PERMIT_LIST));\r
- PromptStr = GetStringById (STRING_TOKEN (STR_PRESS_KEY_CONTINUE));\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- QuestionStr,\r
- L"",\r
- PromptStr,\r
- NULL\r
- );\r
- FreePool (QuestionStr);\r
- FreePool (PromptStr);\r
- if (Key.UnicodeChar != CHAR_CARRIAGE_RETURN) {\r
- break;\r
- }\r
-\r
- DeleteFromForbidLoad ((UINT16)(QuestionId & (KEY_MODIFY_DP_MASK - 1)));\r
- DisplayLoadForbid ();\r
- break;\r
-\r
- //\r
- // Connect permit device path modified.\r
- //\r
- case KEY_CONNECT_PERMIT_MODIFY:\r
- break;\r
-\r
- //\r
- // Connect forbid device path modified.\r
- //\r
- case KEY_CONNECT_FORBID_MODIFY:\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- }\r
- break;\r
-\r
-\r
- case EFI_BROWSER_ACTION_CHANGING:\r
- {\r
- //\r
- // Handle the request from form.\r
- //\r
- if (Value == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- //\r
- // Judge first 2 bits.\r
- //\r
- switch (QuestionId & KEY_FIRST_FORM_MASK) {\r
- //\r
- // Delete user profile operation.\r
- //\r
- case KEY_DEL_USER:\r
- //\r
- // Judge next 2 bits.\r
- //\r
- switch (QuestionId & KEY_SECOND_FORM_MASK) {\r
- //\r
- // Enter delete user profile form.\r
- //\r
- case KEY_ENTER_NEXT_FORM:\r
- SelectUserToDelete ();\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- break;\r
-\r
- //\r
- // Modify user profile operation.\r
- //\r
- case KEY_MODIFY_USER:\r
- //\r
- // Judge next 2 bits.\r
- //\r
- switch (QuestionId & KEY_SECOND_FORM_MASK) {\r
- //\r
- // Enter modify user profile form.\r
- //\r
- case KEY_ENTER_NEXT_FORM:\r
- SelectUserToModify ();\r
- break;\r
-\r
- //\r
- // Enter user profile information form.\r
- //\r
- case KEY_SELECT_USER:\r
- //\r
- // Judge next 3 bits.\r
- //\r
- switch (QuestionId & KEY_MODIFY_INFO_MASK) {\r
- //\r
- // Display user information form.\r
- //\r
- case KEY_ENTER_NEXT_FORM:\r
- ModifyUserInfo ((UINT8) QuestionId);\r
- break;\r
-\r
- //\r
- // Modify identity policy.\r
- //\r
- case KEY_MODIFY_IP:\r
- //\r
- // Judge next 3 bits\r
- //\r
- switch (QuestionId & KEY_MODIFY_IP_MASK) {\r
- //\r
- // Display identity policy modify form.\r
- //\r
- case KEY_ENTER_NEXT_FORM:\r
- ModifyIdentityPolicy ();\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- break;\r
-\r
- //\r
- // Modify access policy.\r
- //\r
- case KEY_MODIFY_AP:\r
- //\r
- // Judge next 3 bits.\r
- //\r
- switch (QuestionId & KEY_MODIFY_AP_MASK) {\r
- //\r
- // Display access policy modify form.\r
- //\r
- case KEY_ENTER_NEXT_FORM:\r
- ModidyAccessPolicy ();\r
- break;\r
- //\r
- // Load device path form.\r
- //\r
- case KEY_MODIFY_LOAD:\r
- //\r
- // Judge next 2 bits.\r
- //\r
- switch (QuestionId & KEY_DISPLAY_DP_MASK) {\r
- //\r
- // Permit load device path.\r
- //\r
- case KEY_PERMIT_MODIFY:\r
- DisplayLoadPermit ();\r
- break;\r
-\r
- //\r
- // Forbid load device path.\r
- //\r
- case KEY_FORBID_MODIFY:\r
- DisplayLoadForbid ();\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- break;\r
-\r
- //\r
- // Connect device path form.\r
- //\r
- case KEY_MODIFY_CONNECT:\r
- //\r
- // Judge next 2 bits.\r
- //\r
- switch (QuestionId & KEY_DISPLAY_DP_MASK) {\r
- //\r
- // Permit connect device path.\r
- //\r
- case KEY_PERMIT_MODIFY:\r
- DisplayConnectPermit ();\r
- break;\r
-\r
- //\r
- // Forbid connect device path.\r
- //\r
- case KEY_FORBID_MODIFY:\r
- DisplayConnectForbid ();\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- }\r
- break;\r
-\r
- default:\r
- //\r
- // All other action return unsupported.\r
- //\r
- Status = EFI_UNSUPPORTED;\r
- break;\r
- }\r
-\r
-\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- This function allows a caller to extract the current configuration for one\r
- or more named elements from the target driver.\r
-\r
-\r
- @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
- @param Request A null-terminated Unicode string in <ConfigRequest> format.\r
- @param Progress On return, points to a character in the Request string.\r
- Points to the string's null terminator if request was successful.\r
- Points to the most recent '&' before the first failing name/value\r
- pair (or the beginning of the string if the failure is in the\r
- first name/value pair) if the request was not successful.\r
- @param Results A null-terminated Unicode string in <ConfigAltResp> format which\r
- has all values filled in for the names in the Request string.\r
- String to be allocated by the called function.\r
-\r
- @retval EFI_SUCCESS The Results is filled with the requested values.\r
- @retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.\r
- @retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.\r
- @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FakeExtractConfig (\r
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
- IN CONST EFI_STRING Request,\r
- OUT EFI_STRING *Progress,\r
- OUT EFI_STRING *Results\r
- )\r
-{\r
- if (Progress == NULL || Results == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- *Progress = Request;\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
- This function processes the results of changes in configuration.\r
-\r
-\r
- @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.\r
- @param Configuration A null-terminated Unicode string in <ConfigResp> format.\r
- @param Progress A pointer to a string filled in with the offset of the most\r
- recent '&' before the first failing name/value pair (or the\r
- beginning of the string if the failure is in the first\r
- name/value pair) or the terminating NULL if all was successful.\r
-\r
- @retval EFI_SUCCESS The Results is processed successfully.\r
- @retval EFI_INVALID_PARAMETER Configuration is NULL.\r
- @retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-FakeRouteConfig (\r
- IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,\r
- IN CONST EFI_STRING Configuration,\r
- OUT EFI_STRING *Progress\r
- )\r
-{\r
- if (Configuration == NULL || Progress == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- *Progress = Configuration;\r
-\r
- return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
- Main entry for this driver.\r
-\r
- @param ImageHandle Image handle this driver.\r
- @param SystemTable Pointer to SystemTable.\r
-\r
- @retval EFI_SUCESS This function always complete successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UserProfileManagerInit (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
- )\r
-{\r
- EFI_STATUS Status;\r
- USER_PROFILE_MANAGER_CALLBACK_INFO *CallbackInfo;\r
-\r
- Status = gBS->LocateProtocol (\r
- &gEfiUserManagerProtocolGuid,\r
- NULL,\r
- (VOID **) &mUserManager\r
- );\r
- if (EFI_ERROR (Status)) {\r
- return EFI_SUCCESS;\r
- }\r
-\r
- //\r
- // Initialize driver private data.\r
- //\r
- ZeroMem (&mUserInfo, sizeof (mUserInfo));\r
- ZeroMem (&mAccessInfo, sizeof (mAccessInfo));\r
-\r
- CallbackInfo = AllocateZeroPool (sizeof (USER_PROFILE_MANAGER_CALLBACK_INFO));\r
- ASSERT (CallbackInfo != NULL);\r
-\r
- CallbackInfo->Signature = USER_PROFILE_MANAGER_SIGNATURE;\r
- CallbackInfo->ConfigAccess.ExtractConfig = FakeExtractConfig;\r
- CallbackInfo->ConfigAccess.RouteConfig = FakeRouteConfig;\r
- CallbackInfo->ConfigAccess.Callback = UserProfileManagerCallback;\r
- CallbackInfo->DriverHandle = NULL;\r
-\r
- //\r
- // Install Device Path Protocol and Config Access protocol to driver handle.\r
- //\r
- Status = gBS->InstallMultipleProtocolInterfaces (\r
- &CallbackInfo->DriverHandle,\r
- &gEfiDevicePathProtocolGuid,\r
- &mHiiVendorDevicePath,\r
- &gEfiHiiConfigAccessProtocolGuid,\r
- &CallbackInfo->ConfigAccess,\r
- NULL\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
-\r
- //\r
- // Publish HII data.\r
- //\r
- CallbackInfo->HiiHandle = HiiAddPackages (\r
- &gUserProfileManagerGuid,\r
- CallbackInfo->DriverHandle,\r
- UserProfileManagerStrings,\r
- UserProfileManagerVfrBin,\r
- NULL\r
- );\r
- ASSERT (CallbackInfo->HiiHandle != NULL);\r
- mCallbackInfo = CallbackInfo;\r
-\r
- return Status;\r
-}\r
-\r
-\r
+++ /dev/null
-/** @file\r
- The header file for user profile manager driver.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __EFI_USER_PROFILE_MANAGER_H__\r
-#define __EFI_USER_PROFILE_MANAGER_H__\r
-\r
-#include <Uefi.h>\r
-\r
-#include <Guid/GlobalVariable.h>\r
-#include <Guid/MdeModuleHii.h>\r
-\r
-#include <Protocol/HiiConfigAccess.h>\r
-#include <Protocol/UserCredential2.h>\r
-#include <Protocol/UserManager.h>\r
-\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/HiiLib.h>\r
-\r
-#include "UserProfileManagerData.h"\r
-\r
-#define USER_NAME_LENGTH 17\r
-\r
-//\r
-// Credential Provider Information.\r
-//\r
-typedef struct {\r
- UINTN Count;\r
- EFI_USER_CREDENTIAL2_PROTOCOL *Provider[1];\r
-} CREDENTIAL_PROVIDER_INFO;\r
-\r
-//\r
-// User profile information structure.\r
-//\r
-typedef struct {\r
- UINT64 UsageCount;\r
- EFI_TIME CreateDate;\r
- EFI_TIME UsageDate;\r
- UINTN AccessPolicyLen;\r
- UINTN IdentityPolicyLen;\r
- UINTN NewIdentityPolicyLen;\r
- UINT8 *AccessPolicy;\r
- UINT8 *IdentityPolicy;\r
- UINT8 *NewIdentityPolicy;\r
- CHAR16 UserName[USER_NAME_LENGTH];\r
- BOOLEAN CreateDateExist;\r
- BOOLEAN UsageDateExist;\r
- BOOLEAN AccessPolicyModified;\r
- BOOLEAN IdentityPolicyModified;\r
- BOOLEAN NewIdentityPolicyModified;\r
-} USER_INFO;\r
-\r
-//\r
-// User access information structure.\r
-//\r
-typedef struct {\r
- UINTN LoadPermitLen;\r
- UINTN LoadForbidLen;\r
- UINTN ConnectPermitLen;\r
- UINTN ConnectForbidLen;\r
- UINT8 *LoadPermit;\r
- UINT8 *LoadForbid;\r
- UINT8 *ConnectPermit;\r
- UINT8 *ConnectForbid;\r
- UINT32 AccessBootOrder;\r
- UINT8 AccessRight;\r
- UINT8 AccessSetup;\r
-} USER_INFO_ACCESS;\r
-\r
-#define USER_PROFILE_MANAGER_SIGNATURE SIGNATURE_32 ('U', 'P', 'M', 'S')\r
-\r
-typedef struct {\r
- UINTN Signature;\r
- EFI_HANDLE DriverHandle;\r
- EFI_HII_HANDLE HiiHandle;\r
- EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccess;\r
-} USER_PROFILE_MANAGER_CALLBACK_INFO;\r
-\r
-//\r
-// HII specific Vendor Device Path definition.\r
-//\r
-typedef struct {\r
- VENDOR_DEVICE_PATH VendorDevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL End;\r
-} HII_VENDOR_DEVICE_PATH;\r
-\r
-//\r
-// This is the generated IFR binary data for each formset defined in VFR.\r
-//\r
-extern UINT8 UserProfileManagerVfrBin[];\r
-\r
-//\r
-// This is the generated String package data for .UNI file.\r
-//\r
-extern UINT8 UserProfileManagerStrings[];\r
-\r
-//\r
-// The user manager protocol, used in several function.\r
-//\r
-extern EFI_USER_MANAGER_PROTOCOL *mUserManager;\r
-\r
-//\r
-// The credential providers database in system.\r
-//\r
-extern CREDENTIAL_PROVIDER_INFO *mProviderInfo;\r
-\r
-//\r
-// The variables used to update identity policy.\r
-//\r
-extern UINT8 mProviderChoice;\r
-extern UINT8 mConncetLogical;\r
-\r
-//\r
-// The variables used to update access policy.\r
-//\r
-extern USER_INFO_ACCESS mAccessInfo;\r
-\r
-//\r
-// The user information used to record all data in UI.\r
-//\r
-extern USER_INFO mUserInfo;\r
-\r
-extern USER_PROFILE_MANAGER_CALLBACK_INFO *mCallbackInfo;\r
-\r
-extern EFI_USER_PROFILE_HANDLE mModifyUser;\r
-\r
-/**\r
- Get string by string id from HII Interface.\r
-\r
-\r
- @param[in] Id String ID to get the string from.\r
-\r
- @retval CHAR16 * String from ID.\r
- @retval NULL If error occurs.\r
-\r
-**/\r
-CHAR16 *\r
-GetStringById (\r
- IN EFI_STRING_ID Id\r
- );\r
-\r
-/**\r
- Add a new user profile into the user profile database.\r
-\r
-**/\r
-VOID\r
-CallAddUser (\r
- VOID\r
- );\r
-\r
-/**\r
- Display user select form; can select a user to modify.\r
-\r
-**/\r
-VOID\r
-SelectUserToModify (\r
- VOID\r
- );\r
-\r
-/**\r
- Display user select form, cab select a user to delete.\r
-\r
-**/\r
-VOID\r
-SelectUserToDelete (\r
- VOID\r
- );\r
-\r
-/**\r
- Delete the user specified by UserIndex in user profile database.\r
-\r
- @param[in] UserIndex The index of user in the user name list to be deleted.\r
-\r
-**/\r
-VOID\r
-DeleteUser (\r
- IN UINT8 UserIndex\r
- );\r
-\r
-/**\r
- Add a username item in form.\r
-\r
- @param[in] User Points to the user profile whose username is added.\r
- @param[in] Index The index of the user in the user name list.\r
- @param[in] OpCodeHandle Points to container for dynamic created opcodes.\r
-\r
-**/\r
-VOID\r
-AddUserToForm (\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN UINT16 Index,\r
- IN VOID *OpCodeHandle\r
- );\r
-\r
-/**\r
- Display modify user information form\r
-\r
- In this form, username, create Date, usage date, usage count, identity policy,\r
- and access policy are displayed.\r
-\r
- @param[in] UserIndex The index of the user in display list to modify.\r
-\r
-**/\r
-VOID\r
-ModifyUserInfo (\r
- IN UINT8 UserIndex\r
- );\r
-\r
-/**\r
- Get the username from user input and update username string in Hii\r
- database with it.\r
-\r
-**/\r
-VOID\r
-ModifyUserName (\r
- VOID\r
- );\r
-\r
-/**\r
- Display the form of modifying user identity policy.\r
-\r
-**/\r
-VOID\r
-ModifyIdentityPolicy (\r
- VOID\r
- );\r
-\r
-/**\r
- Update the mUserInfo.NewIdentityPolicy and UI when 'add option' is pressed.\r
-\r
-**/\r
-VOID\r
-AddIdentityPolicyItem (\r
- VOID\r
- );\r
-\r
-/**\r
- Save the identity policy and update UI with it.\r
-\r
- This function will verify the new identity policy, in current implementation,\r
- the identity policy can be: T, P & P & P & ..., P | P | P | ...\r
- Here, "T" means "True", "P" means "Credential Provider", "&" means "and", "|" means "or".\r
- Other identity policies are not supported.\r
-\r
-**/\r
-VOID\r
-SaveIdentityPolicy (\r
- VOID\r
- );\r
-\r
-/**\r
- Display modify user access policy form\r
-\r
- In this form, access right, access setu,p and access boot order are dynamically\r
- added. Load devicepath and connect devicepath are displayed too.\r
-\r
-**/\r
-VOID\r
-ModidyAccessPolicy (\r
- VOID\r
- );\r
-\r
-/**\r
- Collect all the access policy data to mUserInfo.AccessPolicy,\r
- and save it to user profile.\r
-\r
-**/\r
-VOID\r
-SaveAccessPolicy (\r
- VOID\r
- );\r
-\r
-/**\r
- Get current user's access rights.\r
-\r
- @param[out] AccessRight Points to the buffer used for user's access rights.\r
-\r
- @retval EFI_SUCCESS Get current user access rights successfully.\r
- @retval others Fail to get current user access rights.\r
-\r
-**/\r
-EFI_STATUS\r
-GetAccessRight (\r
- OUT UINT32 *AccessRight\r
- );\r
-\r
-/**\r
- Display the permit load device path in the loadable device path list.\r
-\r
-**/\r
-VOID\r
-DisplayLoadPermit(\r
- VOID\r
- );\r
-\r
-/**\r
- Display the forbid load device path list (mAccessInfo.LoadForbid).\r
-\r
-**/\r
-VOID\r
-DisplayLoadForbid (\r
- VOID\r
- );\r
-\r
-/**\r
- Display the permit connect device path.\r
-\r
-**/\r
-VOID\r
-DisplayConnectPermit (\r
- VOID\r
- );\r
-\r
-/**\r
- Display the forbid connect device path list.\r
-\r
-**/\r
-VOID\r
-DisplayConnectForbid (\r
- VOID\r
- );\r
-\r
-/**\r
- Delete the specified device path by DriverIndex from the forbid device path\r
- list (mAccessInfo.LoadForbid).\r
-\r
- @param[in] DriverIndex The index of driver in a forbidden device path list.\r
-\r
-**/\r
-VOID\r
-DeleteFromForbidLoad (\r
- IN UINT16 DriverIndex\r
- );\r
-\r
-/**\r
- Add the specified device path by DriverIndex to the forbid device path\r
- list (mAccessInfo.LoadForbid).\r
-\r
- @param[in] DriverIndex The index of driver saved in driver options.\r
-\r
-**/\r
-VOID\r
-AddToForbidLoad (\r
- IN UINT16 DriverIndex\r
- );\r
-\r
-/**\r
- Get user name from the popup windows.\r
-\r
- @param[in, out] UserNameLen On entry, point to the buffer lengh of UserName.\r
- On exit, point to the input user name length.\r
- @param[out] UserName The buffer to hold the input user name.\r
-\r
- @retval EFI_ABORTED It is given up by pressing 'ESC' key.\r
- @retval EFI_NOT_READY Not a valid input at all.\r
- @retval EFI_SUCCESS Get a user name successfully.\r
-\r
-**/\r
-EFI_STATUS\r
-GetUserNameInput (\r
- IN OUT UINTN *UserNameLen,\r
- OUT CHAR16 *UserName\r
- );\r
-\r
-/**\r
- Find the specified info in User profile by the InfoType.\r
-\r
- @param[in] User Handle of the user whose information will be searched.\r
- @param[in] InfoType The user information type to find.\r
- @param[out] UserInfo Points to user information handle found.\r
-\r
- @retval EFI_SUCCESS Find the user information successfully.\r
- @retval Others Fail to find the user information.\r
-\r
-**/\r
-EFI_STATUS\r
-FindInfoByType (\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN UINT8 InfoType,\r
- OUT EFI_USER_INFO_HANDLE *UserInfo\r
- );\r
-\r
-/**\r
- Convert the identity policy to a unicode string and update the Hii database\r
- IpStringId string with it.\r
-\r
- @param[in] Ip Points to identity policy.\r
- @param[in] IpLen The identity policy length.\r
- @param[in] IpStringId String ID in the HII database to be replaced.\r
-\r
-**/\r
-VOID\r
-ResolveIdentityPolicy (\r
- IN UINT8 *Ip,\r
- IN UINTN IpLen,\r
- IN EFI_STRING_ID IpStringId\r
- );\r
-\r
-/**\r
- Expand access policy memory size.\r
-\r
- @param[in] ValidLen The valid access policy length.\r
- @param[in] ExpandLen The length that is needed to expand.\r
-\r
-**/\r
-VOID\r
-ExpandMemory (\r
- IN UINTN ValidLen,\r
- IN UINTN ExpandLen\r
- );\r
-\r
-/**\r
- Delete User's credental from all the providers that exist in User's identity policy.\r
-\r
- @param[in] IdentityPolicy Point to User's identity policy.\r
- @param[in] IdentityPolicyLen The length of the identity policy.\r
- @param[in] User Points to user profile.\r
-\r
-**/\r
-VOID\r
-DeleteCredentialFromProviders (\r
- IN UINT8 *IdentityPolicy,\r
- IN UINTN IdentityPolicyLen,\r
- IN EFI_USER_PROFILE_HANDLE User\r
- );\r
-\r
-#endif\r
+++ /dev/null
-// /** @file\r
-// A UI tool to manage user profiles\r
-//\r
-// By this module, user can add/update/delete user profiles, and can also\r
-// modify the user access policy and the user identification policy.\r
-//\r
-// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// This program and the accompanying materials\r
-// are licensed and made available under the terms and conditions of the BSD License\r
-// which accompanies this distribution. The full text of the license may be found at\r
-// http://opensource.org/licenses/bsd-license.php\r
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-//\r
-// **/\r
-\r
-\r
-#string STR_MODULE_ABSTRACT #language en-US "A UI tool to manage user profiles"\r
-\r
-#string STR_MODULE_DESCRIPTION #language en-US "By this module, user can add/update/delete user profiles, and can also modify the user access policy and the user identification policy."\r
-\r
+++ /dev/null
-/** @file\r
- The form data for user profile manager driver.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __USER_PROFILE_MANAGER_DATA_H__\r
-#define __USER_PROFILE_MANAGER_DATA_H__\r
-\r
-#include <Guid/UserProfileManagerHii.h>\r
-\r
-//\r
-// Form ID\r
-//\r
-#define FORMID_USER_MANAGE 0x0001\r
-#define FORMID_MODIFY_USER 0x0002\r
-#define FORMID_DEL_USER 0x0003\r
-#define FORMID_USER_INFO 0x0004\r
-#define FORMID_MODIFY_IP 0x0005\r
-#define FORMID_MODIFY_AP 0x0006\r
-#define FORMID_LOAD_DP 0x0007\r
-#define FORMID_CONNECT_DP 0x0008\r
-#define FORMID_PERMIT_LOAD_DP 0x0009\r
-#define FORMID_FORBID_LOAD_DP 0x000A\r
-#define FORMID_PERMIT_CONNECT_DP 0x000B\r
-#define FORMID_FORBID_CONNECT_DP 0x000C\r
-\r
-//\r
-// Label ID\r
-//\r
-#define LABEL_USER_MANAGE_FUNC 0x0010\r
-#define LABEL_USER_DEL_FUNC 0x0020\r
-#define LABEL_USER_MOD_FUNC 0x0030\r
-#define LABEL_USER_INFO_FUNC 0x0040\r
-#define LABEL_IP_MOD_FUNC 0x0050\r
-#define LABEL_AP_MOD_FUNC 0x0060\r
-#define LABEL_PERMIT_LOAD_FUNC 0x0070\r
-#define LABLE_FORBID_LOAD_FUNC 0x0080\r
-#define LABEL_END 0x00F0\r
-\r
-//\r
-// First form key (Add/modify/del user profile).\r
-// First 2 bits (bit 16~15).\r
-//\r
-#define KEY_MODIFY_USER 0x4000\r
-#define KEY_DEL_USER 0x8000\r
-#define KEY_ADD_USER 0xC000\r
-#define KEY_FIRST_FORM_MASK 0xC000\r
-\r
-//\r
-// Second form key (Display new form /Select user / modify device path in access policy).\r
-// Next 2 bits (bit 14~13).\r
-//\r
-#define KEY_ENTER_NEXT_FORM 0x0000\r
-#define KEY_SELECT_USER 0x1000\r
-#define KEY_MODIFY_AP_DP 0x2000\r
-#define KEY_OPEN_CLOSE_FORM_ACTION 0x3000\r
-#define KEY_SECOND_FORM_MASK 0x3000\r
-\r
-//\r
-// User profile information form key.\r
-// Next 3 bits (bit 12~10).\r
-//\r
-#define KEY_MODIFY_NAME 0x0200\r
-#define KEY_MODIFY_IP 0x0400\r
-#define KEY_MODIFY_AP 0x0600\r
-#define KEY_MODIFY_INFO_MASK 0x0E00\r
-\r
-//\r
-// Specified key, used in VFR (KEY_MODIFY_USER | KEY_SELECT_USER | KEY_MODIFY_NAME).\r
-//\r
-#define KEY_MODIFY_USER_NAME 0x5200\r
-\r
-//\r
-// Modify identity policy form key.\r
-// Next 3 bits (bit 9~7).\r
-//\r
-#define KEY_MODIFY_PROV 0x0040\r
-#define KEY_MODIFY_MTYPE 0x0080\r
-#define KEY_MODIFY_CONN 0x00C0\r
-#define KEY_ADD_IP_OP 0x0100\r
-#define KEY_IP_RETURN_UIF 0x0140\r
-#define KEY_MODIFY_IP_MASK 0x01C0\r
-\r
-//\r
-// Specified key.\r
-//\r
-#define KEY_ADD_LOGICAL_OP 0x5500\r
-#define KEY_IP_RETURN 0x5540\r
-\r
-//\r
-// Modify access policy form key.\r
-// Next 3 bits (bit 9~7).\r
-//\r
-#define KEY_MODIFY_RIGHT 0x0040\r
-#define KEY_MODIFY_SETUP 0x0080\r
-#define KEY_MODIFY_BOOT 0x00C0\r
-#define KEY_MODIFY_LOAD 0x0100\r
-#define KEY_MODIFY_CONNECT 0x0140\r
-#define KEY_AP_RETURN_UIF 0x0180\r
-#define KEY_MODIFY_AP_MASK 0x01C0\r
-\r
-//\r
-// Specified key.\r
-//\r
-#define KEY_LOAD_DP 0x5700\r
-#define KEY_CONN_DP 0x5740\r
-#define KEY_AP_RETURN 0x5780\r
-\r
-//\r
-// Device path form key.\r
-// Next 2 bits (bit 6~5).\r
-//\r
-#define KEY_PERMIT_MODIFY 0x0010\r
-#define KEY_FORBID_MODIFY 0x0020\r
-#define KEY_DISPLAY_DP_MASK 0x0030\r
-\r
-//\r
-// Specified key.\r
-//\r
-#define KEY_LOAD_PERMIT 0x5710\r
-#define KEY_LOAD_FORBID 0x5720\r
-#define KEY_CONNECT_PERMIT 0x5750\r
-#define KEY_CONNECT_FORBID 0x5760\r
-\r
-//\r
-// Device path modify key.\r
-// 2 bits (bit 12~11).\r
-//\r
-#define KEY_LOAD_PERMIT_MODIFY 0x0000\r
-#define KEY_LOAD_FORBID_MODIFY 0x0400\r
-#define KEY_CONNECT_PERMIT_MODIFY 0x0800\r
-#define KEY_CONNECT_FORBID_MODIFY 0x0C00\r
-#define KEY_MODIFY_DP_MASK 0x0C00\r
-\r
-\r
-//\r
-// The permissions usable when configuring the platform.\r
-//\r
-#define ACCESS_SETUP_RESTRICTED 1\r
-#define ACCESS_SETUP_NORMAL 2\r
-#define ACCESS_SETUP_ADMIN 3\r
-\r
-//\r
-// Question ID for the question used in each form (KEY_OPEN_CLOSE_FORM_ACTION | FORMID_FORM_USER_MANAGE)\r
-// This ID is used in FORM OPEN/CLOSE CallBack action.\r
-//\r
-#define QUESTIONID_USER_MANAGE 0x3001\r
-\r
-#endif\r
+++ /dev/null
-## @file\r
-# A UI tool to manage user profiles\r
-#\r
-# By this module, user can add/update/delete user profiles, and can also\r
-# modify the user access policy and the user identification policy.\r
-#\r
-# Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution. The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-#\r
-##\r
-\r
-[Defines]\r
- INF_VERSION = 0x00010005\r
- BASE_NAME = UserProfileManager\r
- MODULE_UNI_FILE = UserProfileManager.uni\r
- FILE_GUID = E38CB52D-A74D-45db-A8D0-290C9B21BBF2\r
- MODULE_TYPE = DXE_DRIVER\r
- VERSION_STRING = 1.0\r
- ENTRY_POINT = UserProfileManagerInit\r
-\r
-[Sources]\r
- UserProfileManager.c\r
- UserProfileManager.h\r
- UserProfileAdd.c\r
- UserProfileDelete.c\r
- UserProfileModify.c\r
- ModifyIdentityPolicy.c\r
- ModifyAccessPolicy.c\r
- UserProfileManagerData.h\r
- UserProfileManagerStrings.uni\r
- UserProfileManagerVfr.Vfr\r
-\r
-[Packages]\r
- MdePkg/MdePkg.dec\r
- MdeModulePkg/MdeModulePkg.dec\r
- SecurityPkg/SecurityPkg.dec\r
-\r
-[LibraryClasses]\r
- UefiRuntimeServicesTableLib\r
- UefiBootServicesTableLib\r
- UefiDriverEntryPoint\r
- MemoryAllocationLib\r
- BaseMemoryLib\r
- DebugLib\r
- HiiLib\r
- UefiLib\r
- DevicePathLib\r
-\r
-[Guids]\r
- gEfiIfrTianoGuid ## SOMETIMES_CONSUMES ## GUID\r
- gEfiUserInfoAccessSetupAdminGuid ## SOMETIMES_CONSUMES ## GUID\r
- gEfiUserInfoAccessSetupNormalGuid ## SOMETIMES_CONSUMES ## GUID\r
- gEfiUserInfoAccessSetupRestrictedGuid ## SOMETIMES_CONSUMES ## GUID\r
- gUserProfileManagerGuid ## CONSUMES ## HII\r
-\r
-[Protocols]\r
- gEfiDevicePathProtocolGuid ## PRODUCES\r
- gEfiHiiConfigAccessProtocolGuid ## PRODUCES\r
- gEfiUserCredential2ProtocolGuid ## SOMETIMES_CONSUMES\r
- gEfiUserManagerProtocolGuid ## CONSUMES\r
-\r
-[Depex]\r
- gEfiUserManagerProtocolGuid\r
-\r
-[UserExtensions.TianoCore."ExtraFiles"]\r
- UserProfileManagerExtra.uni\r
-\r
+++ /dev/null
-// /** @file\r
-// UserProfileManager Localized Strings and Content\r
-//\r
-// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
-//\r
-// This program and the accompanying materials\r
-// are licensed and made available under the terms and conditions of the BSD License\r
-// which accompanies this distribution. The full text of the license may be found at\r
-// http://opensource.org/licenses/bsd-license.php\r
-// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-//\r
-// **/\r
-\r
-#string STR_PROPERTIES_MODULE_NAME\r
-#language en-US\r
-"User Profile Manager"\r
-\r
-\r
+++ /dev/null
-/** @file\r
- String definitions for User Profile Manager driver.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#langdef en-US "English"\r
-#langdef fr-FR "Français"\r
-\r
-#string STR_NULL_STRING #language en-US ""\r
- #language fr-FR ""\r
-#string STR_FORMSET_TITLE #language en-US "User Manager"\r
- #language fr-FR "User Manager(French)"\r
-#string STR_TITLE_HELP #language en-US "This selection will take you to the User Manager"\r
- #language fr-FR "This selection will take you to the User Manager(French)"\r
-#string STR_USERMAN_TITLE #language en-US "User Manager"\r
- #language fr-FR "User Manager(French)"\r
-#string STR_ADD_USER_TITLE #language en-US "Add User Profile"\r
- #language fr-FR "Add User Profile(French)"\r
-#string STR_ADD_USER_HELP #language en-US "Add User Profile to User Database"\r
- #language fr-FR "Add User Profile to User Database(French)"\r
-#string STR_MODIFY_USER_TITLE #language en-US "Modify User Profile"\r
- #language fr-FR "Modify User Profile(French)"\r
-#string STR_MODIFY_USER_HELP #language en-US "Modify User Profile Information"\r
- #language fr-FR "Modify User Profile Information(French)"\r
-#string STR_DELETE_USER_TITLE #language en-US "Delete User Profile"\r
- #language fr-FR "Delete User Profile(French)"\r
-#string STR_DELETE_USER_HELP #language en-US "Delete User Profile from User Database"\r
- #language fr-FR "Delete User Profile from User Database(French)"\r
-#string STR_USER_INFO #language en-US "User Profile Information"\r
- #language fr-FR "User Profile Information(French)"\r
-#string STR_USER_NAME #language en-US "User Name"\r
- #language fr-FR "User Name(French)"\r
-#string STR_USER_NAME_VAL #language en-US ""\r
- #language fr-FR ""\r
-#string STR_CREATE_DATE #language en-US "Create Date"\r
- #language fr-FR "Create Date(French)"\r
-#string STR_CREATE_DATE_VAL #language en-US ""\r
- #language fr-FR ""\r
-#string STR_USAGE_DATE #language en-US "Usage Date"\r
- #language fr-FR "Usage Date(French)"\r
-#string STR_USAGE_DATE_VAL #language en-US ""\r
- #language fr-FR ""\r
-#string STR_USAGE_COUNT #language en-US "Usage Count"\r
- #language fr-FR "Usage Count(French)"\r
-#string STR_USAGE_COUNT_VAL #language en-US ""\r
- #language fr-FR ""\r
-#string STR_IDENTIFY_POLICY #language en-US "Identify Policy"\r
- #language fr-FR "Identify Policy(French)"\r
-#string STR_IDENTIFY_POLICY_VAL #language en-US ""\r
- #language fr-FR ""\r
-#string STR_ACCESS_POLICY #language en-US "Access Policy"\r
- #language fr-FR "Access Policy(French)"\r
-#string STR_SAVE #language en-US "Save & Exit"\r
- #language fr-FR "Save & Exit(French)"\r
-#string STR_IDENTIFY_SAVE_HELP #language en-US "Save Identify Policy and Exit"\r
- #language fr-FR "Save Identify Policy and Exit(French)"\r
-#string STR_PROVIDER #language en-US "Credential Provider"\r
- #language fr-FR "Credential Provider(French)"\r
-#string STR_PROVIDER_HELP #language en-US "Select Credential Provider Option"\r
- #language fr-FR "Select Credential Provider Option(French)"\r
-#string STR_OR_CON #language en-US "Or"\r
- #language fr-FR "Or(French)"\r
-#string STR_AND_CON #language en-US "And"\r
- #language fr-FR "And(French)"\r
-#string STR_CONNECTOR #language en-US "Logical Connector"\r
- #language fr-FR "Logical Connector(French)"\r
-#string STR_CONNECTOR_HELP #language en-US "Select Logical Connector Option"\r
- #language fr-FR "Select Logical Connector Option(French)"\r
-#string STR_IDENTIFY_POLICY_VALUE #language en-US ""\r
- #language fr-FR ""\r
-#string STR_IDENTIFY_POLICY_HELP #language en-US "Current Identify Policy"\r
- #language fr-FR "Current Identify Policy(French)"\r
-#string STR_ADD_OPTION #language en-US "Add Option"\r
- #language fr-FR "Add Option(French)"\r
-#string STR_ADD_OPTION_HELP #language en-US "Add This Option to Identify Policy"\r
- #language fr-FR "Add This Option to Identify Policy(French)"\r
-#string STR_ACCESS_SAVE_HELP #language en-US "Save Access Policy and Exit"\r
- #language fr-FR "Save Access Policy and Exit(French)"\r
-#string STR_ACCESS_RIGHT #language en-US "Access Right"\r
- #language fr-FR "Access Right(French)"\r
-#string STR_ACCESS_RIGHT_HELP #language en-US "Select Access Right Option"\r
- #language fr-FR "Select Access Right Option(French)"\r
-#string STR_NORMAL #language en-US "Normal"\r
- #language fr-FR "Normal(French)"\r
-#string STR_ENROLL #language en-US "Enroll"\r
- #language fr-FR "Enroll(French)"\r
-#string STR_MANAGE #language en-US "Manage"\r
- #language fr-FR "Manage(French)"\r
-#string STR_ACCESS_SETUP #language en-US "Access Setup"\r
- #language fr-FR "Access Setup(French)"\r
-#string STR_ACCESS_SETUP_HELP #language en-US "Select Access Setup Option"\r
- #language fr-FR "Selelct Access Setup Option(French)"\r
-#string STR_RESTRICTED #language en-US "Restricted"\r
- #language fr-FR "Restricted(French)"\r
-#string STR_ADMIN #language en-US "Admin"\r
- #language fr-FR "Admin(French)"\r
-#string STR_BOOR_ORDER #language en-US "Access Boot Order"\r
- #language fr-FR "Access Boot Order(French)"\r
-#string STR_BOOT_ORDER_HELP #language en-US "Select Access Boot Order Option"\r
- #language fr-FR "Select Access Boot Order Option(French)"\r
-#string STR_INSERT #language en-US "Insert"\r
- #language fr-FR "Insert(French)"\r
-#string STR_APPEND #language en-US "Append"\r
- #language fr-FR "Append(French)"\r
-#string STR_REPLACE #language en-US "Replace"\r
- #language fr-FR "Replace(French)"\r
-#string STR_NODEFAULT #language en-US "Nodefault"\r
- #language fr-FR "Nodefault(French)"\r
-#string STR_LOAD #language en-US "Load Device Path"\r
- #language fr-FR "Load Device Path(French)"\r
-#string STR_LOAD_HELP #language en-US "Select Permit/Forbid Load Device Path"\r
- #language fr-FR "Select Permit/Forbid Load Device Path(French)"\r
-#string STR_CONNECT #language en-US "Connect Device Path"\r
- #language fr-FR "Connect Device Path(French)"\r
-#string STR_CONNECT_HELP #language en-US "Select Permit/Forbid Connect Device Path"\r
- #language fr-FR "Select Permit/Forbid Connect Device Path(French)"\r
-#string STR_LOAD_PERMIT #language en-US "Permit Load Device Path"\r
- #language fr-FR "Permit Load Device Path(French)"\r
-#string STR_LOAD_PERMIT_HELP #language en-US "Change Permit Load Device Path to Forbid"\r
- #language fr-FR "Change Permit Load Device Path to Forbid(French)"\r
-#string STR_LOAD_FORBID #language en-US "Forbid Load Device Path"\r
- #language fr-FR "Forbid Load Device Path(French)"\r
-#string STR_LOAD_FORBID_HELP #language en-US "Change Forbid Load Device Path to Permit"\r
- #language fr-FR "Change Forbid Load Device Path to Permit(French)"\r
-#string STR_CONNECT_PERMIT #language en-US "Permit Connect Device Path"\r
- #language fr-FR "Permit Connect Device Path(French)"\r
-#string STR_CONNECT_PERMIT_HELP #language en-US "Change Permit Connect Device Path to Forbid"\r
- #language fr-FR "Change Permit Connect Device Path to Forbid(French)"\r
-#string STR_CONNECT_FORBID #language en-US "Forbid Connect Device Path"\r
- #language fr-FR "Forbid Connect Device Path(French)"\r
-#string STR_CONNECT_FORBID_HELP #language en-US "Change Forbid Connect Device Path to Permit"\r
- #language fr-FR "Change Forbid Connect Device Path to Permit(French)"\r
-#string STR_PRESS_KEY_CONTINUE #language en-US "Press ENTER to Continue, Other Key to Cancel ..."\r
- #language fr-FR "Press ENTER to Continue, Other Key to Cancel ...(French)"\r
-#string STR_MOVE_TO_FORBID_LIST #language en-US "Are You Sure to Move It to Forbid List?"\r
- #language fr-FR "Are You Sure to Move It to Forbid List?(French)"\r
-#string STR_MOVE_TO_PERMIT_LIST #language en-US "Are You Sure to Move It to Permit List?"\r
- #language fr-FR "Are You Sure to Move It to Permit List?(French)"\r
-#string STR_STROKE_KEY_CONTINUE #language en-US "Please Press Any Key to Continue ..."\r
- #language fr-FR "Please Press Any Key to Continue ... (French)"\r
-#string STR_CREATE_PROFILE_FAILED #language en-US "Create New User Profile Failed!"\r
- #language fr-FR "Create New User Profile Failed! (French)"\r
-#string STR_CREATE_PROFILE_SUCCESS #language en-US "Create New User Profile Succeed!"\r
- #language fr-FR "Create New User Profile Succeed! (French)"\r
-#string STR_USER_ALREADY_EXISTED #language en-US "User Name Had Already Existed."\r
- #language fr-FR "User Name Had Already Existed. (French)"\r
-#string STR_GET_USERNAME_FAILED #language en-US "Failed To Get User Name."\r
- #language fr-FR "Failed To Get User Name. (French)"\r
-\r
+++ /dev/null
-/** @file\r
- User Profile Manager formset.\r
-\r
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials \r
-are licensed and made available under the terms and conditions of the BSD License \r
-which accompanies this distribution. The full text of the license may be found at \r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "UserProfileManagerData.h"\r
-\r
-#define USER_MANAGER_CLASS 0x00\r
-#define USER_MANAGER_SUBCLASS 0x04\r
-\r
-formset \r
- guid = USER_PROFILE_MANAGER_GUID,\r
- title = STRING_TOKEN(STR_FORMSET_TITLE), \r
- help = STRING_TOKEN(STR_TITLE_HELP),\r
- \r
- // User manager form\r
- form formid = FORMID_USER_MANAGE,\r
- title = STRING_TOKEN(STR_USERMAN_TITLE);\r
-\r
- label LABEL_USER_MANAGE_FUNC;\r
- label LABEL_END;\r
-\r
- suppressif TRUE;\r
- text\r
- help = STRING_TOKEN(STR_NULL_STRING),\r
- text = STRING_TOKEN(STR_NULL_STRING),\r
- flags = INTERACTIVE,\r
- key = QUESTIONID_USER_MANAGE;\r
- endif;\r
- \r
- endform;\r
- \r
- // Modify user profile form\r
- form formid = FORMID_MODIFY_USER,\r
- title = STRING_TOKEN(STR_MODIFY_USER_TITLE);\r
-\r
- label LABEL_USER_MOD_FUNC;\r
- label LABEL_END;\r
-\r
- endform;\r
- \r
- // Delete user profile form\r
- form formid = FORMID_DEL_USER,\r
- title = STRING_TOKEN(STR_DELETE_USER_TITLE);\r
- \r
- label LABEL_USER_DEL_FUNC;\r
- label LABEL_END;\r
- \r
- subtitle \r
- text = STRING_TOKEN(STR_NULL_STRING);\r
- endform;\r
- \r
- //\r
- // User profile information form\r
- //\r
- form formid = FORMID_USER_INFO,\r
- title = STRING_TOKEN(STR_USER_INFO);\r
-\r
- text \r
- help = STRING_TOKEN(STR_USER_NAME_VAL), \r
- text = STRING_TOKEN(STR_USER_NAME),\r
- flags = INTERACTIVE,\r
- key = KEY_MODIFY_USER_NAME;\r
- \r
- text \r
- help = STRING_TOKEN(STR_CREATE_DATE_VAL), \r
- text = STRING_TOKEN(STR_CREATE_DATE);\r
- \r
- text \r
- help = STRING_TOKEN(STR_USAGE_DATE_VAL), \r
- text = STRING_TOKEN(STR_USAGE_DATE);\r
- \r
- text \r
- help = STRING_TOKEN(STR_USAGE_COUNT_VAL), \r
- text = STRING_TOKEN(STR_USAGE_COUNT);\r
- \r
- label LABEL_USER_INFO_FUNC; \r
- label LABEL_END;\r
-\r
- endform;\r
- \r
- //\r
- // Identify policy modify form\r
- //\r
- form formid = FORMID_MODIFY_IP,\r
- title = STRING_TOKEN(STR_IDENTIFY_POLICY);\r
-\r
- text \r
- help = STRING_TOKEN(STR_IDENTIFY_POLICY_HELP),\r
- text = STRING_TOKEN(STR_IDENTIFY_POLICY),\r
- text = STRING_TOKEN(STR_IDENTIFY_POLICY_VALUE);\r
- \r
- label LABEL_IP_MOD_FUNC;\r
- label LABEL_END;\r
- \r
- text \r
- help = STRING_TOKEN(STR_ADD_OPTION_HELP), \r
- text = STRING_TOKEN(STR_ADD_OPTION),\r
- flags = INTERACTIVE,\r
- key = KEY_ADD_LOGICAL_OP;\r
- \r
- subtitle \r
- text = STRING_TOKEN(STR_NULL_STRING);\r
-\r
- text\r
- help = STRING_TOKEN(STR_IDENTIFY_SAVE_HELP),\r
- text = STRING_TOKEN(STR_SAVE),\r
- flags = INTERACTIVE,\r
- key = KEY_IP_RETURN;\r
-\r
- endform;\r
- \r
- //\r
- // Access policy modify form\r
- //\r
- form formid = FORMID_MODIFY_AP,\r
- title = STRING_TOKEN(STR_ACCESS_POLICY);\r
-\r
- label LABEL_AP_MOD_FUNC;\r
- label LABEL_END;\r
-\r
- goto FORMID_LOAD_DP,\r
- prompt = STRING_TOKEN(STR_LOAD),\r
- help = STRING_TOKEN(STR_LOAD_HELP),\r
- flags = INTERACTIVE,\r
- key = KEY_LOAD_DP;\r
-\r
- goto FORMID_CONNECT_DP,\r
- prompt = STRING_TOKEN(STR_CONNECT),\r
- help = STRING_TOKEN(STR_CONNECT_HELP),\r
- flags = INTERACTIVE,\r
- key = KEY_CONN_DP;\r
-\r
- subtitle \r
- text = STRING_TOKEN(STR_NULL_STRING);\r
- \r
- text\r
- help = STRING_TOKEN(STR_ACCESS_SAVE_HELP),\r
- text = STRING_TOKEN(STR_SAVE),\r
- flags = INTERACTIVE,\r
- key = KEY_AP_RETURN;\r
-\r
- endform;\r
-\r
- //\r
- // Load device path form\r
- //\r
- form formid = FORMID_LOAD_DP,\r
- title = STRING_TOKEN(STR_LOAD);\r
-\r
- goto FORMID_PERMIT_LOAD_DP,\r
- prompt = STRING_TOKEN(STR_LOAD_PERMIT),\r
- help = STRING_TOKEN(STR_LOAD_PERMIT_HELP),\r
- flags = INTERACTIVE,\r
- key = KEY_LOAD_PERMIT;\r
- \r
- goto FORMID_FORBID_LOAD_DP,\r
- prompt = STRING_TOKEN(STR_LOAD_FORBID),\r
- help = STRING_TOKEN(STR_LOAD_FORBID_HELP),\r
- flags = INTERACTIVE,\r
- key = KEY_LOAD_FORBID;\r
- \r
- endform;\r
- \r
- //\r
- // Permit load device path form\r
- //\r
- form formid = FORMID_PERMIT_LOAD_DP,\r
- title = STRING_TOKEN(STR_LOAD_PERMIT);\r
- \r
- label LABEL_PERMIT_LOAD_FUNC;\r
- label LABEL_END;\r
- \r
- subtitle \r
- text = STRING_TOKEN(STR_NULL_STRING);\r
-\r
- endform;\r
- \r
- //\r
- // Forbid load device path form\r
- //\r
- form formid = FORMID_FORBID_LOAD_DP,\r
- title = STRING_TOKEN(STR_LOAD_FORBID);\r
- \r
- label LABLE_FORBID_LOAD_FUNC;\r
- label LABEL_END;\r
- \r
- subtitle \r
- text = STRING_TOKEN(STR_NULL_STRING);\r
-\r
- endform;\r
- \r
- //\r
- // Connect device path form\r
- //\r
- form formid = FORMID_CONNECT_DP,\r
- title = STRING_TOKEN(STR_CONNECT);\r
-\r
- goto FORMID_PERMIT_CONNECT_DP,\r
- prompt = STRING_TOKEN(STR_CONNECT_PERMIT),\r
- help = STRING_TOKEN(STR_CONNECT_PERMIT_HELP),\r
- flags = INTERACTIVE,\r
- key = KEY_CONNECT_PERMIT;\r
- \r
- goto FORMID_FORBID_CONNECT_DP,\r
- prompt = STRING_TOKEN(STR_CONNECT_FORBID),\r
- help = STRING_TOKEN(STR_CONNECT_FORBID_HELP),\r
- flags = INTERACTIVE,\r
- key = KEY_CONNECT_FORBID;\r
- \r
- endform;\r
- \r
- //\r
- // Permit connect device path form\r
- //\r
- form formid = FORMID_PERMIT_CONNECT_DP,\r
- title = STRING_TOKEN(STR_CONNECT_PERMIT);\r
- \r
- subtitle \r
- text = STRING_TOKEN(STR_NULL_STRING);\r
-\r
- endform;\r
- \r
- //\r
- // Forbid connect device path form\r
- //\r
- form formid = FORMID_FORBID_CONNECT_DP,\r
- title = STRING_TOKEN(STR_CONNECT_FORBID);\r
- \r
- subtitle \r
- text = STRING_TOKEN(STR_NULL_STRING);\r
-\r
- endform;\r
- \r
-endformset;\r
+++ /dev/null
-/** @file\r
- The functions to modify a user profile.\r
-\r
-Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include "UserProfileManager.h"\r
-\r
-EFI_USER_PROFILE_HANDLE mModifyUser = NULL;\r
-\r
-/**\r
- Display user select form, cab select a user to modify.\r
-\r
-**/\r
-VOID\r
-SelectUserToModify (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINT8 Index;\r
- EFI_USER_PROFILE_HANDLE User;\r
- EFI_USER_PROFILE_HANDLE CurrentUser;\r
- UINT32 CurrentAccessRight;\r
- VOID *StartOpCodeHandle;\r
- VOID *EndOpCodeHandle;\r
- EFI_IFR_GUID_LABEL *StartLabel;\r
- EFI_IFR_GUID_LABEL *EndLabel;\r
-\r
- //\r
- // Initialize the container for dynamic opcodes.\r
- //\r
- StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (StartOpCodeHandle != NULL);\r
-\r
- EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (EndOpCodeHandle != NULL);\r
-\r
- //\r
- // Create Hii Extend Label OpCode.\r
- //\r
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- StartOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- StartLabel->Number = LABEL_USER_MOD_FUNC;\r
-\r
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- EndOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- EndLabel->Number = LABEL_END;\r
-\r
- //\r
- // Add each user can be modified.\r
- //\r
- User = NULL;\r
- Index = 1;\r
- mUserManager->Current (mUserManager, &CurrentUser);\r
- while (TRUE) {\r
- Status = mUserManager->GetNext (mUserManager, &User);\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
-\r
- Status = GetAccessRight (&CurrentAccessRight);\r
- if (EFI_ERROR (Status)) {\r
- CurrentAccessRight = EFI_USER_INFO_ACCESS_ENROLL_SELF;\r
- }\r
-\r
- if ((CurrentAccessRight == EFI_USER_INFO_ACCESS_MANAGE) || (User == CurrentUser)) {\r
- AddUserToForm (User, (UINT16)(KEY_MODIFY_USER | KEY_SELECT_USER | Index), StartOpCodeHandle);\r
- }\r
- Index++;\r
- }\r
-\r
- HiiUpdateForm (\r
- mCallbackInfo->HiiHandle, // HII handle\r
- &gUserProfileManagerGuid, // Formset GUID\r
- FORMID_MODIFY_USER, // Form ID\r
- StartOpCodeHandle, // Label for where to insert opcodes\r
- EndOpCodeHandle // Replace data\r
- );\r
-\r
- HiiFreeOpCodeHandle (StartOpCodeHandle);\r
- HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-}\r
-\r
-\r
-/**\r
- Get all the user info from mModifyUser in the user manager, and save on the\r
- global variable.\r
-\r
-**/\r
-VOID\r
-GetAllUserInfo (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO_HANDLE UserInfo;\r
- EFI_USER_INFO *Info;\r
- UINTN InfoSize;\r
- UINTN MemSize;\r
- UINTN DataLen;\r
-\r
- //\r
- // Init variable to default value.\r
- //\r
- mProviderChoice = 0;\r
- mConncetLogical = 0;\r
-\r
- mUserInfo.CreateDateExist = FALSE;\r
- mUserInfo.UsageDateExist = FALSE;\r
- mUserInfo.UsageCount = 0;\r
-\r
- mUserInfo.AccessPolicyLen = 0;\r
- mUserInfo.AccessPolicyModified = FALSE;\r
- if (mUserInfo.AccessPolicy != NULL) {\r
- FreePool (mUserInfo.AccessPolicy);\r
- mUserInfo.AccessPolicy = NULL;\r
- }\r
- mUserInfo.IdentityPolicyLen = 0;\r
- mUserInfo.IdentityPolicyModified = FALSE;\r
- if (mUserInfo.IdentityPolicy != NULL) {\r
- FreePool (mUserInfo.IdentityPolicy);\r
- mUserInfo.IdentityPolicy = NULL;\r
- }\r
-\r
- //\r
- // Allocate user information memory.\r
- //\r
- MemSize = sizeof (EFI_USER_INFO) + 63;\r
- Info = AllocateZeroPool (MemSize);\r
- if (Info == NULL) {\r
- return ;\r
- }\r
-\r
- //\r
- // Get each user information.\r
- //\r
- UserInfo = NULL;\r
- while (TRUE) {\r
- Status = mUserManager->GetNextInfo (mUserManager, mModifyUser, &UserInfo);\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
- //\r
- // Get information.\r
- //\r
- InfoSize = MemSize;\r
- Status = mUserManager->GetInfo (\r
- mUserManager,\r
- mModifyUser,\r
- UserInfo,\r
- Info,\r
- &InfoSize\r
- );\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- MemSize = InfoSize;\r
- FreePool (Info);\r
- Info = AllocateZeroPool (MemSize);\r
- if (Info == NULL) {\r
- return ;\r
- }\r
-\r
- Status = mUserManager->GetInfo (\r
- mUserManager,\r
- mModifyUser,\r
- UserInfo,\r
- Info,\r
- &InfoSize\r
- );\r
- }\r
-\r
- if (Status == EFI_SUCCESS) {\r
- //\r
- // Deal with each information according to informaiton type.\r
- //\r
- DataLen = Info->InfoSize - sizeof (EFI_USER_INFO);\r
- switch (Info->InfoType) {\r
- case EFI_USER_INFO_NAME_RECORD:\r
- CopyMem (&mUserInfo.UserName, (UINT8 *) (Info + 1), DataLen);\r
- break;\r
-\r
- case EFI_USER_INFO_CREATE_DATE_RECORD:\r
- CopyMem (&mUserInfo.CreateDate, (UINT8 *) (Info + 1), DataLen);\r
- mUserInfo.CreateDateExist = TRUE;\r
- break;\r
-\r
- case EFI_USER_INFO_USAGE_DATE_RECORD:\r
- CopyMem (&mUserInfo.UsageDate, (UINT8 *) (Info + 1), DataLen);\r
- mUserInfo.UsageDateExist = TRUE;\r
- break;\r
-\r
- case EFI_USER_INFO_USAGE_COUNT_RECORD:\r
- CopyMem (&mUserInfo.UsageCount, (UINT8 *) (Info + 1), DataLen);\r
- break;\r
-\r
- case EFI_USER_INFO_ACCESS_POLICY_RECORD:\r
- mUserInfo.AccessPolicy = AllocateZeroPool (DataLen);\r
- if (mUserInfo.AccessPolicy == NULL) {\r
- break;\r
- }\r
-\r
- CopyMem (mUserInfo.AccessPolicy, (UINT8 *) (Info + 1), DataLen);\r
- mUserInfo.AccessPolicyLen = DataLen;\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_POLICY_RECORD:\r
- mUserInfo.IdentityPolicy = AllocateZeroPool (DataLen);\r
- if (mUserInfo.IdentityPolicy == NULL) {\r
- break;\r
- }\r
-\r
- CopyMem (mUserInfo.IdentityPolicy, (UINT8 *) (Info + 1), DataLen);\r
- mUserInfo.IdentityPolicyLen = DataLen;\r
- break;\r
-\r
- default:\r
- break;\r
- }\r
- }\r
- }\r
- FreePool (Info);\r
-}\r
-\r
-\r
-/**\r
- Convert the Date to a string, and update the Hii database DateID string with it.\r
-\r
- @param[in] Date Points to the date to be converted.\r
- @param[in] DateId String ID in the HII database to be replaced.\r
-\r
-**/\r
-VOID\r
-ResolveDate (\r
- IN EFI_TIME *Date,\r
- IN EFI_STRING_ID DateId\r
- )\r
-{\r
- CHAR16 *Str;\r
- UINTN DateBufLen;\r
-\r
- //\r
- // Convert date to string.\r
- //\r
- DateBufLen = 64;\r
- Str = AllocateZeroPool (DateBufLen);\r
- if (Str == NULL) {\r
- return ;\r
- }\r
-\r
- UnicodeSPrint (\r
- Str,\r
- DateBufLen,\r
- L"%4d-%2d-%2d ",\r
- Date->Year,\r
- Date->Month,\r
- Date->Day\r
- );\r
-\r
- //\r
- // Convert time to string.\r
- //\r
- DateBufLen -= StrLen (Str);\r
- UnicodeSPrint (\r
- Str + StrLen (Str),\r
- DateBufLen,\r
- L"%2d:%2d:%2d",\r
- Date->Hour,\r
- Date->Minute,\r
- Date->Second\r
- );\r
-\r
- HiiSetString (mCallbackInfo->HiiHandle, DateId, Str, NULL);\r
- FreePool (Str);\r
-}\r
-\r
-\r
-/**\r
- Convert the CountVal to a string, and update the Hii database CountId string\r
- with it.\r
-\r
- @param[in] CountVal The hex value to convert.\r
- @param[in] CountId String ID in the HII database to be replaced.\r
-\r
-**/\r
-VOID\r
-ResolveCount (\r
- IN UINT32 CountVal,\r
- IN EFI_STRING_ID CountId\r
- )\r
-{\r
- CHAR16 Count[10];\r
-\r
- UnicodeSPrint (Count, 20, L"%d", CountVal);\r
- HiiSetString (mCallbackInfo->HiiHandle, CountId, Count, NULL);\r
-}\r
-\r
-\r
-/**\r
- Concatenates one Null-terminated Unicode string to another Null-terminated\r
- Unicode string.\r
-\r
- @param[in, out] Source1 On entry, point to a Null-terminated Unicode string.\r
- On exit, point to a new concatenated Unicode string\r
- @param[in] Source2 Pointer to a Null-terminated Unicode string.\r
-\r
-**/\r
-VOID\r
-AddStr (\r
- IN OUT CHAR16 **Source1,\r
- IN CONST CHAR16 *Source2\r
- )\r
-{\r
- CHAR16 *TmpStr;\r
- UINTN StrLength;\r
-\r
- ASSERT (Source1 != NULL);\r
- ASSERT (Source2 != NULL);\r
-\r
- if (*Source1 == NULL) {\r
- StrLength = StrSize (Source2);\r
- } else {\r
- StrLength = StrSize (*Source1);\r
- StrLength += StrSize (Source2) - 2;\r
- }\r
-\r
- TmpStr = AllocateZeroPool (StrLength);\r
- ASSERT (TmpStr != NULL);\r
-\r
- if (*Source1 == NULL) {\r
- StrCpyS (TmpStr, StrLength / sizeof (CHAR16), Source2);\r
- } else {\r
- StrCpyS (TmpStr, StrLength / sizeof (CHAR16), *Source1);\r
- FreePool (*Source1);\r
- StrCatS (TmpStr, StrLength / sizeof (CHAR16),Source2);\r
- }\r
-\r
- *Source1 = TmpStr;\r
-}\r
-\r
-\r
-/**\r
- Convert the identity policy to a unicode string and update the Hii database\r
- IpStringId string with it.\r
-\r
- @param[in] Ip Points to identity policy.\r
- @param[in] IpLen The identity policy length.\r
- @param[in] IpStringId String ID in the HII database to be replaced.\r
-\r
-**/\r
-VOID\r
-ResolveIdentityPolicy (\r
- IN UINT8 *Ip,\r
- IN UINTN IpLen,\r
- IN EFI_STRING_ID IpStringId\r
- )\r
-{\r
- CHAR16 *TmpStr;\r
- UINTN ChkLen;\r
- EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
- UINT16 Index;\r
- CHAR16 *ProvStr;\r
- EFI_STRING_ID ProvId;\r
- EFI_HII_HANDLE HiiHandle;\r
- EFI_USER_CREDENTIAL2_PROTOCOL *UserCredential;\r
-\r
- TmpStr = NULL;\r
-\r
- //\r
- // Resolve each policy.\r
- //\r
- ChkLen = 0;\r
- while (ChkLen < IpLen) {\r
- Identity = (EFI_USER_INFO_IDENTITY_POLICY *) (Ip + ChkLen);\r
- switch (Identity->Type) {\r
- case EFI_USER_INFO_IDENTITY_FALSE:\r
- AddStr (&TmpStr, L"False");\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_TRUE:\r
- AddStr (&TmpStr, L"None");\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_NOT:\r
- AddStr (&TmpStr, L"! ");\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_AND:\r
- AddStr (&TmpStr, L" && ");\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_OR:\r
- AddStr (&TmpStr, L" || ");\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_CREDENTIAL_TYPE:\r
- for (Index = 0; Index < mProviderInfo->Count; Index++) {\r
- UserCredential = mProviderInfo->Provider[Index];\r
- if (CompareGuid ((EFI_GUID *) (Identity + 1), &UserCredential->Type)) {\r
- UserCredential->Title (\r
- UserCredential,\r
- &HiiHandle,\r
- &ProvId\r
- );\r
- ProvStr = HiiGetString (HiiHandle, ProvId, NULL);\r
- if (ProvStr != NULL) {\r
- AddStr (&TmpStr, ProvStr);\r
- FreePool (ProvStr);\r
- }\r
- break;\r
- }\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER:\r
- for (Index = 0; Index < mProviderInfo->Count; Index++) {\r
- UserCredential = mProviderInfo->Provider[Index];\r
- if (CompareGuid ((EFI_GUID *) (Identity + 1), &UserCredential->Identifier)) {\r
- UserCredential->Title (\r
- UserCredential,\r
- &HiiHandle,\r
- &ProvId\r
- );\r
- ProvStr = HiiGetString (HiiHandle, ProvId, NULL);\r
- if (ProvStr != NULL) {\r
- AddStr (&TmpStr, ProvStr);\r
- FreePool (ProvStr);\r
- }\r
- break;\r
- }\r
- }\r
- break;\r
- }\r
-\r
- ChkLen += Identity->Length;\r
- }\r
-\r
- if (TmpStr != NULL) {\r
- HiiSetString (mCallbackInfo->HiiHandle, IpStringId, TmpStr, NULL);\r
- FreePool (TmpStr);\r
- }\r
-}\r
-\r
-\r
-/**\r
- Display modify user information form.\r
-\r
- This form displays, username, create Date, usage date, usage count, identity policy,\r
- and access policy.\r
-\r
- @param[in] UserIndex The index of the user in display list to modify.\r
-\r
-**/\r
-VOID\r
-ModifyUserInfo (\r
- IN UINT8 UserIndex\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_PROFILE_HANDLE CurrentUser;\r
- UINT32 CurrentAccessRight;\r
- VOID *StartOpCodeHandle;\r
- VOID *EndOpCodeHandle;\r
- EFI_IFR_GUID_LABEL *StartLabel;\r
- EFI_IFR_GUID_LABEL *EndLabel;\r
-\r
- //\r
- // Initialize the container for dynamic opcodes.\r
- //\r
- StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (StartOpCodeHandle != NULL);\r
-\r
- EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (EndOpCodeHandle != NULL);\r
-\r
- //\r
- // Create Hii Extend Label OpCode.\r
- //\r
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- StartOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- StartLabel->Number = LABEL_USER_INFO_FUNC;\r
-\r
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- EndOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- EndLabel->Number = LABEL_END;\r
-\r
- //\r
- // Find the user profile to be modified.\r
- //\r
- mModifyUser = NULL;\r
- Status = mUserManager->GetNext (mUserManager, &mModifyUser);\r
- if (EFI_ERROR (Status)) {\r
- return ;\r
- }\r
-\r
- while (UserIndex > 1) {\r
- Status = mUserManager->GetNext (mUserManager, &mModifyUser);\r
- if (EFI_ERROR (Status)) {\r
- return ;\r
- }\r
- UserIndex--;\r
- }\r
-\r
- //\r
- // Get user profile information.\r
- //\r
- GetAllUserInfo ();\r
-\r
- //\r
- // Update user name.\r
- HiiSetString (\r
- mCallbackInfo->HiiHandle,\r
- STRING_TOKEN (STR_USER_NAME_VAL),\r
- mUserInfo.UserName,\r
- NULL\r
- );\r
-\r
- //\r
- // Update create date.\r
- //\r
- if (mUserInfo.CreateDateExist) {\r
- ResolveDate (&mUserInfo.CreateDate, STRING_TOKEN (STR_CREATE_DATE_VAL));\r
- } else {\r
- HiiSetString (\r
- mCallbackInfo->HiiHandle,\r
- STRING_TOKEN (STR_CREATE_DATE_VAL),\r
- L"",\r
- NULL\r
- );\r
- }\r
-\r
- //\r
- // Add usage date.\r
- //\r
- if (mUserInfo.UsageDateExist) {\r
- ResolveDate (&mUserInfo.UsageDate, STRING_TOKEN (STR_USAGE_DATE_VAL));\r
- } else {\r
- HiiSetString (\r
- mCallbackInfo->HiiHandle,\r
- STRING_TOKEN (STR_USAGE_DATE_VAL),\r
- L"",\r
- NULL\r
- );\r
- }\r
-\r
- //\r
- // Add usage count.\r
- //\r
- ResolveCount ((UINT32) mUserInfo.UsageCount, STRING_TOKEN (STR_USAGE_COUNT_VAL));\r
-\r
- //\r
- // Add identity policy.\r
- //\r
- mUserManager->Current (mUserManager, &CurrentUser);\r
- if (mModifyUser == CurrentUser) {\r
- ResolveIdentityPolicy (\r
- mUserInfo.IdentityPolicy,\r
- mUserInfo.IdentityPolicyLen,\r
- STRING_TOKEN (STR_IDENTIFY_POLICY_VAL)\r
- );\r
- HiiCreateGotoOpCode (\r
- StartOpCodeHandle, // Container for opcodes\r
- FORMID_MODIFY_IP, // Target Form ID\r
- STRING_TOKEN (STR_IDENTIFY_POLICY), // Prompt text\r
- STRING_TOKEN (STR_IDENTIFY_POLICY_VAL), // Help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- KEY_MODIFY_USER | KEY_SELECT_USER | KEY_MODIFY_IP // Question ID\r
- );\r
- }\r
-\r
- //\r
- // Add access policy.\r
- //\r
- Status = GetAccessRight (&CurrentAccessRight);\r
- if (EFI_ERROR (Status)) {\r
- CurrentAccessRight = EFI_USER_INFO_ACCESS_ENROLL_SELF;\r
- }\r
-\r
- if (CurrentAccessRight == EFI_USER_INFO_ACCESS_MANAGE) {\r
- HiiCreateGotoOpCode (\r
- StartOpCodeHandle, // Container for opcodes\r
- FORMID_MODIFY_AP, // Target Form ID\r
- STRING_TOKEN (STR_ACCESS_POLICY), // Prompt text\r
- STRING_TOKEN (STR_NULL_STRING), // Help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- KEY_MODIFY_USER | KEY_SELECT_USER | KEY_MODIFY_AP // Question ID\r
- );\r
- }\r
-\r
- HiiUpdateForm (\r
- mCallbackInfo->HiiHandle, // HII handle\r
- &gUserProfileManagerGuid, // Formset GUID\r
- FORMID_USER_INFO, // Form ID\r
- StartOpCodeHandle, // Label\r
- EndOpCodeHandle // Replace data\r
- );\r
-\r
- HiiFreeOpCodeHandle (StartOpCodeHandle);\r
- HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-}\r
-\r
-\r
-/**\r
- Get all the access policy info from current user info, and save in the global\r
- variable.\r
-\r
-**/\r
-VOID\r
-ResolveAccessPolicy (\r
- VOID\r
- )\r
-{\r
- UINTN OffSet;\r
- EFI_USER_INFO_ACCESS_CONTROL Control;\r
- UINTN ValLen;\r
- UINT8 *AccessData;\r
-\r
- //\r
- // Set default value\r
- //\r
- mAccessInfo.AccessRight = EFI_USER_INFO_ACCESS_ENROLL_SELF;\r
- mAccessInfo.AccessSetup = ACCESS_SETUP_RESTRICTED;\r
- mAccessInfo.AccessBootOrder = EFI_USER_INFO_ACCESS_BOOT_ORDER_INSERT;\r
-\r
- mAccessInfo.LoadPermitLen = 0;\r
- mAccessInfo.LoadForbidLen = 0;\r
- mAccessInfo.ConnectPermitLen = 0;\r
- mAccessInfo.ConnectForbidLen = 0;\r
-\r
- //\r
- // Get each user access policy.\r
- //\r
- OffSet = 0;\r
- while (OffSet < mUserInfo.AccessPolicyLen) {\r
- CopyMem (&Control, mUserInfo.AccessPolicy + OffSet, sizeof (Control));\r
- ValLen = Control.Size - sizeof (Control);\r
- switch (Control.Type) {\r
- case EFI_USER_INFO_ACCESS_ENROLL_SELF:\r
- mAccessInfo.AccessRight = EFI_USER_INFO_ACCESS_ENROLL_SELF;\r
- break;\r
-\r
- case EFI_USER_INFO_ACCESS_ENROLL_OTHERS:\r
- mAccessInfo.AccessRight = EFI_USER_INFO_ACCESS_ENROLL_OTHERS;\r
- break;\r
-\r
- case EFI_USER_INFO_ACCESS_MANAGE:\r
- mAccessInfo.AccessRight = EFI_USER_INFO_ACCESS_MANAGE;\r
- break;\r
-\r
- case EFI_USER_INFO_ACCESS_SETUP:\r
- AccessData = mUserInfo.AccessPolicy + OffSet + sizeof (Control);\r
- if (CompareGuid ((EFI_GUID *) AccessData, &gEfiUserInfoAccessSetupNormalGuid)) {\r
- mAccessInfo.AccessSetup = ACCESS_SETUP_NORMAL;\r
- } else if (CompareGuid ((EFI_GUID *) AccessData, &gEfiUserInfoAccessSetupRestrictedGuid)) {\r
- mAccessInfo.AccessSetup = ACCESS_SETUP_RESTRICTED;\r
- } else if (CompareGuid ((EFI_GUID *) AccessData, &gEfiUserInfoAccessSetupAdminGuid)) {\r
- mAccessInfo.AccessSetup = ACCESS_SETUP_ADMIN;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_ACCESS_BOOT_ORDER:\r
- AccessData = mUserInfo.AccessPolicy + OffSet + sizeof (Control);\r
- CopyMem (&mAccessInfo.AccessBootOrder, AccessData, sizeof (UINT32));\r
- break;\r
-\r
- case EFI_USER_INFO_ACCESS_FORBID_LOAD:\r
- if (mAccessInfo.LoadForbid != NULL) {\r
- FreePool (mAccessInfo.LoadForbid);\r
- }\r
-\r
- mAccessInfo.LoadForbid = AllocateZeroPool (ValLen);\r
- if (mAccessInfo.LoadForbid != NULL) {\r
- AccessData = mUserInfo.AccessPolicy + OffSet + sizeof (Control);\r
- CopyMem (mAccessInfo.LoadForbid, AccessData, ValLen);\r
- mAccessInfo.LoadForbidLen = ValLen;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_ACCESS_PERMIT_LOAD:\r
- if (mAccessInfo.LoadPermit != NULL) {\r
- FreePool (mAccessInfo.LoadPermit);\r
- }\r
-\r
- mAccessInfo.LoadPermit = AllocateZeroPool (ValLen);\r
- if (mAccessInfo.LoadPermit != NULL) {\r
- AccessData = mUserInfo.AccessPolicy + OffSet + sizeof (Control);\r
- CopyMem (mAccessInfo.LoadPermit, AccessData, ValLen);\r
- mAccessInfo.LoadPermitLen = ValLen;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_ACCESS_FORBID_CONNECT:\r
- if (mAccessInfo.ConnectForbid != NULL) {\r
- FreePool (mAccessInfo.ConnectForbid);\r
- }\r
-\r
- mAccessInfo.ConnectForbid = AllocateZeroPool (ValLen);\r
- if (mAccessInfo.ConnectForbid != NULL) {\r
- AccessData = mUserInfo.AccessPolicy + OffSet + sizeof (Control);\r
- CopyMem (mAccessInfo.ConnectForbid, AccessData, ValLen);\r
- mAccessInfo.ConnectForbidLen = ValLen;\r
- }\r
- break;\r
-\r
- case EFI_USER_INFO_ACCESS_PERMIT_CONNECT:\r
- if (mAccessInfo.ConnectPermit != NULL) {\r
- FreePool (mAccessInfo.ConnectPermit);\r
- }\r
-\r
- mAccessInfo.ConnectPermit = AllocateZeroPool (ValLen);\r
- if (mAccessInfo.ConnectPermit != NULL) {\r
- AccessData = mUserInfo.AccessPolicy + OffSet + sizeof (Control);\r
- CopyMem (mAccessInfo.ConnectPermit, AccessData, ValLen);\r
- mAccessInfo.ConnectPermitLen = ValLen;\r
- }\r
- break;\r
- }\r
-\r
- OffSet += Control.Size;\r
- }\r
-}\r
-\r
-\r
-/**\r
- Find the specified info in User profile by the InfoType.\r
-\r
- @param[in] User Handle of the user whose information will be searched.\r
- @param[in] InfoType The user information type to find.\r
- @param[out] UserInfo Points to user information handle found.\r
-\r
- @retval EFI_SUCCESS Find the user information successfully.\r
- @retval Others Fail to find the user information.\r
-\r
-**/\r
-EFI_STATUS\r
-FindInfoByType (\r
- IN EFI_USER_PROFILE_HANDLE User,\r
- IN UINT8 InfoType,\r
- OUT EFI_USER_INFO_HANDLE *UserInfo\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO *Info;\r
- UINTN InfoSize;\r
- UINTN MemSize;\r
-\r
- if (UserInfo == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
-\r
- *UserInfo = NULL;\r
- //\r
- // Allocate user information memory.\r
- //\r
- MemSize = sizeof (EFI_USER_INFO) + 63;\r
- Info = AllocateZeroPool (MemSize);\r
- if (Info == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- //\r
- // Get each user information.\r
- //\r
- while (TRUE) {\r
- Status = mUserManager->GetNextInfo (mUserManager, User, UserInfo);\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
- //\r
- // Get information.\r
- //\r
- InfoSize = MemSize;\r
- Status = mUserManager->GetInfo (\r
- mUserManager,\r
- User,\r
- *UserInfo,\r
- Info,\r
- &InfoSize\r
- );\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- MemSize = InfoSize;\r
- FreePool (Info);\r
- Info = AllocateZeroPool (MemSize);\r
- if (Info == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- Status = mUserManager->GetInfo (\r
- mUserManager,\r
- User,\r
- *UserInfo,\r
- Info,\r
- &InfoSize\r
- );\r
- }\r
- if (Status == EFI_SUCCESS) {\r
- if (Info->InfoType == InfoType) {\r
- break;\r
- }\r
- }\r
- }\r
-\r
- FreePool (Info);\r
- return Status;\r
-}\r
-\r
-\r
-/**\r
- Display modify user access policy form.\r
-\r
- In this form, access right, access setup and access boot order are dynamically\r
- added. Load devicepath and connect devicepath are displayed too.\r
-\r
-**/\r
-VOID\r
-ModidyAccessPolicy (\r
- VOID\r
- )\r
-{\r
- VOID *StartOpCodeHandle;\r
- VOID *EndOpCodeHandle;\r
- VOID *OptionsOpCodeHandle;\r
- EFI_IFR_GUID_LABEL *StartLabel;\r
- EFI_IFR_GUID_LABEL *EndLabel;\r
- VOID *DefaultOpCodeHandle;\r
-\r
- //\r
- // Initialize the container for dynamic opcodes.\r
- //\r
- StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (StartOpCodeHandle != NULL);\r
-\r
- EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (EndOpCodeHandle != NULL);\r
-\r
- //\r
- // Create Hii Extend Label OpCode.\r
- //\r
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- StartOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- StartLabel->Number = LABEL_AP_MOD_FUNC;\r
-\r
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- EndOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- EndLabel->Number = LABEL_END;\r
-\r
-\r
- //\r
- // Resolve access policy information.\r
- //\r
- ResolveAccessPolicy ();\r
-\r
- //\r
- // Add access right one-of-code.\r
- //\r
- OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (OptionsOpCodeHandle != NULL);\r
- DefaultOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (DefaultOpCodeHandle != NULL);\r
-\r
- HiiCreateOneOfOptionOpCode (\r
- OptionsOpCodeHandle,\r
- STRING_TOKEN (STR_NORMAL),\r
- 0,\r
- EFI_IFR_NUMERIC_SIZE_1,\r
- EFI_USER_INFO_ACCESS_ENROLL_SELF\r
- );\r
-\r
- HiiCreateOneOfOptionOpCode (\r
- OptionsOpCodeHandle,\r
- STRING_TOKEN (STR_ENROLL),\r
- 0,\r
- EFI_IFR_NUMERIC_SIZE_1,\r
- EFI_USER_INFO_ACCESS_ENROLL_OTHERS\r
- );\r
-\r
- HiiCreateOneOfOptionOpCode (\r
- OptionsOpCodeHandle,\r
- STRING_TOKEN (STR_MANAGE),\r
- 0,\r
- EFI_IFR_NUMERIC_SIZE_1,\r
- EFI_USER_INFO_ACCESS_MANAGE\r
- );\r
-\r
- HiiCreateDefaultOpCode (\r
- DefaultOpCodeHandle,\r
- EFI_HII_DEFAULT_CLASS_STANDARD,\r
- EFI_IFR_NUMERIC_SIZE_1,\r
- mAccessInfo.AccessRight\r
- );\r
-\r
- HiiCreateOneOfOpCode (\r
- StartOpCodeHandle, // Container for dynamic created opcodes\r
- KEY_MODIFY_USER | KEY_SELECT_USER | KEY_MODIFY_AP | KEY_MODIFY_RIGHT, // Question ID\r
- 0, // VarStore ID\r
- 0, // Offset in Buffer Storage\r
- STRING_TOKEN (STR_ACCESS_RIGHT), // Question prompt text\r
- STRING_TOKEN (STR_ACCESS_RIGHT_HELP), // Question help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- EFI_IFR_NUMERIC_SIZE_1, // Data type of Question Value\r
- OptionsOpCodeHandle, // Option Opcode list\r
- DefaultOpCodeHandle // Default Opcode\r
- );\r
- HiiFreeOpCodeHandle (DefaultOpCodeHandle);\r
- HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-\r
-\r
- //\r
- // Add setup type one-of-code.\r
- //\r
- OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (OptionsOpCodeHandle != NULL);\r
- DefaultOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (DefaultOpCodeHandle != NULL);\r
-\r
- HiiCreateOneOfOptionOpCode (\r
- OptionsOpCodeHandle,\r
- STRING_TOKEN (STR_RESTRICTED),\r
- 0,\r
- EFI_IFR_NUMERIC_SIZE_1,\r
- ACCESS_SETUP_RESTRICTED\r
- );\r
-\r
- HiiCreateOneOfOptionOpCode (\r
- OptionsOpCodeHandle,\r
- STRING_TOKEN (STR_NORMAL),\r
- 0,\r
- EFI_IFR_NUMERIC_SIZE_1,\r
- ACCESS_SETUP_NORMAL\r
- );\r
-\r
- HiiCreateOneOfOptionOpCode (\r
- OptionsOpCodeHandle,\r
- STRING_TOKEN (STR_ADMIN),\r
- 0,\r
- EFI_IFR_NUMERIC_SIZE_1,\r
- ACCESS_SETUP_ADMIN\r
- );\r
-\r
- HiiCreateDefaultOpCode (\r
- DefaultOpCodeHandle,\r
- EFI_HII_DEFAULT_CLASS_STANDARD,\r
- EFI_IFR_NUMERIC_SIZE_1,\r
- mAccessInfo.AccessSetup\r
- );\r
-\r
- HiiCreateOneOfOpCode (\r
- StartOpCodeHandle, // Container for dynamic created opcodes\r
- KEY_MODIFY_USER | KEY_SELECT_USER | KEY_MODIFY_AP | KEY_MODIFY_SETUP, // Question ID\r
- 0, // VarStore ID\r
- 0, // Offset in Buffer Storage\r
- STRING_TOKEN (STR_ACCESS_SETUP), // Question prompt text\r
- STRING_TOKEN (STR_ACCESS_SETUP_HELP), // Question help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- EFI_IFR_NUMERIC_SIZE_1, // Data type of Question Value\r
- OptionsOpCodeHandle, // Option Opcode list\r
- DefaultOpCodeHandle // Default Opcode\r
- );\r
- HiiFreeOpCodeHandle (DefaultOpCodeHandle);\r
- HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-\r
- //\r
- // Add boot order one-of-code.\r
- //\r
- OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (OptionsOpCodeHandle != NULL);\r
- DefaultOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (DefaultOpCodeHandle != NULL);\r
-\r
- HiiCreateOneOfOptionOpCode (\r
- OptionsOpCodeHandle,\r
- STRING_TOKEN (STR_INSERT),\r
- 0,\r
- EFI_IFR_NUMERIC_SIZE_4,\r
- EFI_USER_INFO_ACCESS_BOOT_ORDER_INSERT\r
- );\r
-\r
- HiiCreateOneOfOptionOpCode (\r
- OptionsOpCodeHandle,\r
- STRING_TOKEN (STR_APPEND),\r
- 0,\r
- EFI_IFR_NUMERIC_SIZE_4,\r
- EFI_USER_INFO_ACCESS_BOOT_ORDER_APPEND\r
- );\r
-\r
- HiiCreateOneOfOptionOpCode (\r
- OptionsOpCodeHandle,\r
- STRING_TOKEN (STR_REPLACE),\r
- 0,\r
- EFI_IFR_NUMERIC_SIZE_4,\r
- EFI_USER_INFO_ACCESS_BOOT_ORDER_REPLACE\r
- );\r
-\r
- HiiCreateOneOfOptionOpCode (\r
- OptionsOpCodeHandle,\r
- STRING_TOKEN (STR_NODEFAULT),\r
- 0,\r
- EFI_IFR_NUMERIC_SIZE_4,\r
- EFI_USER_INFO_ACCESS_BOOT_ORDER_NODEFAULT\r
- );\r
-\r
- HiiCreateDefaultOpCode (\r
- DefaultOpCodeHandle,\r
- EFI_HII_DEFAULT_CLASS_STANDARD,\r
- EFI_IFR_NUMERIC_SIZE_4,\r
- mAccessInfo.AccessBootOrder\r
- );\r
-\r
- HiiCreateOneOfOpCode (\r
- StartOpCodeHandle, // Container for dynamic created opcodes\r
- KEY_MODIFY_USER | KEY_SELECT_USER | KEY_MODIFY_AP | KEY_MODIFY_BOOT, // Question ID\r
- 0, // VarStore ID\r
- 0, // Offset in Buffer Storage\r
- STRING_TOKEN (STR_BOOR_ORDER), // Question prompt text\r
- STRING_TOKEN (STR_BOOT_ORDER_HELP), // Question help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- EFI_IFR_NUMERIC_SIZE_1, // Data type of Question Value\r
- OptionsOpCodeHandle, // Option Opcode list\r
- DefaultOpCodeHandle // Default Opcode\r
- );\r
- HiiFreeOpCodeHandle (DefaultOpCodeHandle);\r
- HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-\r
- //\r
- // Update Form.\r
- //\r
- HiiUpdateForm (\r
- mCallbackInfo->HiiHandle, // HII handle\r
- &gUserProfileManagerGuid, // Formset GUID\r
- FORMID_MODIFY_AP, // Form ID\r
- StartOpCodeHandle, // Label for where to insert opcodes\r
- EndOpCodeHandle // Replace data\r
- );\r
-\r
- HiiFreeOpCodeHandle (StartOpCodeHandle);\r
- HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-}\r
-\r
-\r
-/**\r
- Expand access policy memory size.\r
-\r
- @param[in] ValidLen The valid access policy length.\r
- @param[in] ExpandLen The length that is needed to expand.\r
-\r
-**/\r
-VOID\r
-ExpandMemory (\r
- IN UINTN ValidLen,\r
- IN UINTN ExpandLen\r
- )\r
-{\r
- UINT8 *Mem;\r
- UINTN Len;\r
-\r
- //\r
- // Expand memory.\r
- //\r
- Len = mUserInfo.AccessPolicyLen + (ExpandLen / 64 + 1) * 64;\r
- Mem = AllocateZeroPool (Len);\r
- ASSERT (Mem != NULL);\r
-\r
- if (mUserInfo.AccessPolicy != NULL) {\r
- CopyMem (Mem, mUserInfo.AccessPolicy, ValidLen);\r
- FreePool (mUserInfo.AccessPolicy);\r
- }\r
-\r
- mUserInfo.AccessPolicy = Mem;\r
- mUserInfo.AccessPolicyLen = Len;\r
-}\r
-\r
-\r
-/**\r
- Get the username from user input, and update username string in the Hii\r
- database with it.\r
-\r
-**/\r
-VOID\r
-ModifyUserName (\r
- VOID\r
- )\r
-{\r
- EFI_STATUS Status;\r
- CHAR16 UserName[USER_NAME_LENGTH];\r
- UINTN Len;\r
- EFI_INPUT_KEY Key;\r
- EFI_USER_INFO_HANDLE UserInfo;\r
- EFI_USER_INFO *Info;\r
- EFI_USER_PROFILE_HANDLE TempUser;\r
-\r
- //\r
- // Get the new user name.\r
- //\r
- Len = sizeof (UserName);\r
- Status = GetUserNameInput (&Len, UserName);\r
- if (EFI_ERROR (Status)) {\r
- if (Status != EFI_ABORTED) {\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- L"Failed To Get User Name.",\r
- L"",\r
- L"Please Press Any Key to Continue ...",\r
- NULL\r
- );\r
- }\r
- return ;\r
- }\r
-\r
- //\r
- // Check whether the username had been used or not.\r
- //\r
- Info = AllocateZeroPool (sizeof (EFI_USER_INFO) + Len);\r
- if (Info == NULL) {\r
- return ;\r
- }\r
-\r
- Info->InfoType = EFI_USER_INFO_NAME_RECORD;\r
- Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV |\r
- EFI_USER_INFO_PUBLIC |\r
- EFI_USER_INFO_EXCLUSIVE;\r
- Info->InfoSize = (UINT32) (sizeof (EFI_USER_INFO) + Len);\r
- CopyMem ((UINT8 *) (Info + 1), UserName, Len);\r
-\r
- TempUser = NULL;\r
- Status = mUserManager->Find (\r
- mUserManager,\r
- &TempUser,\r
- NULL,\r
- Info,\r
- Info->InfoSize\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- CreatePopUp (\r
- EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
- &Key,\r
- L"The User Name Had Been Used.",\r
- L"",\r
- L"Please Use Other User Name",\r
- NULL\r
- );\r
- FreePool (Info);\r
- return ;\r
- }\r
-\r
- //\r
- // Update username display in the form.\r
- //\r
- CopyMem (mUserInfo.UserName, UserName, Len);\r
- HiiSetString (\r
- mCallbackInfo->HiiHandle,\r
- STRING_TOKEN (STR_USER_NAME_VAL),\r
- mUserInfo.UserName,\r
- NULL\r
- );\r
-\r
- //\r
- // Save the user name.\r
- //\r
- Status = FindInfoByType (mModifyUser, EFI_USER_INFO_NAME_RECORD, &UserInfo);\r
- if (!EFI_ERROR (Status)) {\r
- mUserManager->SetInfo (\r
- mUserManager,\r
- mModifyUser,\r
- &UserInfo,\r
- Info,\r
- Info->InfoSize\r
- );\r
- }\r
- FreePool (Info);\r
-}\r
-\r
-\r
-/**\r
- Display the form of the modifying user identity policy.\r
-\r
-**/\r
-VOID\r
-ModifyIdentityPolicy (\r
- VOID\r
- )\r
-{\r
- UINTN Index;\r
- CHAR16 *ProvStr;\r
- EFI_STRING_ID ProvID;\r
- EFI_HII_HANDLE HiiHandle;\r
- VOID *OptionsOpCodeHandle;\r
- VOID *StartOpCodeHandle;\r
- VOID *EndOpCodeHandle;\r
- EFI_IFR_GUID_LABEL *StartLabel;\r
- EFI_IFR_GUID_LABEL *EndLabel;\r
-\r
- //\r
- // Initialize the container for dynamic opcodes.\r
- //\r
- StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (StartOpCodeHandle != NULL);\r
-\r
- EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (EndOpCodeHandle != NULL);\r
-\r
- //\r
- // Create Hii Extend Label OpCode.\r
- //\r
- StartLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- StartOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- StartLabel->Number = LABEL_IP_MOD_FUNC;\r
-\r
- EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
- EndOpCodeHandle,\r
- &gEfiIfrTianoGuid,\r
- NULL,\r
- sizeof (EFI_IFR_GUID_LABEL)\r
- );\r
- EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;\r
- EndLabel->Number = LABEL_END;\r
-\r
- //\r
- // Add credential providers\r
- //.\r
- if (mProviderInfo->Count > 0) {\r
- OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (OptionsOpCodeHandle != NULL);\r
-\r
- //\r
- // Add credential provider Option OpCode.\r
- //\r
- for (Index = 0; Index < mProviderInfo->Count; Index++) {\r
- mProviderInfo->Provider[Index]->Title (\r
- mProviderInfo->Provider[Index],\r
- &HiiHandle,\r
- &ProvID\r
- );\r
- ProvStr = HiiGetString (HiiHandle, ProvID, NULL);\r
- ProvID = HiiSetString (mCallbackInfo->HiiHandle, 0, ProvStr, NULL);\r
- FreePool (ProvStr);\r
- if (ProvID == 0) {\r
- return ;\r
- }\r
-\r
- HiiCreateOneOfOptionOpCode (\r
- OptionsOpCodeHandle,\r
- ProvID,\r
- 0,\r
- EFI_IFR_NUMERIC_SIZE_1,\r
- (UINT8) Index\r
- );\r
- }\r
-\r
- HiiCreateOneOfOpCode (\r
- StartOpCodeHandle, // Container for dynamic created opcodes\r
- KEY_MODIFY_USER | KEY_SELECT_USER | KEY_MODIFY_IP | KEY_MODIFY_PROV, // Question ID\r
- 0, // VarStore ID\r
- 0, // Offset in Buffer Storage\r
- STRING_TOKEN (STR_PROVIDER), // Question prompt text\r
- STRING_TOKEN (STR_PROVIDER_HELP), // Question help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- EFI_IFR_NUMERIC_SIZE_1, // Data type of Question Value\r
- OptionsOpCodeHandle, // Option Opcode list\r
- NULL // Default Opcode is NULl\r
- );\r
-\r
- HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
- }\r
-\r
- //\r
- // Add logical connector Option OpCode.\r
- //\r
- OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();\r
- ASSERT (OptionsOpCodeHandle != NULL);\r
-\r
- HiiCreateOneOfOptionOpCode (\r
- OptionsOpCodeHandle,\r
- STRING_TOKEN (STR_AND_CON),\r
- 0,\r
- EFI_IFR_NUMERIC_SIZE_1,\r
- 0\r
- );\r
-\r
- HiiCreateOneOfOptionOpCode (\r
- OptionsOpCodeHandle,\r
- STRING_TOKEN (STR_OR_CON),\r
- 0,\r
- EFI_IFR_NUMERIC_SIZE_1,\r
- 1\r
- );\r
-\r
- HiiCreateOneOfOpCode (\r
- StartOpCodeHandle, // Container for dynamic created opcodes\r
- KEY_MODIFY_USER | KEY_SELECT_USER | KEY_MODIFY_IP | KEY_MODIFY_CONN, // Question ID\r
- 0, // VarStore ID\r
- 0, // Offset in Buffer Storage\r
- STRING_TOKEN (STR_CONNECTOR), // Question prompt text\r
- STRING_TOKEN (STR_CONNECTOR_HELP), // Question help text\r
- EFI_IFR_FLAG_CALLBACK, // Question flag\r
- EFI_IFR_NUMERIC_SIZE_1, // Data type of Question Value\r
- OptionsOpCodeHandle, // Option Opcode list\r
- NULL // Default Opcode is NULl\r
- );\r
-\r
- HiiFreeOpCodeHandle (OptionsOpCodeHandle);\r
-\r
- //\r
- // Update identity policy in the form.\r
- //\r
- ResolveIdentityPolicy (\r
- mUserInfo.IdentityPolicy,\r
- mUserInfo.IdentityPolicyLen,\r
- STRING_TOKEN (STR_IDENTIFY_POLICY_VALUE)\r
- );\r
-\r
- if (mUserInfo.NewIdentityPolicy != NULL) {\r
- FreePool (mUserInfo.NewIdentityPolicy);\r
- mUserInfo.NewIdentityPolicy = NULL;\r
- mUserInfo.NewIdentityPolicyLen = 0;\r
- mUserInfo.NewIdentityPolicyModified = FALSE;\r
- }\r
- mProviderChoice = 0;\r
- mConncetLogical = 0;\r
-\r
- HiiUpdateForm (\r
- mCallbackInfo->HiiHandle, // HII handle\r
- &gUserProfileManagerGuid, // Formset GUID\r
- FORMID_MODIFY_IP, // Form ID\r
- StartOpCodeHandle, // Label for where to insert opcodes\r
- EndOpCodeHandle // Replace data\r
- );\r
-\r
- HiiFreeOpCodeHandle (StartOpCodeHandle);\r
- HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-}\r
-\r
-\r
-/**\r
- Get current user's access right.\r
-\r
- @param[out] AccessRight Points to the buffer used for user's access right.\r
-\r
- @retval EFI_SUCCESS Get current user access right successfully.\r
- @retval others Fail to get current user access right.\r
-\r
-**/\r
-EFI_STATUS\r
-GetAccessRight (\r
- OUT UINT32 *AccessRight\r
- )\r
-{\r
- EFI_STATUS Status;\r
- EFI_USER_INFO_HANDLE UserInfo;\r
- EFI_USER_INFO *Info;\r
- UINTN InfoSize;\r
- UINTN MemSize;\r
- EFI_USER_INFO_ACCESS_CONTROL Access;\r
- EFI_USER_PROFILE_HANDLE CurrentUser;\r
- UINTN TotalLen;\r
- UINTN CheckLen;\r
-\r
- //\r
- // Allocate user information memory.\r
- //\r
- MemSize = sizeof (EFI_USER_INFO) + 63;\r
- Info = AllocateZeroPool (MemSize);\r
- if (Info == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
-\r
- //\r
- // Get user access information.\r
- //\r
- UserInfo = NULL;\r
- mUserManager->Current (mUserManager, &CurrentUser);\r
- while (TRUE) {\r
- InfoSize = MemSize;\r
- //\r
- // Get next user information.\r
- //\r
- Status = mUserManager->GetNextInfo (mUserManager, CurrentUser, &UserInfo);\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
-\r
- Status = mUserManager->GetInfo (\r
- mUserManager,\r
- CurrentUser,\r
- UserInfo,\r
- Info,\r
- &InfoSize\r
- );\r
- if (Status == EFI_BUFFER_TOO_SMALL) {\r
- MemSize = InfoSize;\r
- FreePool (Info);\r
- Info = AllocateZeroPool (MemSize);\r
- if (Info == NULL) {\r
- return EFI_OUT_OF_RESOURCES;\r
- }\r
- Status = mUserManager->GetInfo (\r
- mUserManager,\r
- CurrentUser,\r
- UserInfo,\r
- Info,\r
- &InfoSize\r
- );\r
- }\r
- if (EFI_ERROR (Status)) {\r
- break;\r
- }\r
-\r
- //\r
- // Check user information.\r
- //\r
- if (Info->InfoType == EFI_USER_INFO_ACCESS_POLICY_RECORD) {\r
- TotalLen = Info->InfoSize - sizeof (EFI_USER_INFO);\r
- CheckLen = 0;\r
- //\r
- // Get specified access information.\r
- //\r
- while (CheckLen < TotalLen) {\r
- CopyMem (&Access, (UINT8 *) (Info + 1) + CheckLen, sizeof (Access));\r
- if ((Access.Type == EFI_USER_INFO_ACCESS_ENROLL_SELF) ||\r
- (Access.Type == EFI_USER_INFO_ACCESS_ENROLL_OTHERS) ||\r
- (Access.Type == EFI_USER_INFO_ACCESS_MANAGE)\r
- ) {\r
- *AccessRight = Access.Type;\r
- FreePool (Info);\r
- return EFI_SUCCESS;\r
- }\r
- CheckLen += Access.Size;\r
- }\r
- }\r
- }\r
- FreePool (Info);\r
- return EFI_NOT_FOUND;\r
-}\r
-\r