jfrazee commented on a change in pull request #5846:
URL: https://github.com/apache/nifi/pull/5846#discussion_r822072061
##########
File path:
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/storage/ADLSCredentialsControllerService.java
##########
@@ -103,39 +106,50 @@
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 useManagedIdentitySet =
validationContext.getProperty(USE_MANAGED_IDENTITY).asBoolean();
+ final boolean accountKeySet =
StringUtils.isNotBlank(validationContext.getProperty(AzureStorageUtils.ACCOUNT_KEY).getValue());
+ final boolean sasTokenSet =
StringUtils.isNotBlank(validationContext.getProperty(AzureStorageUtils.PROP_SAS_TOKEN).getValue());
+ final boolean useManagedIdentitySet =
validationContext.getProperty(USE_MANAGED_IDENTITY).asBoolean();
+
+ final boolean servicePrincipalTenantIdSet =
StringUtils.isNotBlank(validationContext.getProperty(SERVICE_PRINCIPAL_TENANT_ID).getValue());
+ final boolean servicePrincipalClientIdSet =
StringUtils.isNotBlank(validationContext.getProperty(SERVICE_PRINCIPAL_CLIENT_ID).getValue());
+ final boolean servicePrincipalClientSecretSet =
StringUtils.isNotBlank(validationContext.getProperty(SERVICE_PRINCIPAL_CLIENT_SECRET).getValue());
- 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());
+ final boolean servicePrincipalSet = servicePrincipalTenantIdSet ||
servicePrincipalClientIdSet || servicePrincipalClientSecretSet;
- boolean servicePrincipalSet = servicePrincipalTenantIdSet ||
servicePrincipalClientIdSet || servicePrincipalClientSecretSet;
+ final String managedIdentityClientId =
validationContext.getProperty(MANAGED_IDENTITY_CLIENT_ID).getValue();
if (!onlyOneSet(accountKeySet, sasTokenSet, useManagedIdentitySet,
servicePrincipalSet)) {
results.add(new
ValidationResult.Builder().subject(this.getClass().getSimpleName())
.valid(false)
.explanation("one and only one authentication method of
[Account Key, SAS Token, Managed Identity, Service Principal] should be used")
.build());
- } else if (servicePrincipalSet) {
- String template = "'%s' must be set when Service Principal
authentication is being configured";
- if (!servicePrincipalTenantIdSet) {
- results.add(new
ValidationResult.Builder().subject(this.getClass().getSimpleName())
- .valid(false)
- .explanation(String.format(template,
SERVICE_PRINCIPAL_TENANT_ID.getDisplayName()))
- .build());
- }
- if (!servicePrincipalClientIdSet) {
- results.add(new
ValidationResult.Builder().subject(this.getClass().getSimpleName())
- .valid(false)
- .explanation(String.format(template,
SERVICE_PRINCIPAL_CLIENT_ID.getDisplayName()))
- .build());
+ } else {
+ if (servicePrincipalSet) {
+ final String template = "'%s' must be set when Service
Principal authentication is being configured";
+ if (!servicePrincipalTenantIdSet) {
+ results.add(new
ValidationResult.Builder().subject(this.getClass().getSimpleName())
+ .valid(false)
+ .explanation(String.format(template,
SERVICE_PRINCIPAL_TENANT_ID.getDisplayName()))
+ .build());
+ }
+ if (!servicePrincipalClientIdSet) {
+ results.add(new
ValidationResult.Builder().subject(this.getClass().getSimpleName())
+ .valid(false)
+ .explanation(String.format(template,
SERVICE_PRINCIPAL_CLIENT_ID.getDisplayName()))
+ .build());
+ }
+ if (!servicePrincipalClientSecretSet) {
+ results.add(new
ValidationResult.Builder().subject(this.getClass().getSimpleName())
+ .valid(false)
+ .explanation(String.format(template,
SERVICE_PRINCIPAL_CLIENT_SECRET.getDisplayName()))
+ .build());
+ }
Review comment:
Oops. Yeah, forgot about the possibility of multiple validation errors.
--
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]