gschaer commented on a change in pull request #5078: URL: https://github.com/apache/nifi/pull/5078#discussion_r659369388
########## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/utils/AzureBlobClientSideEncryptionUtils.java ########## @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.processors.azure.storage.utils; + +import com.google.common.base.Strings; +import com.microsoft.azure.keyvault.cryptography.SymmetricKey; +import org.apache.commons.codec.DecoderException; +import org.apache.commons.codec.binary.Hex; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.util.StandardValidators; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class AzureBlobClientSideEncryptionUtils { + public static final PropertyDescriptor CSE_KEY_TYPE = new PropertyDescriptor.Builder() + .name("cse-key-type") + .displayName("Client-Side Encryption key type") + .required(true) + .allowableValues(buildCseEncryptionMethodAllowableValues()) + .defaultValue(AzureBlobClientSideEncryptionMethod.NONE.name()) + .description("Specifies the key type to use for client-side encryption.") + .build(); + + public static final PropertyDescriptor CSE_KEY_ID = new PropertyDescriptor.Builder() + .name("cse-key-id") + .displayName("Client-Side Encryption key ID") + .description("Specifies the ID of the key to use for client-side encryption.") + .expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES) + .required(false) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) Review comment: Fixed in b15cfdc ########## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/utils/AzureBlobClientSideEncryptionUtils.java ########## @@ -0,0 +1,116 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.processors.azure.storage.utils; + +import com.google.common.base.Strings; +import com.microsoft.azure.keyvault.cryptography.SymmetricKey; +import org.apache.commons.codec.DecoderException; +import org.apache.commons.codec.binary.Hex; +import org.apache.nifi.components.AllowableValue; +import org.apache.nifi.components.PropertyDescriptor; +import org.apache.nifi.components.ValidationContext; +import org.apache.nifi.components.ValidationResult; +import org.apache.nifi.expression.ExpressionLanguageScope; +import org.apache.nifi.processor.util.StandardValidators; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +public class AzureBlobClientSideEncryptionUtils { + public static final PropertyDescriptor CSE_KEY_TYPE = new PropertyDescriptor.Builder() Review comment: Fixed in b15cfdc ########## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/test/java/org/apache/nifi/processors/azure/storage/ITListAzureBlobStorage.java ########## @@ -20,11 +20,18 @@ import org.apache.nifi.util.MockFlowFile; import org.junit.Before; import org.junit.Test; - +// import org.junit.runner.RunWith; +// import org.junit.runners.Parameterized; Review comment: Fixed in b15cfdc ########## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/test/java/org/apache/nifi/processors/azure/storage/ITListAzureBlobStorage.java ########## @@ -20,11 +20,18 @@ import org.apache.nifi.util.MockFlowFile; import org.junit.Before; import org.junit.Test; - +// import org.junit.runner.RunWith; +// import org.junit.runners.Parameterized; import java.util.concurrent.TimeUnit; +// @RunWith(Parameterized.class) Review comment: Fixed in b15cfdc ########## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/test/java/org/apache/nifi/processors/azure/storage/ITPutAzureBlobStorage.java ########## @@ -48,6 +59,74 @@ public void testPutBlob() throws Exception { assertResult(); } + @Test + public void testPutBlob64BSymmetricCSE() throws Exception { + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_TYPE, AzureBlobClientSideEncryptionMethod.SYMMETRIC.name()); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_ID, KEY_ID_VALUE); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_SYMMETRIC_KEY_HEX, KEY_64B_VALUE); + runner.assertNotValid(); + } + + @Test + public void testPutBlob128BSymmetricCSE() throws Exception { + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_TYPE, AzureBlobClientSideEncryptionMethod.SYMMETRIC.name()); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_ID, KEY_ID_VALUE); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_SYMMETRIC_KEY_HEX, KEY_128B_VALUE); + runner.assertValid(); + runner.enqueue("0123456789".getBytes()); + runner.run(); + + assertResult(); + } + + @Test + public void testPutBlob192BSymmetricCSE() throws Exception { + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_TYPE, AzureBlobClientSideEncryptionMethod.SYMMETRIC.name()); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_ID, KEY_ID_VALUE); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_SYMMETRIC_KEY_HEX, KEY_192B_VALUE); + runner.assertValid(); + runner.enqueue("0123456789".getBytes()); + runner.run(); + + assertResult(); + } + + @Test + public void testPutBlob256BSymmetricCSE() throws Exception { + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_TYPE, AzureBlobClientSideEncryptionMethod.SYMMETRIC.name()); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_ID, KEY_ID_VALUE); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_SYMMETRIC_KEY_HEX, KEY_256B_VALUE); + runner.assertValid(); + runner.enqueue("0123456789".getBytes()); Review comment: Fixed in b15cfdc ########## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/test/java/org/apache/nifi/processors/azure/storage/ITPutAzureBlobStorage.java ########## @@ -48,6 +59,74 @@ public void testPutBlob() throws Exception { assertResult(); } + @Test + public void testPutBlob64BSymmetricCSE() throws Exception { + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_TYPE, AzureBlobClientSideEncryptionMethod.SYMMETRIC.name()); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_ID, KEY_ID_VALUE); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_SYMMETRIC_KEY_HEX, KEY_64B_VALUE); + runner.assertNotValid(); + } + + @Test + public void testPutBlob128BSymmetricCSE() throws Exception { + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_TYPE, AzureBlobClientSideEncryptionMethod.SYMMETRIC.name()); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_ID, KEY_ID_VALUE); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_SYMMETRIC_KEY_HEX, KEY_128B_VALUE); + runner.assertValid(); + runner.enqueue("0123456789".getBytes()); + runner.run(); + + assertResult(); + } + + @Test + public void testPutBlob192BSymmetricCSE() throws Exception { + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_TYPE, AzureBlobClientSideEncryptionMethod.SYMMETRIC.name()); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_ID, KEY_ID_VALUE); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_SYMMETRIC_KEY_HEX, KEY_192B_VALUE); + runner.assertValid(); + runner.enqueue("0123456789".getBytes()); + runner.run(); + + assertResult(); + } + + @Test + public void testPutBlob256BSymmetricCSE() throws Exception { + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_TYPE, AzureBlobClientSideEncryptionMethod.SYMMETRIC.name()); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_ID, KEY_ID_VALUE); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_SYMMETRIC_KEY_HEX, KEY_256B_VALUE); + runner.assertValid(); + runner.enqueue("0123456789".getBytes()); + runner.run(); + + assertResult(); + } + + @Test + public void testPutBlob384BSymmetricCSE() throws Exception { + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_TYPE, AzureBlobClientSideEncryptionMethod.SYMMETRIC.name()); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_ID, KEY_ID_VALUE); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_SYMMETRIC_KEY_HEX, KEY_384B_VALUE); + runner.assertValid(); + runner.enqueue("0123456789".getBytes()); Review comment: Fixed in b15cfdc ########## File path: nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/test/java/org/apache/nifi/processors/azure/storage/ITPutAzureBlobStorage.java ########## @@ -48,6 +59,74 @@ public void testPutBlob() throws Exception { assertResult(); } + @Test + public void testPutBlob64BSymmetricCSE() throws Exception { + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_TYPE, AzureBlobClientSideEncryptionMethod.SYMMETRIC.name()); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_ID, KEY_ID_VALUE); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_SYMMETRIC_KEY_HEX, KEY_64B_VALUE); + runner.assertNotValid(); + } + + @Test + public void testPutBlob128BSymmetricCSE() throws Exception { + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_TYPE, AzureBlobClientSideEncryptionMethod.SYMMETRIC.name()); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_ID, KEY_ID_VALUE); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_SYMMETRIC_KEY_HEX, KEY_128B_VALUE); + runner.assertValid(); + runner.enqueue("0123456789".getBytes()); + runner.run(); + + assertResult(); + } + + @Test + public void testPutBlob192BSymmetricCSE() throws Exception { + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_TYPE, AzureBlobClientSideEncryptionMethod.SYMMETRIC.name()); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_ID, KEY_ID_VALUE); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_SYMMETRIC_KEY_HEX, KEY_192B_VALUE); + runner.assertValid(); + runner.enqueue("0123456789".getBytes()); + runner.run(); + + assertResult(); + } + + @Test + public void testPutBlob256BSymmetricCSE() throws Exception { + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_TYPE, AzureBlobClientSideEncryptionMethod.SYMMETRIC.name()); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_ID, KEY_ID_VALUE); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_SYMMETRIC_KEY_HEX, KEY_256B_VALUE); + runner.assertValid(); + runner.enqueue("0123456789".getBytes()); + runner.run(); + + assertResult(); + } + + @Test + public void testPutBlob384BSymmetricCSE() throws Exception { + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_TYPE, AzureBlobClientSideEncryptionMethod.SYMMETRIC.name()); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_ID, KEY_ID_VALUE); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_SYMMETRIC_KEY_HEX, KEY_384B_VALUE); + runner.assertValid(); + runner.enqueue("0123456789".getBytes()); + runner.run(); + + assertResult(); + } + + @Test + public void testPutBlob512BSymmetricCSE() throws Exception { + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_TYPE, AzureBlobClientSideEncryptionMethod.SYMMETRIC.name()); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_KEY_ID, KEY_ID_VALUE); + runner.setProperty(AzureBlobClientSideEncryptionUtils.CSE_SYMMETRIC_KEY_HEX, KEY_512B_VALUE); + runner.assertValid(); + runner.enqueue("0123456789".getBytes()); Review comment: Fixed in b15cfdc -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
