-
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
Merged
gosar
merged 18 commits into
feature/master/sra-identity-auth
from
gosar/sra-ia-signer-interface-updates-2
May 24, 2023
Merged
Changes from 7 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2fffa5a
Fix generics related warning in Signer interfaces
gosar f1cf80f
Remove <T> for HttpAuthOption.Builder.schemeId
gosar 0690ad8
Remove wildcards from sign methods
gosar daaf834
Make Identity explicit in HttpSignRequest
gosar d9c7ac9
Make IdentityT type extend Identity in HttpSigner
gosar b5c989f
Add consumer builder pattern to HttpSigner methods
gosar 33a9b04
Add test to show HttpSigner usage
gosar fc79989
Note identityType parameter is ignored in HttpSignRequest.builder
gosar e1cc7bc
Use separate interfaces for sync and async sign requests
gosar 74e085b
Use abstract DefaultHttpSignRequest to avoid duplication
gosar 80bc11c
Split sync/async interfaces for SignedHttpRequest
gosar ab7fdd8
Minor fixes
gosar a6b7f64
Make protected properties Map an unmodifiableMap
gosar de704e7
Remove overriding in HttpSignRequest.Builder sub-interfaces
gosar 3e24cc4
Remove overriding in SignedHttpRequest.Builder sub-interfaces
gosar 8d5ee7e
Allow sign methods take request with subtype of the IdentityT
gosar a8ef98f
Make HttpSignRequest @SdkProtectedApi
gosar 6f9d3d1
Make HttpSignRequest @SdkPublicApi
gosar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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); | ||
} | ||
|
||
/** | ||
|
@@ -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>> { | ||
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. Same comment here. |
||
|
||
/** | ||
* 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); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo, this should implement
ToCopyableBuilder
and its builder should implementCopyableBuilder
. That prevents some issues here, like needing to remember to override every parent method in the child class.Unfortunately it makes the parameters on this type even crazier.
To make the room, we could change
IdentityT identity()
toIdentity identity()
andOptional<PayloadT> payload()
toOptional<? extends Object> payload()
, and then override them in the child types to return the exact types. Even better, we might just remove the getters from here entirely and rely on the subtype. I don't expect it to be a major problem to need to use the subtype to get access to the payload or identity.We'd also need to remove the
payload
andidentity
setters from this base builder, but that's probably okay - we can just put them in the child types. It should be very rare that someone needs to set the identity or payload using the base builder type...There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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?