@Immutable public final class AwsSessionCredentials extends Object implements AwsCredentials, AwsSessionCredentialsIdentity, ToCopyableBuilder<AwsSessionCredentials.Builder,AwsSessionCredentials>
AwsCredentials that provides a session token to be used in service authentication. Session
tokens are typically provided by a token broker service, like AWS Security Token Service, and provide temporary access to an
AWS service.| Modifier and Type | Class and Description |
|---|---|
static class |
AwsSessionCredentials.Builder
A builder for creating an instance of
AwsSessionCredentials. |
| Modifier and Type | Method and Description |
|---|---|
String |
accessKeyId()
Retrieve the AWS access key, used to identify the user interacting with AWS.
|
Optional<String> |
accountId()
Retrieve the AWS account id associated with this credentials identity, if found.
|
static AwsSessionCredentials.Builder |
builder()
Returns a builder for this object.
|
AwsSessionCredentials |
copy(Consumer<? super AwsSessionCredentials.Builder> modifier)
A convenience method for calling
ToCopyableBuilder.toBuilder(), updating the returned builder and then calling
SdkBuilder.build(). |
static AwsSessionCredentials |
create(String accessKey,
String secretKey,
String sessionToken)
Constructs a new session credentials object, with the specified AWS access key, AWS secret key and AWS session token.
|
boolean |
equals(Object o) |
Optional<Instant> |
expirationTime()
Retrieve the expiration time of these credentials, if it exists.
|
int |
hashCode() |
Optional<String> |
providerName()
The name of the identity provider that created this credential identity.
|
String |
secretAccessKey()
Retrieve the AWS secret access key, used to authenticate the user interacting with AWS.
|
String |
sessionToken()
Retrieve the AWS session token.
|
AwsSessionCredentials.Builder |
toBuilder()
Take this object and create a builder that contains all of the current property values of this object.
|
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcreatepublic static AwsSessionCredentials.Builder builder()
builder in interface AwsCredentialsIdentitybuilder in interface AwsSessionCredentialsIdentitypublic static AwsSessionCredentials create(String accessKey, String secretKey, String sessionToken)
create in interface AwsSessionCredentialsIdentityaccessKey - The AWS access key, used to identify the user interacting with AWS.secretKey - The AWS secret access key, used to authenticate the user interacting with AWS.sessionToken - The AWS session token, retrieved from an AWS token service, used for authenticating that this user has
received temporary permission to access some resource.public String accessKeyId()
accessKeyId in interface AwsCredentialsIdentitypublic String secretAccessKey()
secretAccessKey in interface AwsCredentialsIdentitypublic Optional<Instant> expirationTime()
expirationTime in interface Identitypublic String sessionToken()
sessionToken in interface AwsSessionCredentialsIdentitypublic Optional<String> providerName()
providerName in interface Identitypublic Optional<String> accountId()
AwsCredentialsIdentityaccountId in interface AwsCredentialsIdentitypublic AwsSessionCredentials.Builder toBuilder()
ToCopyableBuildertoBuilder in interface ToCopyableBuilder<AwsSessionCredentials.Builder,AwsSessionCredentials>public AwsSessionCredentials copy(Consumer<? super AwsSessionCredentials.Builder> modifier)
ToCopyableBuilderToCopyableBuilder.toBuilder(), updating the returned builder and then calling
SdkBuilder.build(). This is useful for making small modifications to the existing object.copy in interface ToCopyableBuilder<AwsSessionCredentials.Builder,AwsSessionCredentials>modifier - A function that mutates this immutable object using the provided builder.Copyright © 2026. All rights reserved.