Skip to content

Commit 2834fa4

Browse files
ijokarumawakMikeThomsen
authored andcommitted
NIFI-4199: Added ProxyConfigurationService
- Added ProxyConfigurationService to manage centralized proxy configurations - Adopt ProxyConfigurationService at FTP and HTTP processors NIFI-4175 - Add HTTP proxy support to *SFTP processors This closes #2018. Signed-off-by: Koji Kawamura <ijokarumawak@apache.org> NIFI-4199: Add ProxyConfigurationService to SFTP processors - Fixed check style issue - Use the same proxy related PropertyDescriptors from FTPTransfer and SFTPTransfer - Dropped FlowFile EL evaluation support to make it align with other processors spec, Now it supports VARIABLE_REGISTRY - Added ProxyConfigurationService to SFTP processors - Added SOCKS proxy support to SFTP processors NIFI-4199: Added ProxyConfigurationService to ElasticsearchHttp processors - ElasticsearchHttp processors now support SOCKS proxy, too - Added proxy support to PutElasticsearchHttpRecord - Moved more common property descriptors to AbstractElasticsearchHttpProcessor and just return static unmodifiable property descriptor list at each implementation processors NIFI-4196 - Expose AWS proxy authentication settings NIFI-4196 - Fix jUnit errors This closes #2016. Signed-off-by: Koji Kawamura <ijokarumawak@apache.org> NIFI-4199: Add ProxyConfigService to AWS processors - Applied ProxyConfigService to S3 processors - Added proxy support to following processors: - PutKinesisFirehose, PutKinesisStream - PutDynamoDB, DeleteDynamoDB, GetDynamoDB - PutKinesisStream - All AWS processors support HTTP proxy now NIFI-4199: Add ProxyConfigService to Azure processors NIFI-4199: More explicit validation and docs for Proxy spec - Each processor has different supporting Proxy specs - Show supported spec to ProxyConfigurationService property doc - Validate not only Proxy type, but also with Authentication NIFI-4199: Incorporated review comments - Fixed TestListS3 property descriptor check - Separate name and displayName This closes #2016 This closes #2018 This closes #2704 Signed-off-by: Mike Thomsen <mikerthomsen@gmail.com>
1 parent d79216d commit 2834fa4

64 files changed

Lines changed: 1326 additions & 195 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

nifi-assembly/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,12 @@ language governing permissions and limitations under the License. -->
703703
<version>1.7.0-SNAPSHOT</version>
704704
<type>nar</type>
705705
</dependency>
706+
<dependency>
707+
<groupId>org.apache.nifi</groupId>
708+
<artifactId>nifi-proxy-configuration-nar</artifactId>
709+
<version>1.7.0-SNAPSHOT</version>
710+
<type>nar</type>
711+
</dependency>
706712
</dependencies>
707713
<profiles>
708714
<profile>

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@
7676
<artifactId>nifi-utils</artifactId>
7777
<version>1.7.0-SNAPSHOT</version>
7878
</dependency>
79+
<dependency>
80+
<groupId>org.apache.nifi</groupId>
81+
<artifactId>nifi-proxy-configuration-api</artifactId>
82+
</dependency>
7983
</dependencies>
8084

8185
</project>

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.amazonaws.regions.Regions;
2929
import java.io.File;
3030
import java.io.IOException;
31+
import java.net.Proxy;
3132
import java.util.ArrayList;
3233
import java.util.Arrays;
3334
import java.util.Collection;
@@ -53,6 +54,8 @@
5354
import org.apache.nifi.processor.util.StandardValidators;
5455
import org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors;
5556
import org.apache.nifi.processors.aws.regions.AWSRegions;
57+
import org.apache.nifi.proxy.ProxyConfiguration;
58+
import org.apache.nifi.proxy.ProxySpec;
5659
import org.apache.nifi.ssl.SSLContextService;
5760

