Skip to content

Commit ab7fdd8

Browse files
committed
Minor fixes
* Added missing Builder method override for identity * Fixed javadocs * Fixed toString
1 parent 80bc11c commit ab7fdd8

File tree

9 files changed

+40
-31
lines changed

9 files changed

+40
-31
lines changed

core/http-auth-spi/src/main/java/software/amazon/awssdk/http/auth/spi/AsyncHttpSignRequest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
import software.amazon.awssdk.identity.spi.Identity;
2626
import software.amazon.awssdk.utils.builder.SdkBuilder;
2727

28+
/**
29+
* Input parameters to sign a request with async payload, using {@link HttpSigner}.
30+
*
31+
* @param <IdentityT> The type of the identity.
32+
*/
2833
@SdkPublicApi
2934
@Immutable
3035
@ThreadSafe
@@ -36,6 +41,9 @@ static <IdentityT extends Identity> Builder<IdentityT> builder(IdentityT identit
3641
return new DefaultAsyncHttpSignRequest.BuilderImpl<>(identity);
3742
}
3843

44+
/**
45+
* A builder for a {@link AsyncHttpSignRequest}.
46+
*/
3947
interface Builder<IdentityT extends Identity> extends HttpSignRequest.Builder<Publisher<ByteBuffer>, IdentityT>,
4048
SdkBuilder<Builder<IdentityT>, AsyncHttpSignRequest<IdentityT>> {
4149
@Override

core/http-auth-spi/src/main/java/software/amazon/awssdk/http/auth/spi/AsyncSignedHttpRequest.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,28 @@
2525
import software.amazon.awssdk.utils.builder.SdkBuilder;
2626

2727
/**
28-
* Represents a request that has been signed by {@link HttpSigner}.
29-
** //TODO:
28+
* Represents a request with async payload that has been signed by {@link HttpSigner}.
3029
*/
3130
@SdkPublicApi
3231
@Immutable
3332
@ThreadSafe
3433
public interface AsyncSignedHttpRequest extends SignedHttpRequest<Publisher<ByteBuffer>> {
3534

3635
/**
37-
* Get a new builder for creating a {@link SyncSignedHttpRequest}.
36+
* Get a new builder for creating a {@link AsyncSignedHttpRequest}.
3837
*/
3938
static Builder builder() {
4039
return new DefaultAsyncSignedHttpRequest.BuilderImpl();
4140
}
4241

4342
/**
44-
* A builder for a {@link SyncSignedHttpRequest}.
43+
* A builder for a {@link AsyncSignedHttpRequest}.
4544
*/
4645
interface Builder extends SignedHttpRequest.Builder<Publisher<ByteBuffer>>, SdkBuilder<Builder, AsyncSignedHttpRequest> {
4746

48-
/**
49-
* Set the HTTP request object, without the request body payload.
50-
*/
5147
@Override
5248
Builder request(SdkHttpRequest request);
5349

54-
/**
55-
* Set the body payload of the request. A payload is optional. By default, the payload will be empty.
56-
*/
5750
@Override
5851
Builder payload(Publisher<ByteBuffer> payload);
5952
}

core/http-auth-spi/src/main/java/software/amazon/awssdk/http/auth/spi/HttpSignRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ interface Builder<PayloadT, IdentityT extends Identity> {
7272
Builder<PayloadT, IdentityT> payload(PayloadT payload);
7373

7474
/**
75-
* Set the body payload of the request. A payload is optional. By default, the payload will be empty.
75+
* Set the identity of the request.
7676
*/
7777
Builder<PayloadT, IdentityT> identity(IdentityT identity);
7878

core/http-auth-spi/src/main/java/software/amazon/awssdk/http/auth/spi/SyncHttpSignRequest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
import software.amazon.awssdk.identity.spi.Identity;
2525
import software.amazon.awssdk.utils.builder.SdkBuilder;
2626

27+
/**
28+
* Input parameters to sign a request with sync payload, using {@link HttpSigner}.
29+
*
30+
* @param <IdentityT> The type of the identity.
31+
*/
2732
@SdkPublicApi
2833
@Immutable
2934
@ThreadSafe
@@ -35,6 +40,9 @@ static <IdentityT extends Identity> Builder<IdentityT> builder(IdentityT identit
3540
return new DefaultSyncHttpSignRequest.BuilderImpl<>(identity);
3641
}
3742

43+
/**
44+
* A builder for a {@link SyncHttpSignRequest}.
45+
*/
3846
interface Builder<IdentityT extends Identity> extends HttpSignRequest.Builder<ContentStreamProvider, IdentityT>,
3947
SdkBuilder<Builder<IdentityT>, SyncHttpSignRequest<IdentityT>> {
4048
@Override
@@ -43,6 +51,9 @@ interface Builder<IdentityT extends Identity> extends HttpSignRequest.Builder<Co
4351
@Override
4452
Builder<IdentityT> payload(ContentStreamProvider payload);
4553

54+
@Override
55+
Builder<IdentityT> identity(IdentityT identity);
56+
4657
@Override
4758
<T> Builder<IdentityT> putProperty(SignerProperty<T> key, T value);
4859
}

core/http-auth-spi/src/main/java/software/amazon/awssdk/http/auth/spi/SyncSignedHttpRequest.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424
import software.amazon.awssdk.utils.builder.SdkBuilder;
2525

2626
/**
27-
* Represents a request that has been signed by {@link HttpSigner}.
28-
* //TODO:
27+
* Represents a request with sync payload that has been signed by {@link HttpSigner}.
2928
*/
3029
@SdkPublicApi
3130
@Immutable
@@ -44,15 +43,9 @@ static Builder builder() {
4443
*/
4544
interface Builder extends SignedHttpRequest.Builder<ContentStreamProvider>, SdkBuilder<Builder, SyncSignedHttpRequest> {
4645

47-
/**
48-
* Set the HTTP request object, without the request body payload.
49-
*/
5046
@Override
5147
Builder request(SdkHttpRequest request);
5248

53-
/**
54-
* Set the body payload of the request. A payload is optional. By default, the payload will be empty.
55-
*/
5649
@Override
5750
Builder payload(ContentStreamProvider payload);
5851
}

core/http-auth-spi/src/main/java/software/amazon/awssdk/http/auth/spi/internal/DefaultAsyncHttpSignRequest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ private DefaultAsyncHttpSignRequest(BuilderImpl<IdentityT> builder) {
3434
public String toString() {
3535
return ToString.builder("AsyncHttpSignRequest")
3636
.add("request", request)
37+
.add("identity", identity)
3738
.add("properties", properties)
3839
.build();
3940
}
@@ -43,9 +44,11 @@ public static final class BuilderImpl<IdentityT extends Identity>
4344
extends DefaultHttpSignRequest.BuilderImpl<BuilderImpl<IdentityT>, Publisher<ByteBuffer>, IdentityT>
4445
implements AsyncHttpSignRequest.Builder<IdentityT> {
4546

47+
// Used to enable consumer builder pattern in HttpSigner.signAsync()
4648
public BuilderImpl() {
4749
}
4850

51+
// Used by AsyncHttpSignRequest#builder() where identity is passed as parameter, to avoid having to pass Class<IdentityT>.
4952
public BuilderImpl(IdentityT identity) {
5053
super(identity);
5154
}

core/http-auth-spi/src/main/java/software/amazon/awssdk/http/auth/spi/internal/DefaultAsyncSignedHttpRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private DefaultAsyncSignedHttpRequest(BuilderImpl builder) {
3131

3232
@Override
3333
public String toString() {
34-
return ToString.builder("SyncSignedHttpRequest")
34+
return ToString.builder("AsyncSignedHttpRequest")
3535
.add("request", request)
3636
.build();
3737
}

core/http-auth-spi/src/main/java/software/amazon/awssdk/http/auth/spi/internal/DefaultSyncHttpSignRequest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ private DefaultSyncHttpSignRequest(BuilderImpl<IdentityT> builder) {
3333
public String toString() {
3434
return ToString.builder("SyncHttpSignRequest")
3535
.add("request", request)
36+
.add("identity", identity)
3637
.add("properties", properties)
3738
.build();
3839
}
@@ -42,9 +43,11 @@ public static final class BuilderImpl<IdentityT extends Identity>
4243
extends DefaultHttpSignRequest.BuilderImpl<BuilderImpl<IdentityT>, ContentStreamProvider, IdentityT>
4344
implements SyncHttpSignRequest.Builder<IdentityT> {
4445

46+
// Used to enable consumer builder pattern in HttpSigner.sign()
4547
public BuilderImpl() {
4648
}
4749

50+
// Used by SyncHttpSignRequest#builder() where identity is passed as parameter, to avoid having to pass Class<IdentityT>.
4851
public BuilderImpl(IdentityT identity) {
4952
super(identity);
5053
}

core/http-auth-spi/src/test/java/software/amazon/awssdk/http/auth/spi/HttpSignerTest.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void sign_usingRequest_works() {
4646
SyncSignedHttpRequest signedRequest =
4747
signer.sign(SyncHttpSignRequest.builder(IDENTITY)
4848
.request(mock(SdkHttpRequest.class))
49-
//.identity(x) // Note, this is doable
49+
.identity(IDENTITY) // Note, this is doable
5050
.putProperty(KEY, VALUE)
5151
.build());
5252
assertNotNull(signedRequest);
@@ -69,16 +69,14 @@ public void signAsync_usingRequest_works() {
6969
signer.signAsync(AsyncHttpSignRequest.builder(IDENTITY)
7070
.request(mock(SdkHttpRequest.class))
7171
.payload(payload)
72-
//.identity(x) // Note, this is doable
72+
.identity(IDENTITY) // Note, this is doable
7373
.putProperty(KEY, VALUE)
7474
.build());
7575
assertNotNull(signedRequest);
7676
}
7777

7878
/**
79-
* NoOp Signer that asserts that the HttpSignRequest created via builder or Consumer builder pattern are set up correctly,
80-
* e.g., have the correct payloadType, and makes sure that payloadType works with SignedHttpRequest without runtime
81-
* exceptions.
79+
* NoOp Signer that asserts that the input created via builder or Consumer builder pattern are set up correctly.
8280
*/
8381
private class TestSigner implements HttpSigner<TokenIdentity> {
8482
@Override
@@ -87,9 +85,9 @@ public SyncSignedHttpRequest sign(SyncHttpSignRequest<TokenIdentity> request) {
8785
assertEquals(IDENTITY, request.identity());
8886

8987
return SyncSignedHttpRequest.builder()
90-
.request(request.request())
91-
.payload(request.payload().orElse(null))
92-
.build();
88+
.request(request.request())
89+
.payload(request.payload().orElse(null))
90+
.build();
9391
}
9492

9593
@Override
@@ -98,9 +96,9 @@ public AsyncSignedHttpRequest signAsync(AsyncHttpSignRequest<TokenIdentity> requ
9896
assertEquals(IDENTITY, request.identity());
9997

10098
return AsyncSignedHttpRequest.builder()
101-
.request(request.request())
102-
.payload(request.payload().orElse(null))
103-
.build();
99+
.request(request.request())
100+
.payload(request.payload().orElse(null))
101+
.build();
104102
}
105103
}
106104
}

0 commit comments

Comments
 (0)