AWSClientAuthSystemComponent.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/Component/Component.h>
  10. #include <Authorization/AWSCognitoAuthorizationController.h>
  11. #include <Authentication/AuthenticationProviderManager.h>
  12. #include <UserManagement/AWSCognitoUserManagementController.h>
  13. #include <AWSClientAuthBus.h>
  14. #include <AWSCoreBus.h>
  15. namespace AWSClientAuth
  16. {
  17. //! Gem System Component. Responsible for instantiating and managing Authentication and Authorization Controller
  18. class AWSClientAuthSystemComponent
  19. : public AZ::Component
  20. , public AWSCore::AWSCoreNotificationsBus::Handler
  21. , public AWSClientAuthRequestBus::Handler
  22. {
  23. public:
  24. ~AWSClientAuthSystemComponent() override = default;
  25. AZ_COMPONENT(AWSClientAuthSystemComponent, "{0C2660C8-1B4A-4474-BE65-B487E2DE8649}");
  26. static void Reflect(AZ::ReflectContext* context);
  27. static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
  28. static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
  29. static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
  30. static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
  31. protected:
  32. // AZ::Component interface implementation
  33. void Init() override;
  34. void Activate() override;
  35. void Deactivate() override;
  36. // AWSCoreNotification interface
  37. void OnSDKInitialized() override;
  38. void OnSDKShutdownStarted() override {}
  39. // AWSClientAuthRequests interface
  40. std::shared_ptr<Aws::CognitoIdentityProvider::CognitoIdentityProviderClient> GetCognitoIDPClient() override;
  41. std::shared_ptr<Aws::CognitoIdentity::CognitoIdentityClient> GetCognitoIdentityClient() override;
  42. bool HasCognitoControllers() const override;
  43. AZStd::vector<ProviderNameEnum> m_enabledProviderNames;
  44. AZStd::unique_ptr<AuthenticationProviderManager> m_authenticationProviderManager;
  45. AZStd::unique_ptr<AWSCognitoUserManagementController> m_awsCognitoUserManagementController;
  46. AZStd::unique_ptr<AWSCognitoAuthorizationController> m_awsCognitoAuthorizationController;
  47. std::shared_ptr<Aws::CognitoIdentityProvider::CognitoIdentityProviderClient> m_cognitoIdentityProviderClient;
  48. std::shared_ptr<Aws::CognitoIdentity::CognitoIdentityClient> m_cognitoIdentityClient;
  49. };
  50. } // namespace AWSClientAuth