public final class ProfileCredentialsProvider extends Object implements AwsCredentialsProvider, SdkAutoCloseable
ProfileFile
, allowing 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
If this credentials provider is loading assume-role credentials from STS, it should be cleaned up with close()
if
it is no longer being used.
ProfileFile
Modifier and Type | Class and Description |
---|---|
static interface |
ProfileCredentialsProvider.Builder
A builder for creating a custom
ProfileCredentialsProvider . |
Modifier and Type | Method and Description |
---|---|
static ProfileCredentialsProvider.Builder |
builder()
Get a builder for creating a custom
ProfileCredentialsProvider . |
void |
close() |
static ProfileCredentialsProvider |
create()
Create a
ProfileCredentialsProvider using the ProfileFile.defaultProfileFile() and default profile name. |
static ProfileCredentialsProvider |
create(String profileName)
Create a
ProfileCredentialsProvider using the given profile name and ProfileFile.defaultProfileFile() . |
AwsCredentials |
resolveCredentials()
Returns
AwsCredentials that can be used to authorize an AWS request. |
String |
toString() |
public static ProfileCredentialsProvider create()
ProfileCredentialsProvider
using the ProfileFile.defaultProfileFile()
and default profile name.
Use builder()
for defining a custom ProfileCredentialsProvider
.public static ProfileCredentialsProvider create(String profileName)
ProfileCredentialsProvider
using the given profile name and ProfileFile.defaultProfileFile()
. Use
builder()
for defining a custom ProfileCredentialsProvider
.profileName
- the name of the profile to use from the ProfileFile.defaultProfileFile()
public static ProfileCredentialsProvider.Builder builder()
ProfileCredentialsProvider
.public AwsCredentials resolveCredentials()
AwsCredentialsProvider
AwsCredentials
that can be used 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.
If an error occurs during the loading of credentials or credentials could not be found, a runtime exception will be raised.
resolveCredentials
in interface AwsCredentialsProvider
public void close()
close
in interface AutoCloseable
close
in interface SdkAutoCloseable
Copyright © 2020. All rights reserved.