-
Notifications
You must be signed in to change notification settings - Fork 916
HttpSigner interface changes #4018
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
Changes from all commits
2fffa5a
f1cf80f
0690ad8
daaf834
d9c7ac9
b5c989f
33a9b04
fc79989
e1cc7bc
74e085b
80bc11c
ab7fdd8
a6b7f64
de704e7
3e24cc4
8d5ee7e
a8ef98f
6f9d3d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.http.auth.spi; | ||
|
||
import java.nio.ByteBuffer; | ||
import org.reactivestreams.Publisher; | ||
import software.amazon.awssdk.annotations.Immutable; | ||
import software.amazon.awssdk.annotations.SdkPublicApi; | ||
import software.amazon.awssdk.annotations.ThreadSafe; | ||
import software.amazon.awssdk.http.auth.spi.internal.DefaultAsyncHttpSignRequest; | ||
import software.amazon.awssdk.identity.spi.Identity; | ||
import software.amazon.awssdk.utils.builder.SdkBuilder; | ||
|
||
/** | ||
* Input parameters to sign a request with async payload, using {@link HttpSigner}. | ||
* | ||
* @param <IdentityT> The type of the identity. | ||
*/ | ||
@SdkPublicApi | ||
@Immutable | ||
@ThreadSafe | ||
public interface AsyncHttpSignRequest<IdentityT extends Identity> extends HttpSignRequest<Publisher<ByteBuffer>, IdentityT> { | ||
/** | ||
* Get a new builder for creating a {@link AsyncHttpSignRequest}. | ||
*/ | ||
static <IdentityT extends Identity> Builder<IdentityT> builder(IdentityT identity) { | ||
return new DefaultAsyncHttpSignRequest.BuilderImpl<>(identity); | ||
} | ||
|
||
/** | ||
* A builder for a {@link AsyncHttpSignRequest}. | ||
*/ | ||
interface Builder<IdentityT extends Identity> | ||
extends HttpSignRequest.Builder<Builder<IdentityT>, Publisher<ByteBuffer>, IdentityT>, | ||
SdkBuilder<Builder<IdentityT>, AsyncHttpSignRequest<IdentityT>> { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.http.auth.spi; | ||
|
||
import java.nio.ByteBuffer; | ||
import org.reactivestreams.Publisher; | ||
import software.amazon.awssdk.annotations.Immutable; | ||
import software.amazon.awssdk.annotations.SdkPublicApi; | ||
import software.amazon.awssdk.annotations.ThreadSafe; | ||
import software.amazon.awssdk.http.auth.spi.internal.DefaultAsyncSignedHttpRequest; | ||
import software.amazon.awssdk.utils.builder.SdkBuilder; | ||
|
||
/** | ||
* Represents a request with async payload that has been signed by {@link HttpSigner}. | ||
*/ | ||
@SdkPublicApi | ||
@Immutable | ||
@ThreadSafe | ||
public interface AsyncSignedHttpRequest extends SignedHttpRequest<Publisher<ByteBuffer>> { | ||
|
||
/** | ||
* Get a new builder for creating a {@link AsyncSignedHttpRequest}. | ||
*/ | ||
static Builder builder() { | ||
return new DefaultAsyncSignedHttpRequest.BuilderImpl(); | ||
} | ||
|
||
/** | ||
* A builder for a {@link AsyncSignedHttpRequest}. | ||
*/ | ||
interface Builder extends SignedHttpRequest.Builder<Builder, Publisher<ByteBuffer>>, | ||
SdkBuilder<Builder, AsyncSignedHttpRequest> { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,30 +20,18 @@ | |
import software.amazon.awssdk.annotations.SdkPublicApi; | ||
import software.amazon.awssdk.annotations.ThreadSafe; | ||
import software.amazon.awssdk.http.SdkHttpRequest; | ||
import software.amazon.awssdk.http.auth.spi.internal.DefaultHttpSignRequest; | ||
import software.amazon.awssdk.utils.builder.SdkBuilder; | ||
import software.amazon.awssdk.identity.spi.Identity; | ||
|
||
/** | ||
* 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. | ||
* @param <IdentityT> The type of the identity. | ||
*/ | ||
@SdkPublicApi | ||
@Immutable | ||
@ThreadSafe | ||
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); | ||
} | ||
|
||
/** | ||
* Returns the type of the payload. | ||
*/ | ||
Class<PayloadT> payloadType(); | ||
public interface HttpSignRequest<PayloadT, IdentityT extends Identity> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Imo, this should implement Unfortunately it makes the parameters on this type even crazier. To make the room, we could change We'd also need to remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Without using To/CopyableBuilder, I was able to remove the overriding of methods in the builder sub-interfaces to return the sub-type by adding a generic type parameter for the builder, in these commits de704e7 and 3e24cc4. I'm not sure if we'll really need to mutate these objects, so I think we can defer making these To/CopyableBuilder until needed? |
||
|
||
/** | ||
* Returns the HTTP request object, without the request body payload. | ||
|
@@ -56,28 +44,38 @@ static <T> Builder<T> builder(Class<T> payloadType) { | |
Optional<PayloadT> payload(); | ||
|
||
/** | ||
* Returns the property that the {@link HttpSigner} can use during signing. | ||
* Returns the identity. | ||
*/ | ||
IdentityT identity(); | ||
Comment on lines
44
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Imo, I'd rather not parameterize this types and just do This makes it so that code that deal with the base sign request can just deal with a WDYT? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think code that deals with base sign request, might benefit from the type, atleast the IdentityT. So the BearerTokenSigner can extract the token from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool. And we can reassess at the surface area review as well, once we can see the impact on the signers, etc. |
||
|
||
/** | ||
* 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<B extends Builder<B, PayloadT, IdentityT>, PayloadT, IdentityT extends Identity> { | ||
|
||
/** | ||
* Set the HTTP request object, without the request body payload. | ||
*/ | ||
Builder request(SdkHttpRequest request); | ||
B 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); | ||
B payload(PayloadT payload); | ||
|
||
/** | ||
* Set the identity of the request. | ||
*/ | ||
B identity(IdentityT identity); | ||
Comment on lines
66
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we go with the suggestion I have above, we'd remove these from the base builder and put it in the subtypes. |
||
|
||
/** | ||
* Set a property that the {@link HttpSigner} can use during signing. | ||
*/ | ||
<T> Builder putProperty(SignerProperty<T> key, T value); | ||
<T> B putProperty(SignerProperty<T> key, T value); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.awssdk.http.auth.spi; | ||
|
||
import software.amazon.awssdk.annotations.Immutable; | ||
import software.amazon.awssdk.annotations.SdkPublicApi; | ||
import software.amazon.awssdk.annotations.ThreadSafe; | ||
import software.amazon.awssdk.http.ContentStreamProvider; | ||
import software.amazon.awssdk.http.auth.spi.internal.DefaultSyncHttpSignRequest; | ||
import software.amazon.awssdk.identity.spi.Identity; | ||
import software.amazon.awssdk.utils.builder.SdkBuilder; | ||
|
||
/** | ||
* Input parameters to sign a request with sync payload, using {@link HttpSigner}. | ||
* | ||
* @param <IdentityT> The type of the identity. | ||
*/ | ||
@SdkPublicApi | ||
@Immutable | ||
@ThreadSafe | ||
public interface SyncHttpSignRequest<IdentityT extends Identity> extends HttpSignRequest<ContentStreamProvider, IdentityT> { | ||
/** | ||
* Get a new builder for creating a {@link SyncHttpSignRequest}. | ||
*/ | ||
static <IdentityT extends Identity> Builder<IdentityT> builder(IdentityT identity) { | ||
return new DefaultSyncHttpSignRequest.BuilderImpl<>(identity); | ||
} | ||
|
||
/** | ||
* A builder for a {@link SyncHttpSignRequest}. | ||
*/ | ||
interface Builder<IdentityT extends Identity> | ||
extends HttpSignRequest.Builder<Builder<IdentityT>, ContentStreamProvider, IdentityT>, | ||
SdkBuilder<Builder<IdentityT>, SyncHttpSignRequest<IdentityT>> { | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.