aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/auth/bearer-token-provider/DefaultBearerTokenProviderChain.cpp
blob: 16b301cd6782543ce2ee40d4c46040f0e0bfa448 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

#include <aws/core/auth/bearer-token-provider/DefaultBearerTokenProviderChain.h>
#include <aws/core/auth/AWSBearerToken.h>
#include <aws/core/auth/bearer-token-provider/SSOBearerTokenProvider.h>
#include <aws/core/utils/logging/LogMacros.h>


static const char SSO_DEFAULT_BEARER_TOKEN_PROVIDER_CHAIN_LOG_TAG[] = "SSOBearerTokenProvider";

Aws::Auth::AWSBearerToken Aws::Auth::DefaultBearerTokenProviderChain::GetAWSBearerToken()
{
    for (auto&& bearerTokenProvider : m_providerChain)
    {
        if(!bearerTokenProvider) {
            AWS_LOGSTREAM_FATAL(SSO_DEFAULT_BEARER_TOKEN_PROVIDER_CHAIN_LOG_TAG,
                                "Unexpected nullptr in DefaultBearerTokenProviderChain::m_providerChain");
            break;
        }
        AWSBearerToken bearerToken = bearerTokenProvider->GetAWSBearerToken();
        if(!bearerToken.IsExpiredOrEmpty())
        {
            return bearerToken;
        }
    }
    return AWSBearerToken("", Aws::Utils::DateTime(0.0));
}

Aws::Auth::DefaultBearerTokenProviderChain::DefaultBearerTokenProviderChain()
{
    AddProvider(Aws::MakeShared<Aws::Auth::SSOBearerTokenProvider>(SSO_DEFAULT_BEARER_TOKEN_PROVIDER_CHAIN_LOG_TAG));
}