thenatog commented on a change in pull request #4673:
URL: https://github.com/apache/nifi/pull/4673#discussion_r541266376



##########
File path: 
nifi-commons/nifi-security-utils-api/src/main/java/org/apache/nifi/security/util/TlsPlatform.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.security.util;
+
+import static java.util.Collections.unmodifiableSet;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLParameters;
+import java.security.NoSuchAlgorithmException;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+/**
+ * Transport Layer Security Platform provides runtime protocol configuration 
information
+ */
+public class TlsPlatform {
+    private static final Pattern PROTOCOL_VERSION = 
Pattern.compile("TLSv(\\d+\\.?\\d*)");
+
+    private static final int FIRST_GROUP = 1;
+
+    private static final List<String> LEGACY_PROTOCOLS = 
Arrays.asList("TLSv1", "TLSv1.1");
+
+    private static final SortedMap<Float, String> SORTED_PROTOCOLS = 
getDefaultSslContextProtocols();
+
+    private static final Set<String> DEFAULT_PROTOCOLS = unmodifiableSet(new 
TreeSet<>(SORTED_PROTOCOLS.values()).descendingSet());
+
+    private static final Set<String> PREFERRED_PROTOCOLS = unmodifiableSet(
+            DEFAULT_PROTOCOLS.stream()
+            .filter(protocol -> !LEGACY_PROTOCOLS.contains(protocol))
+            .collect(Collectors.toSet())
+    );
+
+    /**
+     * Get Default Protocols based on Java Security configuration
+     *
+     * @return Set of Transport Layer Security Protocol names
+     */
+    public static Set<String> getDefaultProtocols() {

Review comment:
       This method returns all available protocols, and not necessarily the 
protocol we will/want to 'default' to. In what circumstances should this method 
be called? Situations where we allow legacy protocols (outgoing processors I 
believe)? I think the naming and comment can be more clear about when we expect 
this to be used and when it should be used over the other methods. 
getAllAvailableProtocols() is more accurate. 




----------------------------------------------------------------
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]


Reply via email to