turcsanyip commented on a change in pull request #4843:
URL: https://github.com/apache/nifi/pull/4843#discussion_r585093599



##########
File path: 
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/storage/ADLSCredentialsControllerService.java
##########
@@ -93,20 +137,41 @@
     protected Collection<ValidationResult> customValidate(ValidationContext 
validationContext) {
         final List<ValidationResult> results = new ArrayList<>();
 
-        boolean accountKeySet = 
StringUtils.isNotBlank(validationContext.getProperty(AzureStorageUtils.ACCOUNT_KEY).getValue());
-        boolean sasTokenSet = 
StringUtils.isNotBlank(validationContext.getProperty(AzureStorageUtils.PROP_SAS_TOKEN).getValue());
+        boolean accountKeySet = 
StringUtils.isNotBlank(validationContext.getProperty(ACCOUNT_KEY).getValue());
+        boolean sasTokenSet = 
StringUtils.isNotBlank(validationContext.getProperty(SAS_TOKEN).getValue());
         boolean useManagedIdentitySet = 
validationContext.getProperty(USE_MANAGED_IDENTITY).asBoolean();
 
-        if (!onlyOneSet(accountKeySet, sasTokenSet, useManagedIdentitySet)) {
-            StringJoiner options = new StringJoiner(", ")
-                .add(AzureStorageUtils.ACCOUNT_KEY.getDisplayName())
-                .add(AzureStorageUtils.PROP_SAS_TOKEN.getDisplayName())
-                .add(USE_MANAGED_IDENTITY.getDisplayName());
+        boolean servicePrincipalTenantIdSet = 
StringUtils.isNotBlank(validationContext.getProperty(SERVICE_PRINCIPAL_TENANT_ID).getValue());
+        boolean servicePrincipalClientIdSet = 
StringUtils.isNotBlank(validationContext.getProperty(SERVICE_PRINCIPAL_CLIENT_ID).getValue());
+        boolean servicePrincipalClientSecretSet = 
StringUtils.isNotBlank(validationContext.getProperty(SERVICE_PRINCIPAL_CLIENT_SECRET).getValue());
 
+        boolean servicePrincipalSet = servicePrincipalTenantIdSet || 
servicePrincipalClientIdSet || servicePrincipalClientSecretSet;
+
+        if (!onlyOneSet(accountKeySet, sasTokenSet, useManagedIdentitySet, 
servicePrincipalSet)) {
             results.add(new 
ValidationResult.Builder().subject(this.getClass().getSimpleName())
                 .valid(false)
-                .explanation("one and only one of [" + options + "] should be 
set")
+                .explanation("one and only one authentication method of 
[Account Key, SAS Token, Managed Identity, Service Principal] should be used")

Review comment:
       `Account Key` and `SAS Token` would be fine but I would simply use 
`Managed Identity` (without the "Use" prefix from the displayname).
   I think it is something we should rather fix when the new `Authentication 
Type` property is added (which will have the same AllowableValue-s that would 
be needed here too).




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to