NIFI-11360 Support Client-Side Encryption for Azure Blob v12 Processors#7182
NIFI-11360 Support Client-Side Encryption for Azure Blob v12 Processors#7182mkalavala wants to merge 4 commits intoapache:mainfrom
Conversation
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for working on this new feature @mkalavala!
Although the approach is similar to the legacy implementation, this is a good opportunity to make some improvements. I noted some naming and implementation recommendations in several places. I also recommend removing the integration tests since they are not run automatically and can get stale quickly.
...rocessors/src/main/java/org/apache/nifi/processors/azure/AbstractAzureBlobProcessor_v12.java
Outdated
Show resolved
Hide resolved
...rocessors/src/main/java/org/apache/nifi/processors/azure/AbstractAzureBlobProcessor_v12.java
Outdated
Show resolved
Hide resolved
.../org/apache/nifi/processors/azure/storage/utils/AzureBlobClientSideEncryptionMethod_v12.java
Outdated
Show resolved
Hide resolved
.../org/apache/nifi/processors/azure/storage/utils/AzureBlobClientSideEncryptionMethod_v12.java
Outdated
Show resolved
Hide resolved
.../org/apache/nifi/processors/azure/storage/utils/AzureBlobClientSideEncryptionMethod_v12.java
Outdated
Show resolved
Hide resolved
| .name("cse-key-type") | ||
| .displayName("Client-Side Encryption Key Type") |
There was a problem hiding this comment.
Although the conventions are not consistent, in this case, the new properties can have the same name and displayName.
| .name("cse-key-type") | |
| .displayName("Client-Side Encryption Key Type") | |
| .name("Client-Side Encryption Key Type") | |
| .displayName("Client-Side Encryption Key Type") |
...a/org/apache/nifi/processors/azure/storage/utils/AzureBlobClientSideEncryptionUtils_v12.java
Outdated
Show resolved
Hide resolved
...a/org/apache/nifi/processors/azure/storage/utils/AzureBlobClientSideEncryptionUtils_v12.java
Outdated
Show resolved
Hide resolved
...a/org/apache/nifi/processors/azure/storage/utils/AzureBlobClientSideEncryptionUtils_v12.java
Outdated
Show resolved
Hide resolved
...s/src/test/java/org/apache/nifi/processors/azure/storage/AbstractAzureBlobStorage_v12IT.java
Show resolved
Hide resolved
…s-api This closes apache#7186 Signed-off-by: David Handermann <exceptionfactory@apache.org> (cherry picked from commit 8586ac5)
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for the updates @mkalavala! Functional behavior works as expected, and these changes interoperate with the earlier versions of the Processors. I noted some additional wording and style adjustments, but otherwise this looks close to completion.
| byte[] keyBytes; | ||
| try { | ||
| keyBytes = Hex.decodeHex(keyHex); |
There was a problem hiding this comment.
The declaration and assignment can be merged.
| byte[] keyBytes; | |
| try { | |
| keyBytes = Hex.decodeHex(keyHex); | |
| try { | |
| final byte[] keyBytes = Hex.decodeHex(keyHex); |
| keyBytes = Hex.decodeHex(keyHex); | ||
| if (getKeyWrapAlgorithm(keyBytes) == null) { | ||
| validationResults.add(new ValidationResult.Builder().subject(CSE_LOCAL_KEY_HEX.getDisplayName()) | ||
| .explanation("the local key must be 128, 192, 256, 384 or 512 bits of data.").build()); |
There was a problem hiding this comment.
Recommend adjusting the wording and including the actual length.
| .explanation("the local key must be 128, 192, 256, 384 or 512 bits of data.").build()); | |
| .explanation(String.format("Key size in bits must be one of [128, 192, 256, 384, 512] instead of [%d]", keyBytes.length * 8)).build()); |
| } | ||
| } catch (DecoderException e) { | ||
| validationResults.add(new ValidationResult.Builder().subject(CSE_LOCAL_KEY_HEX.getDisplayName()) | ||
| .explanation("the local key must be a valid hexadecimal string.").build()); |
There was a problem hiding this comment.
| .explanation("the local key must be a valid hexadecimal string.").build()); | |
| .explanation("Key must be a valid hexadecimal string").build()); |
| final List<ValidationResult> validationResults = new ArrayList<>(); | ||
| if (StringUtils.isBlank(keyHex)) { | ||
| validationResults.add(new ValidationResult.Builder().subject(CSE_LOCAL_KEY_HEX.getDisplayName()) | ||
| .explanation("a local key must be set when client-side encryption is enabled with local encryption.").build()); |
There was a problem hiding this comment.
| .explanation("a local key must be set when client-side encryption is enabled with local encryption.").build()); | |
| .explanation("a local key must be set when client-side encryption is enabled").build()); |
| final String cseLocalKeyHex = validationContext.getProperty(CSE_LOCAL_KEY_HEX).getValue(); | ||
| if (cseKeyType != ClientSideEncryptionMethod.NONE && StringUtils.isBlank(cseKeyId)) { | ||
| validationResults.add(new ValidationResult.Builder().subject(CSE_KEY_ID.getDisplayName()) | ||
| .explanation("a key ID must be set when client-side encryption is enabled.").build()); |
There was a problem hiding this comment.
| .explanation("a key ID must be set when client-side encryption is enabled.").build()); | |
| .explanation("a key ID must be set when client-side encryption is enabled").build()); |
| .dependsOn(CSE_KEY_TYPE, ClientSideEncryptionMethod.LOCAL.name()) | ||
| .build(); | ||
|
|
||
| PropertyDescriptor CSE_LOCAL_KEY_HEX = new PropertyDescriptor.Builder() |
There was a problem hiding this comment.
| PropertyDescriptor CSE_LOCAL_KEY_HEX = new PropertyDescriptor.Builder() | |
| PropertyDescriptor CSE_LOCAL_KEY = new PropertyDescriptor.Builder() |
| .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) |
There was a problem hiding this comment.
This can be changed to required(true) since it depends on the Local Type, which should remove the need for custom validation.
| .name("cse-local-key-hex") | ||
| .displayName("Client-Side Encryption Local Key") | ||
| .description("When using local client-side encryption, this is the raw key, encoded in hexadecimal") | ||
| .required(false) |
There was a problem hiding this comment.
| .required(false) | |
| .required(true) |
| CSE_KEY_ID, | ||
| CSE_KEY_TYPE, |
There was a problem hiding this comment.
The Key Type should be listed before the Key ID:
| CSE_KEY_ID, | |
| CSE_KEY_TYPE, | |
| CSE_KEY_TYPE, | |
| CSE_KEY_ID, |
| CSE_KEY_ID, | ||
| CSE_KEY_TYPE, |
There was a problem hiding this comment.
| CSE_KEY_ID, | |
| CSE_KEY_TYPE, | |
| CSE_KEY_TYPE, | |
| CSE_KEY_ID, |
|
@mkalavala I also cherry-picked the fix from NIFI-11475 on to the pull request branch to correct a missing runtime dependency on jackson-dataformat-xml, which is already corrected in the main branch. |
exceptionfactory
left a comment
There was a problem hiding this comment.
Thanks for the updates @mkalavala, the latest version looks good! +1 merging
Summary
NIFI-11360
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000Pull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation