Skip to content

Commit

Permalink
keep it consistent with C and others. Just skip signing if no config … (
Browse files Browse the repository at this point in the history
#640)

* keep it consistent with C and others. Just skip signing if no config provided.
  • Loading branch information
TingDaoK committed Jun 16, 2023
1 parent d050a0c commit 642ae05
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public CredentialsProvider getCredentialsProvider() {
/**
* The configuration related to signing used by S3 client.
* `AwsSigningConfig.getDefaultS3SigningConfig(region, credentialsProvider);` can be used as helper to create the default configuration to be used for S3.
* If no signing config provided, the client will skip signing.
* In case of public object, or the http message already has a presigned URL, signing can be skipped.
*
* @param signingConfig configuration related to signing via an AWS signing process.
* @return this
Expand Down
18 changes: 7 additions & 11 deletions src/native/s3_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,12 @@ JNIEXPORT jlong JNICALL Java_software_amazon_awssdk_crt_s3_S3Client_s3ClientNew(

struct aws_signing_config_aws signing_config;
AWS_ZERO_STRUCT(signing_config);
if (java_signing_config == NULL) {
aws_jni_throw_illegal_argument_exception(env, "Missing signingConfig");
aws_mem_release(allocator, callback_data);
return (jlong)NULL;
}

if (aws_build_signing_config(env, java_signing_config, &callback_data->signing_config_data, &signing_config)) {
aws_jni_throw_runtime_exception(env, "Invalid signingConfig");
aws_mem_release(allocator, callback_data);
return (jlong)NULL;
if (java_signing_config != NULL) {
if (aws_build_signing_config(env, java_signing_config, &callback_data->signing_config_data, &signing_config)) {
aws_jni_throw_runtime_exception(env, "Invalid signingConfig");
aws_mem_release(allocator, callback_data);
return (jlong)NULL;
}
}

AWS_FATAL_ASSERT(callback_data);
Expand All @@ -193,7 +189,7 @@ JNIEXPORT jlong JNICALL Java_software_amazon_awssdk_crt_s3_S3Client_s3ClientNew(
.region = region,
.client_bootstrap = client_bootstrap,
.tls_connection_options = tls_options,
.signing_config = &signing_config,
.signing_config = java_signing_config == NULL ? NULL : &signing_config,
.part_size = part_size,
.multipart_upload_threshold = multipart_upload_threshold,
.throughput_target_gbps = throughput_target_gbps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void testS3ClientCreateDestroyWithCredentialsProvider() {
}

@Test
public void testS3ClientCreateDestroyWithoutSigningConfig() {
public void testS3ClientCreateDestroyWithoutSigningConfig() throws Exception {
skipIfNetworkUnavailable();
try (EventLoopGroup elg = new EventLoopGroup(0, 1);
HostResolver hostResolver = new HostResolver(elg);
Expand All @@ -129,8 +129,6 @@ public void testS3ClientCreateDestroyWithoutSigningConfig() {
.withClientBootstrap(clientBootstrap);
try (S3Client client = new S3Client(clientOptions)) {

} catch (IllegalArgumentException ex) {
assertNotNull(ex);
}
}
}
Expand Down

0 comments on commit 642ae05

Please sign in to comment.