Package com.amazonaws.auth.profile
Class ProfilesConfigFile
- java.lang.Object
-
- com.amazonaws.auth.profile.ProfilesConfigFile
-
public class ProfilesConfigFile extends Object
Loads the local AWS credential profiles from the standard location (~/.aws/credentials), which can be easily overridden through theAWS_CREDENTIAL_PROFILES_FILE
environment variable or by specifying an alternate credentials file location through this class' constructor.The AWS credentials file format allows you to specify multiple profiles, each with their own set of AWS security credentials:
[default] aws_access_key_id=testAccessKey aws_secret_access_key=testSecretKey aws_session_token=testSessionToken [test-user] aws_access_key_id=testAccessKey aws_secret_access_key=testSecretKey aws_session_token=testSessionToken
These credential profiles allow you to share multiple sets of AWS security credentails between different tools such as the AWS SDK for Java and the AWS CLI.
For more information on setting up AWS credential profiles, see: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
- See Also:
ProfileCredentialsProvider
-
-
Field Summary
Fields Modifier and Type Field Description static String
AWS_PROFILE_ENVIRONMENT_VARIABLE
Environment variable name for overriding the default AWS profilestatic String
AWS_PROFILE_SYSTEM_PROPERTY
System property name for overriding the default AWS profilestatic String
DEFAULT_PROFILE_NAME
Name of the default profile as specified in the configuration file.
-
Constructor Summary
Constructors Constructor Description ProfilesConfigFile()
Loads the AWS credential profiles file from the default location (~/.aws/credentials) or from an alternate location ifAWS_CREDENTIAL_PROFILES_FILE
is set.ProfilesConfigFile(File file)
Loads the AWS credential profiles from the file.ProfilesConfigFile(File file, ProfileCredentialsService credentialsService)
Loads the AWS credential profiles from the file.ProfilesConfigFile(String filePath)
Loads the AWS credential profiles from the file.ProfilesConfigFile(String filePath, ProfileCredentialsService credentialsService)
Loads the AWS credential profiles from the file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,com.amazonaws.auth.profile.internal.Profile>
getAllProfiles()
Returns all the profiles declared in this config file.AWSCredentials
getCredentials(String profile)
Returns the AWS credentials for the specified profile.void
refresh()
Reread data from disk.
-
-
-
Field Detail
-
AWS_PROFILE_ENVIRONMENT_VARIABLE
public static final String AWS_PROFILE_ENVIRONMENT_VARIABLE
Environment variable name for overriding the default AWS profile- See Also:
- Constant Field Values
-
AWS_PROFILE_SYSTEM_PROPERTY
public static final String AWS_PROFILE_SYSTEM_PROPERTY
System property name for overriding the default AWS profile- See Also:
- Constant Field Values
-
DEFAULT_PROFILE_NAME
public static final String DEFAULT_PROFILE_NAME
Name of the default profile as specified in the configuration file.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ProfilesConfigFile
public ProfilesConfigFile() throws AmazonClientException
Loads the AWS credential profiles file from the default location (~/.aws/credentials) or from an alternate location ifAWS_CREDENTIAL_PROFILES_FILE
is set.- Throws:
AmazonClientException
-
ProfilesConfigFile
public ProfilesConfigFile(String filePath)
Loads the AWS credential profiles from the file. The path of the file is specified as a parameter to the constructor.
-
ProfilesConfigFile
public ProfilesConfigFile(String filePath, ProfileCredentialsService credentialsService) throws AmazonClientException
Loads the AWS credential profiles from the file. The path of the file is specified as a parameter to the constructor.- Throws:
AmazonClientException
-
ProfilesConfigFile
public ProfilesConfigFile(File file) throws AmazonClientException
Loads the AWS credential profiles from the file. The reference to the file is specified as a parameter to the constructor.- Throws:
AmazonClientException
-
ProfilesConfigFile
public ProfilesConfigFile(File file, ProfileCredentialsService credentialsService) throws AmazonClientException
Loads the AWS credential profiles from the file. The reference to the file is specified as a parameter to the constructor.- Throws:
AmazonClientException
-
-
Method Detail
-
getCredentials
public AWSCredentials getCredentials(String profile)
Returns the AWS credentials for the specified profile.
-
refresh
public void refresh()
Reread data from disk.
-
-