Class SignerProperty<T>

java.lang.Object
software.amazon.awssdk.http.auth.spi.signer.SignerProperty<T>
Type Parameters:
T - The type of the property.

@SdkPublicApi @Immutable @ThreadSafe public final class SignerProperty<T> extends Object
A strongly-typed property for input to an HttpSigner.

Signer properties are used to configure signing behavior by passing parameters to signers through AuthSchemeOptions. Common properties include signing region, service name, and signing algorithm parameters.

Common Built-in Properties

The SDK provides several built-in AWS V4 signer properties:

  • AwsV4FamilyHttpSigner.SERVICE_SIGNING_NAME - The service name to use in the signature
  • AwsV4FamilyHttpSigner.REGION_NAME - The AWS region for signing
  • AwsV4FamilyHttpSigner.DOUBLE_URL_ENCODE - Whether to double URL-encode the path
  • AwsV4FamilyHttpSigner.NORMALIZE_PATH - Whether to normalize the request path
  • AwsV4FamilyHttpSigner.PAYLOAD_SIGNING_ENABLED - Whether to indicate that a payload is signed or not.

Overriding Properties via AuthSchemeProvider

To override signer properties, implement a custom AuthSchemeProvider that wraps the default provider and modifies the properties on resolved AuthSchemeOptions.

Example - Overriding service signing name:

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());
    }
}

Creating Custom Properties

When implementing a custom HttpSigner, you can define your own properties to accept additional configuration. Properties should be defined as public static constants in your signer class.

Example - Custom signer with custom property:

public class CustomHttpSigner implements HttpSigner<AwsCredentialsIdentity> {
    // Define custom property
    public static final SignerProperty<String> CUSTOM_HEADER_NAME =
        SignerProperty.create(CustomHttpSigner.class, "CustomHeaderName");

    @Override
    public SignedRequest sign(SignRequest<? extends AwsCredentialsIdentity> request) {
        // Retrieve property value
        String headerName = request.property(CUSTOM_HEADER_NAME);
        // Use the property in signing logic
        // ...
    }
}

// Configure the property via AuthSchemeProvider
public class CustomPropertyAuthSchemeProvider implements S3AuthSchemeProvider {
    private final S3AuthSchemeProvider delegate;

    public CustomPropertyAuthSchemeProvider() {
        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(CustomHttpSigner.CUSTOM_HEADER_NAME, "X-Custom-Auth")
                                           .build())
                      .collect(Collectors.toList());
    }
}
See Also:
  • Method Details

    • create

      public static <T> SignerProperty<T> create(Class<?> namespace, String name)
      Create a property.
      Type Parameters:
      T - the type of the property.
      Parameters:
      namespace - the class *where* the property is being defined
      name - the name for the property
      Throws:
      IllegalArgumentException - if a property with this namespace and name already exist
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object