public class ProfileCredentialsProvider extends java.lang.Object implements AWSCredentialsProvider
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
ProfilesConfigFile
Modifier and Type | Field and Description |
---|---|
private static long |
DEFAULT_FORCE_RELOAD_INTERVAL_NANOS
Default force reload interval
|
private static long |
DEFAULT_REFRESH_INTERVAL_NANOS
Default refresh interval
|
private long |
lastRefreshed
When the profiles file was last refreshed.
|
private java.lang.String |
profileName
The name of the credential profile
|
private ProfilesConfigFile |
profilesConfigFile
The credential profiles file from which this provider loads the security
credentials.
|
private long |
refreshForceIntervalNanos
Force reload interval.
|
private long |
refreshIntervalNanos
Refresh interval.
|
private java.util.concurrent.Semaphore |
refreshSemaphore
Used to have only one thread block on refresh, for applications making
at least one call every REFRESH_INTERVAL_NANOS.
|
Constructor and Description |
---|
ProfileCredentialsProvider()
Creates a new profile credentials provider that returns the AWS security
credentials configured for the default profile.
|
ProfileCredentialsProvider(ProfilesConfigFile profilesConfigFile,
java.lang.String profileName)
Creates a new profile credentials provider that returns the AWS security
credentials for the specified profiles configuration file and profile
name.
|
ProfileCredentialsProvider(java.lang.String profileName)
Creates a new profile credentials provider that returns the AWS security
credentials configured for the named profile.
|
ProfileCredentialsProvider(java.lang.String profilesConfigFilePath,
java.lang.String profileName)
Creates a new profile credentials provider that returns the AWS security
credentials for the specified profiles configuration file and profile
name.
|
Modifier and Type | Method and Description |
---|---|
AWSCredentials |
getCredentials()
Returns AWSCredentials which the caller can use to authorize an AWS request.
|
long |
getRefreshForceIntervalNanos()
Gets the forced refresh interval in nanoseconds.
|
long |
getRefreshIntervalNanos()
Gets the refresh interval in nanoseconds.
|
void |
refresh()
Forces this credentials provider to refresh its credentials.
|
void |
setRefreshForceIntervalNanos(long refreshForceIntervalNanos)
Sets the forced refresh interval in nanoseconds.
|
void |
setRefreshIntervalNanos(long refreshIntervalNanos)
Sets the refresh interval in nanoseconds.
|
private static final long DEFAULT_REFRESH_INTERVAL_NANOS
private static final long DEFAULT_FORCE_RELOAD_INTERVAL_NANOS
private volatile ProfilesConfigFile profilesConfigFile
private volatile long lastRefreshed
private final java.lang.String profileName
private final java.util.concurrent.Semaphore refreshSemaphore
private long refreshIntervalNanos
DEFAULT_REFRESH_INTERVAL_NANOS
private long refreshForceIntervalNanos
DEFAULT_FORCE_RELOAD_INTERVAL_NANOS
public ProfileCredentialsProvider()
public ProfileCredentialsProvider(java.lang.String profileName)
profileName
- The name of a local configuration profile.public ProfileCredentialsProvider(java.lang.String profilesConfigFilePath, java.lang.String profileName)
profilesConfigFilePath
- The file path where the profile configuration file is located.profileName
- The name of a configuration profile in the specified
configuration file.public ProfileCredentialsProvider(ProfilesConfigFile profilesConfigFile, java.lang.String profileName)
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.public AWSCredentials getCredentials()
AWSCredentialsProvider
getCredentials
in interface AWSCredentialsProvider
public void refresh()
AWSCredentialsProvider
refresh
in interface AWSCredentialsProvider
public long getRefreshIntervalNanos()
public void setRefreshIntervalNanos(long refreshIntervalNanos)
refreshIntervalNanos
- nanosecondspublic long getRefreshForceIntervalNanos()
public void setRefreshForceIntervalNanos(long refreshForceIntervalNanos)
refreshForceIntervalNanos
-