Skip to content
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

Add flexible checksum support for chunked-encoding cases #4383

Conversation

haydenbaker
Copy link
Contributor

Motivation and Context

Modifications

  • Updates AwsChunkedEncodedInputStream to take a checksum-algorithm parameter
  • Flexible checksum is now added to the encoded stream as a trailer
  • Pre-existing trailers on the request (which there are none today) will be added as trailers to the stream (and removed from the request) as well

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the CONTRIBUTING document
  • Local run of mvn install succeeds
  • My code follows the code style of this project
  • My change requires a change to the Javadoc documentation
  • [] I have updated the Javadoc documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed
  • I have added a changelog entry. Adding a new entry must be accomplished by running the scripts/new-change script and following the instructions. Commit the new file created by the script in .changes/next-release with your changes.
  • My change is to implement 1.11 parity feature and I have updated LaunchChangelog

License

  • I confirm that this pull request can be released under the Apache 2 license

@haydenbaker haydenbaker requested a review from a team as a code owner August 31, 2023 23:53

public AwsChunkedV4PayloadSigner(CredentialScope credentialScope, int chunkSize) {
public AwsChunkedV4PayloadSigner(CredentialScope credentialScope, int chunkSize, ChecksumAlgorithm checksumAlgorithm) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change this to a builder.

@haydenbaker haydenbaker force-pushed the haydenbaker/sra-ia-awssigners-flexible-checksums branch from eb70caa to 3124558 Compare September 1, 2023 16:20
credentialScope.getDatetime(),
credentialScope.scope(),
previousSignature,
toHex(hash(getCanonicalHeadersString(getCanonicalHeaders(headers))))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chained methods are a bit hard to read, can we create variables?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll break it up

* <p>
* The checksum-algorithm MUST be set if this is called, otherwise it will throw.
*/
private void setupChecksumTrailer(ChunkedEncodedInputStream.Builder builder, SdkHttpRequest.Builder request) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can rename it to setUpChecksumTrailerIfNeeded and return if checksumAlgorithm is null? Then we can remove the checksumAlgorithm null check from the callers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, if that's an established naming pattern, I can do that

Base automatically changed from haydenbaker/sra-ia-awssigners-flexible-checksums to feature/master/sra-identity-auth September 6, 2023 16:34
@haydenbaker haydenbaker force-pushed the haydenbaker/sra-ia-awssigners-flexible-checksums-chunked branch from f5a1a44 to fec7712 Compare September 6, 2023 16:42
public interface Builder {
Builder credentialScope(CredentialScope credentialScope);

Builder chunkSize(int chunkSize);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be boxed type so that we can throw an exception or set a default if the caller doesn't set it.

@sonarcloud
Copy link

sonarcloud bot commented Sep 6, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug C 5 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot E 2 Security Hotspots
Code Smell A 370 Code Smells

0.0% 0.0% Coverage
9.0% 9.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@haydenbaker haydenbaker merged commit 8f7070b into feature/master/sra-identity-auth Sep 7, 2023
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants