Skip to content

Conversation

@aajtodd
Copy link
Contributor

@aajtodd aajtodd commented Sep 17, 2021

Issue #, if available:
N/A

Description of changes:

  • expose sigva algorithm and add sign() method that returns an AwsSigningResult

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Comment on lines +30 to +46
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other == null || this::class != other::class) return false

other as AwsSigningResult

if (signedRequest != other.signedRequest) return false
if (!signature.contentEquals(other.signature)) return false

return true
}

override fun hashCode(): Int {
var result = signedRequest?.hashCode() ?: 0
result = 31 * result + signature.contentHashCode()
return result
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Why are these custom equals/hashCode implementations necessary? They seem identical to what I'd expect from the default implementations in a data class.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

^^ yup that's why

Comment on lines +33 to +34
public actual suspend fun signRequest(request: HttpRequest, config: AwsSigningConfig): HttpRequest =
checkNotNull(sign(request, config).signedRequest) { "AwsSigningResult request must not be null" }
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: What circumstances could lead to the signing result's request being null? Looking through the code I can't see how that would occur.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on the comments from crt-java:
https://github.com/awslabs/aws-crt-java/blob/main/src/main/java/software/amazon/awssdk/crt/auth/signing/AwsSigningResult.java#L15-L19

I think it's due to the flexibility in the signing implementation but in practice it shouldn't be null the way we use it. Or at least that's my understanding.

@aajtodd aajtodd merged commit 74f6a6e into main Sep 27, 2021
@aajtodd aajtodd deleted the refactor-auth-pkg branch September 27, 2021 17:35
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