This is an automated email from the ASF dual-hosted git repository. daim pushed a commit to branch OAK-10093 in repository https://gitbox.apache.org/repos/asf/jackrabbit-oak.git
commit 91db3d4f163ecf4869f76926b26eaa604b72b8bd Author: Rishabh Kumar <[email protected]> AuthorDate: Mon Jun 5 14:18:29 2023 +0530 OAK-10093 : replaces if/else block with switch statement --- .../oak/blob/cloud/s3/S3RequestDecorator.java | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3RequestDecorator.java b/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3RequestDecorator.java index af670c436b..8e66124a20 100644 --- a/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3RequestDecorator.java +++ b/oak-blob-cloud/src/main/java/org/apache/jackrabbit/oak/blob/cloud/s3/S3RequestDecorator.java @@ -28,13 +28,14 @@ import com.amazonaws.services.s3.model.SSEAlgorithm; import com.amazonaws.services.s3.model.SSEAwsKeyManagementParams; import com.amazonaws.services.s3.model.SSECustomerKey; -import java.util.Objects; - import static com.amazonaws.services.s3.model.SSEAlgorithm.AES256; import static com.amazonaws.util.StringUtils.hasValue; import static java.nio.charset.StandardCharsets.UTF_8; +import static org.apache.jackrabbit.oak.blob.cloud.s3.S3Constants.S3_ENCRYPTION; import static org.apache.jackrabbit.oak.blob.cloud.s3.S3Constants.S3_ENCRYPTION_SSE_C; +import static org.apache.jackrabbit.oak.blob.cloud.s3.S3Constants.S3_ENCRYPTION_SSE_KMS; import static org.apache.jackrabbit.oak.blob.cloud.s3.S3Constants.S3_SSE_C_KEYID; +import static org.apache.jackrabbit.oak.blob.cloud.s3.S3Constants.S3_SSE_KMS_KEYID; /** * This class to sets encrption mode in S3 request. @@ -48,20 +49,25 @@ public class S3RequestDecorator { SSECustomerKey sseCustomerKey; public S3RequestDecorator(Properties props) { - String encryptionType = props.getProperty(S3Constants.S3_ENCRYPTION); + final String encryptionType = props.getProperty(S3_ENCRYPTION); if (encryptionType != null) { this.dataEncryption = DataEncryption.valueOf(encryptionType); - if (encryptionType.equals(S3Constants.S3_ENCRYPTION_SSE_KMS)) { - String keyId = props.getProperty(S3Constants.S3_SSE_KMS_KEYID); - sseParams = new SSEAwsKeyManagementParams(); - if (hasValue(keyId)) { - sseParams.withAwsKmsKeyId(keyId); + switch (encryptionType) { + case S3_ENCRYPTION_SSE_KMS: { + final String keyId = props.getProperty(S3_SSE_KMS_KEYID); + sseParams = new SSEAwsKeyManagementParams(); + if (hasValue(keyId)) { + sseParams.withAwsKmsKeyId(keyId); + } + break; } - } else if (Objects.equals(S3_ENCRYPTION_SSE_C, encryptionType)) { - final String keyId = props.getProperty(S3_SSE_C_KEYID); - if (hasValue(keyId)) { - sseCustomerKey = new SSECustomerKey(keyId.getBytes(UTF_8)); + case S3_ENCRYPTION_SSE_C: { + final String keyId = props.getProperty(S3_SSE_C_KEYID); + if (hasValue(keyId)) { + sseCustomerKey = new SSECustomerKey(keyId.getBytes(UTF_8)); + } + break; } } }