5861
/**
@@ -93,6 +96,25 @@ public abstract class AbstractAWSProcessor<ClientType extends AmazonWebServiceCl
9396
.addValidator(StandardValidators.PORT_VALIDATOR)
9497
.build();
9598

99+
public static final PropertyDescriptor PROXY_USERNAME = new PropertyDescriptor.Builder()
100+
.name("proxy-user-name")
101+
.displayName("Proxy Username")
102+
.description("Proxy username")
103+
.expressionLanguageSupported(true)
104+
.required(false)
105+
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
106+
.build();
107+
108+
public static final PropertyDescriptor PROXY_PASSWORD = new PropertyDescriptor.Builder()
109+
.name("proxy-user-password")
110+
.displayName("Proxy Password")
111+
.description("Proxy password")
112+
.expressionLanguageSupported(true)
113+
.required(false)
114+
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
115+
.sensitive(true)
116+
.build();
117+
96118
public static final PropertyDescriptor REGION = new PropertyDescriptor.Builder()
97119
.name("Region")
98120
.required(true)
@@ -131,6 +153,9 @@ public abstract class AbstractAWSProcessor<ClientType extends AmazonWebServiceCl
131153
protected static final Protocol DEFAULT_PROTOCOL = Protocol.HTTPS;
132154
protected static final String DEFAULT_USER_AGENT = "NiFi";
133155

156+
private static final ProxySpec[] PROXY_SPECS = {ProxySpec.HTTP_AUTH};
157+
public static final PropertyDescriptor PROXY_CONFIGURATION_SERVICE = ProxyConfiguration.createProxyConfigPropertyDescriptor(true, PROXY_SPECS);
158+
134159
private static AllowableValue createAllowableValue(final Regions region) {
135160
return new AllowableValue(region.getName(), AWSRegions.getRegionDisplayName(region.getName()));
136161
}
@@ -169,6 +194,8 @@ protected Collection<ValidationResult> customValidate(final ValidationContext va
169194
problems.add(new ValidationResult.Builder().input("Proxy Host Port").valid(false).explanation("Both proxy host and port must be set").build());
170195
}
171196

197+
ProxyConfiguration.validateProxySpec(validationContext, problems, PROXY_SPECS);
198+
172199
return problems;
173200
}
174201

@@ -193,11 +220,31 @@ protected ClientConfiguration createConfiguration(final ProcessContext context)
193220
}
194221
}
195222

196-
if (context.getProperty(PROXY_HOST).isSet()) {
197-
String proxyHost = context.getProperty(PROXY_HOST).evaluateAttributeExpressions().getValue();
198-
config.setProxyHost(proxyHost);
199-
Integer proxyPort = context.getProperty(PROXY_HOST_PORT).evaluateAttributeExpressions().asInteger();
200-
config.setProxyPort(proxyPort);
223+
final ProxyConfiguration proxyConfig = ProxyConfiguration.getConfiguration(context, () -> {
224+
if (context.getProperty(PROXY_HOST).isSet()) {
225+
final ProxyConfiguration componentProxyConfig = new ProxyConfiguration();
226+
String proxyHost = context.getProperty(PROXY_HOST).evaluateAttributeExpressions().getValue();
227+
Integer proxyPort = context.getProperty(PROXY_HOST_PORT).evaluateAttributeExpressions().asInteger();
228+
String proxyUsername = context.getProperty(PROXY_USERNAME).evaluateAttributeExpressions().getValue();
229+
String proxyPassword = context.getProperty(PROXY_PASSWORD).evaluateAttributeExpressions().getValue();
230+
componentProxyConfig.setProxyType(Proxy.Type.HTTP);
231+
componentProxyConfig.setProxyServerHost(proxyHost);
232+
componentProxyConfig.setProxyServerPort(proxyPort);
233+
componentProxyConfig.setProxyUserName(proxyUsername);
234+
componentProxyConfig.setProxyUserPassword(proxyPassword);
235+
return componentProxyConfig;
236+
}
237+
return ProxyConfiguration.DIRECT_CONFIGURATION;
238+
});
239+
240+
if (Proxy.Type.HTTP.equals(proxyConfig.getProxyType())) {
241+
config.setProxyHost(proxyConfig.getProxyServerHost());
242+
config.setProxyPort(proxyConfig.getProxyServerPort());
243+
244+
if (proxyConfig.hasCredential()) {
245+
config.setProxyUsername(proxyConfig.getProxyUserName());
246+
config.setProxyPassword(proxyConfig.getProxyUserPassword());
247+
}
201248
}
202249

203250
return config;

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/cloudwatch/PutCloudWatchMetric.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public ValidationResult validate(String subject, String input, ValidationContext
174174
Collections.unmodifiableList(
175175
Arrays.asList(NAMESPACE, METRIC_NAME, VALUE, MAXIMUM, MINIMUM, SAMPLECOUNT, SUM, TIMESTAMP,
176176
UNIT, REGION, ACCESS_KEY, SECRET_KEY, CREDENTIALS_FILE, AWS_CREDENTIALS_PROVIDER_SERVICE,
177-
TIMEOUT, SSL_CONTEXT_SERVICE, ENDPOINT_OVERRIDE, PROXY_HOST, PROXY_HOST_PORT)
177+
TIMEOUT, SSL_CONTEXT_SERVICE, ENDPOINT_OVERRIDE, PROXY_HOST, PROXY_HOST_PORT, PROXY_USERNAME, PROXY_PASSWORD)
178178
);
179179

180180
private volatile Set<String> dynamicPropertyNames = new HashSet<>();

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/DeleteDynamoDB.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ public class DeleteDynamoDB extends AbstractWriteDynamoDBProcessor {
7474
public static final List<PropertyDescriptor> properties = Collections.unmodifiableList(
7575
Arrays.asList(TABLE, HASH_KEY_NAME, RANGE_KEY_NAME, HASH_KEY_VALUE, RANGE_KEY_VALUE,
7676
HASH_KEY_VALUE_TYPE, RANGE_KEY_VALUE_TYPE, BATCH_SIZE, REGION, ACCESS_KEY, SECRET_KEY,
77-
CREDENTIALS_FILE, AWS_CREDENTIALS_PROVIDER_SERVICE, TIMEOUT, SSL_CONTEXT_SERVICE));
77+
CREDENTIALS_FILE, AWS_CREDENTIALS_PROVIDER_SERVICE, TIMEOUT, SSL_CONTEXT_SERVICE,
78+
PROXY_CONFIGURATION_SERVICE, PROXY_HOST, PROXY_HOST_PORT, PROXY_USERNAME, PROXY_PASSWORD));
7879

7980
@Override
8081
protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/GetDynamoDB.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ public class GetDynamoDB extends AbstractDynamoDBProcessor {
8080
public static final List<PropertyDescriptor> properties = Collections.unmodifiableList(
8181
Arrays.asList(TABLE, HASH_KEY_NAME, RANGE_KEY_NAME, HASH_KEY_VALUE, RANGE_KEY_VALUE,
8282
HASH_KEY_VALUE_TYPE, RANGE_KEY_VALUE_TYPE, JSON_DOCUMENT, BATCH_SIZE, REGION, ACCESS_KEY, SECRET_KEY,
83-
CREDENTIALS_FILE, AWS_CREDENTIALS_PROVIDER_SERVICE, TIMEOUT, SSL_CONTEXT_SERVICE));
83+
CREDENTIALS_FILE, AWS_CREDENTIALS_PROVIDER_SERVICE, TIMEOUT, SSL_CONTEXT_SERVICE,
84+
PROXY_CONFIGURATION_SERVICE, PROXY_HOST, PROXY_HOST_PORT, PROXY_USERNAME, PROXY_PASSWORD));
8485

8586
public static final Relationship REL_NOT_FOUND = new Relationship.Builder().name("not found")
8687
.description("FlowFiles are routed to not found relationship if key not found in the table").build();

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/dynamodb/PutDynamoDB.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ public class PutDynamoDB extends AbstractWriteDynamoDBProcessor {
8484
public static final List<PropertyDescriptor> properties = Collections.unmodifiableList(
8585
Arrays.asList(TABLE, HASH_KEY_NAME, RANGE_KEY_NAME, HASH_KEY_VALUE, RANGE_KEY_VALUE,
8686
HASH_KEY_VALUE_TYPE, RANGE_KEY_VALUE_TYPE, JSON_DOCUMENT, DOCUMENT_CHARSET, BATCH_SIZE,
87-
REGION, ACCESS_KEY, SECRET_KEY, CREDENTIALS_FILE, AWS_CREDENTIALS_PROVIDER_SERVICE, TIMEOUT, SSL_CONTEXT_SERVICE));
87+
REGION, ACCESS_KEY, SECRET_KEY, CREDENTIALS_FILE, AWS_CREDENTIALS_PROVIDER_SERVICE, TIMEOUT, SSL_CONTEXT_SERVICE,
88+
PROXY_CONFIGURATION_SERVICE, PROXY_HOST, PROXY_HOST_PORT, PROXY_USERNAME, PROXY_PASSWORD));
8889

8990
/**
9091
* Dyamodb max item size limit 400 kb

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/kinesis/firehose/PutKinesisFirehose.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class PutKinesisFirehose extends AbstractKinesisFirehoseProcessor {
7272

7373
public static final List<PropertyDescriptor> properties = Collections.unmodifiableList(
7474
Arrays.asList(KINESIS_FIREHOSE_DELIVERY_STREAM_NAME, BATCH_SIZE, MAX_MESSAGE_BUFFER_SIZE_MB, REGION, ACCESS_KEY, SECRET_KEY, CREDENTIALS_FILE, AWS_CREDENTIALS_PROVIDER_SERVICE, TIMEOUT,
75-
PROXY_HOST, PROXY_HOST_PORT, ENDPOINT_OVERRIDE));
75+
PROXY_CONFIGURATION_SERVICE, PROXY_HOST, PROXY_HOST_PORT, PROXY_USERNAME, PROXY_PASSWORD, ENDPOINT_OVERRIDE));
7676

7777
/**
7878
* Max buffer size 1 MB

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/kinesis/stream/PutKinesisStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public class PutKinesisStream extends AbstractKinesisStreamProcessor {
8080

8181
public static final List<PropertyDescriptor> properties = Collections.unmodifiableList(
8282
Arrays.asList(KINESIS_STREAM_NAME, KINESIS_PARTITION_KEY, BATCH_SIZE, MAX_MESSAGE_BUFFER_SIZE_MB, REGION, ACCESS_KEY, SECRET_KEY, CREDENTIALS_FILE,
83-
AWS_CREDENTIALS_PROVIDER_SERVICE, TIMEOUT, PROXY_HOST, PROXY_HOST_PORT, ENDPOINT_OVERRIDE));
83+
AWS_CREDENTIALS_PROVIDER_SERVICE, TIMEOUT, PROXY_CONFIGURATION_SERVICE, PROXY_HOST, PROXY_HOST_PORT, PROXY_USERNAME, PROXY_PASSWORD, ENDPOINT_OVERRIDE));
8484

8585
/** A random number generator for cases where partition key is not available */
8686
protected Random randomParitionKeyGenerator = new Random();

nifi-nar-bundles/nifi-aws-bundle/nifi-aws-processors/src/main/java/org/apache/nifi/processors/aws/lambda/PutLambda.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ public class PutLambda extends AbstractAWSLambdaProcessor {
127127
public static final long MAX_REQUEST_SIZE = 6 * 1000 * 1000;
128128

129129
public static final List<PropertyDescriptor> properties = Collections.unmodifiableList(
130-
Arrays.asList(AWS_LAMBDA_FUNCTION_NAME, AWS_LAMBDA_FUNCTION_QUALIFIER, REGION, ACCESS_KEY, SECRET_KEY, CREDENTIALS_FILE, AWS_CREDENTIALS_PROVIDER_SERVICE, TIMEOUT
131-
));
130+
Arrays.asList(AWS_LAMBDA_FUNCTION_NAME, AWS_LAMBDA_FUNCTION_QUALIFIER, REGION, ACCESS_KEY, SECRET_KEY, CREDENTIALS_FILE, AWS_CREDENTIALS_PROVIDER_SERVICE, TIMEOUT,
131+
PROXY_CONFIGURATION_SERVICE, PROXY_HOST, PROXY_HOST_PORT, PROXY_USERNAME, PROXY_PASSWORD));
132132

133133
@Override
134134
protected List<PropertyDescriptor> getSupportedPropertyDescriptors() {

0 commit comments

Comments
 (0)