AWSClientAuthPersistentCognitoIdentityProvider.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #include <Authorization/AWSClientAuthPersistentCognitoIdentityProvider.h>
  9. namespace AWSClientAuth
  10. {
  11. AWSClientAuthPersistentCognitoIdentityProvider::~AWSClientAuthPersistentCognitoIdentityProvider()
  12. {
  13. m_logins.clear();
  14. m_awsAccountId = "";
  15. m_identityPoolId = "";
  16. m_identityId = "";
  17. m_identityIdUpdatedCallback = nullptr;
  18. m_loginsUpdatedCallback = nullptr;
  19. }
  20. void AWSClientAuthPersistentCognitoIdentityProvider::Initialize(const Aws::String& awsAccountId, const Aws::String& identityPoolId)
  21. {
  22. m_identityPoolId = identityPoolId;
  23. m_awsAccountId = awsAccountId;
  24. }
  25. bool AWSClientAuthPersistentCognitoIdentityProvider::HasIdentityId() const
  26. {
  27. return !m_identityId.empty();
  28. }
  29. bool AWSClientAuthPersistentCognitoIdentityProvider::HasLogins() const
  30. {
  31. return m_logins.size() > 0;
  32. }
  33. Aws::String AWSClientAuthPersistentCognitoIdentityProvider::GetIdentityId() const
  34. {
  35. return m_identityId;
  36. }
  37. Aws::Map<Aws::String, Aws::Auth::LoginAccessTokens> AWSClientAuthPersistentCognitoIdentityProvider::GetLogins()
  38. {
  39. return m_logins;
  40. }
  41. Aws::String AWSClientAuthPersistentCognitoIdentityProvider::GetAccountId() const
  42. {
  43. return m_awsAccountId;
  44. }
  45. Aws::String AWSClientAuthPersistentCognitoIdentityProvider::GetIdentityPoolId() const
  46. {
  47. return m_identityPoolId;
  48. }
  49. void AWSClientAuthPersistentCognitoIdentityProvider::PersistIdentityId(const Aws::String& identityId)
  50. {
  51. m_identityId = identityId;
  52. if (m_identityIdUpdatedCallback)
  53. {
  54. m_identityIdUpdatedCallback(*this);
  55. }
  56. }
  57. void AWSClientAuthPersistentCognitoIdentityProvider::PersistLogins(const Aws::Map<Aws::String, Aws::Auth::LoginAccessTokens>& logins)
  58. {
  59. m_logins = logins;
  60. if (m_loginsUpdatedCallback)
  61. {
  62. m_loginsUpdatedCallback(*this);
  63. }
  64. }
  65. void AWSClientAuthPersistentCognitoIdentityProvider::RemoveLogin(const Aws::String& key)
  66. {
  67. m_logins.erase(key);
  68. if (m_loginsUpdatedCallback)
  69. {
  70. m_loginsUpdatedCallback(*this);
  71. }
  72. }
  73. } // namespace AWSClientAuth