]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/UserIdentification/UserIdentifyManagerDxe/UserIdentifyManager.c
Update UID drivers to align with latest UEFI spec 2.3.1.
[mirror_edk2.git] / SecurityPkg / UserIdentification / UserIdentifyManagerDxe / UserIdentifyManager.c
index e846b71f035903562258638bc6dcbd8279c451b5..268dfab469992b0470d86e8a49ed0b2177e9b42b 100644 (file)
@@ -400,43 +400,6 @@ FindUserProfileByInfo (
   return EFI_NOT_FOUND;\r
 }\r
 \r
-/**\r
-  Find the credential provider in the specified identity policy.\r
-\r
-  @param[in]  FindIdentity        Point to the user identity policy.\r
-  @param[in]  IdentifyInfo        Point to the user information to be searched.\r
-\r
-  @retval TRUE     The credential provider was found in the identity policy.\r
-  @retval FALSE    The credential provider was not found.\r
-**/\r
-BOOLEAN\r
-FindProvider (\r
-  IN       EFI_USER_INFO_IDENTITY_POLICY        *FindIdentity,\r
-  IN CONST EFI_USER_INFO                        *IdentifyInfo\r
-  )\r
-{\r
-  UINTN                         TotalLen;\r
-  EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
-\r
-  //\r
-  // Found the credential provider.\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
-    if ((Identity->Type == FindIdentity->Type) &&\r
-        (Identity->Length == FindIdentity->Length) &&\r
-        CompareGuid ((EFI_GUID *) (Identity + 1), (EFI_GUID *) (FindIdentity + 1))\r
-        ) {\r
-      return TRUE;\r
-    }\r
-\r
-    TotalLen += Identity->Length;\r
-  }\r
-\r
-  return FALSE;\r
-}\r
-\r
 \r
 /**\r
   Check whether the access policy is valid.\r
@@ -1009,110 +972,6 @@ ExpandUserProfile (
 }\r
 \r
 \r
-/**\r
-  Add or delete the user's credential record in the provider.\r
-\r
-  @param[in]  ProviderGuid        Point to credential provider guid or class guid.\r
-  @param[in]  ByType              If TRUE, Provider is credential class guid.\r
-                                  If FALSE, Provider is provider guid.\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
-ModifyProviderCredential (\r
-  IN  EFI_GUID                                  *Provider,\r
-  IN  BOOLEAN                                   ByType,\r
-  IN  USER_PROFILE_ENTRY                        *User\r
-  )\r
-{\r
-  UINTN                         Index;\r
-  EFI_USER_CREDENTIAL_PROTOCOL  *UserCredential;\r
-  \r
-  if (Provider == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-\r
-  \r
-  //\r
-  // Find the specified credential provider.\r
-  //\r
-  for (Index = 0; Index < mProviderDb->Count; Index++) {\r
-    //\r
-    // Check credential provider ID.\r
-    //\r
-    UserCredential = mProviderDb->Provider[Index];\r
-    if (CompareGuid (&UserCredential->Identifier, Provider)) {\r
-      return UserCredential->Enroll (UserCredential, User);\r
-    }\r
-  }\r
-\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-\r
-/**\r
-  Modify user's credential record in the providers.\r
-\r
-  Found the providers information in PolicyInfo, and then add or delete the user's credential\r
-  record in the providers.\r
-\r
-  @param  User                    Points to user profile.\r
-  @param  PolicyInfo              Point to identification policy to be modified.\r
-  @param  InfoLen                 The length of PolicyInfo.\r
-\r
-  @retval EFI_SUCCESS      Modify PolicyInfo successfully.\r
-  @retval Others           Fail to modify PolicyInfo.\r
-\r
-**/\r
-EFI_STATUS\r
-ModifyCredentialInfo (\r
-  IN  USER_PROFILE_ENTRY                        *User,\r
-  IN  UINT8                                     *PolicyInfo,\r
-  IN  UINTN                                     InfoLen\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  UINTN                         TotalLen;\r
-  EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
-\r
-  //\r
-  // Modify user's credential.\r
-  //\r
-  TotalLen = 0;\r
-  while (TotalLen < InfoLen) {\r
-    //\r
-    // Check identification policy according to type.\r
-    //\r
-    Identity = (EFI_USER_INFO_IDENTITY_POLICY *) (PolicyInfo + TotalLen);\r
-    switch (Identity->Type) {\r
-    case EFI_USER_INFO_IDENTITY_CREDENTIAL_TYPE:\r
-      Status = ModifyProviderCredential ((EFI_GUID *) (Identity + 1), TRUE, User);\r
-      if (EFI_ERROR (Status)) {\r
-        return Status;\r
-      }\r
-      break;\r
-\r
-    case EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER:\r
-      Status = ModifyProviderCredential ((EFI_GUID *) (Identity + 1), FALSE, User);\r
-      if (EFI_ERROR (Status)) {\r
-        return Status;\r
-      }\r
-      break;\r
-\r
-    default:\r
-      break;\r
-    }\r
-\r
-    TotalLen += Identity->Length;\r
-  }\r
-\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
 /**\r
   Save the user profile to non-volatile memory, or delete it from non-volatile memory.\r
 \r
@@ -1152,327 +1011,6 @@ SaveNvUserProfile (
   return Status;\r
 }\r
 \r
-\r
-/**\r
-  Replace the old identity info with NewInfo in NV Flash.\r
-\r
-  This function only replace the identity record in the user profile. Don't update\r
-  the the information on the credential provider.\r
-  \r
-  @param[in]   User               Point to the user profile.\r
-  @param[in]   NewInfo            Point to the new identity policy info.\r
-  @param[out]  UserInfo           Point to the new added identity info.\r
-\r
-  @retval EFI_SUCCESS      Replace user identity successfully.\r
-  @retval Others           Fail to Replace user identity.\r
-\r
-**/\r
-EFI_STATUS\r
-SaveUserIpInfo (\r
-  IN       USER_PROFILE_ENTRY                   * User,\r
-  IN CONST EFI_USER_INFO                        * NewInfo,\r
-  OUT   EFI_USER_INFO                           **UserInfo OPTIONAL\r
-  )\r
-{\r
-  EFI_STATUS    Status;\r
-  EFI_USER_INFO *OldIpInfo;\r
-  UINTN         Offset;\r
-  UINTN         NextOffset;\r
-\r
-  if ((NewInfo == NULL) || (User == NULL)) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  //\r
-  // Get user old identify policy information.\r
-  //\r
-  OldIpInfo = NULL;\r
-  Status    = FindUserInfoByType (User, &OldIpInfo, EFI_USER_INFO_IDENTITY_POLICY_RECORD);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  \r
-  //\r
-  // Get the old identity policy offset.\r
-  //\r
-  Status = FindUserInfo (User, &OldIpInfo, FALSE, &Offset);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  \r
-  //\r
-  // Delete the old identity policy information.\r
-  //\r
-  NextOffset = ALIGN_VARIABLE (OldIpInfo->InfoSize) + Offset;\r
-  User->UserProfileSize -= ALIGN_VARIABLE (OldIpInfo->InfoSize);\r
-  if (Offset < User->UserProfileSize) {\r
-    CopyMem (User->ProfileInfo + Offset, User->ProfileInfo + NextOffset, User->UserProfileSize - Offset);\r
-  }\r
-  \r
-  //\r
-  // Add new user information.\r
-  //\r
-  if (User->MaxProfileSize - User->UserProfileSize < ALIGN_VARIABLE (NewInfo->InfoSize)) {\r
-    if (!ExpandUserProfile (User, ALIGN_VARIABLE (NewInfo->InfoSize))) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-  }\r
-\r
-  CopyMem (User->ProfileInfo + User->UserProfileSize, (VOID *) NewInfo, NewInfo->InfoSize);\r
-  if (UserInfo != NULL) {\r
-    *UserInfo = (EFI_USER_INFO *) (User->ProfileInfo + User->UserProfileSize);\r
-  }\r
-\r
-  User->UserProfileSize += ALIGN_VARIABLE (NewInfo->InfoSize);\r
-\r
-  //\r
-  // Save user profile information.\r
-  //\r
-  Status = SaveNvUserProfile (User, FALSE);\r
-  return Status;\r
-}\r
-\r
-\r
-/**\r
-  Remove the provider in FindIdentity from the user identification information record.\r
-  \r
-  @param[in, out] NewInfo       On entry, points to the user information to remove provider. \r
-                                On return, points to the user information the provider is removed.\r
-  @param[in]      FindIdentity  Point to the user identity policy.\r
-\r
-  @retval TRUE                  The provider is removed successfully.\r
-  @retval FALSE                 Fail to remove the provider.\r
-\r
-**/\r
-BOOLEAN\r
-RemoveProvider (\r
-  IN OUT EFI_USER_INFO                         **NewInfo,\r
-  IN     EFI_USER_INFO_IDENTITY_POLICY         *FindIdentity\r
-  )\r
-{\r
-  UINTN                         TotalLen;\r
-  EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
-  EFI_USER_INFO                 *IdentifyInfo;\r
-  UINT8                         *Buffer;\r
-\r
-  IdentifyInfo = *NewInfo;\r
-  TotalLen = IdentifyInfo->InfoSize - sizeof (EFI_USER_INFO);\r
-  if (TotalLen == FindIdentity->Length) {\r
-    //\r
-    // Only one credential provider in the identification policy.\r
-    // Set the new policy to be TRUE after removed the provider.\r
-    //\r
-    Identity = (EFI_USER_INFO_IDENTITY_POLICY *) (IdentifyInfo + 1);\r
-    Identity->Type         = EFI_USER_INFO_IDENTITY_TRUE;\r
-    Identity->Length       = sizeof (EFI_USER_INFO_IDENTITY_POLICY);  \r
-    IdentifyInfo->InfoSize = sizeof (EFI_USER_INFO) + Identity->Length;\r
-    return TRUE;\r
-  }\r
-\r
-  //\r
-  // Found the credential provider.\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
-    if ((Identity->Type == FindIdentity->Type) &&\r
-        (Identity->Length == FindIdentity->Length) &&\r
-        CompareGuid ((EFI_GUID *) (Identity + 1), (EFI_GUID *) (FindIdentity + 1))\r
-        ) {\r
-      //\r
-      // Found the credential provider to delete\r
-      //\r
-      if (Identity == (EFI_USER_INFO_IDENTITY_POLICY *)(IdentifyInfo + 1)) {\r
-        //\r
-        // It is the first item in the identification policy, delete it and the connector after it.\r
-        //\r
-        Buffer = (UINT8 *) Identity + Identity->Length + sizeof(EFI_USER_INFO_IDENTITY_POLICY);\r
-        IdentifyInfo->InfoSize -= Identity->Length + sizeof(EFI_USER_INFO_IDENTITY_POLICY);\r
-        TotalLen = IdentifyInfo->InfoSize - sizeof (EFI_USER_INFO);\r
-        CopyMem (Identity, Buffer, TotalLen);\r
-       } else {\r
-        //\r
-        // It is not the first item in the identification policy, delete it and the connector before it.\r
-        //\r
-        Buffer    = (UINT8 *) Identity + Identity->Length;\r
-        TotalLen  = IdentifyInfo->InfoSize - sizeof (EFI_USER_INFO);\r
-        TotalLen -= (Buffer - (UINT8 *)(IdentifyInfo + 1));\r
-        IdentifyInfo->InfoSize -= Identity->Length + sizeof(EFI_USER_INFO_IDENTITY_POLICY);\r
-        CopyMem ((UINT8 *) (Identity - 1), Buffer, TotalLen);\r
-      }      \r
-      return TRUE;\r
-    }\r
-\r
-    TotalLen += Identity->Length;\r
-  }  \r
-  return FALSE;\r
-}\r
-\r
-\r
-/**\r
-  This function replaces the old identity policy with a new identity policy.\r
-\r
-  This function changes user identity policy information.\r
-  If enroll new credential failed, recover the old identity policy.\r
-\r
-  For new policy:\r
-  a. For each credential, if it is newly added, try to enroll it.\r
-     If enroll failed, try to delete the newly added ones.\r
-  \r
-  b. For each credential, if it exists in the old policy, delete old one, \r
-     and enroll new one. If failed to enroll the new one, removed it from new \r
-     identification policy.\r
-\r
-  For old policy:  \r
-  a. For each credential, if it does not exist in new one, delete it.\r
-\r
-  @param[in]  User         Point to the user profile.\r
-  @param[in]  Info         Points to the user identity information.\r
-  @param[in]  InfoSize     The size of Info (Not used in this function).\r
-  @param[out] IpInfo       The new identification info after modify.\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
-ModifyUserIpInfo (\r
-  IN        USER_PROFILE_ENTRY                  *User,\r
-  IN CONST  EFI_USER_INFO                       *Info,\r
-  IN        UINTN                               InfoSize,\r
-     OUT    EFI_USER_INFO                       **IpInfo\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  EFI_USER_INFO                 *OldIpInfo;\r
-  UINTN                         TotalLen;\r
-  EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
-  UINT32                        CredentialCount;\r
-  EFI_USER_INFO                 *NewIpInfo;\r
-\r
-  //\r
-  // Get user old identify policy information.\r
-  //\r
-  OldIpInfo = NULL;\r
-  Status    = FindUserInfoByType (User, &OldIpInfo, EFI_USER_INFO_IDENTITY_POLICY_RECORD);\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  ASSERT (OldIpInfo != NULL);\r
-  \r
-  //\r
-  // Enroll new added credential provider.\r
-  //\r
-  CredentialCount = 0;\r
-  TotalLen        = 0;\r
-  while (TotalLen < Info->InfoSize - sizeof (EFI_USER_INFO)) {\r
-    Identity = (EFI_USER_INFO_IDENTITY_POLICY *) ((UINT8 *) (Info + 1) + TotalLen);\r
-    if (Identity->Type == EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER) {\r
-      if (!FindProvider (Identity, OldIpInfo)) {\r
-        //\r
-        // The credential is NOT found in the old identity policy; add it.\r
-        //\r
-        Status = ModifyCredentialInfo (User, (UINT8 *) Identity, Identity->Length);\r
-        if (EFI_ERROR (Status)) {\r
-          break;\r
-        }\r
-        CredentialCount++;\r
-      }\r
-    }\r
-\r
-    TotalLen += Identity->Length;\r
-  }\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    //\r
-    // Enroll new credential failed. Delete the newly enrolled credential, and return.\r
-    //\r
-    TotalLen = 0;\r
-    while (TotalLen < Info->InfoSize - sizeof (EFI_USER_INFO)) {\r
-      Identity = (EFI_USER_INFO_IDENTITY_POLICY *) ((UINT8 *) (Info + 1) + TotalLen);\r
-      if (Identity->Type == EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER) {\r
-        if (!FindProvider (Identity, OldIpInfo)) {\r
-          //\r
-          // The credential is NOT found in the old identity policy. Delete it.\r
-          //\r
-          if (CredentialCount == 0) {\r
-            break;\r
-          }\r
-\r
-          ModifyCredentialInfo (User, (UINT8 *) Identity, Identity->Length);\r
-          CredentialCount--;\r
-        }\r
-      }\r
-      TotalLen += Identity->Length;\r
-    }\r
-\r
-    return EFI_DEVICE_ERROR;\r
-  }\r
-  \r
-  //\r
-  // Backup new identification policy\r
-  //\r
-  NewIpInfo = AllocateCopyPool (Info->InfoSize, Info);    \r
-  ASSERT (NewIpInfo != NULL);\r
-\r
-  //\r
-  // Enroll the credential that existed in the old identity policy.\r
-  //\r
-  TotalLen = 0;\r
-  while (TotalLen < Info->InfoSize - sizeof (EFI_USER_INFO)) {\r
-    Identity = (EFI_USER_INFO_IDENTITY_POLICY *) ((UINT8 *) (Info + 1) + TotalLen);\r
-    if (Identity->Type == EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER) {\r
-      if (FindProvider (Identity, OldIpInfo)) {\r
-        //\r
-        // The credential is found in the old identity policy, so delete the old credential first.\r
-        //\r
-        Status = ModifyCredentialInfo (User, (UINT8 *) Identity, Identity->Length);\r
-        if (EFI_ERROR (Status)) {\r
-          //\r
-          // Failed to delete old credential.\r
-          //\r
-          FreePool (NewIpInfo);\r
-          return EFI_DEVICE_ERROR;\r
-        }\r
-\r
-        //\r
-        // Add the new credential.\r
-        //\r
-        Status = ModifyCredentialInfo (User, (UINT8 *) Identity, Identity->Length);\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
-          RemoveProvider (&NewIpInfo, Identity);\r
-        }        \r
-      }\r
-    }\r
-    TotalLen += Identity->Length;\r
-  }\r
-  \r
-  //\r
-  // Delete old credential that didn't exist in the new identity policy.\r
-  //\r
-  TotalLen = 0;\r
-  while (TotalLen < OldIpInfo->InfoSize - sizeof (EFI_USER_INFO)) {\r
-    Identity = (EFI_USER_INFO_IDENTITY_POLICY *) ((UINT8 *) (OldIpInfo + 1) + TotalLen);\r
-    if (Identity->Type == EFI_USER_INFO_IDENTITY_CREDENTIAL_PROVIDER) {\r
-      if (!FindProvider (Identity, Info)) {\r
-        //\r
-        // The credential is NOT found in the new identity policy. Delete the old credential.\r
-        //\r
-        ModifyCredentialInfo (User, (UINT8 *) Identity, Identity->Length);\r
-      }\r
-    }\r
-    TotalLen += Identity->Length;\r
-  }\r
-\r
-  *IpInfo = NewIpInfo;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-\r
 /**\r
   Add one new user info into the user's profile.\r
 \r
@@ -1519,20 +1057,6 @@ AddUserInfo (
     }\r
   }\r
   \r
-  //\r
-  // Add credential.\r
-  //\r
-  if (((EFI_USER_INFO *) Info)->InfoType == EFI_USER_INFO_IDENTITY_POLICY_RECORD) {\r
-    Status = ModifyCredentialInfo (\r
-              User,\r
-              (UINT8 *) ((EFI_USER_INFO *) Info + 1),\r
-              InfoSize - sizeof (EFI_USER_INFO)\r
-              );\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-  \r
   //\r
   // Add new user information.\r
   //\r
@@ -1671,11 +1195,6 @@ DelUserInfo (
 \r
   if (Info->InfoType == EFI_USER_INFO_IDENTIFIER_RECORD) {\r
     return EFI_ACCESS_DENIED;\r
-  } else if (Info->InfoType == EFI_USER_INFO_IDENTITY_POLICY_RECORD) {\r
-    Status = ModifyCredentialInfo (User, (UINT8 *) (Info + 1), Info->InfoSize - sizeof (EFI_USER_INFO));\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
   }\r
   \r
   //\r
@@ -1721,7 +1240,6 @@ ModifyUserInfo (
   EFI_STATUS    Status;\r
   UINTN         PayloadLen;\r
   EFI_USER_INFO *OldInfo;\r
-  EFI_USER_INFO *IpInfo;\r
 \r
   if ((UserInfo == NULL) || (Info == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -1823,25 +1341,6 @@ ModifyUserInfo (
     } while (TRUE);    \r
   }\r
 \r
-  if (Info->InfoType == EFI_USER_INFO_IDENTITY_POLICY_RECORD) {\r
-    //\r
-    // For user identification policy, need to update the info in credential provider.\r
-    //\r
-    IpInfo = NULL;\r
-    Status = ModifyUserIpInfo (User, Info, InfoSize, &IpInfo);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-\r
-    ASSERT (IpInfo != NULL);\r
-    Status = SaveUserIpInfo (User, IpInfo, UserInfo);\r
-    if (IpInfo->InfoSize != Info->InfoSize) {\r
-      Status = EFI_DEVICE_ERROR;\r
-    }\r
-    FreePool (IpInfo);    \r
-    return Status;\r
-  }\r
-\r
   Status = DelUserInfo (User, *UserInfo, FALSE);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
@@ -1867,7 +1366,6 @@ DelUserProfile (
 {\r
   EFI_STATUS          Status;\r
   UINTN               Index;\r
-  EFI_USER_INFO       *UserInfo;\r
 \r
   //\r
   // Check whether it is in the user profile database.\r
@@ -1884,18 +1382,6 @@ DelUserProfile (
     return EFI_ACCESS_DENIED;\r
   }\r
   \r
-  //\r
-  // Delete user credential information.\r
-  //\r
-  UserInfo  = NULL;\r
-  Status    = FindUserInfoByType (User, &UserInfo, EFI_USER_INFO_IDENTITY_POLICY_RECORD);\r
-  if (Status == EFI_SUCCESS) {\r
-    Status = DelUserInfo (User, UserInfo, FALSE);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  }\r
-  \r
   //\r
   // Delete user profile from the non-volatile memory.\r
   //\r
@@ -2331,7 +1817,7 @@ IdentifyByProviderId (
   EFI_HII_HANDLE                HiiHandle;\r
   EFI_GUID                      FormSetId;\r
   EFI_FORM_ID                   FormId;\r
-  EFI_USER_CREDENTIAL_PROTOCOL  *UserCredential;\r
+  EFI_USER_CREDENTIAL2_PROTOCOL *UserCredential;\r
 \r
   if (Provider == NULL) {\r
     return EFI_INVALID_PARAMETER;\r
@@ -2523,7 +2009,7 @@ AddProviderSelection (
   EFI_STRING_ID                 ProvID;\r
   CHAR16                        *ProvStr;\r
   UINTN                         Index;\r
-  EFI_USER_CREDENTIAL_PROTOCOL  *UserCredential;\r
+  EFI_USER_CREDENTIAL2_PROTOCOL *UserCredential;\r
 \r
   for (Index = 0; Index < mProviderDb->Count; Index++) {\r
     UserCredential = mProviderDb->Provider[Index];\r
@@ -3152,7 +2638,7 @@ InitProviderInfo (
   HandleBuf   = NULL;\r
   Status = gBS->LocateHandleBuffer (\r
                   ByProtocol,\r
-                  &gEfiUserCredentialProtocolGuid,\r
+                  &gEfiUserCredential2ProtocolGuid,\r
                   NULL,\r
                   &HandleCount,\r
                   &HandleBuf\r
@@ -3166,8 +2652,8 @@ InitProviderInfo (
   //\r
   mProviderDb = AllocateZeroPool (\r
                   sizeof (CREDENTIAL_PROVIDER_INFO) - \r
-                  sizeof (EFI_USER_CREDENTIAL_PROTOCOL *) + \r
-                  HandleCount * sizeof (EFI_USER_CREDENTIAL_PROTOCOL *)\r
+                  sizeof (EFI_USER_CREDENTIAL2_PROTOCOL *) + \r
+                  HandleCount * sizeof (EFI_USER_CREDENTIAL2_PROTOCOL *)\r
                   );\r
   if (mProviderDb == NULL) {\r
     FreePool (HandleBuf);\r
@@ -3178,7 +2664,7 @@ InitProviderInfo (
   for (Index = 0; Index < HandleCount; Index++) {\r
     Status = gBS->HandleProtocol (\r
                     HandleBuf[Index],\r
-                    &gEfiUserCredentialProtocolGuid,\r
+                    &gEfiUserCredential2ProtocolGuid,\r
                     (VOID **) &mProviderDb->Provider[Index]\r
                     );\r
     if (EFI_ERROR (Status)) {\r
@@ -3513,7 +2999,7 @@ IdentifyUser (
   EFI_CREDENTIAL_LOGON_FLAGS    AutoLogon;\r
   EFI_USER_INFO                 *IdentifyInfo;\r
   EFI_USER_INFO_IDENTITY_POLICY *Identity;\r
-  EFI_USER_CREDENTIAL_PROTOCOL  *UserCredential;\r
+  EFI_USER_CREDENTIAL2_PROTOCOL *UserCredential;\r
   USER_PROFILE_ENTRY            *UserEntry;\r
 \r
   //\r
@@ -4018,6 +3504,8 @@ UserProfileGetInfo (
   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
@@ -4106,15 +3594,18 @@ UserProfileSetInfo (
   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 while deselected.\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 the User Identity Manager supports this, it will call User() to get the user identifier and then \r
-  GetNextInfo() and GetInfo() in the User Credential Protocol to get all of the information from the \r
-  credential and add it.\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_CREDENTIAL_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
@@ -4128,102 +3619,8 @@ UserProfileNotify (
   IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,\r
   IN        EFI_HANDLE                          Changed\r
   )\r
-{\r
-  EFI_STATUS                    Status;\r
-  EFI_USER_CREDENTIAL_PROTOCOL  *Provider;\r
-  EFI_USER_INFO_IDENTIFIER      UserId;\r
-  EFI_USER_INFO_HANDLE          UserInfo;\r
-  EFI_USER_INFO_HANDLE          UserInfo2;\r
-  UINTN                         InfoSize;\r
-  EFI_USER_INFO                 *Info;\r
-  USER_PROFILE_ENTRY            *User;\r
-\r
-  if (This == NULL) {\r
-    return EFI_INVALID_PARAMETER;\r
-  }\r
-  \r
-  Status = gBS->HandleProtocol (\r
-                  Changed,\r
-                  &gEfiUserCredentialProtocolGuid,\r
-                  (VOID **) &Provider\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  Status = Provider->User (Provider, NULL, &UserId);\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_NOT_READY;\r
-  }\r
-\r
-  //\r
-  // Find user with the UserId.\r
-  //\r
-  User = NULL;\r
-  while (TRUE) {\r
-    //\r
-    // Find next user profile.\r
-    // \r
-    Status = FindUserProfile (&User, TRUE, NULL);\r
-    if (EFI_ERROR (Status)) {\r
-      return Status;\r
-    }\r
-  \r
-    //\r
-    // Find the user information.\r
-    //\r
-    Info = NULL;\r
-    FindUserInfoByType (User, &Info, EFI_USER_INFO_IDENTIFIER_RECORD);\r
-    if (CompareMem ((UINT8 *) (Info + 1), UserId, sizeof (UserId)) == 0) {\r
-      //\r
-      // Found the infomation record. \r
-      //\r
-      break;\r
-    }\r
-  }\r
-\r
-  UserInfo = NULL;\r
-  do {\r
-    //\r
-    // Get user info handle.\r
-    //\r
-    Status = Provider->GetNextInfo(Provider, &UserInfo);\r
-    if (EFI_ERROR (Status)) {\r
-      return EFI_SUCCESS;\r
-    }\r
-\r
-    //\r
-    // Get the user information from the user info handle.\r
-    // \r
-    InfoSize = 0;\r
-    Status = Provider->GetInfo(Provider, UserInfo, NULL, &InfoSize);\r
-    if (EFI_ERROR (Status)) {\r
-      if (Status == EFI_BUFFER_TOO_SMALL) {\r
-        Info = AllocateZeroPool (InfoSize);\r
-        if (Info == NULL) {\r
-          return EFI_OUT_OF_RESOURCES;\r
-        }\r
-        Status = Provider->GetInfo(Provider, UserInfo, Info, &InfoSize);\r
-        if (EFI_ERROR (Status)) {\r
-          FreePool (Info);\r
-          break;\r
-        }\r
-      }\r
-      break;\r
-    }\r
-\r
-    //\r
-    // Save the user information.\r
-    // \r
-    UserInfo2 = NULL;\r
-    Status = UserProfileSetInfo (&gUserIdentifyManager, (EFI_USER_PROFILE_HANDLE)User, &UserInfo2, Info, InfoSize);\r
-    FreePool (Info);\r
-    if (EFI_ERROR (Status)) {\r
-      break;\r
-    }\r
-  } while (TRUE);\r
-  \r
-  return Status;\r
+{    \r
+  return EFI_UNSUPPORTED;\r
 }\r
 \r
 \r