Interface HttpSigner<IdentityT extends Identity>
- Type Parameters:
IdentityT- The type of the identity.
- All Known Subinterfaces:
AwsV4aHttpSigner,AwsV4FamilyHttpSigner<T>,AwsV4HttpSigner,BearerHttpSigner
- All Known Implementing Classes:
DefaultAwsCrtV4aHttpSigner,DefaultAwsV4HttpSigner,DefaultBearerHttpSigner,DefaultS3ExpressHttpSigner,DpopSigner,NoOpHttpSigner
You can configure the signer by first implementing a custom AuthScheme returning this signer and then configuring
the AuthSchemes on the client builder via SdkClientBuilder#putAuthScheme(AuthScheme).
Example - Custom signer implementation:
S3AsyncClient s3 = S3AsyncClient.builder()
.region(Region.US_WEST_2)
.credentialsProvider(CREDENTIALS)
.putAuthScheme(new CustomSigV4AuthScheme())
.build();
public class CustomSigV4AuthScheme implements AwsV4AuthScheme {
@Override
public String schemeId() {
return AwsV4AuthScheme.SCHEME_ID;
}
@Override
public IdentityProvider<AwsCredentialsIdentity> identityProvider(IdentityProviders providers) {
return providers.identityProvider(AwsCredentialsIdentity.class);
}
@Override
public AwsV4HttpSigner signer() {
return new CustomSigV4Signer();
}
private class CustomSigV4Signer implements AwsV4HttpSigner {
@Override
public SignedRequest sign(SignRequest<? extends AwsCredentialsIdentity> request) {
// Custom implementation
}
@Override
public CompletableFuture<AsyncSignedRequest> signAsync(AsyncSignRequest<? extends AwsCredentialsIdentity> request) {
// Custom implementation
}
}
}
When to Use Each Approach
- Use custom
AuthSchemeProviderwhen you only need to override signing properties (service name, region, etc.). SeeAuthSchemeProviderfor examples. - Use custom
HttpSignerwhen you need to change the signing algorithm or logic itself.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SignerProperty<Clock> AClockto be used to derive the signing time. -
Method Summary
Modifier and TypeMethodDescriptiondefault <T extends Identity>
HttpSigner<T> Retrieve a signer that returns the input message, without signing.default SignedRequestsign(Consumer<SignRequest.Builder<IdentityT>> consumer) Method that takes in inputs to sign a request with sync payload and returns a signed version of the request.sign(SignRequest<? extends IdentityT> request) Method that takes in inputs to sign a request with sync payload and returns a signed version of the request.default CompletableFuture<AsyncSignedRequest> signAsync(Consumer<AsyncSignRequest.Builder<IdentityT>> consumer) Method that takes in inputs to sign a request with async payload and returns a future containing the signed version of the request.signAsync(AsyncSignRequest<? extends IdentityT> request) Method that takes in inputs to sign a request with async payload and returns a future containing the signed version of the request.
-
Field Details
-
SIGNING_CLOCK
AClockto be used to derive the signing time. This property defaults to the system clock.Note, signing time may not be relevant to some signers.
-
-
Method Details
-
doNotSign
Retrieve a signer that returns the input message, without signing. -
sign
Method that takes in inputs to sign a request with sync payload and returns a signed version of the request.- Parameters:
request- The inputs to sign a request.- Returns:
- A signed version of the request.
-
sign
Method that takes in inputs to sign a request with sync payload and returns a signed version of the request.Similar to
sign(SignRequest), but takes a lambda to configure a newSignRequest.Builder. This removes the need to call} andinvalid reference
SignRequest#builder(IdentityT)SdkBuilder.build().- Parameters:
consumer- AConsumerto which an emptySignRequest.Builderwill be given.- Returns:
- A signed version of the request.
-
signAsync
Method that takes in inputs to sign a request with async payload and returns a future containing the signed version of the request.- Parameters:
request- The inputs to sign a request.- Returns:
- A future containing the signed version of the request.
-
signAsync
default CompletableFuture<AsyncSignedRequest> signAsync(Consumer<AsyncSignRequest.Builder<IdentityT>> consumer) Method that takes in inputs to sign a request with async payload and returns a future containing the signed version of the request.Similar to
signAsync(AsyncSignRequest), but takes a lambda to configure a newAsyncSignRequest.Builder. This removes the need to call} andinvalid reference
AsyncSignRequest#builder(IdentityT)SdkBuilder.build().- Parameters:
consumer- AConsumerto which an emptyBaseSignRequest.Builderwill be given.- Returns:
- A future containing the signed version of the request.
-