Interface Signer

All Known Subinterfaces:
AwsCrtS3V4aSigner, AwsCrtV4aSigner
All Known Implementing Classes:
AbstractAws4Signer, AbstractAwsS3V4Signer, AbstractAwsSigner, AsyncAws4Signer, Aws4Signer, Aws4UnsignedPayloadSigner, AwsS3V4Signer, BaseAsyncAws4Signer, BaseAws4Signer, BaseEventStreamAsyncAws4Signer, BearerTokenSigner, DefaultAwsCrtS3V4aSigner, DefaultAwsCrtV4aSigner, EventStreamAws4Signer, NoOpSigner
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

Deprecated.
Replaced by software.amazon.awssdk.http.auth.spi.signer.HttpSigner in 'http-auth-spi'.

Migration Guide:

  • For custom signing logic: Implement HttpSigner and configure via AuthScheme. See example 1 below.
  • For overriding signing properties only: Use custom AuthSchemeProvider instead. See example 2 below.

Example 1 - 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
        }
    }
}

Example 2 - Overriding signer properties only:

S3AsyncClient s3 = S3AsyncClient.builder()
                                .region(Region.US_WEST_2)
                                .credentialsProvider(CREDENTIALS)
                                .authSchemeProvider(new CustomSigningNameAuthSchemeProvider())
                                .build();

public class CustomSigningNameAuthSchemeProvider implements S3AuthSchemeProvider {
    private final S3AuthSchemeProvider delegate;

    public CustomSigningNameAuthSchemeProvider() {
        this.delegate = S3AuthSchemeProvider.defaultProvider();
    }

    @Override
    public List<AuthSchemeOption> resolveAuthScheme(S3AuthSchemeParams authSchemeParams) {
        List<AuthSchemeOption> options = delegate.resolveAuthScheme(authSchemeParams);
        return options.stream()
                      .map(option -> option.toBuilder()
                                           .putSignerProperty(AwsV4HttpSigner.SERVICE_SIGNING_NAME, "custom-service")
                                           .build())
                      .collect(Collectors.toList());
    }
}
Interface for the signer used for signing the requests. All SDK signer implementations will implement this interface.
  • Method Details

    • sign

      SdkHttpFullRequest sign(SdkHttpFullRequest request, ExecutionAttributes executionAttributes)
      Deprecated.
      Method that takes in an request and returns a signed version of the request.
      Parameters:
      request - The request to sign
      executionAttributes - Contains the attributes required for signing the request
      Returns:
      A signed version of the input request
    • credentialType

      default CredentialType credentialType()
      Deprecated.
      Method that retrieves CredentialType i.e. the type of Credentials used by the Signer while authorizing a request.
      Returns:
      null by default else return CredentialType as defined by the signer implementation.