Skip to content

Commit b6382c5

Browse files
authored
Add default bearer signer and stubs for other signers (#4003)
* Add interface stubs for new signer implementations * Fix HttpSign* interfaces with correct types * Add initial default implementation of BearerHttpSigner * Fix pom descriptions * Update signer stubs with latest interface changes * Fix JavaDoc styling * Optimize performance when creating bearer authz header string
1 parent c456c5b commit b6382c5

File tree

20 files changed

+556
-14
lines changed

20 files changed

+556
-14
lines changed

core/auth/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@
8282
<groupId>software.amazon.eventstream</groupId>
8383
<artifactId>eventstream</artifactId>
8484
</dependency>
85+
<dependency>
86+
<groupId>software.amazon.awssdk</groupId>
87+
<artifactId>http-auth</artifactId>
88+
<version>${awsjavasdk.version}</version>
89+
</dependency>
8590

8691
<dependency>
8792
<groupId>org.junit.jupiter</groupId>

core/http-auth-aws-crt/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
<artifactId>http-auth-aws-crt</artifactId>
2929
<name>AWS Java SDK :: HTTP Auth AWS CRT</name>
3030
<description>
31-
The AWS SDK for Java - HTTP Auth AWS module contains interfaces and implementations for http authentication
32-
specific to the AWS CRT.
31+
The AWS SDK for Java - HTTP Auth AWS CRT module holds the AWS Common Runtime based implementations
32+
that are used for authentication with HTTP services.
3333
</description>
3434
<url>https://aws.amazon.com/sdkforjava</url>
3535

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,23 @@
1616
package software.amazon.awssdk.http.auth.aws.crt;
1717

1818
import software.amazon.awssdk.annotations.SdkPublicApi;
19+
import software.amazon.awssdk.http.auth.aws.crt.internal.DefaultAwsCrtS3V4aHttpSigner;
1920
import software.amazon.awssdk.http.auth.spi.HttpSigner;
21+
import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity;
2022

23+
/**
24+
* An {@link HttpSigner} that will sign a request using an AWS credentials ({@link AwsCredentialsIdentity}),
25+
* specifically for S3-CRT.
26+
*/
2127
@SdkPublicApi
22-
public interface AwsCrtV4aHttpAuthScheme extends HttpSigner {
28+
public interface AwsCrtS3V4aHttpSigner extends HttpSigner<AwsCredentialsIdentity> {
2329

30+
/**
31+
* Get a default implementation of a {@link AwsCrtS3V4aHttpSigner}
32+
*
33+
* @return AwsCrtS3V4aHttpSigner
34+
*/
35+
static AwsCrtS3V4aHttpSigner create() {
36+
return new DefaultAwsCrtS3V4aHttpSigner();
37+
}
2438
}
Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,23 @@
1616
package software.amazon.awssdk.http.auth.aws.crt;
1717

1818
import software.amazon.awssdk.annotations.SdkPublicApi;
19+
import software.amazon.awssdk.http.auth.aws.crt.internal.DefaultAwsCrtV4aHttpSigner;
1920
import software.amazon.awssdk.http.auth.spi.HttpSigner;
21+
import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity;
2022

23+
/**
24+
* An {@link HttpSigner} that will sign a request using an AWS credentials ({@link AwsCredentialsIdentity}),
25+
* specifically for CRT.
26+
*/
2127
@SdkPublicApi
22-
public interface AwsCrtS3V4aHttpAuthScheme extends HttpSigner {
28+
public interface AwsCrtV4aHttpSigner extends HttpSigner<AwsCredentialsIdentity> {
2329

30+
/**
31+
* Get a default implementation of a {@link AwsCrtV4aHttpSigner}
32+
*
33+
* @return AwsCrtV4aHttpSigner
34+
*/
35+
static AwsCrtV4aHttpSigner create() {
36+
return new DefaultAwsCrtV4aHttpSigner();
37+
}
2438
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.awssdk.http.auth.aws.crt.internal;
17+
18+
import software.amazon.awssdk.annotations.SdkInternalApi;
19+
import software.amazon.awssdk.http.auth.aws.crt.AwsCrtS3V4aHttpSigner;
20+
import software.amazon.awssdk.http.auth.spi.AsyncHttpSignRequest;
21+
import software.amazon.awssdk.http.auth.spi.AsyncSignedHttpRequest;
22+
import software.amazon.awssdk.http.auth.spi.SyncHttpSignRequest;
23+
import software.amazon.awssdk.http.auth.spi.SyncSignedHttpRequest;
24+
import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity;
25+
26+
/**
27+
* A default implementation of {@link AwsCrtS3V4aHttpSigner}.
28+
*/
29+
@SdkInternalApi
30+
public class DefaultAwsCrtS3V4aHttpSigner implements AwsCrtS3V4aHttpSigner {
31+
32+
@Override
33+
public SyncSignedHttpRequest sign(SyncHttpSignRequest<? extends AwsCredentialsIdentity> request) {
34+
throw new UnsupportedOperationException();
35+
}
36+
37+
@Override
38+
public AsyncSignedHttpRequest signAsync(AsyncHttpSignRequest<? extends AwsCredentialsIdentity> request) {
39+
throw new UnsupportedOperationException();
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.awssdk.http.auth.aws.crt.internal;
17+
18+
import software.amazon.awssdk.annotations.SdkInternalApi;
19+
import software.amazon.awssdk.http.auth.aws.crt.AwsCrtV4aHttpSigner;
20+
import software.amazon.awssdk.http.auth.spi.AsyncHttpSignRequest;
21+
import software.amazon.awssdk.http.auth.spi.AsyncSignedHttpRequest;
22+
import software.amazon.awssdk.http.auth.spi.SyncHttpSignRequest;
23+
import software.amazon.awssdk.http.auth.spi.SyncSignedHttpRequest;
24+
import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity;
25+
26+
/**
27+
* A default implementation of {@link AwsCrtV4aHttpSigner}.
28+
*/
29+
@SdkInternalApi
30+
public class DefaultAwsCrtV4aHttpSigner implements AwsCrtV4aHttpSigner {
31+
32+
@Override
33+
public SyncSignedHttpRequest sign(SyncHttpSignRequest<? extends AwsCredentialsIdentity> request) {
34+
throw new UnsupportedOperationException();
35+
}
36+
37+
@Override
38+
public AsyncSignedHttpRequest signAsync(AsyncHttpSignRequest<? extends AwsCredentialsIdentity> request) {
39+
throw new UnsupportedOperationException();
40+
}
41+
}

core/http-auth-aws/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
<artifactId>http-auth-aws</artifactId>
2929
<name>AWS Java SDK :: HTTP Auth AWS</name>
3030
<description>
31-
The AWS SDK for Java - HTTP Auth AWS module contains interfaces and implementations for http authentication
32-
specific to AWS.
31+
The AWS SDK for Java - HTTP Auth AWS module contains interfaces and implementations for HTTP
32+
authentication specific to AWS.
3333
</description>
3434
<url>https://aws.amazon.com/sdkforjava</url>
3535

core/http-auth-aws/src/main/java/software/amazon/awssdk/http/auth/aws/AwsS3V4HttpSigner.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,23 @@
1616
package software.amazon.awssdk.http.auth.aws;
1717

1818
import software.amazon.awssdk.annotations.SdkPublicApi;
19+
import software.amazon.awssdk.http.auth.aws.internal.DefaultAwsS3V4HttpSigner;
1920
import software.amazon.awssdk.http.auth.spi.HttpSigner;
21+
import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity;
2022

23+
/**
24+
* An {@link HttpSigner} that will sign a request using an AWS credentials ({@link AwsCredentialsIdentity}),
25+
* specifically for S3.
26+
*/
2127
@SdkPublicApi
22-
public interface AwsS3V4HttpSigner extends HttpSigner {
28+
public interface AwsS3V4HttpSigner extends HttpSigner<AwsCredentialsIdentity> {
2329

30+
/**
31+
* Get a default implementation of a {@link AwsS3V4HttpSigner}
32+
*
33+
* @return AwsS3V4HttpSigner
34+
*/
35+
static AwsS3V4HttpSigner create() {
36+
return new DefaultAwsS3V4HttpSigner();
37+
}
2438
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.awssdk.http.auth.aws.internal;
17+
18+
import software.amazon.awssdk.annotations.SdkInternalApi;
19+
import software.amazon.awssdk.http.auth.aws.AwsS3V4HttpSigner;
20+
import software.amazon.awssdk.http.auth.spi.AsyncHttpSignRequest;
21+
import software.amazon.awssdk.http.auth.spi.AsyncSignedHttpRequest;
22+
import software.amazon.awssdk.http.auth.spi.SyncHttpSignRequest;
23+
import software.amazon.awssdk.http.auth.spi.SyncSignedHttpRequest;
24+
import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity;
25+
26+
/**
27+
* A default implementation of {@link AwsS3V4HttpSigner}.
28+
*/
29+
@SdkInternalApi
30+
public class DefaultAwsS3V4HttpSigner implements AwsS3V4HttpSigner {
31+
32+
@Override
33+
public SyncSignedHttpRequest sign(SyncHttpSignRequest<? extends AwsCredentialsIdentity> request) {
34+
throw new UnsupportedOperationException();
35+
}
36+
37+
@Override
38+
public AsyncSignedHttpRequest signAsync(AsyncHttpSignRequest<? extends AwsCredentialsIdentity> request) {
39+
throw new UnsupportedOperationException();
40+
}
41+
}

core/http-auth-event-stream/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
<artifactId>http-auth-event-stream</artifactId>
2929
<name>AWS Java SDK :: HTTP Auth Event Stream</name>
3030
<description>
31-
The AWS SDK for Java - HTTP Auth module contains interfaces and implementations for http authentication
32-
specific to the event streams.
31+
The AWS SDK for Java - HTTP Auth Event Stream module contains interfaces and implementations
32+
for authentication of event streams in HTTP services.
3333
</description>
3434
<url>https://aws.amazon.com/sdkforjava</url>
3535

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,23 @@
1616
package software.amazon.awssdk.http.auth.eventstream;
1717

1818
import software.amazon.awssdk.annotations.SdkPublicApi;
19+
import software.amazon.awssdk.http.auth.eventstream.internal.DefaultAwsV4EventStreamHttpSigner;
1920
import software.amazon.awssdk.http.auth.spi.HttpSigner;
21+
import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity;
2022

23+
/**
24+
* An {@link HttpSigner} that will sign a request using an AWS credentials ({@link AwsCredentialsIdentity}),
25+
* specifically for Event Streams.
26+
*/
2127
@SdkPublicApi
22-
public interface AwsV4EventStreamHttpAuthScheme extends HttpSigner {
28+
public interface AwsV4EventStreamHttpSigner extends HttpSigner<AwsCredentialsIdentity> {
2329

30+
/**
31+
* Get a default implementation of a {@link AwsV4EventStreamHttpSigner}
32+
*
33+
* @return AwsV4EventStreamHttpSigner
34+
*/
35+
static AwsV4EventStreamHttpSigner create() {
36+
return new DefaultAwsV4EventStreamHttpSigner();
37+
}
2438
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.awssdk.http.auth.eventstream.internal;
17+
18+
import software.amazon.awssdk.annotations.SdkInternalApi;
19+
import software.amazon.awssdk.http.auth.eventstream.AwsV4EventStreamHttpSigner;
20+
import software.amazon.awssdk.http.auth.spi.AsyncHttpSignRequest;
21+
import software.amazon.awssdk.http.auth.spi.AsyncSignedHttpRequest;
22+
import software.amazon.awssdk.http.auth.spi.SyncHttpSignRequest;
23+
import software.amazon.awssdk.http.auth.spi.SyncSignedHttpRequest;
24+
import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity;
25+
26+
/**
27+
* A default implementation of {@link AwsV4EventStreamHttpSigner}.
28+
*/
29+
@SdkInternalApi
30+
public class DefaultAwsV4EventStreamHttpSigner implements AwsV4EventStreamHttpSigner {
31+
32+
@Override
33+
public SyncSignedHttpRequest sign(SyncHttpSignRequest<? extends AwsCredentialsIdentity> request) {
34+
throw new UnsupportedOperationException();
35+
}
36+
37+
@Override
38+
public AsyncSignedHttpRequest signAsync(AsyncHttpSignRequest<? extends AwsCredentialsIdentity> request) {
39+
throw new UnsupportedOperationException();
40+
}
41+
}

core/http-auth/pom.xml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
<artifactId>http-auth</artifactId>
2929
<name>AWS Java SDK :: HTTP Auth</name>
3030
<description>
31-
The AWS SDK for Java - HTTP Auth module contains interfaces and implementations for http authentication
31+
The AWS SDK for Java - HTTP Auth module contains interfaces and implementations
32+
for generic HTTP authentication
3233
</description>
3334
<url>https://aws.amazon.com/sdkforjava</url>
3435

@@ -43,6 +44,22 @@
4344
<artifactId>http-auth-spi</artifactId>
4445
<version>${awsjavasdk.version}</version>
4546
</dependency>
47+
<dependency>
48+
<groupId>software.amazon.awssdk</groupId>
49+
<artifactId>identity-spi</artifactId>
50+
<version>${awsjavasdk.version}</version>
51+
</dependency>
52+
53+
<dependency>
54+
<groupId>org.junit.jupiter</groupId>
55+
<artifactId>junit-jupiter</artifactId>
56+
<scope>test</scope>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.assertj</groupId>
60+
<artifactId>assertj-core</artifactId>
61+
<scope>test</scope>
62+
</dependency>
4663
</dependencies>
4764

4865
<build>

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,22 @@
1616
package software.amazon.awssdk.http.auth;
1717

1818
import software.amazon.awssdk.annotations.SdkPublicApi;
19+
import software.amazon.awssdk.http.auth.internal.DefaultAwsV4HttpSigner;
1920
import software.amazon.awssdk.http.auth.spi.HttpSigner;
21+
import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity;
2022

23+
/**
24+
* An {@link HttpSigner} that will sign a request using an AWS credentials {@link AwsCredentialsIdentity}).
25+
*/
2126
@SdkPublicApi
22-
public interface AwsV4HttpSigner extends HttpSigner {
27+
public interface AwsV4HttpSigner extends HttpSigner<AwsCredentialsIdentity> {
2328

29+
/**
30+
* Get a default implementation of a {@link AwsV4HttpSigner}
31+
*
32+
* @return AwsV4HttpSigner
33+
*/
34+
static AwsV4HttpSigner create() {
35+
return new DefaultAwsV4HttpSigner();
36+
}
2437
}

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,23 @@
1616
package software.amazon.awssdk.http.auth;
1717

1818
import software.amazon.awssdk.annotations.SdkPublicApi;
19+
import software.amazon.awssdk.http.auth.internal.DefaultAwsV4QueryHttpSigner;
1920
import software.amazon.awssdk.http.auth.spi.HttpSigner;
21+
import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity;
2022

23+
/**
24+
* An {@link HttpSigner} that will sign a request using an AWS credentials ({@link AwsCredentialsIdentity}),
25+
* specifically for query.
26+
*/
2127
@SdkPublicApi
22-
public interface AwsV4QueryHttpSigner extends HttpSigner {
28+
public interface AwsV4QueryHttpSigner extends HttpSigner<AwsCredentialsIdentity> {
2329

30+
/**
31+
* Get a default implementation of a {@link AwsV4QueryHttpSigner}
32+
*
33+
* @return AwsV4QueryHttpSigner
34+
*/
35+
static AwsV4QueryHttpSigner create() {
36+
return new DefaultAwsV4QueryHttpSigner();
37+
}
2438
}

0 commit comments

Comments
 (0)