]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/UserIdentification/UserProfileManagerDxe/UserProfileManager.c
SecurityPkg: Clean up source files
[mirror_edk2.git] / SecurityPkg / UserIdentification / UserProfileManagerDxe / UserProfileManager.c
index 74c979d58eec49f712ad57248abd44d27cfffa62..e73ba3a8fc50703abd3116e6b692775831d52c76 100644 (file)
@@ -1,23 +1,23 @@
 /** @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
+  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 - 2011, 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
+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
+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_GUID                  mUserProfileManagerGuid = USER_PROFILE_MANAGER_GUID;\r
 EFI_USER_MANAGER_PROTOCOL *mUserManager           = NULL;\r
 CREDENTIAL_PROVIDER_INFO  *mProviderInfo          = NULL;\r
 UINT8                     mProviderChoice;\r
@@ -35,7 +35,7 @@ HII_VENDOR_DEVICE_PATH  mHiiVendorDevicePath = {
         (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
       }\r
     },\r
-    {0xad2e3474, 0x93e6, 0x488b, {0x93, 0x19, 0x64, 0x88, 0xfc, 0x68, 0x1f, 0x16}}\r
+    USER_PROFILE_MANAGER_GUID\r
   },\r
   {\r
     END_DEVICE_PATH_TYPE,\r
@@ -71,12 +71,12 @@ GetStringById (
 \r
 \r
 /**\r
-  This function gets all the credential providers in the system and saved them \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
 **/\r
 EFI_STATUS\r
 InitProviderInfo (\r
@@ -86,8 +86,8 @@ InitProviderInfo (
   EFI_STATUS  Status;\r
   UINTN       HandleCount;\r
   EFI_HANDLE  *HandleBuf;\r
-  UINTN       Index;  \r
-  \r
+  UINTN       Index;\r
+\r
   //\r
   // Try to find all the user credential provider driver.\r
   //\r
@@ -95,7 +95,7 @@ InitProviderInfo (
   HandleBuf   = NULL;\r
   Status = gBS->LocateHandleBuffer (\r
                   ByProtocol,\r
-                  &gEfiUserCredentialProtocolGuid,\r
+                  &gEfiUserCredential2ProtocolGuid,\r
                   NULL,\r
                   &HandleCount,\r
                   &HandleBuf\r
@@ -103,7 +103,7 @@ InitProviderInfo (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-  \r
+\r
   //\r
   // Get provider infomation.\r
   //\r
@@ -111,9 +111,9 @@ InitProviderInfo (
     FreePool (mProviderInfo);\r
   }\r
   mProviderInfo = AllocateZeroPool (\r
-                    sizeof (CREDENTIAL_PROVIDER_INFO) - \r
-                    sizeof (EFI_USER_CREDENTIAL_PROTOCOL *) +\r
-                    HandleCount * sizeof (EFI_USER_CREDENTIAL_PROTOCOL *)\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
@@ -124,7 +124,7 @@ InitProviderInfo (
   for (Index = 0; Index < HandleCount; Index++) {\r
     Status = gBS->HandleProtocol (\r
                     HandleBuf[Index],\r
-                    &gEfiUserCredentialProtocolGuid,\r
+                    &gEfiUserCredential2ProtocolGuid,\r
                     (VOID **) &mProviderInfo->Provider[Index]\r
                     );\r
     if (EFI_ERROR (Status)) {\r
@@ -192,7 +192,7 @@ UserProfileManagerCallback (
       if (QuestionId != QUESTIONID_USER_MANAGE) {\r
         return EFI_SUCCESS;\r
       }\r
-  \r
+\r
       //\r
       // Get current user\r
       //\r
@@ -202,7 +202,7 @@ UserProfileManagerCallback (
         DEBUG ((DEBUG_ERROR, "Error: current user does not exist!\n"));\r
         return EFI_NOT_READY;\r
       }\r
-      \r
+\r
       //\r
       // Get current user's right information.\r
       //\r
@@ -210,7 +210,7 @@ UserProfileManagerCallback (
       if (EFI_ERROR (Status)) {\r
         CurrentAccessRight = EFI_USER_INFO_ACCESS_ENROLL_SELF;\r
       }\r
-  \r
+\r
       //\r
       // Init credential provider information.\r
       //\r
@@ -218,16 +218,16 @@ UserProfileManagerCallback (
       if (EFI_ERROR (Status)) {\r
         return Status;\r
       }\r
-      \r
+\r
       //\r
       // Initialize the container for dynamic opcodes.\r
       //\r
       StartOpCodeHandle = HiiAllocateOpCodeHandle ();\r
       ASSERT (StartOpCodeHandle != NULL);\r
-  \r
+\r
       EndOpCodeHandle = HiiAllocateOpCodeHandle ();\r
       ASSERT (EndOpCodeHandle != NULL);\r
-  \r
+\r
       //\r
       // Create Hii Extend Label OpCode.\r
       //\r
@@ -239,7 +239,7 @@ UserProfileManagerCallback (
                                             );\r
       StartLabel->ExtendOpCode  = EFI_IFR_EXTEND_OP_LABEL;\r
       StartLabel->Number        = LABEL_USER_MANAGE_FUNC;\r
-  \r
+\r
       EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (\r
                                           EndOpCodeHandle,\r
                                           &gEfiIfrTianoGuid,\r
@@ -248,7 +248,7 @@ UserProfileManagerCallback (
                                           );\r
       EndLabel->ExtendOpCode  = EFI_IFR_EXTEND_OP_LABEL;\r
       EndLabel->Number        = LABEL_END;\r
-  \r
+\r
       //\r
       // Add user profile option.\r
       //\r
@@ -264,7 +264,7 @@ UserProfileManagerCallback (
           0                                   // Action String ID\r
           );\r
       }\r
-      \r
+\r
       //\r
       // Add modify user profile option.\r
       //\r
@@ -276,7 +276,7 @@ UserProfileManagerCallback (
         EFI_IFR_FLAG_CALLBACK,                // Question flag\r
         KEY_MODIFY_USER                       // Question ID\r
         );\r
-  \r
+\r
       //\r
       // Add delete user profile option\r
       //\r
@@ -290,18 +290,18 @@ UserProfileManagerCallback (
           KEY_DEL_USER                          // Question ID\r
           );\r
       }\r
-  \r
+\r
       HiiUpdateForm (\r
         mCallbackInfo->HiiHandle,               // HII handle\r
-        &mUserProfileManagerGuid,               // Formset GUID\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
+\r
       HiiFreeOpCodeHandle (StartOpCodeHandle);\r
       HiiFreeOpCodeHandle (EndOpCodeHandle);\r
-  \r
+\r
       return EFI_SUCCESS;\r
     }\r
     break;\r
@@ -310,15 +310,15 @@ UserProfileManagerCallback (
     Status = EFI_SUCCESS;\r
     break;\r
 \r
-  case EFI_BROWSER_ACTION_CHANGING:\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
     //\r
     // Judge first 2 bits.\r
     //\r
@@ -338,13 +338,6 @@ UserProfileManagerCallback (
       // 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
       //\r
       // Delete specified user profile.\r
       //\r
@@ -369,13 +362,6 @@ UserProfileManagerCallback (
       // 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
@@ -384,13 +370,6 @@ UserProfileManagerCallback (
         // 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 user name.\r
         //\r
@@ -410,19 +389,11 @@ UserProfileManagerCallback (
           // 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
           //\r
           // Change credential provider option.\r
           //\r
-          case KEY_MODIFY_PROV:         \r
+          case KEY_MODIFY_PROV:\r
             mProviderChoice = Value->u8;\r
-            *ActionRequest  = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r
             break;\r
 \r
           //\r
@@ -430,7 +401,6 @@ UserProfileManagerCallback (
           //\r
           case KEY_MODIFY_CONN:\r
             mConncetLogical = Value->u8;\r
-            *ActionRequest  = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r
             break;\r
 \r
           //\r
@@ -445,7 +415,7 @@ UserProfileManagerCallback (
           //\r
           case KEY_IP_RETURN_UIF:\r
             SaveIdentityPolicy ();\r
-            *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r
+            *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;\r
             break;\r
 \r
           default:\r
@@ -461,19 +431,11 @@ UserProfileManagerCallback (
           // 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
           //\r
           // Change access right choice.\r
           //\r
           case KEY_MODIFY_RIGHT:\r
             mAccessInfo.AccessRight = Value->u8;\r
-            *ActionRequest  = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r
             break;\r
 \r
           //\r
@@ -481,7 +443,6 @@ UserProfileManagerCallback (
           //\r
           case KEY_MODIFY_SETUP:\r
             mAccessInfo.AccessSetup= Value->u8;\r
-            *ActionRequest  = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r
             break;\r
 \r
           //\r
@@ -489,61 +450,6 @@ UserProfileManagerCallback (
           //\r
           case KEY_MODIFY_BOOT:\r
             mAccessInfo.AccessBootOrder = Value->u32;\r
-            *ActionRequest  = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r
-            break;\r
-\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
           //\r
@@ -551,7 +457,7 @@ UserProfileManagerCallback (
           //\r
           case KEY_AP_RETURN_UIF:\r
             SaveAccessPolicy ();\r
-            *ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;\r
+            *ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_SUBMIT_EXIT;\r
             break;\r
 \r
           default:\r
@@ -648,6 +554,179 @@ UserProfileManagerCallback (
   }\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
@@ -727,6 +806,8 @@ FakeRouteConfig (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
+  *Progress = Configuration;\r
+\r
   return EFI_NOT_FOUND;\r
 }\r
 \r
@@ -758,7 +839,7 @@ UserProfileManagerInit (
   if (EFI_ERROR (Status)) {\r
     return EFI_SUCCESS;\r
   }\r
-  \r
+\r
   //\r
   // Initialize driver private data.\r
   //\r
@@ -766,14 +847,14 @@ UserProfileManagerInit (
   ZeroMem (&mAccessInfo, sizeof (mAccessInfo));\r
 \r
   CallbackInfo = AllocateZeroPool (sizeof (USER_PROFILE_MANAGER_CALLBACK_INFO));\r
-  ASSERT (CallbackInfo != NULL);  \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
   //\r
   // Install Device Path Protocol and Config Access protocol to driver handle.\r
   //\r
@@ -791,16 +872,16 @@ UserProfileManagerInit (
   // Publish HII data.\r
   //\r
   CallbackInfo->HiiHandle = HiiAddPackages (\r
-                              &mUserProfileManagerGuid,\r
+                              &gUserProfileManagerGuid,\r
                               CallbackInfo->DriverHandle,\r
                               UserProfileManagerStrings,\r
                               UserProfileManagerVfrBin,\r
                               NULL\r
                               );\r
-  ASSERT (CallbackInfo->HiiHandle != NULL);                              \r
+  ASSERT (CallbackInfo->HiiHandle != NULL);\r
   mCallbackInfo = CallbackInfo;\r
 \r
   return Status;\r
 }\r
 \r
-  \r
+\r