Skip to content

Commit

Permalink
Move signer back to being protected
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenbaker committed Sep 5, 2023
1 parent 386ee09 commit 25cdb4a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.awssdk.http.auth.aws.crt.internal.signer;
package software.amazon.awssdk.http.auth.aws.crt;

import static software.amazon.awssdk.crt.auth.signing.AwsSigningConfig.AwsSignatureType.HTTP_REQUEST_VIA_QUERY_PARAMS;
import static software.amazon.awssdk.crt.auth.signing.AwsSigningConfig.AwsSignedBodyHeaderType.X_AMZ_CONTENT_SHA256;
Expand All @@ -33,15 +33,18 @@
import java.time.Duration;
import java.time.Instant;
import java.util.concurrent.CompletableFuture;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.annotations.SdkProtectedApi;
import software.amazon.awssdk.crt.auth.signing.AwsSigner;
import software.amazon.awssdk.crt.auth.signing.AwsSigningConfig;
import software.amazon.awssdk.crt.auth.signing.AwsSigningResult;
import software.amazon.awssdk.crt.http.HttpRequest;
import software.amazon.awssdk.http.ContentStreamProvider;
import software.amazon.awssdk.http.SdkHttpRequest;
import software.amazon.awssdk.http.auth.aws.AwsV4HttpSigner;
import software.amazon.awssdk.http.auth.aws.AwsV4aHttpSigner;
import software.amazon.awssdk.http.auth.aws.crt.internal.signer.AwsChunkedV4aPayloadSigner;
import software.amazon.awssdk.http.auth.aws.crt.internal.signer.V4aContext;
import software.amazon.awssdk.http.auth.aws.crt.internal.signer.V4aPayloadSigner;
import software.amazon.awssdk.http.auth.aws.crt.internal.signer.V4aProperties;
import software.amazon.awssdk.http.auth.aws.signer.CredentialScope;
import software.amazon.awssdk.http.auth.aws.util.CredentialUtils;
import software.amazon.awssdk.http.auth.spi.AsyncSignRequest;
Expand All @@ -56,20 +59,20 @@
* An implementation of a {@link AwsV4aHttpSigner} that uses properties to compose v4a-signers in order to delegate signing of a
* request and payload (if applicable) accordingly.
*/
@SdkInternalApi
@SdkProtectedApi
public final class DefaultAwsCrtV4aHttpSigner implements AwsV4aHttpSigner {

private static final int DEFAULT_CHUNK_SIZE_IN_BYTES = 128 * 1024;

private static V4aProperties v4aProperties(SignRequest<?, ? extends AwsCredentialsIdentity> request) {
Clock signingClock = request.requireProperty(AwsV4HttpSigner.SIGNING_CLOCK, Clock.systemUTC());
Clock signingClock = request.requireProperty(SIGNING_CLOCK, Clock.systemUTC());
Instant signingInstant = signingClock.instant();
AwsCredentialsIdentity credentials = sanitizeCredentials(request.identity());
String regionName = request.requireProperty(AwsV4HttpSigner.REGION_NAME);
String serviceSigningName = request.requireProperty(AwsV4HttpSigner.SERVICE_SIGNING_NAME);
String regionName = request.requireProperty(REGION_NAME);
String serviceSigningName = request.requireProperty(SERVICE_SIGNING_NAME);
CredentialScope credentialScope = new CredentialScope(regionName, serviceSigningName, signingInstant);
boolean doubleUrlEncode = request.requireProperty(AwsV4HttpSigner.DOUBLE_URL_ENCODE, true);
boolean normalizePath = request.requireProperty(AwsV4HttpSigner.NORMALIZE_PATH, true);
boolean doubleUrlEncode = request.requireProperty(DOUBLE_URL_ENCODE, true);
boolean normalizePath = request.requireProperty(NORMALIZE_PATH, true);

return V4aProperties
.builder()
Expand All @@ -95,8 +98,6 @@ private static V4aPayloadSigner v4aPayloadSigner(
}

private static boolean hasTrailer(SdkHttpRequest request) {
// TODO: Trailer would be determined by being a flexible-checksum enabled request, we will need to update
// this once flexible checksums is enabled
return request.firstMatchingHeader(X_AMZ_TRAILER).isPresent();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* permissions and limitations under the License.
*/

package software.amazon.awssdk.http.auth.aws.crt.internal.signer;
package software.amazon.awssdk.http.auth.aws.crt;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNull;
Expand All @@ -32,7 +32,6 @@
import software.amazon.awssdk.crt.auth.signing.AwsSigningConfig;
import software.amazon.awssdk.http.Header;
import software.amazon.awssdk.http.auth.aws.AwsV4HttpSigner;
import software.amazon.awssdk.http.auth.aws.crt.TestUtils;
import software.amazon.awssdk.http.auth.spi.AsyncSignRequest;
import software.amazon.awssdk.http.auth.spi.SyncSignRequest;
import software.amazon.awssdk.http.auth.spi.SyncSignedRequest;
Expand Down

0 comments on commit 25cdb4a

Please sign in to comment.