Class ProfileCredentialsProvider

  • All Implemented Interfaces:
    AWSCredentialsProvider

    public class ProfileCredentialsProvider
    extends Object
    implements AWSCredentialsProvider
    Credentials provider based on AWS configuration profiles. This provider vends AWSCredentials from the profile configuration file for the default profile, or for a specific, named profile.

    AWS credential profiles allow you to share multiple sets of AWS security credentials between different tools like the AWS SDK for Java and the AWS CLI.

    See http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html

    See Also:
    ProfilesConfigFile
    • Constructor Detail

      • ProfileCredentialsProvider

        public ProfileCredentialsProvider()
        Creates a new profile credentials provider that returns the AWS security credentials configured for the default profile. Loading the credential file is deferred until the getCredentials() method is called.
      • ProfileCredentialsProvider

        public ProfileCredentialsProvider​(String profileName)
        Creates a new profile credentials provider that returns the AWS security credentials configured for the named profile. Loading the credential file is deferred until the getCredentials() method is called.
        Parameters:
        profileName - The name of a local configuration profile.
      • ProfileCredentialsProvider

        public ProfileCredentialsProvider​(String profilesConfigFilePath,
                                          String profileName)
        Creates a new profile credentials provider that returns the AWS security credentials for the specified profiles configuration file and profile name.
        Parameters:
        profilesConfigFilePath - The file path where the profile configuration file is located.
        profileName - The name of a configuration profile in the specified configuration file.
      • ProfileCredentialsProvider

        public ProfileCredentialsProvider​(ProfilesConfigFile profilesConfigFile,
                                          String profileName)
        Creates a new profile credentials provider that returns the AWS security credentials for the specified profiles configuration file and profile name.
        Parameters:
        profilesConfigFile - The profile configuration file containing the profiles used by this credentials provider or null to defer load to first use.
        profileName - The name of a configuration profile in the specified configuration file.
    • Method Detail

      • getCredentials

        public AWSCredentials getCredentials()
        Description copied from interface: AWSCredentialsProvider
        Returns AWSCredentials which the caller can use to authorize an AWS request. Each implementation of AWSCredentialsProvider can chose its own strategy for loading credentials. For example, an implementation might load credentials from an existing key management system, or load new credentials when credentials are rotated.
        Specified by:
        getCredentials in interface AWSCredentialsProvider
        Returns:
        AWSCredentials which the caller can use to authorize an AWS request.
      • refresh

        public void refresh()
        Description copied from interface: AWSCredentialsProvider
        Forces this credentials provider to refresh its credentials. For many implementations of credentials provider, this method may simply be a no-op, such as any credentials provider implementation that vends static/non-changing credentials. For other implementations that vend different credentials through out their lifetime, this method should force the credentials provider to refresh its credentials.
        Specified by:
        refresh in interface AWSCredentialsProvider
      • getRefreshIntervalNanos

        public long getRefreshIntervalNanos()
        Gets the refresh interval in nanoseconds.
        Returns:
        nanoseconds
      • setRefreshIntervalNanos

        public void setRefreshIntervalNanos​(long refreshIntervalNanos)
        Sets the refresh interval in nanoseconds.
        Parameters:
        refreshIntervalNanos - nanoseconds
      • getRefreshForceIntervalNanos

        public long getRefreshForceIntervalNanos()
        Gets the forced refresh interval in nanoseconds.
        Returns:
        nanoseconds
      • setRefreshForceIntervalNanos

        public void setRefreshForceIntervalNanos​(long refreshForceIntervalNanos)
        Sets the forced refresh interval in nanoseconds.
        Parameters:
        refreshForceIntervalNanos -