exceptionfactory commented on a change in pull request #5061:
URL: https://github.com/apache/nifi/pull/5061#discussion_r655660187
##########
File path:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java
##########
@@ -72,17 +74,49 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
import static
org.apache.nifi.processors.standard.util.FTPTransfer.createComponentProxyConfigSupplier;
public class SFTPTransfer implements FileTransfer {
+ private static final Set<String> DEFAULT_KEY_ALGORITHM_NAMES;
+ private static final Set<String> DEFAULT_CIPHER_NAMES;
+ private static final Set<String> DEFAULT_MESSAGE_AUTHENTICATION_CODE_NAMES;
+ private static final Set<String> DEFAULT_KEY_EXCHANGE_ALGORITHM_NAMES;
+
+ static {
+ DefaultConfig defaultConfig = new DefaultConfig();
+
+ DEFAULT_KEY_ALGORITHM_NAMES = defaultConfig.getKeyAlgorithms().stream()
+
.map(Factory.Named::getName).collect(Collectors.toUnmodifiableSet());
Review comment:
Unfortunately `Collectors.toUnmodifiableSet()` is not supported on Java
8, so GitHub automated builds failed. Switching to `Collectors.toSet()` and
wrapping it with `Collections.unmodifableSet()` should work for both Java 8 and
11.
##########
File path:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/util/SFTPTransfer.java
##########
@@ -642,6 +712,44 @@ public Socket createSocket(InetAddress inetAddress, int i,
InetAddress inetAddre
return sftpClient;
}
+ void updateConfigAlgorithms(Config config) {
+ if(ctx.getProperty(CIPHERS_ALLOWED).isSet()) {
+ Set<String> allowedCiphers =
Arrays.stream(ctx.getProperty(CIPHERS_ALLOWED).evaluateAttributeExpressions().getValue().split(","))
+ .map(String::trim)
+ .collect(Collectors.toSet());
Review comment:
To reduce duplication and ensure the same behavior, what do you think
about refactoring similar property processing behavior to a shared method?
Something along the following lines:
```
private Set<String> getCommaSeparatedValues(final PropertyValue
propertyValue) {
Set<String> values = Collections.emptySet();
if (propertyValue.isSet()) {
values =
Arrays.stream(propertyValue.evaluateAttributeExpressions().getValue().split(","))
.map(String::trim)
.collect(Collectors.toSet());
}
return values;
}
```
It may also be possible to create a shared method for collected allowed
values, but at least creating a shared method for parsing property values would
be helpful.
--
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]