Package org.apache.hadoop.fs.s3a
Class AWSCredentialProviderList
java.lang.Object
org.apache.hadoop.fs.s3a.AWSCredentialProviderList
- All Implemented Interfaces:
AutoCloseable,software.amazon.awssdk.auth.credentials.AwsCredentialsProvider,software.amazon.awssdk.identity.spi.IdentityProvider<software.amazon.awssdk.identity.spi.AwsCredentialsIdentity>
@LimitedPrivate("extensions")
@Evolving
public final class AWSCredentialProviderList
extends Object
implements software.amazon.awssdk.auth.credentials.AwsCredentialsProvider, AutoCloseable
A list of providers.
This is similar to the AWS SDK
AWSCredentialsProviderChain,
except that:
- Allows extra providers to be added dynamically.
- If any provider in the chain throws an exception other than
an
SdkException, that is rethrown, rather than swallowed. - Has some more diagnostics.
- On failure, the last "relevant"
SdkExceptionraised is rethrown; exceptions other than 'no credentials' have priority. - Special handling of
AnonymousCredentialsProvider.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEmpty instance.AWSCredentialProviderList(String name, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider... providerArgs) Create with an initial list of SDK V2 credential providers.AWSCredentialProviderList(Collection<software.amazon.awssdk.auth.credentials.AwsCredentialsProvider> providers) Create with an initial list of providers. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider provider) Add a new SDK V2 provider.voidaddAll(AWSCredentialProviderList other) Add all providers from another list to this one.voidVerify that the provider list is not empty.voidclose()Close routine will close all providers in the list which implementCloseable.List<software.amazon.awssdk.auth.credentials.AwsCredentialsProvider>Returns the underlying list of providers.intGet the current reference count.booleanisClosed()Get the closed flag.List all the providers' names.static IOExceptionmaybeTranslateCredentialException(String path, Throwable throwable) Translate an exception if it or its inner exception is anCredentialInitializationException.voidrefresh()Deprecated.software.amazon.awssdk.auth.credentials.AwsCredentialsIterate through the list of providers, to find one with credentials.voidSet the name; adds a ": " if needed.share()Get a reference to this object with an updated reference count.intsize()Get the size of this list.toString()The string value is this class name and the string values of nested providers.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.awssdk.auth.credentials.AwsCredentialsProvider
identityType, resolveIdentityMethods inherited from interface software.amazon.awssdk.identity.spi.IdentityProvider
resolveIdentity, resolveIdentity
-
Field Details
-
NO_AWS_CREDENTIAL_PROVIDERS
- See Also:
-
-
Constructor Details
-
AWSCredentialProviderList
public AWSCredentialProviderList()Empty instance. This is not ready to be used. -
AWSCredentialProviderList
public AWSCredentialProviderList(Collection<software.amazon.awssdk.auth.credentials.AwsCredentialsProvider> providers) Create with an initial list of providers.- Parameters:
providers- provider list.
-
AWSCredentialProviderList
public AWSCredentialProviderList(String name, software.amazon.awssdk.auth.credentials.AwsCredentialsProvider... providerArgs) Create with an initial list of SDK V2 credential providers.- Parameters:
name- name for error messages, may be ""providerArgs- provider list.
-
-
Method Details
-
setName
Set the name; adds a ": " if needed.- Parameters:
name- name to add, or "" for no name.
-
add
public void add(software.amazon.awssdk.auth.credentials.AwsCredentialsProvider provider) Add a new SDK V2 provider.- Parameters:
provider- provider
-
addAll
Add all providers from another list to this one.- Parameters:
other- the other list.
-
refresh
Deprecated.Was an implementation of the v1 refresh; now just a no-op. -
resolveCredentials
public software.amazon.awssdk.auth.credentials.AwsCredentials resolveCredentials()Iterate through the list of providers, to find one with credentials. IfreuseLastProvideris true, then it is re-used.- Specified by:
resolveCredentialsin interfacesoftware.amazon.awssdk.auth.credentials.AwsCredentialsProvider- Returns:
- a set of credentials (possibly anonymous), for authenticating.
-
getProviders
Returns the underlying list of providers.- Returns:
- providers
-
checkNotEmpty
public void checkNotEmpty()Verify that the provider list is not empty.- Throws:
software.amazon.awssdk.core.exception.SdkException- if there are no providers.
-
listProviderNames
List all the providers' names.- Returns:
- a list of names, separated by spaces (with a trailing one). If there are no providers, "" is returned.
-
toString
The string value is this class name and the string values of nested providers. -
getRefCount
@VisibleForTesting public int getRefCount()Get the current reference count.- Returns:
- the current ref count
-
isClosed
@VisibleForTesting public boolean isClosed()Get the closed flag.- Returns:
- true iff the list is closed.
-
close
public void close()Close routine will close all providers in the list which implementCloseable. This matters because some providers start a background thread to refresh their secrets.- Specified by:
closein interfaceAutoCloseable
-
size
public int size()Get the size of this list.- Returns:
- the number of providers in the list.
-
maybeTranslateCredentialException
Translate an exception if it or its inner exception is anCredentialInitializationException. If this condition is not met, null is returned.- Parameters:
path- path of operation.throwable- exception- Returns:
- a translated exception or null.
-