com.amazonaws.auth.profile
Class ProfileCredentialsProvider

java.lang.Object
  extended by com.amazonaws.auth.profile.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 Summary
ProfileCredentialsProvider()
          Creates a new profile credentials provider that returns the AWS security credentials configured for the default profile.
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.
ProfileCredentialsProvider(String profileName)
          Creates a new profile credentials provider that returns the AWS security credentials configured for the named profile.
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.
 
Method Summary
 AWSCredentials getCredentials()
          Returns AWSCredentials which the caller can use to authorize an AWS request.
 void refresh()
          Forces this credentials provider to refresh its credentials.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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.
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


Copyright © 2016. All rights reserved.