TianoCore EDK2 master
Loading...
Searching...
No Matches
RedfishCredentialDxe.c
Go to the documentation of this file.
1
13
14#define REDFISH_VERSION_DEFAULT_STRING L"v1"
15
16REDFISH_CREDENTIAL_PRIVATE *mCredentialPrivate = NULL;
17
24VOID
25EFIAPI
27 IN EFI_EVENT Event,
28 OUT VOID *Context
29 )
30{
32}
33
40VOID
41EFIAPI
43 IN EFI_EVENT Event,
44 OUT VOID *Context
45 )
46{
48
49 //
50 // Close event, so it will not be invoked again.
51 //
52 gBS->CloseEvent (Event);
53}
54
57 );
58
61 IN REDFISH_SERVICE RedfishService
62 );
63
89EFIAPI
93 OUT CHAR8 **UserId,
94 OUT CHAR8 **Password
95 )
96{
97 if ((This == NULL) || (AuthMethod == NULL) || (UserId == NULL) || (Password == NULL)) {
98 return EFI_INVALID_PARAMETER;
99 }
100
101 return LibCredentialGetAuthInfo (This, AuthMethod, UserId, Password);
102}
103
122EFIAPI
126 )
127{
128 if (This == NULL) {
129 return EFI_INVALID_PARAMETER;
130 }
131
132 return LibStopRedfishService (This, ServiceStopType);
133}
134
160EFIAPI
163 OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
164 OUT CHAR8 **UserId,
165 OUT CHAR8 **Password
166 )
167{
168 EFI_STATUS Status;
169
170 if ((AuthMethod == NULL) || (UserId == NULL) || (Password == NULL)) {
171 return EFI_INVALID_PARAMETER;
172 }
173
174 if (mCredentialPrivate == NULL) {
175 DEBUG ((DEBUG_ERROR, "%a: failed with error - %r\n", __func__, EFI_NOT_STARTED));
176 return EFI_NOT_STARTED;
177 }
178
179 Status = mCredentialPrivate->RedfishCredentialProtocol.GetAuthInfo (
180 &mCredentialPrivate->RedfishCredentialProtocol,
181 AuthMethod,
182 UserId,
183 Password
184 );
185 if (EFI_ERROR (Status)) {
186 DEBUG ((DEBUG_ERROR, "%a: Failed to retrieve Redfish credential - %r\n", __func__, Status));
187 }
188
189 return Status;
190}
191
212EFIAPI
216 )
217{
218 EFI_STATUS Status;
219 REDFISH_SERVICE_LIST *Instance;
220
221 if (mCredentialPrivate == NULL) {
222 DEBUG ((DEBUG_ERROR, "%a: failed with error - %r\n", __func__, EFI_NOT_STARTED));
223 return EFI_NOT_STARTED;
224 }
225
226 if ((ServiceStopType == ServiceStopTypeExitBootService) ||
227 (ServiceStopType == ServiceStopTypeNone))
228 {
229 // Check PCD and skip the action if platform library is responsible for deleting account
230 // on exit boot service event
231 if (FixedPcdGetBool (PcdRedfishCredentialDeleteAccount)) {
232 if (!IsListEmpty (&mCredentialPrivate->RedfishServiceList)) {
233 Instance = (REDFISH_SERVICE_LIST *)GetFirstNode (&mCredentialPrivate->RedfishServiceList);
234 IterateThroughBootstrapAccounts (Instance->RedfishService);
235 }
236
238 }
239 }
240
241 Status = mCredentialPrivate->RedfishCredentialProtocol.StopService (
242 &mCredentialPrivate->RedfishCredentialProtocol,
243 ServiceStopType
244 );
245 if (EFI_ERROR (Status)) {
246 DEBUG ((DEBUG_ERROR, "%a: Failed to stop service - %r\n", __func__, Status));
247 }
248
249 return Status;
250}
251
261EFIAPI
263 IN REDFISH_SERVICE RedfishService,
264 IN CHAR16 *TargetUri
265 )
266{
267 EFI_STATUS Status;
268 REDFISH_RESPONSE RedfishResponse;
269
270 if (mCredentialPrivate == NULL) {
271 DEBUG ((DEBUG_ERROR, "%a: failed with error - %r\n", __func__, EFI_NOT_STARTED));
272 return EFI_NOT_STARTED;
273 }
274
275 if ((RedfishService == NULL) || (mCredentialPrivate->AuthMethod != AuthMethodHttpBasic)) {
276 DEBUG ((DEBUG_ERROR, "%a: Redfish service is not available\n", __func__));
277 return EFI_INVALID_PARAMETER;
278 }
279
280 //
281 // Remove bootstrap account at /redfish/v1/AccountService/AccountId
282 //
283 ZeroMem (&RedfishResponse, sizeof (REDFISH_RESPONSE));
285 RedfishService,
286 TargetUri,
287 "{}",
288 2,
289 NULL,
290 &RedfishResponse
291 );
292 if (EFI_ERROR (Status)) {
293 DEBUG ((DEBUG_ERROR, "%a: can not remove bootstrap account at BMC: %r", __func__, Status));
294 DumpRedfishResponse (__func__, DEBUG_ERROR, &RedfishResponse);
295 } else {
296 DEBUG (
297 (REDFISH_CREDENTIAL_DEBUG, "%a: bootstrap account: %a is removed from: %s\nURI - %s",
298 __func__, mCredentialPrivate->AccountName, REDFISH_MANAGER_ACCOUNT_COLLECTION_URI, TargetUri)
299 );
300 }
301
302 RedfishHttpFreeResponse (&RedfishResponse);
303
304 return Status;
305}
306
317BOOLEAN
319 IN REDFISH_SERVICE RedfishService,
320 IN EFI_STRING AccountUri
321 )
322{
323 EDKII_JSON_VALUE JsonUserName;
324 EDKII_JSON_VALUE JsonValue;
325 EFI_STATUS Status;
326 REDFISH_RESPONSE RedfishResponse;
327 REDFISH_REQUEST RedfishRequest;
328 BOOLEAN Ret;
329
330 if (mCredentialPrivate == NULL) {
331 DEBUG ((DEBUG_ERROR, "%a: failed with error - %r\n", __func__, EFI_NOT_STARTED));
332 return FALSE;
333 }
334
335 if ((RedfishService == NULL) || IS_EMPTY_STRING (AccountUri) ||
336 (mCredentialPrivate->AuthMethod != AuthMethodHttpBasic))
337 {
338 return FALSE;
339 }
340
341 ZeroMem (&RedfishResponse, sizeof (REDFISH_RESPONSE));
342 ZeroMem (&RedfishRequest, sizeof (REDFISH_REQUEST));
343 Status = RedfishHttpGetResource (RedfishService, AccountUri, &RedfishRequest, &RedfishResponse, FALSE);
344 if (EFI_ERROR (Status) || (RedfishResponse.Payload == NULL)) {
345 DEBUG ((DEBUG_ERROR, "%a: can not get account from BMC: %r", __func__, Status));
346 DumpRedfishResponse (__func__, DEBUG_ERROR, &RedfishResponse);
347 return FALSE;
348 }
349
350 Ret = FALSE;
351 JsonValue = RedfishJsonInPayload (RedfishResponse.Payload);
352 if (JsonValueIsObject (JsonValue)) {
353 JsonUserName = JsonObjectGetValue (JsonValueGetObject (JsonValue), "UserName");
354 if (JsonValueIsString (JsonUserName) && (JsonValueGetAsciiString (JsonUserName) != NULL)) {
355 if (AsciiStrCmp (mCredentialPrivate->AccountName, JsonValueGetAsciiString (JsonUserName)) == 0) {
356 DeleteRedfishBootstrapAccount (RedfishService, AccountUri);
357 Ret = TRUE;
358 }
359 }
360 }
361
362 RedfishHttpFreeResponse (&RedfishResponse);
363 RedfishHttpFreeRequest (&RedfishRequest);
364
365 return Ret;
366}
367
378 OUT CHAR16 **ServiceVersionStr
379 )
380{
381 *ServiceVersionStr = (CHAR16 *)PcdGetPtr (PcdDefaultRedfishVersion);
382 if (*ServiceVersionStr == NULL) {
383 *ServiceVersionStr = REDFISH_VERSION_DEFAULT_STRING;
384 }
385
386 return EFI_SUCCESS;
387}
388
401 IN REDFISH_SERVICE RedfishService
402 )
403{
404 EFI_STATUS Status;
405 EDKII_JSON_VALUE JsonMembers;
406 EDKII_JSON_VALUE JsonValue;
407 EDKII_JSON_VALUE OdataId;
408 CHAR16 TargetUri[REDFISH_URI_LENGTH];
409 CHAR16 *RedfishVersion;
410 REDFISH_RESPONSE RedfishResponse;
411 REDFISH_REQUEST RedfishRequest;
412 UINTN MembersCount, Index;
413
414 RedfishVersion = NULL;
415 Status = EFI_NOT_FOUND;
416
417 if (mCredentialPrivate == NULL) {
418 DEBUG ((DEBUG_ERROR, "%a: failed with error - %r\n", __func__, EFI_NOT_STARTED));
419 return EFI_NOT_STARTED;
420 }
421
422 if ((RedfishService == NULL) || (mCredentialPrivate->AuthMethod != AuthMethodHttpBasic) ||
423 IS_EMPTY_STRING (mCredentialPrivate->AccountName))
424 {
425 return EFI_INVALID_PARAMETER;
426 }
427
428 //
429 // Carving the URI
430 //
431
432 Status = RedfishGetServiceVersion (&RedfishVersion);
433 if (EFI_ERROR (Status)) {
434 DEBUG ((DEBUG_ERROR, "%a: can not get Redfish version\n", __func__));
435 return Status;
436 }
437
439 TargetUri,
440 (sizeof (CHAR16) * REDFISH_URI_LENGTH),
441 L"/redfish/%s/%s",
442 RedfishVersion,
443 REDFISH_MANAGER_ACCOUNT_COLLECTION_URI
444 );
445
446 DEBUG ((REDFISH_CREDENTIAL_DEBUG, "%a: account collection URI: %s\n", __func__, TargetUri));
447
448 ZeroMem (&RedfishResponse, sizeof (REDFISH_RESPONSE));
449 ZeroMem (&RedfishRequest, sizeof (REDFISH_REQUEST));
450 Status = RedfishHttpGetResource (RedfishService, TargetUri, &RedfishRequest, &RedfishResponse, FALSE);
451 if (EFI_ERROR (Status) || (RedfishResponse.Payload == NULL)) {
452 DEBUG ((DEBUG_ERROR, "%a: can not get accounts from BMC: %r\n", __func__, Status));
453 DumpRedfishResponse (__func__, DEBUG_ERROR, &RedfishResponse);
454 return Status;
455 }
456
457 JsonValue = RedfishJsonInPayload (RedfishResponse.Payload);
458 if (!JsonValueIsObject (JsonValue)) {
459 Status = EFI_LOAD_ERROR;
460 goto ON_EXIT;
461 }
462
463 JsonMembers = JsonObjectGetValue (JsonValueGetObject (JsonValue), "Members");
464 if (!JsonValueIsArray (JsonMembers)) {
465 Status = EFI_LOAD_ERROR;
466 goto ON_EXIT;
467 }
468
469 Status = EFI_NOT_FOUND;
470
471 MembersCount = JsonArrayCount (JsonValueGetArray (JsonMembers));
472 for (Index = 0; Index < MembersCount; Index++) {
473 JsonValue = JsonArrayGetValue (JsonValueGetArray (JsonMembers), Index);
474 if (!JsonValueIsObject (JsonValue)) {
475 Status = EFI_LOAD_ERROR;
476 goto ON_EXIT;
477 }
478
479 OdataId = JsonObjectGetValue (JsonValueGetObject (JsonValue), "@odata.id");
480 if (!JsonValueIsString (OdataId) || (JsonValueGetAsciiString (OdataId) == NULL)) {
481 Status = EFI_LOAD_ERROR;
482 goto ON_EXIT;
483 }
484
486 TargetUri,
487 (sizeof (CHAR16) * REDFISH_URI_LENGTH),
488 L"%a",
490 );
491 DEBUG ((REDFISH_CREDENTIAL_DEBUG, "%a: account URI: %s\n", __func__, TargetUri));
492 // Verify bootstrap account User Name and delete the account if User Name matches
493 if (ProcessRedfishBootstarpAccount (RedfishService, TargetUri)) {
494 Status = EFI_SUCCESS;
495 break;
496 }
497 }
498
499ON_EXIT:
500
501 RedfishHttpFreeResponse (&RedfishResponse);
502 RedfishHttpFreeRequest (&RedfishRequest);
503
504 return Status;
505}
506
524 OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod,
525 OUT CHAR8 **UserId
526 )
527{
528 EFI_STATUS Status;
529 CHAR8 *Password;
530
531 Password = NULL;
532
533 if ((AuthMethod == NULL) || (UserId == NULL)) {
534 return EFI_INVALID_PARAMETER;
535 }
536
537 if (mCredentialPrivate == NULL) {
538 DEBUG ((DEBUG_ERROR, "%a: failed with error - %r\n", __func__, EFI_NOT_STARTED));
539 return EFI_NOT_STARTED;
540 }
541
542 Status = mCredentialPrivate->RedfishCredentialProtocol.GetAuthInfo (
543 &mCredentialPrivate->RedfishCredentialProtocol,
544 AuthMethod,
545 UserId,
546 &Password
547 );
548 if (EFI_ERROR (Status)) {
549 DEBUG ((DEBUG_ERROR, "%a: failed to retrieve Redfish credential - %r\n", __func__, Status));
550 return Status;
551 }
552
553 if (Password != NULL) {
554 ZeroMem (Password, AsciiStrSize (Password));
555 FreePool (Password);
556 }
557
558 return Status;
559}
560
570 VOID
571 )
572{
573 REDFISH_SERVICE_LIST *Instance;
574 REDFISH_SERVICE_LIST *NextInstance;
575
576 if (mCredentialPrivate == NULL) {
577 DEBUG ((DEBUG_ERROR, "%a: failed with error - %r\n", __func__, EFI_NOT_STARTED));
578 return EFI_NOT_STARTED;
579 }
580
581 if (!IsListEmpty (&mCredentialPrivate->RedfishServiceList)) {
582 //
583 // Free memory of REDFISH_SERVICE_LIST instance.
584 //
585 Instance = (REDFISH_SERVICE_LIST *)GetFirstNode (&mCredentialPrivate->RedfishServiceList);
586 do {
587 NextInstance = NULL;
588 if (!IsNodeAtEnd (&mCredentialPrivate->RedfishServiceList, &Instance->NextInstance)) {
589 NextInstance = (REDFISH_SERVICE_LIST *)GetNextNode (
590 &mCredentialPrivate->RedfishServiceList,
591 &Instance->NextInstance
592 );
593 }
594
595 RemoveEntryList (&Instance->NextInstance);
596 FreePool ((VOID *)Instance);
597 Instance = NextInstance;
598 } while (Instance != NULL);
599 }
600
601 return EFI_SUCCESS;
602}
603
614 IN REDFISH_SERVICE RedfishService
615 )
616{
617 BOOLEAN ServiceFound;
618 REDFISH_SERVICE_LIST *RedfishServiceInstance;
619
620 RedfishServiceInstance = NULL;
621 ServiceFound = FALSE;
622
623 if (mCredentialPrivate == NULL) {
624 DEBUG ((DEBUG_ERROR, "%a: failed with error - %r\n", __func__, EFI_NOT_STARTED));
625 return EFI_NOT_STARTED;
626 }
627
628 if (!IsListEmpty (&mCredentialPrivate->RedfishServiceList)) {
629 RedfishServiceInstance = (REDFISH_SERVICE_LIST *)GetFirstNode (&mCredentialPrivate->RedfishServiceList);
630 do {
631 if (RedfishServiceInstance->RedfishService == RedfishService) {
632 ServiceFound = TRUE;
633 break;
634 }
635
636 if (IsNodeAtEnd (&mCredentialPrivate->RedfishServiceList, &RedfishServiceInstance->NextInstance)) {
637 break;
638 }
639
640 RedfishServiceInstance = (REDFISH_SERVICE_LIST *)GetNextNode (
641 &mCredentialPrivate->RedfishServiceList,
642 &RedfishServiceInstance->NextInstance
643 );
644 } while (TRUE);
645 }
646
647 if (!ServiceFound) {
648 RedfishServiceInstance = (REDFISH_SERVICE_LIST *)AllocateZeroPool (sizeof (REDFISH_SERVICE_LIST));
649 if (RedfishServiceInstance == NULL) {
650 return EFI_OUT_OF_RESOURCES;
651 }
652
653 RedfishServiceInstance->RedfishService = RedfishService;
654 InsertTailList (&mCredentialPrivate->RedfishServiceList, &RedfishServiceInstance->NextInstance);
655 }
656
657 return EFI_SUCCESS;
658}
659
671 IN REDFISH_SERVICE RedfishService
672 )
673{
674 REDFISH_SERVICE_LIST *RedfishServiceInstance;
675
676 if (mCredentialPrivate == NULL) {
677 DEBUG ((DEBUG_ERROR, "%a: failed with error - %r\n", __func__, EFI_NOT_STARTED));
678 return EFI_NOT_STARTED;
679 }
680
681 if (!IsListEmpty (&mCredentialPrivate->RedfishServiceList)) {
682 RedfishServiceInstance = (REDFISH_SERVICE_LIST *)GetFirstNode (&mCredentialPrivate->RedfishServiceList);
683 do {
684 if (RedfishServiceInstance->RedfishService == RedfishService) {
685 RemoveEntryList (&RedfishServiceInstance->NextInstance);
686 FreePool (RedfishServiceInstance);
687 return EFI_SUCCESS;
688 }
689
690 if (IsNodeAtEnd (&mCredentialPrivate->RedfishServiceList, &RedfishServiceInstance->NextInstance)) {
691 break;
692 }
693
694 RedfishServiceInstance = (REDFISH_SERVICE_LIST *)GetNextNode (&mCredentialPrivate->RedfishServiceList, &RedfishServiceInstance->NextInstance);
695 } while (TRUE);
696 }
697
698 return EFI_NOT_FOUND;
699}
700
712EFIAPI
715 IN REDFISH_SERVICE RedfishService
716 )
717{
718 EFI_STATUS Status;
719
720 Status = EFI_SUCCESS;
721
722 if (mCredentialPrivate == NULL) {
723 DEBUG ((DEBUG_ERROR, "%a: failed with error - %r\n", __func__, EFI_NOT_STARTED));
724 return EFI_NOT_STARTED;
725 }
726
727 // Check if AuthMethod has been initialized yet
728 if (mCredentialPrivate->AuthMethod == AuthMethodMax) {
729 Status = RedfishGetAuthConfig (
730 &mCredentialPrivate->AuthMethod,
731 &mCredentialPrivate->AccountName
732 );
733 }
734
735 // Bootstrap account should be deleted only if Basic Authentication is used.
736 if (!EFI_ERROR (Status) && (mCredentialPrivate->AuthMethod == AuthMethodHttpBasic)) {
737 Status = AddRedfishServiceToList (RedfishService);
738 if (EFI_ERROR (Status)) {
739 DEBUG ((DEBUG_ERROR, "%a: Failed to register Redfish service - %r\n", __func__, Status));
740 }
741 }
742
743 return Status;
744}
745
758EFIAPI
761 IN REDFISH_SERVICE RedfishService
762 )
763{
764 EFI_STATUS Status;
765
766 // Bootstrap account should be deleted only if Basic Authentication is used.
767 if (mCredentialPrivate->AuthMethod != AuthMethodHttpBasic) {
768 return EFI_SUCCESS;
769 }
770
771 // Delete Redfish Service from the registered list
772 Status = DeleteRedfishServiceFromList (RedfishService);
773 // Check if registered list is empty
774 if (IsListEmpty (&mCredentialPrivate->RedfishServiceList)) {
775 // Iterate through all accounts in the account collection and delete the bootstrap account
776 Status = IterateThroughBootstrapAccounts (RedfishService);
777 if (!EFI_ERROR (Status)) {
778 if (mCredentialPrivate->AccountName != NULL) {
779 ZeroMem (mCredentialPrivate->AccountName, AsciiStrSize (mCredentialPrivate->AccountName));
780 FreePool (mCredentialPrivate->AccountName);
781 mCredentialPrivate->AccountName = NULL;
782 }
783
784 mCredentialPrivate->AuthMethod = AuthMethodMax;
785 Status = mCredentialPrivate->RedfishCredentialProtocol.StopService (
786 &mCredentialPrivate->RedfishCredentialProtocol,
788 );
789 if (EFI_ERROR (Status)) {
790 DEBUG ((DEBUG_ERROR, "%a: Failed to stop service - %r\n", __func__, Status));
791 }
792 }
793 }
794
795 return Status;
796}
797
808EFIAPI
810 IN EFI_HANDLE ImageHandle,
811 IN EFI_SYSTEM_TABLE *SystemTable
812 )
813{
814 EFI_STATUS Status;
815
817 if (mCredentialPrivate == NULL) {
818 return EFI_OUT_OF_RESOURCES;
819 }
820
821 mCredentialPrivate->AuthMethod = AuthMethodMax;
822 InitializeListHead (&mCredentialPrivate->RedfishServiceList);
823
824 mCredentialPrivate->RedfishCredentialProtocol.GetAuthInfo = RedfishCredentialGetAuthInfo;
825 mCredentialPrivate->RedfishCredentialProtocol.StopService = RedfishCredentialStopService;
826
827 mCredentialPrivate->RedfishCredential2Protocol.Revision = REDFISH_CREDENTIAL_PROTOCOL_REVISION;
828 mCredentialPrivate->RedfishCredential2Protocol.GetAuthInfo = RedfishCredential2GetAuthInfo;
829 mCredentialPrivate->RedfishCredential2Protocol.StopService = RedfishCredential2StopService;
830 mCredentialPrivate->RedfishCredential2Protocol.RegisterRedfishService = RedfishCredential2RegisterService;
831 mCredentialPrivate->RedfishCredential2Protocol.UnregisterRedfishService = RedfishCredential2UnregisterService;
832
833 //
834 // Install the RedfishCredentialProtocol onto Handle.
835 //
836 Status = gBS->InstallMultipleProtocolInterfaces (
837 &mCredentialPrivate->Handle,
838 &gEdkIIRedfishCredentialProtocolGuid,
839 &mCredentialPrivate->RedfishCredentialProtocol,
840 &gEdkIIRedfishCredential2ProtocolGuid,
841 &mCredentialPrivate->RedfishCredential2Protocol,
842 NULL
843 );
844 if (EFI_ERROR (Status)) {
845 return Status;
846 }
847
848 //
849 // After EndOfDxe, if SecureBoot is disabled, Redfish Credential Protocol should return
850 // error code to caller to avoid the 3rd code to bypass Redfish Credential Protocol and
851 // retrieve userid/pwd directly. So, here, we create EndOfDxe Event to check SecureBoot
852 // status.
853 //
854 Status = gBS->CreateEventEx (
855 EVT_NOTIFY_SIGNAL,
856 TPL_CALLBACK,
858 (VOID *)&mCredentialPrivate->RedfishCredentialProtocol,
859 &gEfiEndOfDxeEventGroupGuid,
860 &mCredentialPrivate->EndOfDxeEvent
861 );
862 if (EFI_ERROR (Status)) {
863 goto ON_ERROR;
864 }
865
866 //
867 // After ExitBootServices, Redfish Credential Protocol should stop the service.
868 // So, here, we create ExitBootService Event to stop service.
869 //
870 Status = gBS->CreateEventEx (
871 EVT_NOTIFY_SIGNAL,
872 TPL_CALLBACK,
874 (VOID *)&mCredentialPrivate->RedfishCredentialProtocol,
875 &gEfiEventExitBootServicesGuid,
876 &mCredentialPrivate->ExitBootServiceEvent
877 );
878 if (EFI_ERROR (Status)) {
879 gBS->CloseEvent (mCredentialPrivate->EndOfDxeEvent);
880 mCredentialPrivate->EndOfDxeEvent = NULL;
881 goto ON_ERROR;
882 }
883
884 return EFI_SUCCESS;
885
886ON_ERROR:
887
888 gBS->UninstallMultipleProtocolInterfaces (
889 mCredentialPrivate->Handle,
890 &gEdkIIRedfishCredentialProtocolGuid,
891 &mCredentialPrivate->RedfishCredentialProtocol,
892 &gEdkIIRedfishCredential2ProtocolGuid,
893 &mCredentialPrivate->RedfishCredential2Protocol,
894 NULL
895 );
896
897 FreePool (mCredentialPrivate);
898
899 return Status;
900}
901
912 )
913{
914 if (mCredentialPrivate != NULL) {
915 if (mCredentialPrivate->AccountName != NULL) {
916 ZeroMem (mCredentialPrivate->AccountName, AsciiStrSize (mCredentialPrivate->AccountName));
917 FreePool (mCredentialPrivate->AccountName);
918 mCredentialPrivate->AccountName = NULL;
919 }
920
922 }
923
924 return EFI_SUCCESS;
925}
926
940EFIAPI
942 IN EFI_HANDLE ImageHandle
943 )
944{
945 if (mCredentialPrivate != NULL) {
946 gBS->UninstallMultipleProtocolInterfaces (
947 mCredentialPrivate->Handle,
948 &gEdkIIRedfishCredentialProtocolGuid,
949 &mCredentialPrivate->RedfishCredentialProtocol,
950 &gEdkIIRedfishCredential2ProtocolGuid,
951 &mCredentialPrivate->RedfishCredential2Protocol,
952 NULL
953 );
954
955 if (mCredentialPrivate->EndOfDxeEvent != NULL) {
956 gBS->CloseEvent (mCredentialPrivate->EndOfDxeEvent);
957 mCredentialPrivate->EndOfDxeEvent = NULL;
958 }
959
960 if (mCredentialPrivate->ExitBootServiceEvent != NULL) {
961 gBS->CloseEvent (mCredentialPrivate->ExitBootServiceEvent);
962 mCredentialPrivate->ExitBootServiceEvent = NULL;
963 }
964
966
967 FreePool (mCredentialPrivate);
968 mCredentialPrivate = NULL;
969 }
970
971 return EFI_SUCCESS;
972}
UINT64 UINTN
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
Definition: LinkedList.c:403
LIST_ENTRY *EFIAPI GetNextNode(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:333
BOOLEAN EFIAPI IsNodeAtEnd(IN CONST LIST_ENTRY *List, IN CONST LIST_ENTRY *Node)
Definition: LinkedList.c:481
LIST_ENTRY *EFIAPI GetFirstNode(IN CONST LIST_ENTRY *List)
Definition: LinkedList.c:298
INTN EFIAPI AsciiStrCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
Definition: String.c:716
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
Definition: LinkedList.c:182
UINTN EFIAPI AsciiStrSize(IN CONST CHAR8 *String)
Definition: String.c:681
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
Definition: LinkedList.c:259
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE
@ ServiceStopTypeExitBootService
@ ServiceStopTypeNone
Stop Redfsih service without reason.
EDKII_REDFISH_AUTH_METHOD
@ AuthMethodHttpBasic
Basic authentication is required.
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
BOOLEAN EFIAPI JsonValueIsString(IN EDKII_JSON_VALUE Json)
Definition: JsonLib.c:350
EDKII_JSON_ARRAY EFIAPI JsonValueGetArray(IN EDKII_JSON_VALUE Json)
Definition: JsonLib.c:485
EDKII_JSON_OBJECT EFIAPI JsonValueGetObject(IN EDKII_JSON_VALUE Json)
Definition: JsonLib.c:508
EDKII_JSON_VALUE EFIAPI JsonArrayGetValue(IN EDKII_JSON_ARRAY JsonArray, IN UINTN Index)
Definition: JsonLib.c:873
CONST CHAR8 *EFIAPI JsonValueGetAsciiString(IN EDKII_JSON_VALUE Json)
Definition: JsonLib.c:531
BOOLEAN EFIAPI JsonValueIsArray(IN EDKII_JSON_VALUE Json)
Definition: JsonLib.c:313
EDKII_JSON_VALUE EFIAPI JsonObjectGetValue(IN CONST EDKII_JSON_OBJECT JsonObj, IN CONST CHAR8 *Key)
Definition: JsonLib.c:772
UINTN EFIAPI JsonArrayCount(IN EDKII_JSON_ARRAY JsonArray)
Definition: JsonLib.c:848
BOOLEAN EFIAPI JsonValueIsObject(IN EDKII_JSON_VALUE Json)
Definition: JsonLib.c:331
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
Definition: PrintLib.c:408
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define FixedPcdGetBool(TokenName)
Definition: PcdLib.h:120
#define PcdGetPtr(TokenName)
Definition: PcdLib.h:388
EFI_STATUS ReleaseCredentialPrivate()
EFI_STATUS EFIAPI RedfishCredential2StopService(IN EDKII_REDFISH_CREDENTIAL2_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType)
EFI_STATUS EFIAPI RedfishCredential2GetAuthInfo(IN EDKII_REDFISH_CREDENTIAL2_PROTOCOL *This, OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT CHAR8 **UserId, OUT CHAR8 **Password)
EFI_STATUS EFIAPI RedfishCredential2RegisterService(IN EDKII_REDFISH_CREDENTIAL2_PROTOCOL *This, IN REDFISH_SERVICE RedfishService)
EFI_STATUS DeleteRedfishServiceFromList(IN REDFISH_SERVICE RedfishService)
EFI_STATUS EFIAPI DeleteRedfishBootstrapAccount(IN REDFISH_SERVICE RedfishService, IN CHAR16 *TargetUri)
EFI_STATUS ClearRedfishServiceList(VOID)
EFI_STATUS EFIAPI RedfishCredentialDxeDriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS RedfishGetServiceVersion(OUT CHAR16 **ServiceVersionStr)
EFI_STATUS RedfishGetAuthConfig(OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT CHAR8 **UserId)
EFI_STATUS EFIAPI RedfishCredentialStopService(IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType)
EFI_STATUS EFIAPI RedfishCredential2UnregisterService(IN EDKII_REDFISH_CREDENTIAL2_PROTOCOL *This, IN REDFISH_SERVICE RedfishService)
VOID EFIAPI RedfishCredentialEndOfDxeEventNotify(IN EFI_EVENT Event, OUT VOID *Context)
EFI_STATUS IterateThroughBootstrapAccounts(IN REDFISH_SERVICE RedfishService)
VOID EFIAPI RedfishCredentialExitBootServicesEventNotify(IN EFI_EVENT Event, OUT VOID *Context)
EFI_STATUS EFIAPI RedfishCredentialDxeDriverUnload(IN EFI_HANDLE ImageHandle)
EFI_STATUS EFIAPI RedfishCredentialGetAuthInfo(IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT CHAR8 **UserId, OUT CHAR8 **Password)
EFI_STATUS AddRedfishServiceToList(IN REDFISH_SERVICE RedfishService)
BOOLEAN ProcessRedfishBootstarpAccount(IN REDFISH_SERVICE RedfishService, IN EFI_STRING AccountUri)
EFI_STATUS DumpRedfishResponse(IN CONST CHAR8 *Message, IN UINTN ErrorLevel, IN REDFISH_RESPONSE *Response)
EFI_STATUS RedfishHttpGetResource(IN REDFISH_SERVICE Service, IN EFI_STRING Uri, IN REDFISH_REQUEST *Request OPTIONAL, OUT REDFISH_RESPONSE *Response, IN BOOLEAN UseCache)
EFI_STATUS RedfishHttpDeleteResourceEx(IN REDFISH_SERVICE Service, IN EFI_STRING Uri, IN CHAR8 *Content OPTIONAL, IN UINTN ContentSize OPTIONAL, IN CHAR8 *ContentType OPTIONAL, OUT REDFISH_RESPONSE *Response)
EFI_STATUS RedfishHttpFreeResponse(IN REDFISH_RESPONSE *Response)
EFI_STATUS RedfishHttpFreeRequest(IN REDFISH_REQUEST *Request)
EDKII_JSON_VALUE RedfishJsonInPayload(IN REDFISH_PAYLOAD RedfishPayload)
EFI_STATUS EFIAPI LibStopRedfishService(IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, IN EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType)
VOID EFIAPI LibCredentialExitBootServicesNotify(IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This)
EFI_STATUS EFIAPI LibCredentialGetAuthInfo(IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This, OUT EDKII_REDFISH_AUTH_METHOD *AuthMethod, OUT CHAR8 **UserId, OUT CHAR8 **Password)
VOID EFIAPI LibCredentialEndOfDxeNotify(IN EDKII_REDFISH_CREDENTIAL_PROTOCOL *This)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_EVENT
Definition: UefiBaseType.h:37
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS