diff --git a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/AbstractGCPProcessor.java b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/AbstractGCPProcessor.java index 995805c0ce..9b9a2531be 100644 --- a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/AbstractGCPProcessor.java +++ b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/AbstractGCPProcessor.java @@ -55,6 +55,25 @@ public abstract class AbstractGCPProcessor< .addValidator(StandardValidators.INTEGER_VALIDATOR) .build(); + public static final PropertyDescriptor PROXY_HOST = new PropertyDescriptor + .Builder().name("gcp-proxy-host") + .displayName("Proxy host") + .description("IP or hostname of the proxy to be used") + .required(false) + .expressionLanguageSupported(false) + .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .build(); + + public static final PropertyDescriptor PROXY_PORT = new PropertyDescriptor + .Builder().name("gcp-proxy-port") + .displayName("Proxy port") + .description("Proxy port number") + .required(false) + .expressionLanguageSupported(false) + .addValidator(StandardValidators.INTEGER_VALIDATOR) + .build(); + + /** * Links to the {@link GCPCredentialsService} which provides credentials for this particular processor. */ @@ -78,7 +97,9 @@ public abstract class AbstractGCPProcessor< return ImmutableList.of( GCP_CREDENTIALS_PROVIDER_SERVICE, PROJECT_ID, - RETRY_COUNT + RETRY_COUNT, + PROXY_HOST, + PROXY_PORT ); } diff --git a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/storage/AbstractGCSProcessor.java b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/storage/AbstractGCSProcessor.java index ff368b55df..7cc854d02b 100644 --- a/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/storage/AbstractGCSProcessor.java +++ b/nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/storage/AbstractGCSProcessor.java @@ -16,6 +16,9 @@ */ package org.apache.nifi.processors.gcp.storage; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.http.javanet.NetHttpTransport; +import com.google.auth.http.HttpTransportFactory; import com.google.auth.oauth2.GoogleCredentials; import com.google.cloud.RetryParams; import com.google.cloud.storage.Storage; @@ -26,7 +29,10 @@ import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.processor.ProcessContext; import org.apache.nifi.processor.Relationship; import org.apache.nifi.processors.gcp.AbstractGCPProcessor; +import org.apache.nifi.util.StringUtils; +import java.net.InetSocketAddress; +import java.net.Proxy; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; @@ -66,15 +72,36 @@ public abstract class AbstractGCSProcessor extends AbstractGCPProcessor 0) { + storageOptionsBuilder.setHttpTransportFactory(new HttpTransportFactory() { + @Override + public HttpTransport create() { + final HttpTransport transport = new NetHttpTransport.Builder() + .setProxy( + new Proxy( + Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort) + ) + ) + .build(); + return transport; + } + }); + } + return storageOptionsBuilder.build(); } + + }