From 2a37ac83a8d297bf6dc2f63bde0b381f6563dd3f Mon Sep 17 00:00:00 2001 From: Peter Turcsanyi Date: Fri, 11 Oct 2024 23:48:20 +0200 Subject: [PATCH] NIFI-13867 Removed legacy code supporting component level proxy properties --- ...stractAWSCredentialsProviderProcessor.java | 19 ++----- .../aws/v2/AbstractAwsProcessor.java | 18 ++----- .../AmazonGlueSchemaRegistry.java | 11 +---- .../queue/GetAzureQueueStorage_v12.java | 2 +- .../queue/PutAzureQueueStorage_v12.java | 2 +- .../storage/utils/AzureStorageUtils.java | 2 +- .../eventhubs/AzureEventHubComponent.java | 2 +- .../JsonConfigBasedBoxClientService.java | 2 +- .../nifi/processors/dropbox/FetchDropbox.java | 2 +- .../nifi/processors/dropbox/ListDropbox.java | 2 +- .../nifi/processors/dropbox/PutDropbox.java | 2 +- .../ElasticSearchClientService.java | 2 +- .../processors/gcp/AbstractGCPProcessor.java | 2 +- .../GCPCredentialsControllerService.java | 2 +- .../gcp/drive/FetchGoogleDrive.java | 2 +- .../processors/gcp/drive/ListGoogleDrive.java | 2 +- .../processors/gcp/drive/PutGoogleDrive.java | 2 +- .../nifi/reporting/s2s/SiteToSiteUtils.java | 2 +- .../nifi/processors/standard/InvokeHTTP.java | 2 +- .../processors/standard/util/FTPTransfer.java | 3 +- .../processors/standard/util/HTTPUtils.java | 49 +------------------ .../standard/util/SFTPTransfer.java | 3 +- .../apache/nifi/lookup/RestLookupService.java | 2 +- .../StandardOauth2AccessTokenProvider.java | 2 +- .../apache/nifi/proxy/ProxyConfiguration.java | 27 +++------- .../nifi/proxy/ProxyConfigurationService.java | 3 +- .../nifi/proxy/TestProxyConfiguration.java | 2 +- 27 files changed, 37 insertions(+), 134 deletions(-) diff --git a/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSCredentialsProviderProcessor.java b/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSCredentialsProviderProcessor.java index a79f245f1bbf..247c073d1a27 100644 --- a/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSCredentialsProviderProcessor.java +++ b/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSCredentialsProviderProcessor.java @@ -45,7 +45,7 @@ import org.apache.nifi.processor.util.StandardValidators; import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderService; import org.apache.nifi.proxy.ProxyConfiguration; -import org.apache.nifi.proxy.ProxyConfigurationService; +import org.apache.nifi.proxy.ProxySpec; import org.apache.nifi.ssl.SSLContextService; import javax.net.ssl.SSLContext; @@ -119,13 +119,7 @@ public abstract class AbstractAWSCredentialsProviderProcessor { - if (context.getProperty(PROXY_CONFIGURATION_SERVICE).isSet()) { - final ProxyConfigurationService configurationService = context.getProperty(PROXY_CONFIGURATION_SERVICE).asControllerService(ProxyConfigurationService.class); - return configurationService.getConfiguration(); - } - - return ProxyConfiguration.DIRECT_CONFIGURATION; - }); + final ProxyConfiguration proxyConfig = ProxyConfiguration.getConfiguration(context); if (Proxy.Type.HTTP.equals(proxyConfig.getProxyType())) { config.setProxyHost(proxyConfig.getProxyServerHost()); diff --git a/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/v2/AbstractAwsProcessor.java b/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/v2/AbstractAwsProcessor.java index e6c9393faef3..db88c6170689 100644 --- a/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/v2/AbstractAwsProcessor.java +++ b/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/v2/AbstractAwsProcessor.java @@ -38,7 +38,7 @@ import org.apache.nifi.processor.util.StandardValidators; import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderService; import org.apache.nifi.proxy.ProxyConfiguration; -import org.apache.nifi.proxy.ProxyConfigurationService; +import org.apache.nifi.proxy.ProxySpec; import org.apache.nifi.ssl.SSLContextService; import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider; import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder; @@ -139,13 +139,7 @@ public abstract class AbstractAwsProcessor extends Abstract .identifiesControllerService(AWSCredentialsProviderService.class) .build(); - public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE = new PropertyDescriptor.Builder() - .name("proxy-configuration-service") - .displayName("Proxy Configuration Service") - .description("Specifies the Proxy Configuration Controller Service to proxy network requests.") - .identifiesControllerService(ProxyConfigurationService.class) - .required(false) - .build(); + public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE = ProxyConfiguration.createProxyConfigPropertyDescriptor(ProxySpec.HTTP, ProxySpec.HTTP_AUTH); protected static final String DEFAULT_USER_AGENT = "NiFi"; @@ -304,13 +298,7 @@ protected void configureSdkHttpClient(final ProcessContext context, final AwsHtt } } - final ProxyConfiguration proxyConfig = ProxyConfiguration.getConfiguration(context, () -> { - if (context.getProperty(ProxyConfigurationService.PROXY_CONFIGURATION_SERVICE).isSet()) { - final ProxyConfigurationService configurationService = context.getProperty(ProxyConfigurationService.PROXY_CONFIGURATION_SERVICE).asControllerService(ProxyConfigurationService.class); - return configurationService.getConfiguration(); - } - return ProxyConfiguration.DIRECT_CONFIGURATION; - }); + final ProxyConfiguration proxyConfig = ProxyConfiguration.getConfiguration(context); if (Proxy.Type.HTTP.equals(proxyConfig.getProxyType())) { httpClientConfigurer.configureProxy(proxyConfig); diff --git a/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-schema-registry-service/src/main/java/org/apache/nifi/aws/schemaregistry/AmazonGlueSchemaRegistry.java b/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-schema-registry-service/src/main/java/org/apache/nifi/aws/schemaregistry/AmazonGlueSchemaRegistry.java index d54c36c5b8a5..f755a6415894 100644 --- a/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-schema-registry-service/src/main/java/org/apache/nifi/aws/schemaregistry/AmazonGlueSchemaRegistry.java +++ b/nifi-extension-bundles/nifi-aws-bundle/nifi-aws-schema-registry-service/src/main/java/org/apache/nifi/aws/schemaregistry/AmazonGlueSchemaRegistry.java @@ -30,7 +30,6 @@ import org.apache.nifi.processor.util.StandardValidators; import org.apache.nifi.processors.aws.credentials.provider.service.AWSCredentialsProviderService; import org.apache.nifi.proxy.ProxyConfiguration; -import org.apache.nifi.proxy.ProxyConfigurationService; import org.apache.nifi.proxy.ProxySpec; import org.apache.nifi.schema.access.SchemaField; import org.apache.nifi.schema.access.SchemaNotFoundException; @@ -135,7 +134,7 @@ public class AmazonGlueSchemaRegistry extends AbstractControllerService implemen private static final ProxySpec[] PROXY_SPECS = {ProxySpec.HTTP_AUTH}; - private static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE = ProxyConfiguration.createProxyConfigPropertyDescriptor(true, PROXY_SPECS); + private static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE = ProxyConfiguration.createProxyConfigPropertyDescriptor(PROXY_SPECS); private static final List PROPERTIES = new ArrayList<>(Arrays.asList( SCHEMA_REGISTRY_NAME, @@ -232,13 +231,7 @@ private SdkHttpClient createSdkHttpClient(final ConfigurationContext context) { } } } - final ProxyConfiguration proxyConfig = ProxyConfiguration.getConfiguration(context, () -> { - if (context.getProperty(ProxyConfigurationService.PROXY_CONFIGURATION_SERVICE).isSet()) { - final ProxyConfigurationService configurationService = context.getProperty(ProxyConfigurationService.PROXY_CONFIGURATION_SERVICE).asControllerService(ProxyConfigurationService.class); - return configurationService.getConfiguration(); - } - return ProxyConfiguration.DIRECT_CONFIGURATION; - }); + final ProxyConfiguration proxyConfig = ProxyConfiguration.getConfiguration(context); if (Proxy.Type.HTTP.equals(proxyConfig.getProxyType())) { final software.amazon.awssdk.http.apache.ProxyConfiguration.Builder proxyConfigBuilder = software.amazon.awssdk.http.apache.ProxyConfiguration.builder() diff --git a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/queue/GetAzureQueueStorage_v12.java b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/queue/GetAzureQueueStorage_v12.java index d602a6a51e70..bbd71ab0caf1 100644 --- a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/queue/GetAzureQueueStorage_v12.java +++ b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/queue/GetAzureQueueStorage_v12.java @@ -104,7 +104,7 @@ public class GetAzureQueueStorage_v12 extends AbstractAzureQueueStorage_v12 { MESSAGE_BATCH_SIZE, VISIBILITY_TIMEOUT, REQUEST_TIMEOUT, - ProxyConfiguration.createProxyConfigPropertyDescriptor(false, PROXY_SPECS) + ProxyConfiguration.createProxyConfigPropertyDescriptor(PROXY_SPECS) ); private static final Set RELATIONSHIPS = Set.of(REL_SUCCESS); diff --git a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/queue/PutAzureQueueStorage_v12.java b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/queue/PutAzureQueueStorage_v12.java index 88344ce73c8f..efea7bcb3f48 100644 --- a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/queue/PutAzureQueueStorage_v12.java +++ b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/queue/PutAzureQueueStorage_v12.java @@ -72,7 +72,7 @@ public class PutAzureQueueStorage_v12 extends AbstractAzureQueueStorage_v12 { MESSAGE_TIME_TO_LIVE, VISIBILITY_TIMEOUT, REQUEST_TIMEOUT, - ProxyConfiguration.createProxyConfigPropertyDescriptor(false, PROXY_SPECS) + ProxyConfiguration.createProxyConfigPropertyDescriptor(PROXY_SPECS) ); // 7 days is the maximum timeout as per https://learn.microsoft.com/en-us/rest/api/storageservices/get-messages diff --git a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/utils/AzureStorageUtils.java b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/utils/AzureStorageUtils.java index 7a0165d7dece..eead8366ae81 100644 --- a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/utils/AzureStorageUtils.java +++ b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/processors/azure/storage/utils/AzureStorageUtils.java @@ -260,7 +260,7 @@ private AzureStorageUtils() { private static final ProxySpec[] PROXY_SPECS = {ProxySpec.HTTP, ProxySpec.SOCKS}; public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE = new PropertyDescriptor.Builder() - .fromPropertyDescriptor(ProxyConfiguration.createProxyConfigPropertyDescriptor(false, PROXY_SPECS)) + .fromPropertyDescriptor(ProxyConfiguration.createProxyConfigPropertyDescriptor(PROXY_SPECS)) .build(); public static void validateProxySpec(ValidationContext context, Collection results) { diff --git a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/shared/azure/eventhubs/AzureEventHubComponent.java b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/shared/azure/eventhubs/AzureEventHubComponent.java index 613a757b4472..9348ab69061d 100644 --- a/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/shared/azure/eventhubs/AzureEventHubComponent.java +++ b/nifi-extension-bundles/nifi-azure-bundle/nifi-azure-processors/src/main/java/org/apache/nifi/shared/azure/eventhubs/AzureEventHubComponent.java @@ -38,7 +38,7 @@ public interface AzureEventHubComponent { .build(); ProxySpec[] PROXY_SPECS = {ProxySpec.HTTP, ProxySpec.HTTP_AUTH}; PropertyDescriptor PROXY_CONFIGURATION_SERVICE = new PropertyDescriptor.Builder() - .fromPropertyDescriptor(ProxyConfiguration.createProxyConfigPropertyDescriptor(false, PROXY_SPECS)) + .fromPropertyDescriptor(ProxyConfiguration.createProxyConfigPropertyDescriptor(PROXY_SPECS)) .dependsOn(TRANSPORT_TYPE, AzureEventHubTransportType.AMQP_WEB_SOCKETS) .build(); } diff --git a/nifi-extension-bundles/nifi-box-bundle/nifi-box-services/src/main/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientService.java b/nifi-extension-bundles/nifi-box-bundle/nifi-box-services/src/main/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientService.java index 990017e58726..c79b87017ad7 100644 --- a/nifi-extension-bundles/nifi-box-bundle/nifi-box-services/src/main/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientService.java +++ b/nifi-extension-bundles/nifi-box-bundle/nifi-box-services/src/main/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientService.java @@ -84,7 +84,7 @@ public class JsonConfigBasedBoxClientService extends AbstractControllerService i ACCOUNT_ID, APP_CONFIG_FILE, APP_CONFIG_JSON, - ProxyConfiguration.createProxyConfigPropertyDescriptor(false, PROXY_SPECS) + ProxyConfiguration.createProxyConfigPropertyDescriptor(PROXY_SPECS) )); private volatile BoxAPIConnection boxAPIConnection; diff --git a/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-processors/src/main/java/org/apache/nifi/processors/dropbox/FetchDropbox.java b/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-processors/src/main/java/org/apache/nifi/processors/dropbox/FetchDropbox.java index 2a9fb9c1789e..15a41fce6d3a 100644 --- a/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-processors/src/main/java/org/apache/nifi/processors/dropbox/FetchDropbox.java +++ b/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-processors/src/main/java/org/apache/nifi/processors/dropbox/FetchDropbox.java @@ -111,7 +111,7 @@ public class FetchDropbox extends AbstractProcessor implements DropboxTrait { private static final List PROPERTIES = Collections.unmodifiableList(Arrays.asList( CREDENTIAL_SERVICE, FILE, - ProxyConfiguration.createProxyConfigPropertyDescriptor(false, ProxySpec.HTTP_AUTH) + ProxyConfiguration.createProxyConfigPropertyDescriptor(ProxySpec.HTTP_AUTH) )); private volatile DbxClientV2 dropboxApiClient; diff --git a/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-processors/src/main/java/org/apache/nifi/processors/dropbox/ListDropbox.java b/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-processors/src/main/java/org/apache/nifi/processors/dropbox/ListDropbox.java index 4a7c4a0fd90b..49aac2f642cd 100644 --- a/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-processors/src/main/java/org/apache/nifi/processors/dropbox/ListDropbox.java +++ b/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-processors/src/main/java/org/apache/nifi/processors/dropbox/ListDropbox.java @@ -155,7 +155,7 @@ public class ListDropbox extends AbstractListProcessor implemen TRACKING_TIME_WINDOW, INITIAL_LISTING_TARGET, RECORD_WRITER, - ProxyConfiguration.createProxyConfigPropertyDescriptor(false, ProxySpec.HTTP_AUTH) + ProxyConfiguration.createProxyConfigPropertyDescriptor(ProxySpec.HTTP_AUTH) )); private volatile DbxClientV2 dropboxApiClient; diff --git a/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-processors/src/main/java/org/apache/nifi/processors/dropbox/PutDropbox.java b/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-processors/src/main/java/org/apache/nifi/processors/dropbox/PutDropbox.java index 1bd0398bcc86..2970d11b6a53 100644 --- a/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-processors/src/main/java/org/apache/nifi/processors/dropbox/PutDropbox.java +++ b/nifi-extension-bundles/nifi-dropbox-bundle/nifi-dropbox-processors/src/main/java/org/apache/nifi/processors/dropbox/PutDropbox.java @@ -172,7 +172,7 @@ public class PutDropbox extends AbstractProcessor implements DropboxTrait { CONFLICT_RESOLUTION, CHUNKED_UPLOAD_THRESHOLD, CHUNKED_UPLOAD_SIZE, - ProxyConfiguration.createProxyConfigPropertyDescriptor(false, ProxySpec.HTTP_AUTH) + ProxyConfiguration.createProxyConfigPropertyDescriptor(ProxySpec.HTTP_AUTH) )); private static final Set RELATIONSHIPS; diff --git a/nifi-extension-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service-api/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientService.java b/nifi-extension-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service-api/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientService.java index 3f87deb73cb0..504988b1929d 100644 --- a/nifi-extension-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service-api/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientService.java +++ b/nifi-extension-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-client-service-api/src/main/java/org/apache/nifi/elasticsearch/ElasticSearchClientService.java @@ -50,7 +50,7 @@ public interface ElasticSearchClientService extends ControllerService, Verifiabl .identifiesControllerService(SSLContextService.class) .addValidator(Validator.VALID) .build(); - PropertyDescriptor PROXY_CONFIGURATION_SERVICE = ProxyConfiguration.createProxyConfigPropertyDescriptor(false, ProxySpec.HTTP); + PropertyDescriptor PROXY_CONFIGURATION_SERVICE = ProxyConfiguration.createProxyConfigPropertyDescriptor(ProxySpec.HTTP); PropertyDescriptor AUTHORIZATION_SCHEME = new PropertyDescriptor.Builder() .name("authorization-scheme") diff --git a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/AbstractGCPProcessor.java b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/AbstractGCPProcessor.java index db6fc1e722dd..5ca79a8bff29 100644 --- a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/AbstractGCPProcessor.java +++ b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/AbstractGCPProcessor.java @@ -77,7 +77,7 @@ public abstract class AbstractGCPProcessor< .identifiesControllerService(GCPCredentialsService.class) .build(); - public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE = ProxyConfiguration.createProxyConfigPropertyDescriptor(false, ProxyAwareTransportFactory.PROXY_SPECS); + public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE = ProxyConfiguration.createProxyConfigPropertyDescriptor(ProxyAwareTransportFactory.PROXY_SPECS); protected volatile CloudService cloudService; diff --git a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/credentials/service/GCPCredentialsControllerService.java b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/credentials/service/GCPCredentialsControllerService.java index 2226c711bc32..a4a5a20bbbda 100644 --- a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/credentials/service/GCPCredentialsControllerService.java +++ b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/credentials/service/GCPCredentialsControllerService.java @@ -81,7 +81,7 @@ public class GCPCredentialsControllerService extends AbstractControllerService i props.add(USE_COMPUTE_ENGINE_CREDENTIALS); props.add(SERVICE_ACCOUNT_JSON_FILE); props.add(SERVICE_ACCOUNT_JSON); - props.add(ProxyConfiguration.createProxyConfigPropertyDescriptor(false, ProxyAwareTransportFactory.PROXY_SPECS)); + props.add(ProxyConfiguration.createProxyConfigPropertyDescriptor(ProxyAwareTransportFactory.PROXY_SPECS)); properties = Collections.unmodifiableList(props); } diff --git a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDrive.java b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDrive.java index 5cae9e97d9b1..1a8e8f45086e 100644 --- a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDrive.java +++ b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/FetchGoogleDrive.java @@ -233,7 +233,7 @@ public class FetchGoogleDrive extends AbstractProcessor implements GoogleDriveTr private static final List PROPERTIES = List.of( GoogleUtils.GCP_CREDENTIALS_PROVIDER_SERVICE, FILE_ID, - ProxyConfiguration.createProxyConfigPropertyDescriptor(false, ProxyAwareTransportFactory.PROXY_SPECS), + ProxyConfiguration.createProxyConfigPropertyDescriptor(ProxyAwareTransportFactory.PROXY_SPECS), GOOGLE_DOC_EXPORT_TYPE, GOOGLE_SPREADSHEET_EXPORT_TYPE, GOOGLE_PRESENTATION_EXPORT_TYPE, diff --git a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/ListGoogleDrive.java b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/ListGoogleDrive.java index 997e0307cce0..d8f9d769cba3 100644 --- a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/ListGoogleDrive.java +++ b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/ListGoogleDrive.java @@ -160,7 +160,7 @@ public class ListGoogleDrive extends AbstractListProcessor TRACKING_TIME_WINDOW, INITIAL_LISTING_TARGET, RECORD_WRITER, - ProxyConfiguration.createProxyConfigPropertyDescriptor(false, ProxyAwareTransportFactory.PROXY_SPECS) + ProxyConfiguration.createProxyConfigPropertyDescriptor(ProxyAwareTransportFactory.PROXY_SPECS) )); private volatile Drive driveService; diff --git a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/PutGoogleDrive.java b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/PutGoogleDrive.java index 632ff541e5de..a46c24745e0a 100644 --- a/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/PutGoogleDrive.java +++ b/nifi-extension-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/drive/PutGoogleDrive.java @@ -168,7 +168,7 @@ public class PutGoogleDrive extends AbstractProcessor implements GoogleDriveTrai CONFLICT_RESOLUTION, CHUNKED_UPLOAD_THRESHOLD, CHUNKED_UPLOAD_SIZE, - ProxyConfiguration.createProxyConfigPropertyDescriptor(false, ProxyAwareTransportFactory.PROXY_SPECS) + ProxyConfiguration.createProxyConfigPropertyDescriptor(ProxyAwareTransportFactory.PROXY_SPECS) )); public static final Relationship REL_SUCCESS = diff --git a/nifi-extension-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/s2s/SiteToSiteUtils.java b/nifi-extension-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/s2s/SiteToSiteUtils.java index 9c6f739a429e..44aa1ef1f912 100644 --- a/nifi-extension-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/s2s/SiteToSiteUtils.java +++ b/nifi-extension-bundles/nifi-site-to-site-reporting-bundle/nifi-site-to-site-reporting-task/src/main/java/org/apache/nifi/reporting/s2s/SiteToSiteUtils.java @@ -115,7 +115,7 @@ public class SiteToSiteUtils { .defaultValue(SiteToSiteTransportProtocol.RAW.name()) .build(); public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE = new PropertyDescriptor.Builder() - .fromPropertyDescriptor(ProxyConfiguration.createProxyConfigPropertyDescriptor(false, ProxySpec.HTTP, ProxySpec.HTTP_AUTH)) + .fromPropertyDescriptor(ProxyConfiguration.createProxyConfigPropertyDescriptor(ProxySpec.HTTP, ProxySpec.HTTP_AUTH)) .dependsOn(TRANSPORT_PROTOCOL, SiteToSiteTransportProtocol.HTTP.name()) .build(); public static final PropertyDescriptor PLATFORM = new PropertyDescriptor.Builder() diff --git a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java index 89486b169617..4855a8843891 100644 --- a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java +++ b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java @@ -475,7 +475,7 @@ public class InvokeHTTP extends AbstractProcessor { private static final ProxySpec[] PROXY_SPECS = {ProxySpec.HTTP_AUTH, ProxySpec.SOCKS}; - private static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE = ProxyConfiguration.createProxyConfigPropertyDescriptor(true, PROXY_SPECS); + private static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE = ProxyConfiguration.createProxyConfigPropertyDescriptor(PROXY_SPECS); public static final List PROPERTIES = List.of( HTTP_METHOD, diff --git a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/FTPTransfer.java b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/FTPTransfer.java index d2bbc94efa72..80ef2d758d3d 100644 --- a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/FTPTransfer.java +++ b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/FTPTransfer.java @@ -116,8 +116,7 @@ public class FTPTransfer implements FileTransfer { private static final FTPClientProvider FTP_CLIENT_PROVIDER = new StandardFTPClientProvider(); private static final ProxySpec[] PROXY_SPECS = {ProxySpec.HTTP_AUTH, ProxySpec.SOCKS_AUTH}; - public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE - = ProxyConfiguration.createProxyConfigPropertyDescriptor(false, PROXY_SPECS); + public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE = ProxyConfiguration.createProxyConfigPropertyDescriptor(PROXY_SPECS); private final ComponentLog logger; diff --git a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/HTTPUtils.java b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/HTTPUtils.java index 1fbf30c2c61d..6888939bd476 100644 --- a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/HTTPUtils.java +++ b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/HTTPUtils.java @@ -21,16 +21,10 @@ import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.CredentialsProvider; import org.apache.http.impl.client.HttpClientBuilder; -import org.apache.nifi.components.PropertyDescriptor; -import org.apache.nifi.components.ValidationContext; -import org.apache.nifi.components.ValidationResult; import org.apache.nifi.processor.ProcessContext; -import org.apache.nifi.processor.util.StandardValidators; import org.apache.nifi.proxy.ProxyConfiguration; -import org.apache.nifi.proxy.ProxySpec; import java.net.Proxy; -import java.util.Collection; import java.util.Map; public class HTTPUtils { @@ -54,39 +48,10 @@ public static String getURI(Map map) { } } - public static final PropertyDescriptor PROXY_HOST = new PropertyDescriptor.Builder() - .name("Proxy Host") - .description("The fully qualified hostname or IP address of the proxy server") - .required(false) - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) - .build(); - - public static final PropertyDescriptor PROXY_PORT = new PropertyDescriptor.Builder() - .name("Proxy Port") - .description("The port of the proxy server") - .required(false) - .addValidator(StandardValidators.PORT_VALIDATOR) - .build(); - - private static final ProxySpec[] PROXY_SPECS = {ProxySpec.HTTP_AUTH}; - public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE - = ProxyConfiguration.createProxyConfigPropertyDescriptor(true, PROXY_SPECS); - public static void setProxy(final ProcessContext context, final HttpClientBuilder clientBuilder, final CredentialsProvider credentialsProvider) { // Set the proxy if specified - final ProxyConfiguration proxyConfig = ProxyConfiguration.getConfiguration(context, () -> { - if (context.getProperty(PROXY_HOST).isSet() && context.getProperty(PROXY_PORT).isSet()) { - final ProxyConfiguration componentProxyConfig = new ProxyConfiguration(); - final String host = context.getProperty(PROXY_HOST).getValue(); - final int port = context.getProperty(PROXY_PORT).asInteger(); - componentProxyConfig.setProxyType(Proxy.Type.HTTP); - componentProxyConfig.setProxyServerHost(host); - componentProxyConfig.setProxyServerPort(port); - return componentProxyConfig; - } - return ProxyConfiguration.DIRECT_CONFIGURATION; - }); + final ProxyConfiguration proxyConfig = ProxyConfiguration.getConfiguration(context); if (Proxy.Type.HTTP.equals(proxyConfig.getProxyType())) { final String host = proxyConfig.getProxyServerHost(); @@ -101,16 +66,4 @@ public static void setProxy(final ProcessContext context, final HttpClientBuilde } } } - - public static void validateProxyProperties(ValidationContext context, Collection results) { - if (context.getProperty(PROXY_HOST).isSet() && !context.getProperty(PROXY_PORT).isSet()) { - results.add(new ValidationResult.Builder() - .explanation("Proxy Host was set but no Proxy Port was specified") - .valid(false) - .subject("Proxy server configuration") - .build()); - } - - ProxyConfiguration.validateProxySpec(context, results, PROXY_SPECS); - } } diff --git a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java index e7ee10dabe44..ce9cc19c6911 100644 --- a/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java +++ b/nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java @@ -233,8 +233,7 @@ private static boolean isDirectory(FileAttributes attributes) { .build(); private static final ProxySpec[] PROXY_SPECS = {ProxySpec.HTTP_AUTH, ProxySpec.SOCKS_AUTH}; - public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE - = ProxyConfiguration.createProxyConfigPropertyDescriptor(true, PROXY_SPECS); + public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE = ProxyConfiguration.createProxyConfigPropertyDescriptor(PROXY_SPECS); private final ComponentLog logger; diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java index d6ea51935247..ae58c5c143e2 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/main/java/org/apache/nifi/lookup/RestLookupService.java @@ -206,7 +206,7 @@ public class RestLookupService extends AbstractControllerService implements Reco private static final ProxySpec[] PROXY_SPECS = {ProxySpec.HTTP_AUTH, ProxySpec.SOCKS}; public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE - = ProxyConfiguration.createProxyConfigPropertyDescriptor(true, PROXY_SPECS); + = ProxyConfiguration.createProxyConfigPropertyDescriptor(PROXY_SPECS); static final String MIME_TYPE_KEY = "mime.type"; static final String BODY_KEY = "request.body"; diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java b/nifi-extension-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java index 1e6ab22f7d84..ca32ae8b3f2e 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-oauth2-provider-bundle/nifi-oauth2-provider-service/src/main/java/org/apache/nifi/oauth2/StandardOauth2AccessTokenProvider.java @@ -225,7 +225,7 @@ public class StandardOauth2AccessTokenProvider extends AbstractControllerService REFRESH_WINDOW, SSL_CONTEXT, HTTP_PROTOCOL_STRATEGY, - ProxyConfiguration.createProxyConfigPropertyDescriptor(false, PROXY_SPECS) + ProxyConfiguration.createProxyConfigPropertyDescriptor(PROXY_SPECS) )); private static final String AUTHORIZATION_HEADER = "Authorization"; diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-api/src/main/java/org/apache/nifi/proxy/ProxyConfiguration.java b/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-api/src/main/java/org/apache/nifi/proxy/ProxyConfiguration.java index 7eb0554dc1e0..58a717f4273b 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-api/src/main/java/org/apache/nifi/proxy/ProxyConfiguration.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-api/src/main/java/org/apache/nifi/proxy/ProxyConfiguration.java @@ -26,7 +26,6 @@ import java.util.Arrays; import java.util.Collection; import java.util.Set; -import java.util.function.Supplier; import java.util.stream.Collectors; import static org.apache.nifi.proxy.ProxyConfigurationService.PROXY_CONFIGURATION_SERVICE; @@ -39,14 +38,11 @@ public class ProxyConfiguration { public static final ProxyConfiguration DIRECT_CONFIGURATION = new ProxyConfiguration(); - public static PropertyDescriptor createProxyConfigPropertyDescriptor(final boolean hasComponentProxyConfigs, final ProxySpec... _specs) { + public static PropertyDescriptor createProxyConfigPropertyDescriptor(final ProxySpec... _specs) { final Set specs = getUniqueProxySpecs(_specs); final StringBuilder description = new StringBuilder("Specifies the Proxy Configuration Controller Service to proxy network requests."); - if (hasComponentProxyConfigs) { - description.append(" If set, it supersedes proxy settings configured per component."); - } description.append(" Supported proxies: "); description.append(specs.stream().map(ProxySpec::getDisplayName).collect(Collectors.joining(", "))); @@ -126,28 +122,17 @@ public static void validateProxySpec(ValidationContext context, Collection DIRECT_CONFIGURATION); - } - - /** - * This method can be used by Components those originally have per component proxy configurations - * to implement ProxyConfiguration Controller Service with backward compatibility. - * @param context the process context - * @param perComponentSetting the function to supply ProxyConfiguration based on per component settings, - * only called when Proxy Configuration Service is not set - * @return The proxy configurations at Controller Service if set, or per component settings otherwise - */ - public static ProxyConfiguration getConfiguration(PropertyContext context, Supplier perComponentSetting) { if (context.getProperty(PROXY_CONFIGURATION_SERVICE).isSet()) { final ProxyConfigurationService proxyService = context.getProperty(PROXY_CONFIGURATION_SERVICE).asControllerService(ProxyConfigurationService.class); return proxyService.getConfiguration(); } else { - return perComponentSetting.get(); + return DIRECT_CONFIGURATION; } } diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-api/src/main/java/org/apache/nifi/proxy/ProxyConfigurationService.java b/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-api/src/main/java/org/apache/nifi/proxy/ProxyConfigurationService.java index 8e6594bf3635..026f050de60c 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-api/src/main/java/org/apache/nifi/proxy/ProxyConfigurationService.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-api/src/main/java/org/apache/nifi/proxy/ProxyConfigurationService.java @@ -27,8 +27,7 @@ public interface ProxyConfigurationService extends ControllerService { PropertyDescriptor PROXY_CONFIGURATION_SERVICE = new PropertyDescriptor.Builder() .name("proxy-configuration-service") .displayName("Proxy Configuration Service") - .description("Specifies the Proxy Configuration Controller Service to proxy network requests." + - " If set, it supersedes proxy settings configured per component.") + .description("Specifies the Proxy Configuration Controller Service to proxy network requests.") .identifiesControllerService(ProxyConfigurationService.class) .required(false) .build(); diff --git a/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-api/src/test/java/org/apache/nifi/proxy/TestProxyConfiguration.java b/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-api/src/test/java/org/apache/nifi/proxy/TestProxyConfiguration.java index 9ab60eef2779..d27798f0e7eb 100644 --- a/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-api/src/test/java/org/apache/nifi/proxy/TestProxyConfiguration.java +++ b/nifi-extension-bundles/nifi-standard-services/nifi-proxy-configuration-api/src/test/java/org/apache/nifi/proxy/TestProxyConfiguration.java @@ -56,7 +56,7 @@ private void setProxySpecs(ProxySpec... proxySpecs) { @Override protected List getSupportedPropertyDescriptors() { - return Collections.singletonList(createProxyConfigPropertyDescriptor(true, proxySpecs)); + return Collections.singletonList(createProxyConfigPropertyDescriptor(proxySpecs)); } @Override