Skip to content

HttpSigner interface changes #4017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ interface SignerPropertyConsumer {
}

interface Builder extends SdkBuilder<Builder, HttpAuthOption> {
<T> Builder schemeId(String schemeId);
Builder schemeId(String schemeId);

<T> Builder putIdentityProperty(IdentityProperty<T> key, T value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,5 @@ public interface HttpAuthScheme<T extends Identity> {
* Retrieve the signer associated with this authentication scheme. This signer is guaranteed to support the identity
* generated by the identity provider in this authentication scheme.
*/
HttpSigner signer();
HttpSigner<T> signer();
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import software.amazon.awssdk.utils.builder.SdkBuilder;

/**
* Represents a request to be signed by {@link HttpSigner}.
* Input parameters to sign a request using {@link HttpSigner}.
*
* @param <PayloadT> The type of payload of this request.
* @param <PayloadT> The type of payload of the request.
*/
@SdkPublicApi
@Immutable
Expand All @@ -36,8 +36,8 @@ public interface HttpSignRequest<PayloadT> {
/**
* Get a new builder for creating a {@link HttpSignRequest}.
*/
static <T> Builder<T> builder(Class<T> payloadType) {
return new DefaultHttpSignRequest.BuilderImpl(payloadType);
static <PayloadT> Builder<PayloadT> builder(Class<PayloadT> payloadType) {
return new DefaultHttpSignRequest.BuilderImpl<>(payloadType);
}

/**
Expand All @@ -56,28 +56,28 @@ static <T> Builder<T> builder(Class<T> payloadType) {
Optional<PayloadT> payload();

/**
* Returns the property that the {@link HttpSigner} can use during signing.
* Returns the value of a property that the {@link HttpSigner} can use during signing.
*/
<T> T property(SignerProperty<T> property);

/**
* A builder for a {@link HttpSignRequest}.
*/
interface Builder<PayloadT> extends SdkBuilder<Builder<PayloadT>, HttpSignRequest> {
interface Builder<PayloadT> extends SdkBuilder<Builder<PayloadT>, HttpSignRequest<PayloadT>> {

/**
* Set the HTTP request object, without the request body payload.
*/
Builder request(SdkHttpRequest request);
Builder<PayloadT> request(SdkHttpRequest request);

/**
* Set the body payload of the request. A payload is optional. By default, the payload will be empty.
*/
Builder payload(PayloadT payload);
Builder<PayloadT> payload(PayloadT payload);

/**
* Set a property that the {@link HttpSigner} can use during signing.
*/
<T> Builder putProperty(SignerProperty<T> key, T value);
<T> Builder<PayloadT> putProperty(SignerProperty<T> key, T value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,30 @@
import org.reactivestreams.Publisher;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.http.ContentStreamProvider;
import software.amazon.awssdk.identity.spi.Identity;

/**
* Interface for the process of modifying a request destined for a service so that the service can authenticate the SDK
* customer’s identity
* customer’s identity.
*/
@SdkPublicApi
public interface HttpSigner {
public interface HttpSigner<IdentityT extends Identity> {

/**
* Method that takes in a request and returns a signed version of the request.
* Method that takes in inputs to sign a request with sync payload and returns a signed version of the request.
*
* @param request The request to sign, with sync payload
* @return A signed version of the input request
* @param identity The identity to use to sign the request.
* @param request The inputs to sign a request.
* @return A signed version of the request.
*/
SignedHttpRequest<ContentStreamProvider> sign(HttpSignRequest<? extends ContentStreamProvider> request);
SignedHttpRequest<ContentStreamProvider> sign(IdentityT identity, HttpSignRequest<ContentStreamProvider> request);

/**
* Method that takes in a request and returns a signed version of the request.
* Method that takes in inputs to sign a request with async payload and returns a signed version of the request.
*
* @param request The request to sign, with async payload
* @return A signed version of the input request
* @param identity The identity to use to sign the request.
* @param request The inputs to sign a request.
* @return A signed version of the request.
*/
SignedHttpRequest<Publisher<ByteBuffer>> signAsync(HttpSignRequest<? extends Publisher<? extends ByteBuffer>> request);
SignedHttpRequest<Publisher<ByteBuffer>> signAsync(IdentityT identity, HttpSignRequest<Publisher<ByteBuffer>> request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
/**
* Represents a request that has been signed by {@link HttpSigner}.
*
* @param <PayloadT> The type of payload of this request.
* @param <PayloadT> The type of payload of the request.
*/
@SdkPublicApi
@Immutable
Expand All @@ -37,7 +37,7 @@ public interface SignedHttpRequest<PayloadT> {
* Get a new builder for creating a {@link SignedHttpRequest}.
*/
static <T> Builder<T> builder(Class<T> payloadType) {
return new DefaultSignedHttpRequest.BuilderImpl(payloadType);
return new DefaultSignedHttpRequest.BuilderImpl<>(payloadType);
}

/**
Expand All @@ -58,16 +58,16 @@ static <T> Builder<T> builder(Class<T> payloadType) {
/**
* A builder for a {@link SignedHttpRequest}.
*/
interface Builder<PayloadT> extends SdkBuilder<Builder<PayloadT>, SignedHttpRequest> {
interface Builder<PayloadT> extends SdkBuilder<Builder<PayloadT>, SignedHttpRequest<PayloadT>> {

/**
* Set the HTTP request object, without the request body payload.
*/
Builder request(SdkHttpRequest request);
Builder<PayloadT> request(SdkHttpRequest request);

/**
* Set the body payload of the request. A payload is optional. By default, the payload will be empty.
*/
Builder payload(PayloadT payload);
Builder<PayloadT> payload(PayloadT payload);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

/**
* A strongly-typed property for input to an {@link HttpSigner}.
* @param <T> The type of the attribute.
* @param <T> The type of the property.
*/
@SdkPublicApi
@Immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static final class BuilderImpl implements Builder {
private final Map<SignerProperty<?>, Object> signerProperties = new HashMap<>();

@Override
public <T> Builder schemeId(String schemeId) {
public Builder schemeId(String schemeId) {
this.schemeId = schemeId;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public SdkHttpRequest request() {
}

@Override
public Optional payload() {
public Optional<PayloadT> payload() {
return payload == null ? Optional.empty() : Optional.of(payload);
}

Expand Down Expand Up @@ -81,26 +81,26 @@ public BuilderImpl(Class<PayloadT> payloadType) {
}

@Override
public Builder request(SdkHttpRequest request) {
public Builder<PayloadT> request(SdkHttpRequest request) {
this.request = request;
return this;
}

@Override
public Builder payload(PayloadT payload) {
public Builder<PayloadT> payload(PayloadT payload) {
this.payload = payload;
return this;
}

@Override
public <T> Builder putProperty(SignerProperty<T> key, T value) {
public <T> Builder<PayloadT> putProperty(SignerProperty<T> key, T value) {
this.properties.put(key, value);
return this;
}

@Override
public HttpSignRequest build() {
return new DefaultHttpSignRequest(this);
public HttpSignRequest<PayloadT> build() {
return new DefaultHttpSignRequest<>(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public SdkHttpRequest request() {
}

@Override
public Optional payload() {
public Optional<PayloadT> payload() {
return payload == null ? Optional.empty() : Optional.of(payload);
}

Expand All @@ -68,20 +68,20 @@ public BuilderImpl(Class<PayloadT> payloadType) {
}

@Override
public Builder request(SdkHttpRequest request) {
public Builder<PayloadT> request(SdkHttpRequest request) {
this.request = request;
return this;
}

@Override
public Builder payload(PayloadT payload) {
public Builder<PayloadT> payload(PayloadT payload) {
this.payload = payload;
return this;
}

@Override
public SignedHttpRequest build() {
return new DefaultSignedHttpRequest(this);
public SignedHttpRequest<PayloadT> build() {
return new DefaultSignedHttpRequest<>(this);
}
}
}