public class ProfilesConfigFile
extends java.lang.Object
AWS_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
ProfileCredentialsProvider
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AWS_PROFILE_ENVIRONMENT_VARIABLE
Environment variable name for overriding the default AWS profile
|
static java.lang.String |
AWS_PROFILE_SYSTEM_PROPERTY
System property name for overriding the default AWS profile
|
private static java.lang.String |
CREDENTIAL_PROFILES_FILE_ENVIRONMENT_VARIABLE |
private static java.lang.String |
DEFAULT_CREDENTIAL_PROFILES_FILENAME |
static java.lang.String |
DEFAULT_PROFILE_NAME
Name of the default profile as specified in the configuration file.
|
private static java.lang.String |
LEGACY_CONFIG_FILE_ENVIRONMENT_VARIABLE
Deprecated.
|
private static java.lang.String |
LEGACY_CONFIG_PROFILES_FILENAME
Deprecated.
|
private static org.apache.commons.logging.Log |
LOG |
private ProfileCredentialsService |
profileCredentialsService |
private java.io.File |
profileFile |
private long |
profileFileLastModified |
private java.util.Map<java.lang.String,Profile> |
profilesByName |
Constructor and Description |
---|
ProfilesConfigFile()
Loads the AWS credential profiles file from the default location
(~/.aws/credentials) or from an alternate location if
AWS_CREDENTIAL_PROFILES_FILE is set. |
ProfilesConfigFile(java.io.File file)
Loads the AWS credential profiles from the file.
|
ProfilesConfigFile(java.io.File file,
ProfileCredentialsService credentialsService)
Loads the AWS credential profiles from the file.
|
ProfilesConfigFile(java.lang.String filePath)
Loads the AWS credential profiles from the file.
|
ProfilesConfigFile(java.lang.String filePath,
ProfileCredentialsService credentialsService)
Loads the AWS credential profiles from the file.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,Profile> |
getAllProfiles()
Returns all the profiles declared in this config file.
|
private static java.io.File |
getCredentialProfilesFile() |
AWSCredentials |
getCredentials(java.lang.String profile)
Returns the AWS credentials for the specified profile.
|
private static java.util.Map<java.lang.String,Profile> |
loadProfiles(java.io.File file,
ProfileCredentialsService profileCredentialsService) |
void |
refresh()
Reread data from disk.
|
private static java.lang.String |
validateFilePath(java.lang.String filePath) |
private static final org.apache.commons.logging.Log LOG
public static final java.lang.String AWS_PROFILE_ENVIRONMENT_VARIABLE
public static final java.lang.String AWS_PROFILE_SYSTEM_PROPERTY
@Deprecated private static final java.lang.String LEGACY_CONFIG_FILE_ENVIRONMENT_VARIABLE
private static final java.lang.String CREDENTIAL_PROFILES_FILE_ENVIRONMENT_VARIABLE
@Deprecated private static final java.lang.String LEGACY_CONFIG_PROFILES_FILENAME
private static final java.lang.String DEFAULT_CREDENTIAL_PROFILES_FILENAME
public static final java.lang.String DEFAULT_PROFILE_NAME
private final java.io.File profileFile
private final ProfileCredentialsService profileCredentialsService
private volatile java.util.Map<java.lang.String,Profile> profilesByName
private volatile long profileFileLastModified
public ProfilesConfigFile() throws AmazonClientException
AWS_CREDENTIAL_PROFILES_FILE
is set.AmazonClientException
public ProfilesConfigFile(java.lang.String filePath)
public ProfilesConfigFile(java.lang.String filePath, ProfileCredentialsService credentialsService) throws AmazonClientException
AmazonClientException
public ProfilesConfigFile(java.io.File file) throws AmazonClientException
AmazonClientException
public ProfilesConfigFile(java.io.File file, ProfileCredentialsService credentialsService) throws AmazonClientException
AmazonClientException
private static java.lang.String validateFilePath(java.lang.String filePath)
public AWSCredentials getCredentials(java.lang.String profile)
public void refresh()
public java.util.Map<java.lang.String,Profile> getAllProfiles()
private static java.io.File getCredentialProfilesFile()
private static java.util.Map<java.lang.String,Profile> loadProfiles(java.io.File file, ProfileCredentialsService profileCredentialsService)