Class AwsCredentialsProviderChain

java.lang.Object
software.amazon.awssdk.auth.credentials.AwsCredentialsProviderChain
All Implemented Interfaces:
AutoCloseable, AwsCredentialsProvider, IdentityProvider<AwsCredentialsIdentity>, ToCopyableBuilder<AwsCredentialsProviderChain.Builder,AwsCredentialsProviderChain>, SdkAutoCloseable

AwsCredentialsProvider implementation that chains together multiple credentials providers.

When a caller first requests credentials from this provider, it calls all the providers in the chain, in the original order specified, until one can provide credentials, and then returns those credentials. If all of the credential providers in the chain have been called, and none of them can provide credentials, then this class will throw an exception indicated that no credentials are available.

By default, this class will remember the first credentials provider in the chain that was able to provide credentials, and will continue to use that provider when credentials are requested in the future, instead of traversing the chain each time. This behavior can be controlled through the AwsCredentialsProviderChain.Builder.reuseLastProviderEnabled(Boolean) method.

This chain implements AutoCloseable. When closed, it will call the AutoCloseable.close() on any credential providers in the chain that need to be closed.

  • Method Details