All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.aws.smithy.kotlin.runtime.auth.awscredentials.CredentialsProviderChain.kt Maven / Gradle / Ivy

The newest version!
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

package aws.smithy.kotlin.runtime.auth.awscredentials

import aws.smithy.kotlin.runtime.collections.Attributes
import aws.smithy.kotlin.runtime.identity.IdentityProviderChain

/**
 * Composite [CredentialsProvider] that delegates to a chain of providers. When asked for credentials, providers
 * are consulted in the order given until one succeeds. If none of the providers in the chain can provide credentials
 * then this class will throw an exception. The exception will include the providers tried in the message. Each
 * individual exception is available as a suppressed exception.
 */
public class CredentialsProviderChain(vararg providers: CredentialsProvider) :
    IdentityProviderChain(*providers),
    CredentialsProvider {

    public constructor(providers: List) : this(*providers.toTypedArray())

    override suspend fun resolve(attributes: Attributes): Credentials = super.resolve(attributes)

    override fun toString(): String = providers.joinToString(" -> ")
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy