sjyang18 commented on a change in pull request #4863:
URL: https://github.com/apache/nifi/pull/4863#discussion_r587868912
##########
File path:
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/cosmos/document/AzureCosmosDBClientService.java
##########
@@ -44,67 +37,30 @@
"Provides a controller service that configures a connection to Cosmos
DB (Core SQL API) " +
" and provides access to that connection to other Cosmos DB-related
components."
)
-public class AzureCosmosDBClientService extends AbstractControllerService
implements AzureCosmosDBConnectionService {
+public class AzureCosmosDBClientService
+ extends AbstractCosmosDBClientService
+ implements AzureCosmosDBConnectionService {
Review comment:
Redundant superinterface AzureCosmosDBConnectionService for the type
AzureCosmosSecureDBClientService, already defined by
AbstractCosmosDBClientServiceJava(16777547)
##########
File path:
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/utils/AzureStorageUtils.java
##########
@@ -143,6 +144,54 @@
.required(false)
.build();
+ public static final PropertyDescriptor ACCOUNT_NAME_SECRET = new
PropertyDescriptor.Builder()
+ .name("storage-account-name-secret")
+ .displayName("Storage Account Name Secret Name")
+ .description("Storage Account Name Secret Name")
Review comment:
meaningful & user friendly description, not just display name in
description.
##########
File path:
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/cosmos/document/AzureCosmosSecureDBClientService.java
##########
@@ -0,0 +1,158 @@
+/*
+ * 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.services.azure.cosmos.document;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnEnabled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.processors.azure.cosmos.document.AzureCosmosDBUtils;
+import org.apache.nifi.services.azure.cosmos.AzureCosmosDBConnectionService;
+import org.apache.nifi.services.azure.keyvault.AzureKeyVaultConnectionService;
+import org.apache.nifi.util.StringUtils;
+
+@Tags({"azure", "cosmos", "document", "service", "secure"})
+@CapabilityDescription(
+ "Provides a controller service that configures a connection to Cosmos
DB (Core SQL API) " +
+ " and provides access to that connection to other Cosmos
DB-related components."
+)
+public class AzureCosmosSecureDBClientService
+ extends AbstractCosmosDBClientService
+ implements AzureCosmosDBConnectionService {
Review comment:
Redundant superinterface AzureCosmosDBConnectionService for the type
AzureCosmosSecureDBClientService, already defined by
AbstractCosmosDBClientServiceJava(16777547)
##########
File path:
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/storage/ADLSCredentialsControllerService.java
##########
@@ -221,4 +211,4 @@ public ADLSCredentialsDetails
getCredentialsDetails(Map<String, String> attribut
setBuilderValue.accept(credentialsBuilder, value);
}
}
-}
+}
Review comment:
add a new line at the end of file
##########
File path:
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/storage/ADLSSecureCredentialsControllerService.java
##########
@@ -0,0 +1,157 @@
+/*
+ * 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.services.azure.storage;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnEnabled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.PropertyValue;
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.controller.AbstractControllerService;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.processors.azure.storage.utils.AzureStorageUtils;
+import org.apache.nifi.services.azure.keyvault.AzureKeyVaultConnectionService;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.StringJoiner;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+
+/**
+ * Provides secure credentials details for ADLS
+ *
+ * @see AbstractControllerService
+ */
+@Tags({"azure", "microsoft", "cloud", "storage", "adls", "credentials",
"secure"})
+@CapabilityDescription("Defines credentials for ADLS processors.")
+public class ADLSSecureCredentialsControllerService
+ extends AbstractControllerService
+ implements ADLSCredentialsService {
+
+ private static final List<PropertyDescriptor> PROPERTIES =
Collections.unmodifiableList(Arrays.asList(
+ AzureStorageUtils.KEYVAULT_CONNECTION_SERVICE,
+ AzureStorageUtils.ACCOUNT_NAME_SECRET,
+ AzureStorageUtils.ADLS_ENDPOINT_SUFFIX,
+ AzureStorageUtils.ACCOUNT_KEY_SECRET,
+ AzureStorageUtils.ACCOUNT_SAS_TOKEN_SECRET
+ ));
+
+ private ConfigurationContext context;
+
+ @Override
+ protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
+ return PROPERTIES;
+ }
+
+ @Override
+ protected Collection<ValidationResult> customValidate(ValidationContext
validationContext) {
+ final List<ValidationResult> results = new ArrayList<>();
+
+ boolean accountKeySet =
StringUtils.isNotBlank(validationContext.getProperty(
+ AzureStorageUtils.ACCOUNT_KEY_SECRET).getValue());
+ boolean sasTokenSet =
StringUtils.isNotBlank(validationContext.getProperty(
+ AzureStorageUtils.ACCOUNT_SAS_TOKEN_SECRET).getValue());
+
+ if (!onlyOneSet(accountKeySet, sasTokenSet)) {
+ StringJoiner options = new StringJoiner(", ")
+ .add(AzureStorageUtils.ACCOUNT_KEY_SECRET.getDisplayName())
+
.add(AzureStorageUtils.ACCOUNT_SAS_TOKEN_SECRET.getDisplayName());
+
+ results.add(new
ValidationResult.Builder().subject(this.getClass().getSimpleName())
+ .valid(false)
+ .explanation("one and only one of [" + options + "] should
be set")
+ .build());
+ }
+
+ return results;
+ }
+
+ private boolean onlyOneSet(Boolean... checks) {
+ long nrOfSet = Arrays.stream(checks)
+ .filter(check -> check)
+ .count();
+
+ return nrOfSet == 1;
+ }
+
+ @OnEnabled
+ public void onEnabled(ConfigurationContext context) {
+ this.context = context;
+ }
+
+ @Override
+ public ADLSCredentialsDetails getCredentialsDetails(Map<String, String>
attributes) {
+ ADLSCredentialsDetails.Builder credentialsBuilder =
ADLSCredentialsDetails.Builder.newBuilder();
+
+ setValue(credentialsBuilder,
+ AzureStorageUtils.ADLS_ENDPOINT_SUFFIX,
+ PropertyValue::getValue,
+ ADLSCredentialsDetails.Builder::setEndpointSuffix);
+
+ final AzureKeyVaultConnectionService keyVaultClientService =
context.getProperty(
+ AzureStorageUtils.KEYVAULT_CONNECTION_SERVICE
+ ).asControllerService(AzureKeyVaultConnectionService.class);
+ String accountNameSecret = context.getProperty(
+ AzureStorageUtils.ACCOUNT_NAME_SECRET).getValue();
+ String accountKeySecret = context.getProperty(
+ AzureStorageUtils.ACCOUNT_KEY_SECRET).getValue();
+ String sasTokenSecret = context.getProperty(
+ AzureStorageUtils.ACCOUNT_SAS_TOKEN_SECRET).getValue();
+
+ if(StringUtils.isNotBlank(accountNameSecret)) {
+ credentialsBuilder.setAccountName(
+ keyVaultClientService.getSecret(accountNameSecret));
+ }
+ if(StringUtils.isNotBlank(accountKeySecret)) {
+ credentialsBuilder.setAccountKey(
+ keyVaultClientService.getSecret(accountKeySecret));
Review comment:
what if secret is not set for this key in keyvault? or key is mispelled?
Does this throw exception?
##########
File path:
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/cosmos/document/AbstractCosmosDBClientService.java
##########
@@ -0,0 +1,91 @@
+/*
+ * 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.services.azure.cosmos.document;
+
+import com.azure.cosmos.ConsistencyLevel;
+import com.azure.cosmos.CosmosClient;
+import com.azure.cosmos.CosmosClientBuilder;
+import com.azure.cosmos.CosmosException;
+
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnStopped;
+import org.apache.nifi.controller.AbstractControllerService;
+import org.apache.nifi.processors.azure.cosmos.document.AzureCosmosDBUtils;
+import org.apache.nifi.services.azure.cosmos.AzureCosmosDBConnectionService;
+
+@Tags({"azure", "cosmos", "document", "service"})
+@CapabilityDescription(
+ "Provides a controller service that configures a connection to Cosmos
DB (Core SQL API) " +
+ " and provides access to that connection to other Cosmos
DB-related components."
+)
+public abstract class AbstractCosmosDBClientService
+ extends AbstractControllerService
+ implements AzureCosmosDBConnectionService {
+
+ protected CosmosClient cosmosClient;
Review comment:
feedback I got in my previous PR was to use private for this line and
use getCosmosClient method to access.
##########
File path:
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/storage/AzureStorageSecureCredentialsControllerService.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.services.azure.storage;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import com.microsoft.azure.storage.StorageCredentials;
+import com.microsoft.azure.storage.StorageCredentialsAccountAndKey;
+import com.microsoft.azure.storage.StorageCredentialsSharedAccessSignature;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnEnabled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.controller.AbstractControllerService;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.logging.ComponentLog;
+import org.apache.nifi.processors.azure.storage.utils.AzureStorageUtils;
+import org.apache.nifi.services.azure.keyvault.AzureKeyVaultConnectionService;
+
+/**
+ * Implementation of AbstractControllerService interface
+ *
+ * @see AbstractControllerService
+ */
+@Tags({ "azure", "microsoft", "cloud", "storage", "blob", "queue",
"credentials" })
Review comment:
Is this controller supporting queue?
##########
File path:
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/storage/ADLSSecureCredentialsControllerService.java
##########
@@ -0,0 +1,157 @@
+/*
+ * 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.services.azure.storage;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnEnabled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.PropertyValue;
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.controller.AbstractControllerService;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.processors.azure.storage.utils.AzureStorageUtils;
+import org.apache.nifi.services.azure.keyvault.AzureKeyVaultConnectionService;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.StringJoiner;
+import java.util.function.BiConsumer;
+import java.util.function.Function;
+
+/**
+ * Provides secure credentials details for ADLS
+ *
+ * @see AbstractControllerService
+ */
+@Tags({"azure", "microsoft", "cloud", "storage", "adls", "credentials",
"secure"})
+@CapabilityDescription("Defines credentials for ADLS processors.")
+public class ADLSSecureCredentialsControllerService
+ extends AbstractControllerService
+ implements ADLSCredentialsService {
+
+ private static final List<PropertyDescriptor> PROPERTIES =
Collections.unmodifiableList(Arrays.asList(
+ AzureStorageUtils.KEYVAULT_CONNECTION_SERVICE,
+ AzureStorageUtils.ACCOUNT_NAME_SECRET,
+ AzureStorageUtils.ADLS_ENDPOINT_SUFFIX,
+ AzureStorageUtils.ACCOUNT_KEY_SECRET,
+ AzureStorageUtils.ACCOUNT_SAS_TOKEN_SECRET
+ ));
+
+ private ConfigurationContext context;
+
+ @Override
+ protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {
+ return PROPERTIES;
+ }
+
+ @Override
+ protected Collection<ValidationResult> customValidate(ValidationContext
validationContext) {
+ final List<ValidationResult> results = new ArrayList<>();
+
+ boolean accountKeySet =
StringUtils.isNotBlank(validationContext.getProperty(
+ AzureStorageUtils.ACCOUNT_KEY_SECRET).getValue());
+ boolean sasTokenSet =
StringUtils.isNotBlank(validationContext.getProperty(
+ AzureStorageUtils.ACCOUNT_SAS_TOKEN_SECRET).getValue());
+
+ if (!onlyOneSet(accountKeySet, sasTokenSet)) {
+ StringJoiner options = new StringJoiner(", ")
+ .add(AzureStorageUtils.ACCOUNT_KEY_SECRET.getDisplayName())
+
.add(AzureStorageUtils.ACCOUNT_SAS_TOKEN_SECRET.getDisplayName());
+
+ results.add(new
ValidationResult.Builder().subject(this.getClass().getSimpleName())
+ .valid(false)
+ .explanation("one and only one of [" + options + "] should
be set")
+ .build());
+ }
+
Review comment:
Should we validate the non-blank secret value for non-blank keySet in
your key vault service?
##########
File path:
nifi-nar-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/services/azure/storage/AzureStorageSecureCredentialsControllerService.java
##########
@@ -0,0 +1,154 @@
+/*
+ * 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.services.azure.storage;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import com.microsoft.azure.storage.StorageCredentials;
+import com.microsoft.azure.storage.StorageCredentialsAccountAndKey;
+import com.microsoft.azure.storage.StorageCredentialsSharedAccessSignature;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnEnabled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.ValidationContext;
+import org.apache.nifi.components.ValidationResult;
+import org.apache.nifi.controller.AbstractControllerService;
+import org.apache.nifi.controller.ConfigurationContext;
+import org.apache.nifi.logging.ComponentLog;
+import org.apache.nifi.processors.azure.storage.utils.AzureStorageUtils;
+import org.apache.nifi.services.azure.keyvault.AzureKeyVaultConnectionService;
+
+/**
+ * Implementation of AbstractControllerService interface
+ *
+ * @see AbstractControllerService
+ */
+@Tags({ "azure", "microsoft", "cloud", "storage", "blob", "queue",
"credentials" })
Review comment:
can we also support queue?
----------------------------------------------------------------
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]