/** @file
This driver manages user information and produces user manager protocol.
Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "UserIdentifyManager.h"
//
// Default user name.
//
//
// Points to the user profile database.
//
//
// Points to the credential providers found in system.
//
//
// Current user shared in multi function.
//
//
// Flag indicates a user is identified.
//
{
{
{
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
}
},
},
{
{
}
}
};
};
/**
Find the specified user in the user database.
This function searches the specified user from the beginning of the user database.
And if NextUser is TRUE, return the next User in the user database.
@param[in, out] User On entry, points to the user profile entry to search.
On return, points to the user profile entry or NULL if not found.
@param[in] NextUser If FALSE, find the user in user profile database specifyed by User
If TRUE, find the next user in user profile database specifyed
by User.
@param[out] ProfileIndex A pointer to the index of user profile database that matches the
user specifyed by User.
@retval EFI_NOT_FOUND User was NULL, or User was not found, or the next user was not found.
@retval EFI_SUCCESS User or the next user are found in user profile database
**/
)
{
//
// Check parameters
//
return EFI_NOT_FOUND;
}
//
// Check whether the user profile is in the user profile database.
//
if (ProfileIndex != NULL) {
*ProfileIndex = Index;
}
break;
}
}
if (NextUser) {
//
// Find the next user profile.
//
Index++;
return EFI_NOT_FOUND;
} else {
} else {
return EFI_NOT_FOUND;
}
}
return EFI_NOT_FOUND;
}
return EFI_SUCCESS;
}
/**
Find the specified user information record in the specified User profile.
This function searches the specified user information record from the beginning of the user
profile. And if NextInfo is TRUE, return the next info in the user profile.
@param[in] User Points to the user profile entry.
@param[in, out] Info On entry, points to the user information record or NULL to start
searching with the first user information record.
On return, points to the user information record or NULL if not found.
@param[in] NextInfo If FALSE, find the user information record in profile specifyed by User.
If TRUE, find the next user information record in profile specifyed
by User.
@param[out] Offset A pointer to the offset of the information record in the user profile.
@retval EFI_INVALID_PARAMETER Info is NULL
@retval EFI_NOT_FOUND Info was not found, or the next Info was not found.
@retval EFI_SUCCESS Info or the next info are found in user profile.
**/
)
{
return EFI_INVALID_PARAMETER;
}
//
// Check user profile entry
//
return Status;
}
//
// Find user information in the specified user record.
//
InfoLen = 0;
}
break;
}
}
//
// Check whether to find the next user information.
//
if (NextInfo) {
}
return EFI_NOT_FOUND;
}
} else {
*Offset = 0;
}
} else {
return EFI_NOT_FOUND;
}
}
return EFI_NOT_FOUND;
}
return EFI_SUCCESS;
}
/**
Find a user infomation record by the information record type.
This function searches all user information records of User. The search starts with the
user information record following Info and continues until either the information is found
or there are no more user infomation record.
A match occurs when a Info.InfoType field matches the user information record type.
@param[in] User Points to the user profile record to search.
@param[in, out] Info On entry, points to the user information record or NULL to start
searching with the first user information record.
On return, points to the user information record or NULL if not found.
@param[in] InfoType The infomation type to be searched.
@retval EFI_SUCCESS User information was found. Info points to the user information record.
@retval EFI_NOT_FOUND User information was not found.
@retval EFI_INVALID_PARAMETER User is NULL or Info is NULL.
**/
)
{
return EFI_INVALID_PARAMETER;
}
//
// Check whether the user has the specified user information.
//
InfoLen = 0;
} else {
}
return EFI_NOT_FOUND;
}
return EFI_SUCCESS;
}
}
}
return EFI_NOT_FOUND;
}
/**
Find a user using a user information record.
This function searches all user profiles for the specified user information record. The
search starts with the user information record handle following UserInfo and continues
until either the information is found or there are no more user profiles.
A match occurs when the Info.InfoType field matches the user information record type and the
user information record data matches the portion of Info passed the EFI_USER_INFO header.
@param[in, out] User On entry, points to the previously returned user profile record,
or NULL to start searching with the first user profile.
On return, points to the user profile entry, or NULL if not found.
@param[in, out] UserInfo On entry, points to the previously returned user information record,
or NULL to start searching with the first.
On return, points to the user information record, or NULL if not found.
@param[in] Info Points to the buffer containing the user information to be compared
to the user information record.
@param[in] InfoSize The size of Info, in bytes. Same as Info->InfoSize.
@retval EFI_SUCCESS User information was found. User points to the user profile record,
and UserInfo points to the user information record.
@retval EFI_NOT_FOUND User information was not found.
@retval EFI_INVALID_PARAMETER User is NULL; Info is NULL; or, InfoSize is too small.
**/
)
{
return EFI_INVALID_PARAMETER;
}
if (InfoSize < sizeof (EFI_USER_INFO)) {
return EFI_INVALID_PARAMETER;
}
} else {
}
//
// Find user profile according to information.
//
}
//
// Check user profile handle.
//
//
// Find the user information in a user profile.
//
while (TRUE) {
break;
}
if (CompareMem ((UINT8 *) (InfoEntry + 1), (UINT8 *) (Info + 1), InfoSize - sizeof (EFI_USER_INFO)) == 0) {
//
// Found the infomation record.
//
}
return EFI_SUCCESS;
}
}
}
//
// Get next user profile.
//
}
return EFI_NOT_FOUND;
}
/**
Check whether the access policy is valid.
@param[in] PolicyInfo Point to the access policy.
@param[in] InfoLen The policy length.
@retval TRUE The policy is a valid access policy.
@retval FALSE The access policy is not a valid access policy.
**/
)
{
TotalLen = 0;
//
// Check access policy according to type.
//
OffSet = 0;
}
return FALSE;
}
break;
return FALSE;
}
break;
if (ValueLen % sizeof (EFI_USER_INFO_ACCESS_BOOT_ORDER_HDR) != 0) {
return FALSE;
}
break;
if (ValueLen != 0) {
return FALSE;
}
break;
default:
return FALSE;
break;
}
}
return FALSE;
}
return TRUE;
}
/**
Check whether the identity policy is valid.
@param[in] PolicyInfo Point to the identity policy.
@param[in] InfoLen The policy length.
@retval TRUE The policy is a valid identity policy.
@retval FALSE The access policy is not a valid identity policy.
**/
)
{
TotalLen = 0;
//
// Check each part of policy expression.
//
//
// Check access polisy according to type.
//
//
// Check False option.
//
if (ValueLen != 0) {
return FALSE;
}
break;
//
// Check True option.
//
if (ValueLen != 0) {
return FALSE;
}
break;
//
// Check negative operation.
//
if (ValueLen != 0) {
return FALSE;
}
break;
//
// Check and operation.
//
if (ValueLen != 0) {
return FALSE;
}
break;
//
// Check or operation.
//
if (ValueLen != 0) {
return FALSE;
}
break;
//
// Check credential provider by type.
//
return FALSE;
}
break;
//
// Check credential provider by ID.
//
return FALSE;
}
break;
default:
return FALSE;
break;
}
}
return FALSE;
}
return TRUE;
}
/**
Check whether the user information is a valid user information record.
@param[in] Info points to the user information.
@retval TRUE The info is a valid user information record.
@retval FALSE The info is not a valid user information record.
**/
)
{
return FALSE;
}
//
// Check user information according to information type.
//
if (InfoLen != 0) {
return FALSE;
}
break;
break;
return FALSE;
}
break;
return FALSE;
}
break;
if (InfoLen != 16) {
return FALSE;
}
break;
return FALSE;
}
break;
break;
case EFI_USER_INFO_FAR_RECORD:
if (InfoLen != 1) {
return FALSE;
}
break;
return FALSE;
}
break;
return FALSE;
}
break;
default:
return FALSE;
break;
}
return TRUE;
}
/**
Check the user profile data format to be added.
@param[in] UserProfileInfo Points to the user profile data.
@param[in] UserProfileSize The length of user profile data.
@retval TRUE It is a valid user profile.
@retval FALSE It is not a valid user profile.
**/
)
{
if (UserProfileInfo == NULL) {
return FALSE;
}
//
// Check user profile information length.
//
ChkLen = 0;
while (ChkLen < UserProfileSize) {
//
// Check user information format.
//
if (!CheckUserInfo (Info)) {
return FALSE;
}
}
if (ChkLen != UserProfileSize) {
return FALSE;
}
return TRUE;
}
/**
Find the specified RightType in current user profile.
@param[in] RightType Could be EFI_USER_INFO_ACCESS_MANAGE,
EFI_USER_INFO_ACCESS_ENROLL_OTHERS or
EFI_USER_INFO_ACCESS_ENROLL_SELF.
@retval TRUE Find the specified RightType in current user profile.
@retval FALSE Can't find the right in the profile.
**/
)
{
//
// Get user access right information.
//
&Info,
);
return FALSE;
}
CheckLen = 0;
//
// Check right according to access type.
//
return TRUE;;
}
}
return FALSE;
}
/**
Create a unique user identifier.
@param[out] Identifier This points to the identifier.
**/
)
{
//
// Create a unique user identifier.
//
//
// Remove zeros.
//
if (Identifier[Index] == 0) {
}
}
}
/**
Generate unique user ID.
@param[out] UserId Points to the user identifer.
**/
)
{
//
// Generate unique user ID
//
while (TRUE) {
//
// Check whether it's unique in user profile database.
//
if (mUserProfileDb == NULL) {
return ;
}
continue;
}
break;
}
}
return ;
}
}
}
/**
Expand user profile database.
@retval TRUE Success to expand user profile database.
@retval FALSE Fail to expand user profile database.
**/
)
{
//
// Create new user profile database.
//
if (mUserProfileDb == NULL) {
} else {
}
sizeof (USER_PROFILE_DB) - sizeof (EFI_USER_PROFILE_HANDLE) +
MaxNum * sizeof (EFI_USER_PROFILE_HANDLE)
);
if (NewDataBase == NULL) {
return FALSE;
}
//
// Copy old user profile database value
//
if (mUserProfileDb == NULL) {
NewDataBase->UserProfileNum = 0;
} else {
CopyMem (
);
}
return TRUE;
}
/**
Expand user profile
@param[in] User Points to user profile.
@param[in] ExpandSize The size of user profile.
@retval TRUE Success to expand user profile size.
@retval FALSE Fail to expand user profile size.
**/
)
{
//
// Allocate new memory.
//
InfoSizeInc = 128;
return FALSE;
}
//
// Copy exist information.
//
if (User->UserProfileSize > 0) {
}
return TRUE;
}
/**
Save the user profile to non-volatile memory, or delete it from non-volatile memory.
@param[in] User Point to the user profile
@param[in] Delete If TRUE, delete the found user profile.
If FALSE, save the user profile.
@retval EFI_SUCCESS Save or delete user profile successfully.
@retval Others Fail to change the profile.
**/
)
{
//
// Check user profile entry.
//
return Status;
}
//
// Save the user profile to non-volatile memory.
//
);
return Status;
}
/**
Add one new user info into the user's profile.
@param[in] User point to the user profile
@param[in] Info Points to the user information payload.
@param[in] InfoSize The size of the user information payload, in bytes.
@param[out] UserInfo Point to the new info in user profile
@param[in] Save If TRUE, save the profile to NV flash.
If FALSE, don't need to save the profile to NV flash.
@retval EFI_SUCCESS Add user info to user profile successfully.
@retval Others Fail to add user info to user profile.
**/
)
{
return EFI_INVALID_PARAMETER;
}
//
// Check user profile handle.
//
return Status;
}
//
// Check user information memory size.
//
return EFI_OUT_OF_RESOURCES;
}
}
//
// Add new user information.
//
}
//
// Save user profile information.
//
if (Save) {
}
return Status;
}
/**
Get the user info from the specified user info handle.
@param[in] User Point to the user profile.
@param[in] UserInfo Point to the user information record to get.
@param[out] Info On entry, points to a buffer of at least *InfoSize bytes.
On exit, holds the user information.
@param[in, out] InfoSize On entry, points to the size of Info.
On return, points to the size of the user information.
@param[in] ChkRight If TRUE, check the user info attribute.
If FALSE, don't check the user info attribute.
@retval EFI_ACCESS_DENIED The information cannot be accessed by the current user.
@retval EFI_INVALID_PARAMETER InfoSize is NULL or UserInfo is NULL.
@retval EFI_BUFFER_TOO_SMALL The number of bytes specified by *InfoSize is too small to hold the
returned data. The actual size required is returned in *InfoSize.
@retval EFI_SUCCESS Information returned successfully.
**/
)
{
return EFI_INVALID_PARAMETER;
}
return EFI_INVALID_PARAMETER;
}
//
// Find the user information to get.
//
return Status;
}
//
// Check information attributes.
//
if (ChkRight) {
case EFI_USER_INFO_PRIVATE:
case EFI_USER_INFO_PROTECTED:
if (User != mCurrentUser) {
return EFI_ACCESS_DENIED;
}
break;
case EFI_USER_INFO_PUBLIC:
break;
default:
return EFI_INVALID_PARAMETER;
break;
}
}
//
// Get user information.
//
return EFI_BUFFER_TOO_SMALL;
}
}
return EFI_SUCCESS;
}
/**
Delete the specified user information from user profile.
@param[in] User Point to the user profile.
@param[in] Info Point to the user information record to delete.
@param[in] Save If TRUE, save the profile to NV flash.
If FALSE, don't need to save the profile to NV flash.
@retval EFI_SUCCESS Delete user info from user profile successfully.
@retval Others Fail to delete user info from user profile.
**/
)
{
//
// Check user information handle.
//
return Status;
}
return EFI_ACCESS_DENIED;
}
//
// Delete the specified user information.
//
CopyMem (User->ProfileInfo + Offset, User->ProfileInfo + NextOffset, User->UserProfileSize - Offset);
}
if (Save) {
}
return Status;
}
/**
Add or update user information.
@param[in] User Point to the user profile.
@param[in, out] UserInfo On entry, points to the user information to modify,
or NULL to add a new UserInfo.
On return, points to the modified user information.
@param[in] Info Points to the new user information.
@param[in] InfoSize The size of Info,in bytes.
@retval EFI_INVALID_PARAMETER UserInfo is NULL or Info is NULL.
@retval EFI_ACCESS_DENIED The record is exclusive.
**/
)
{
return EFI_INVALID_PARAMETER;
}
return EFI_INVALID_PARAMETER;
}
//
// Check user information.
//
return EFI_ACCESS_DENIED;
}
if (!CheckUserInfo (Info)) {
return EFI_INVALID_PARAMETER;
}
//
// Add new user information.
//
do {
break;
}
//
// Same type can not co-exist for exclusive information.
//
return EFI_ACCESS_DENIED;
}
//
// Check whether it exists in DB.
//
continue;
}
continue;
}
if (PayloadLen == 0) {
continue;
}
continue;
}
//
// Yes. The new info is as same as the one in profile.
//
return EFI_SUCCESS;
return Status;
}
//
// Modify existing user information.
//
return EFI_INVALID_PARAMETER;
}
//
// Try to add exclusive attrib in new info.
// Check whether there is another information with the same type in profile.
//
do {
break;
}
//
// There is another information with the same type in profile.
// Therefore, can't modify existing user information to add exclusive attribute.
//
return EFI_ACCESS_DENIED;
}
} while (TRUE);
}
return Status;
}
}
/**
Delete the user profile from non-volatile memory and database.
@param[in] User Points to the user profile.
@retval EFI_SUCCESS Delete user from the user profile successfully.
@retval Others Fail to delete user from user profile
**/
)
{
//
// Check whether it is in the user profile database.
//
return EFI_INVALID_PARAMETER;
}
//
// Check whether it is the current user.
//
if (User == mCurrentUser) {
return EFI_ACCESS_DENIED;
}
//
// Delete user profile from the non-volatile memory.
//
return Status;
}
//
// Modify user profile database.
//
CopyMem (
sizeof (User->UserVarName)
);
return Status;
}
}
//
// Delete user profile information.
//
}
return EFI_SUCCESS;
}
/**
Add user profile to user profile database.
@param[out] UserProfile Point to the newly added user profile.
@param[in] ProfileSize The size of the user profile.
@param[in] ProfileInfo Point to the user profie data.
@param[in] Save If TRUE, save the new added profile to NV flash.
If FALSE, don't save the profile to NV flash.
@retval EFI_SUCCESS Add user profile to user profile database successfully.
@retval Others Fail to add user profile to user profile database.
**/
)
{
//
// Check the data format to be added.
//
return EFI_SECURITY_VIOLATION;
}
//
// Create user profile entry.
//
return EFI_OUT_OF_RESOURCES;
}
//
// Add the entry to the user profile database.
//
if (!ExpandUsermUserProfileDb ()) {
return EFI_OUT_OF_RESOURCES;
}
}
sizeof (User->UserVarName),
L"User%04x",
);
User->UserProfileSize = 0;
User->MaxProfileSize = 0;
//
// Add user profile information.
//
return Status;
}
//
// Set new user profile handle.
//
if (UserProfile != NULL) {
*UserProfile = User;
}
return EFI_SUCCESS;
}
/**
This function creates a new user profile with only a new user identifier
attached and returns its handle. The user profile is non-volatile, but the
handle User can change across reboots.
@param[out] User Handle of a new user profile.
@retval EFI_SUCCESS User profile was successfully created.
@retval Others Fail to create user profile
**/
)
{
return EFI_INVALID_PARAMETER;
}
//
// Generate user id information.
//
return EFI_OUT_OF_RESOURCES;
}
UserInfo->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;
//
// Add user profile to the user profile database.
//
return Status;
}
/**
Add a default user profile to user profile database.
@retval EFI_SUCCESS A default user profile is added successfully.
@retval Others Fail to add a default user profile
**/
)
{
//
// Create a user profile.
//
return Status;
}
//
// Allocate a buffer to add all default user information.
//
return EFI_OUT_OF_RESOURCES;
}
//
// Add user name.
//
Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;
goto Done;
}
//
// Add user profile create date record.
//
Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;
goto Done;
}
goto Done;
}
//
// Add user profile usage count record.
//
Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;
UsageCount = 0;
goto Done;
}
//
// Add user access right.
//
Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;
goto Done;
}
//
// Add user identity policy.
//
Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PRIVATE | EFI_USER_INFO_EXCLUSIVE;
Done:
return Status;
}
/**
Publish current user information into EFI System Configuration Table.
By UEFI spec, the User Identity Manager will publish the current user profile
into the EFI System Configuration Table. Currently, only the user identifier and user
name are published.
@retval EFI_SUCCESS Current user information is published successfully.
@retval Others Fail to publish current user information
**/
)
{
(VOID **) &EfiConfigurationTable
);
//
// The table existed!
//
return EFI_SUCCESS;
}
//
// Get user ID information.
//
return Status;
}
//
// Get user name information.
//
return Status;
}
//
// Allocate a buffer for user information table.
//
sizeof (EFI_USER_INFO_TABLE) +
);
if (UserInfoTable == NULL) {
return Status;
}
//
// Append the user information to the user info table
//
return Status;
}
/**
Get the user's identity type.
The identify manager only supports the identity policy in which the credential
provider handles are connected by the operator 'AND' or 'OR'.
@param[in] User Handle of a user profile.
@param[out] PolicyType Point to the identity type.
@retval EFI_SUCCESS Get user's identity type successfully.
@retval Others Fail to get user's identity type.
**/
)
{
//
// Get user identify policy information.
//
IdentifyInfo = NULL;
return Status;
}
//
// Search the user identify policy according to type.
//
TotalLen = 0;
break;
}
break;
}
}
return EFI_SUCCESS;
}
/**
Identify the User by the specfied provider.
@param[in] User Handle of a user profile.
@param[in] Provider Points to the identifier of credential provider.
@retval EFI_INVALID_PARAMETER Provider is NULL.
@retval EFI_NOT_FOUND Fail to identify the specified user.
@retval EFI_SUCCESS User is identified successfully.
**/
)
{
return EFI_INVALID_PARAMETER;
}
//
// Check the user ID identified by the specified credential provider.
//
//
// Check credential provider class.
//
return Status;
}
if ((AutoLogon & EFI_CREDENTIAL_LOGON_FLAG_AUTO) == 0) {
//
// Get credential provider form.
//
);
//
// Send form to get user input.
//
1,
NULL,
);
return Status;
}
}
}
return Status;
}
return Status;
}
return EFI_SUCCESS;
}
}
return EFI_NOT_FOUND;
}
/**
Update user information when user is logon on successfully.
@param[in] User Points to user profile.
@retval EFI_SUCCESS Update user information successfully.
@retval Others Fail to update user information.
**/
)
{
//
// Allocate a buffer to update user's date record and usage record.
//
return EFI_OUT_OF_RESOURCES;
}
//
// Check create date record.
//
if (Status == EFI_NOT_FOUND) {
Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;
return Status;
}
return Status;
}
}
//
// Update usage date record.
//
Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;
return Status;
}
return Status;
}
}
//
// Update usage count record.
//
UsageCount = 0;
//
// Get usage count.
//
if (Status == EFI_SUCCESS) {
}
UsageCount++;
Info->InfoAttribs = EFI_USER_INFO_STORAGE_PLATFORM_NV | EFI_USER_INFO_PUBLIC | EFI_USER_INFO_EXCLUSIVE;
return Status;
}
}
return EFI_SUCCESS;
}
/**
Add a credenetial provider item in form.
@param[in] ProviderGuid Points to the identifir of credential provider.
@param[in] OpCodeHandle Points to container for dynamic created opcodes.
**/
)
{
//
// Add credential provider selection.
//
continue ;
}
OpCodeHandle, // Container for dynamic created opcodes
ProvID, // Prompt text
0 // Action String ID
);
break;
}
}
}
/**
Add a username item in form.
@param[in] Index The index of the user in the user name list.
@param[in] User Points to the user profile whose username is added.
@param[in] OpCodeHandle Points to container for dynamic created opcodes.
@retval EFI_SUCCESS Add a username successfully.
@retval Others Fail to add a username.
**/
)
{
return Status;
}
//
// Add user name selection.
//
if (UserName == 0) {
return EFI_OUT_OF_RESOURCES;
}
OpCodeHandle, // Container for dynamic created opcodes
FORMID_PROVIDER_FORM, // Target Form ID
UserName, // Prompt text
EFI_IFR_FLAG_CALLBACK, // Question flag
);
return EFI_SUCCESS;
}
/**
Identify the user whose identity policy does not contain the operator 'OR'.
@param[in] User Points to the user profile.
@retval EFI_SUCCESS The specified user is identified successfully.
@retval Others Fail to identify the user.
**/
)
{
//
// Get user identify policy information.
//
IdentifyInfo = NULL;
return Status;
}
//
// Check each part of identification policy expression.
//
TotalLen = 0;
//
// Check False option.
//
break;
//
// Check True option.
//
break;
//
// Check negative operation.
//
break;
//
// Check and operation.
//
if (!Success) {
return EFI_NOT_READY;
}
break;
//
// Check or operation.
//
if (Success) {
return EFI_SUCCESS;
}
break;
//
// Check credential provider by type.
//
break;
//
// Check credential provider by ID.
//
return EFI_INVALID_PARAMETER;
}
return Status;
}
break;
default:
return EFI_INVALID_PARAMETER;
break;
}
}
return EFI_INVALID_PARAMETER;
}
if (!Success) {
return EFI_NOT_READY;
}
return EFI_SUCCESS;
}
/**
Identify the user whose identity policy does not contain the operator 'AND'.
@param[in] User Points to the user profile.
@retval EFI_SUCCESS The specified user is identified successfully.
@retval Others Fail to identify the user.
**/
)
{
//
// Get user identify policy information.
//
IdentifyInfo = NULL;
return Status;
}
//
// Initialize the container for dynamic opcodes.
//
//
// Create Hii Extend Label OpCode.
//
NULL,
sizeof (EFI_IFR_GUID_LABEL)
);
NULL,
sizeof (EFI_IFR_GUID_LABEL)
);
//
// Add the providers that exists in the user's policy.
//
TotalLen = 0;
}
}
&gUserIdentifyManagerGuid,// Formset GUID
FORMID_PROVIDER_FORM, // Form ID
StartOpCodeHandle, // Label for where to insert opcodes
EndOpCodeHandle // Replace data
);
return EFI_SUCCESS;
}
/**
This function processes the results of changes in configuration.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
@param Action Specifies the type of action taken by the browser.
@param QuestionId A unique value which is sent to the original
exporting driver so that it can identify the type
of data to expect.
@param Type The type of value for the question.
@param Value A pointer to the data being sent to the original
exporting driver.
@param ActionRequest On return, points to the action requested by the
callback function.
@retval EFI_SUCCESS The callback successfully handled the action.
@retval Others Fail to handle the action.
**/
)
{
switch (Action) {
{
//
// Update user Form when user Form is opened.
// This will be done only in FORM_OPEN CallBack of question with FORM_OPEN_QUESTION_ID from user Form.
//
if (QuestionId != FORM_OPEN_QUESTION_ID) {
return EFI_SUCCESS;
}
//
// Initialize the container for dynamic opcodes.
//
//
// Create Hii Extend Label OpCode.
//
NULL,
sizeof (EFI_IFR_GUID_LABEL)
);
NULL,
sizeof (EFI_IFR_GUID_LABEL)
);
//
// Add all the user profile in the user profile database.
//
}
&gUserIdentifyManagerGuid,// Formset GUID
FORMID_USER_FORM, // Form ID
StartOpCodeHandle, // Label for where to insert opcodes
EndOpCodeHandle // Replace data
);
return EFI_SUCCESS;
}
break;
break;
if (QuestionId >= LABEL_PROVIDER_NAME) {
//
// QuestionId comes from the second Form (Select a Credential Provider if identity
// policy is OR type). Identify the user by the selected provider.
//
Status = IdentifyByProviderId (mCurrentUser, &mProviderDb->Provider[QuestionId & 0xFFF]->Identifier);
if (Status == EFI_SUCCESS) {
mIdentified = TRUE;
}
return EFI_SUCCESS;
}
break;
//
// QuestionId comes from the first Form (Select a user to identify).
//
if (QuestionId >= LABEL_PROVIDER_NAME) {
return EFI_SUCCESS;
}
return Status;
}
if (PolicyType == EFI_USER_INFO_IDENTITY_OR) {
//
// Identify the user by "OR" logical.
//
return Status;
}
} else {
//
// Identify the user by "AND" logical.
//
return Status;
}
mIdentified = TRUE;
if (Type == EFI_IFR_TYPE_REF) {
}
}
break;
default:
//
// All other action return unsupported.
//
break;
}
return Status;
}
/**
This function construct user profile database from user data saved in the Flash.
If no user is found in Flash, add one default user "administrator" in the user
profile database.
@retval EFI_SUCCESS Init user profile database successfully.
@retval Others Fail to init user profile database.
**/
)
{
if (mUserProfileDb != NULL) {
//
// The user profiles had been already initialized.
//
return EFI_SUCCESS;
}
//
// Init user profile database structure.
//
if (!ExpandUsermUserProfileDb ()) {
return EFI_OUT_OF_RESOURCES;
}
return EFI_OUT_OF_RESOURCES;
}
//
// Get all user proifle entries.
//
Index = 0;
while (TRUE) {
//
// Get variable name.
//
sizeof (VarName),
L"User%04x",
);
Index++;
//
// Get variable value.
//
if (Status == EFI_BUFFER_TOO_SMALL) {
break;
}
}
if (Status == EFI_NOT_FOUND) {
}
break;
}
//
// Check variable attributes.
//
continue;
}
//
// Add user profile to the user profile database.
//
if (Status == EFI_SECURITY_VIOLATION) {
//
// Delete invalid user profile
//
} else if (Status == EFI_OUT_OF_RESOURCES) {
break;
}
} else {
//
// Delete and save the profile again if some invalid profiles are deleted.
//
}
}
}
}
return Status;
}
//
// Check whether the user profile database is empty.
//
if (mUserProfileDb->UserProfileNum == 0) {
Status = AddDefaultUserProfile ();
}
return Status;
}
/**
This function collects all the credential providers and saves to mProviderDb.
@retval EFI_SUCCESS Collect credential providers successfully.
@retval Others Fail to collect credential providers.
**/
)
{
if (mProviderDb != NULL) {
//
// The credential providers had been collected before.
//
return EFI_SUCCESS;
}
//
// Try to find all the user credential provider driver.
//
HandleCount = 0;
NULL,
);
return Status;
}
//
// Get provider infomation.
//
sizeof (CREDENTIAL_PROVIDER_INFO) -
sizeof (EFI_USER_CREDENTIAL2_PROTOCOL *) +
HandleCount * sizeof (EFI_USER_CREDENTIAL2_PROTOCOL *)
);
if (mProviderDb == NULL) {
return EFI_OUT_OF_RESOURCES;
}
);
mProviderDb = NULL;
return Status;
}
}
return EFI_SUCCESS;
}
/**
This function allows a caller to extract the current configuration for one
or more named elements from the target driver.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
@param Request A null-terminated Unicode string in <ConfigRequest> format.
@param Progress On return, points to a character in the Request string.
Points to the string's null terminator if request was successful.
pair (or the beginning of the string if the failure is in the
@param Results A null-terminated Unicode string in <ConfigAltResp> format which
has all values filled in for the names in the Request string.
String to be allocated by the called function.
@retval EFI_SUCCESS The Results is filled with the requested values.
@retval EFI_OUT_OF_RESOURCES Not enough memory to store the results.
@retval EFI_INVALID_PARAMETER Request is illegal syntax, or unknown name.
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
**/
)
{
return EFI_INVALID_PARAMETER;
}
return EFI_NOT_FOUND;
}
/**
This function processes the results of changes in configuration.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
@param Configuration A null-terminated Unicode string in <ConfigResp> format.
@param Progress A pointer to a string filled in with the offset of the most
beginning of the string if the failure is in the first
@retval EFI_SUCCESS The Results is processed successfully.
@retval EFI_INVALID_PARAMETER Configuration is NULL.
@retval EFI_NOT_FOUND Routing data doesn't match any storage in this driver.
**/
)
{
return EFI_INVALID_PARAMETER;
}
return EFI_NOT_FOUND;
}
/**
This function initialize the data mainly used in form browser.
@retval EFI_SUCCESS Initialize form data successfully.
@retval Others Fail to Initialize form data.
**/
)
{
//
// Initialize driver private data.
//
if (CallbackInfo == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// Locate Hii Database protocol.
//
return Status;
}
//
// Locate HiiString protocol.
//
return Status;
}
//
// Locate Formbrowser2 protocol.
//
return Status;
}
//
// Install Device Path Protocol and Config Access protocol to driver handle.
//
);
//
// Publish HII data.
//
);
return EFI_OUT_OF_RESOURCES;
}
return EFI_SUCCESS;
}
/**
Identify the user whose identification policy supports auto logon.
@param[in] ProviderIndex The provider index in the provider list.
@param[out] User Points to user user profile if a user is identified successfully.
@retval EFI_SUCCESS Identify a user with the specified provider successfully.
@retval Others Fail to identify a user.
**/
)
{
return EFI_OUT_OF_RESOURCES;
}
//
// Identify the specified credential provider's auto logon user.
//
NULL,
);
return Status;
}
//
// Find user with the specified user ID.
//
return Status;
}
if (PolicyType == EFI_USER_INFO_IDENTITY_AND) {
//
// The identified user need also identified by other credential provider.
// This can handle through select user.
//
return EFI_NOT_READY;
}
return Status;
}
/**
Check whether the given console is ready.
@param[in] ProtocolGuid Points to the protocol guid of sonsole .
@retval TRUE The given console is ready.
@retval FALSE The given console is not ready.
**/
)
{
//
// Try to find all the handle driver.
//
HandleCount = 0;
NULL,
);
return FALSE;
}
if (DevicePath != NULL) {
return TRUE;
}
}
return FALSE;
}
/**
Check whether the console is ready.
@retval TRUE The console is ready.
@retval FALSE The console is not ready.
**/
)
{
if (!CheckConsole (&gEfiSimpleTextOutProtocolGuid)) {
return FALSE;
}
if (!CheckConsole (&gEfiSimpleTextInProtocolGuid)) {
if (!CheckConsole (&gEfiSimpleTextInputExProtocolGuid)) {
return FALSE;
}
}
return TRUE;
}
/**
Identify a user to logon.
@param[out] User Points to user user profile if a user is identified successfully.
@retval EFI_SUCCESS Identify a user successfully.
**/
)
{
//
// Initialize credential providers.
//
InitProviderInfo ();
//
// Initialize user profile database.
//
//
// If only one user in system, and its identify policy is TRUE, then auto logon.
//
IdentifyInfo = NULL;
return Status;
}
return EFI_SUCCESS;
}
}
//
// Find and login the default & AutoLogon user.
//
continue;
}
if (Status == EFI_SUCCESS) {
return EFI_SUCCESS;
}
}
}
if (!IsConsoleReady ()) {
//
// The console is still not ready for user selection.
//
return EFI_ACCESS_DENIED;
}
//
// Select a user and identify it.
//
1,
0,
NULL,
);
if (mIdentified) {
UpdateUserInfo (*User);
return EFI_SUCCESS;
}
return EFI_ACCESS_DENIED;
}
/**
An empty function to pass error checking of CreateEventEx ().
@param Event Event whose notification function is being invoked.
@param Context Pointer to the notification function's context,
which is implementation-dependent.
**/
)
{
}
/**
Create, Signal, and Close the User Profile Changed event.
**/
)
{
NULL,
);
}
/**
Create a new user profile.
This function creates a new user profile with only a new user identifier attached and returns
its handle. The user profile is non-volatile, but the handle User can change across reboots.
@param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.
@param[out] User On return, points to the new user profile handle.
The user profile handle is unique only during this boot.
@retval EFI_SUCCESS User profile was successfully created.
@retval EFI_ACCESS_DENIED Current user does not have sufficient permissions to create a
user profile.
@retval EFI_UNSUPPORTED Creation of new user profiles is not supported.
@retval EFI_INVALID_PARAMETER The User parameter is NULL.
**/
)
{
return EFI_INVALID_PARAMETER;
}
//
// Check the right of the current user.
//
return EFI_ACCESS_DENIED;
}
}
//
// Create new user profile
//
return EFI_ACCESS_DENIED;
}
return EFI_SUCCESS;
}
/**
Delete an existing user profile.
@param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.
@param[in] User User profile handle.
@retval EFI_SUCCESS User profile was successfully deleted.
@retval EFI_ACCESS_DENIED Current user does not have sufficient permissions to delete a user
profile or there is only one user profile.
@retval EFI_UNSUPPORTED Deletion of new user profiles is not supported.
@retval EFI_INVALID_PARAMETER User does not refer to a valid user profile.
**/
)
{
return EFI_INVALID_PARAMETER;
}
//
// Check the right of the current user.
//
return EFI_ACCESS_DENIED;
}
//
// Delete user profile.
//
if (Status != EFI_INVALID_PARAMETER) {
return EFI_ACCESS_DENIED;
}
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
/**
Enumerate all of the enrolled users on the platform.
This function returns the next enrolled user profile. To retrieve the first user profile handle,
point User at a NULL. Each subsequent call will retrieve another user profile handle until there
are no more, at which point User will point to NULL.
@param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.
@param[in, out] User On entry, points to the previous user profile handle or NULL to
start enumeration. On exit, points to the next user profile handle
or NULL if there are no more user profiles.
@retval EFI_SUCCESS Next enrolled user profile successfully returned.
@retval EFI_ACCESS_DENIED Next enrolled user profile was not successfully returned.
@retval EFI_INVALID_PARAMETER The User parameter is NULL.
**/
)
{
return EFI_INVALID_PARAMETER;
}
return EFI_ACCESS_DENIED;
}
return EFI_SUCCESS;
}
/**
Return the current user profile handle.
@param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.
@param[out] CurrentUser On return, points to the current user profile handle.
@retval EFI_SUCCESS Current user profile handle returned successfully.
@retval EFI_INVALID_PARAMETER The CurrentUser parameter is NULL.
**/
)
{
//
// Get current user profile.
//
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
/**
Identify a user.
Identify the user and, if authenticated, returns the user handle and changes the current
user profile. All user information marked as private in a previously selected profile
is no longer available for inspection.
Whenever the current user profile is changed then the an event with the GUID
EFI_EVENT_GROUP_USER_PROFILE_CHANGED is signaled.
@param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.
@param[out] User On return, points to the user profile handle for the current
user profile.
@retval EFI_SUCCESS User was successfully identified.
@retval EFI_ACCESS_DENIED User was not successfully identified.
@retval EFI_INVALID_PARAMETER The User parameter is NULL.
**/
)
{
return EFI_INVALID_PARAMETER;
}
if (mCurrentUser != NULL) {
*User = mCurrentUser;
return EFI_SUCCESS;
}
//
// Identify user
//
return EFI_ACCESS_DENIED;
}
//
// Publish the user info into the EFI system configuration table.
//
PublishUserTable ();
//
// Signal User Profile Changed event.
//
return EFI_SUCCESS;
}
/**
Find a user using a user information record.
This function searches all user profiles for the specified user information record.
The search starts with the user information record handle following UserInfo and
continues until either the information is found or there are no more user profiles.
A match occurs when the Info.InfoType field matches the user information record
type and the user information record data matches the portion of Info.
@param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.
@param[in, out] User On entry, points to the previously returned user profile
handle, or NULL to start searching with the first user profile.
On return, points to the user profile handle, or NULL if not
found.
@param[in, out] UserInfo On entry, points to the previously returned user information
handle, or NULL to start searching with the first. On return,
points to the user information handle of the user information
record, or NULL if not found. Can be NULL, in which case only
one user information record per user can be returned.
@param[in] Info Points to the buffer containing the user information to be
compared to the user information record. If the user information
record data is empty, then only the user information record type
is compared. If InfoSize is 0, then the user information record
must be empty.
@param[in] InfoSize The size of Info, in bytes.
@retval EFI_SUCCESS User information was found. User points to the user profile
handle, and UserInfo points to the user information handle.
@retval EFI_NOT_FOUND User information was not found. User points to NULL, and
UserInfo points to NULL.
@retval EFI_INVALID_PARAMETER User is NULL. Or Info is NULL.
**/
)
{
return EFI_INVALID_PARAMETER;
}
if (InfoSize == 0) {
//
// If InfoSize is 0, then the user information record must be empty.
//
return EFI_INVALID_PARAMETER;
}
} else {
return EFI_INVALID_PARAMETER;
}
}
//
// Find user profile accdoring to user information.
//
(USER_PROFILE_ENTRY **) User,
(EFI_USER_INFO **) UserInfo,
(EFI_USER_INFO *) Info,
);
}
return EFI_NOT_FOUND;
}
return EFI_SUCCESS;
}
/**
Return information attached to the user.
This function returns user information. The format of the information is described in User
Information. The function may return EFI_ACCESS_DENIED if the information is marked private
and the handle specified by User is not the current user profile. The function may return
EFI_ACCESS_DENIED if the information is marked protected and the information is associated
with a credential provider for which the user has not been authenticated.
@param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.
@param[in] User Handle of the user whose profile will be retrieved.
@param[in] UserInfo Handle of the user information data record.
@param[out] Info On entry, points to a buffer of at least *InfoSize bytes. On exit,
holds the user information. If the buffer is too small to hold the
information, then EFI_BUFFER_TOO_SMALL is returned and InfoSize is
updated to contain the number of bytes actually required.
@param[in, out] InfoSize On entry, points to the size of Info. On return, points to the size
of the user information.
@retval EFI_SUCCESS Information returned successfully.
@retval EFI_ACCESS_DENIED The information about the specified user cannot be accessed by the
current user.
@retval EFI_BUFFER_TOO_SMALL The number of bytes specified by *InfoSize is too small to hold the
returned data. The actual size required is returned in *InfoSize.
@retval EFI_NOT_FOUND User does not refer to a valid user profile or UserInfo does not refer
to a valid user info handle.
@retval EFI_INVALID_PARAMETER Info is NULL or InfoSize is NULL.
**/
)
{
return EFI_INVALID_PARAMETER;
}
return EFI_INVALID_PARAMETER;
}
return EFI_NOT_FOUND;
}
if (Status == EFI_BUFFER_TOO_SMALL) {
return EFI_BUFFER_TOO_SMALL;
}
return EFI_ACCESS_DENIED;
}
return EFI_SUCCESS;
}
/**
Add or update user information.
This function changes user information. If NULL is pointed to by UserInfo, then a new user
information record is created and its handle is returned in UserInfo. Otherwise, the existing
one is replaced.
If EFI_USER_INFO_IDENITTY_POLICY_RECORD is changed, it is the caller's responsibility to keep
it to be synced with the information on credential providers.
If EFI_USER_INFO_EXCLUSIVE is specified in Info and a user information record of the same
type already exists in the user profile, then EFI_ACCESS_DENIED will be returned and UserInfo
will point to the handle of the existing record.
@param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.
@param[in] User Handle of the user whose profile will be retrieved.
@param[in, out] UserInfo Handle of the user information data record.
@param[in] Info On entry, points to a buffer of at least *InfoSize bytes. On exit,
holds the user information. If the buffer is too small to hold the
information, then EFI_BUFFER_TOO_SMALL is returned and InfoSize is
updated to contain the number of bytes actually required.
@param[in] InfoSize On entry, points to the size of Info. On return, points to the size
of the user information.
@retval EFI_SUCCESS Information returned successfully.
@retval EFI_ACCESS_DENIED The record is exclusive.
@retval EFI_SECURITY_VIOLATION The current user does not have permission to change the specified
user profile or user information record.
@retval EFI_NOT_FOUND User does not refer to a valid user profile or UserInfo does not
refer to a valid user info handle.
@retval EFI_INVALID_PARAMETER UserInfo is NULL or Info is NULL.
**/
)
{
return EFI_INVALID_PARAMETER;
}
//
// Check the right of the current user.
//
if (User != mCurrentUser) {
//
// Can't update info in other profiles without MANAGE right.
//
return EFI_SECURITY_VIOLATION;
}
//
// Can't add info into other profiles.
//
return EFI_SECURITY_VIOLATION;
}
}
}
if (User == mCurrentUser) {
//
//
return EFI_SECURITY_VIOLATION;
}
}
}
//
// Modify user information.
//
if (Status == EFI_ACCESS_DENIED) {
return EFI_ACCESS_DENIED;
}
return EFI_SECURITY_VIOLATION;
}
return EFI_SUCCESS;
}
/**
Called by credential provider to notify of information change.
This function allows the credential provider to notify the User Identity Manager when user status
has changed.
If the User Identity Manager doesn't support asynchronous changes in credentials, then this function
should return EFI_UNSUPPORTED.
If current user does not exist, and the credential provider can identify a user, then make the user
to be current user and signal the EFI_EVENT_GROUP_USER_PROFILE_CHANGED event.
If current user already exists, and the credential provider can identify another user, then switch
current user to the newly identified user, and signal the EFI_EVENT_GROUP_USER_PROFILE_CHANGED event.
If current user was identified by this credential provider and now the credential provider cannot identify
current user, then logout current user and signal the EFI_EVENT_GROUP_USER_PROFILE_CHANGED event.
@param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.
@param[in] Changed Handle on which is installed an instance of the EFI_USER_CREDENTIAL2_PROTOCOL
where the user has changed.
@retval EFI_SUCCESS The User Identity Manager has handled the notification.
@retval EFI_NOT_READY The function was called while the specified credential provider was not selected.
@retval EFI_UNSUPPORTED The User Identity Manager doesn't support asynchronous notifications.
**/
)
{
return EFI_UNSUPPORTED;
}
/**
Delete user information.
Delete the user information attached to the user profile specified by the UserInfo.
@param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.
@param[in] User Handle of the user whose information will be deleted.
@param[in] UserInfo Handle of the user information to remove.
@retval EFI_SUCCESS User information deleted successfully.
@retval EFI_NOT_FOUND User information record UserInfo does not exist in the user profile.
@retval EFI_ACCESS_DENIED The current user does not have permission to delete this user information.
**/
)
{
return EFI_INVALID_PARAMETER;
}
//
// Check the right of the current user.
//
if (User != mCurrentUser) {
return EFI_ACCESS_DENIED;
}
}
//
// Delete user information.
//
if (Status == EFI_NOT_FOUND) {
return EFI_NOT_FOUND;
}
return EFI_ACCESS_DENIED;
}
return EFI_SUCCESS;
}
/**
Enumerate user information of all the enrolled users on the platform.
This function returns the next user information record. To retrieve the first user
information record handle, point UserInfo at a NULL. Each subsequent call will retrieve
another user information record handle until there are no more, at which point UserInfo
will point to NULL.
@param[in] This Points to this instance of the EFI_USER_MANAGER_PROTOCOL.
@param[in] User Handle of the user whose information will be deleted.
@param[in, out] UserInfo Handle of the user information to remove.
@retval EFI_SUCCESS User information returned.
@retval EFI_NOT_FOUND No more user information found.
@retval EFI_INVALID_PARAMETER UserInfo is NULL.
**/
)
{
return EFI_INVALID_PARAMETER;
}
//
// Get next user information entry.
//
}
/**
Main entry for this driver.
@param[in] ImageHandle Image handle this driver.
@param[in] SystemTable Pointer to SystemTable.
@retval EFI_SUCESS This function always complete successfully.
**/
)
{
//
// Initiate form browser.
//
InitFormBrowser ();
//
// Install protocol interfaces for the User Identity Manager.
//
);
return EFI_SUCCESS;
}