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:
  1. Allows extra providers to be added dynamically.
  2. If any provider in the chain throws an exception other than an SdkException, that is rethrown, rather than swallowed.
  3. Has some more diagnostics.
  4. On failure, the last "relevant" SdkException raised is rethrown; exceptions other than 'no credentials' have priority.
  5. Special handling of AnonymousCredentialsProvider.
  • Field Details

  • 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

      public void setName(String name)
      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

      public void addAll(AWSCredentialProviderList other)
      Add all providers from another list to this one.
      Parameters:
      other - the other list.
    • refresh

      @Deprecated public void 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. If reuseLastProvider is true, then it is re-used.
      Specified by:
      resolveCredentials in interface software.amazon.awssdk.auth.credentials.AwsCredentialsProvider
      Returns:
      a set of credentials (possibly anonymous), for authenticating.
    • getProviders

      public List<software.amazon.awssdk.auth.credentials.AwsCredentialsProvider> 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

      public String 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

      public String toString()
      The string value is this class name and the string values of nested providers.
      Overrides:
      toString in class Object
      Returns:
      a string value for debugging.
    • share

      public AWSCredentialProviderList share()
      Get a reference to this object with an updated reference count.
      Returns:
      a reference to this
    • 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 implement Closeable. This matters because some providers start a background thread to refresh their secrets.
      Specified by:
      close in interface AutoCloseable
    • size

      public int size()
      Get the size of this list.
      Returns:
      the number of providers in the list.
    • maybeTranslateCredentialException

      public static IOException maybeTranslateCredentialException(String path, Throwable throwable)
      Translate an exception if it or its inner exception is an CredentialInitializationException. If this condition is not met, null is returned.
      Parameters:
      path - path of operation.
      throwable - exception
      Returns:
      a translated exception or null.