This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new abf88c3aab NIFI-10240 Removed custom validation for SSL Context 
Service in ListenSyslog
abf88c3aab is described below

commit abf88c3aab3919f3a43cb181aa38e3a54be81010
Author: Emilio Setiadarma <[email protected]>
AuthorDate: Wed Sep 21 10:15:45 2022 -0700

    NIFI-10240 Removed custom validation for SSL Context Service in ListenSyslog
    
    - Made sure to check TCP is protocol set before using SSL Context Service 
during runtime
    
    This closes #6441
    
    Signed-off-by: David Handermann <[email protected]>
---
 .../nifi/processors/standard/ListenSyslog.java       | 16 ++++------------
 .../nifi/processors/standard/TestListenSyslog.java   | 20 --------------------
 2 files changed, 4 insertions(+), 32 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ListenSyslog.java
 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ListenSyslog.java
index 1927b9ac7e..74409e836a 100644
--- 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ListenSyslog.java
+++ 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/ListenSyslog.java
@@ -267,15 +267,6 @@ public class ListenSyslog extends AbstractSyslogProcessor {
                 .explanation("Cannot set Parse Messages to 'true' if Batch 
Size is greater than 1").build());
         }
 
-        final String protocol = 
validationContext.getProperty(PROTOCOL).getValue();
-        final SSLContextService sslContextService = 
validationContext.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
-
-        if (UDP_VALUE.getValue().equals(protocol) && sslContextService != 
null) {
-            results.add(new ValidationResult.Builder()
-                    .explanation("SSL can not be used with UDP")
-                    .valid(false).subject("SSL Context").build());
-        }
-
         return results;
     }
 
@@ -285,7 +276,8 @@ public class ListenSyslog extends AbstractSyslogProcessor {
         final int receiveBufferSize = 
context.getProperty(RECV_BUFFER_SIZE).asDataSize(DataUnit.B).intValue();
         final int maxSocketBufferSize = 
context.getProperty(MAX_SOCKET_BUFFER_SIZE).asDataSize(DataUnit.B).intValue();
         final int maxMessageQueueSize = 
context.getProperty(MAX_MESSAGE_QUEUE_SIZE).asInteger();
-        final TransportProtocol protocol = 
TransportProtocol.valueOf(context.getProperty(PROTOCOL).getValue());
+        final String protocol = context.getProperty(PROTOCOL).getValue();
+        final TransportProtocol transportProtocol = 
TransportProtocol.valueOf(protocol);
         final String networkInterfaceName = 
context.getProperty(NETWORK_INTF_NAME).evaluateAttributeExpressions().getValue();
         final Charset charset = 
Charset.forName(context.getProperty(CHARSET).evaluateAttributeExpressions().getValue());
         final String msgDemarcator = 
context.getProperty(MESSAGE_DELIMITER).getValue().replace("\\n", 
"\n").replace("\\r", "\r").replace("\\t", "\t");
@@ -295,7 +287,7 @@ public class ListenSyslog extends AbstractSyslogProcessor {
 
         final InetAddress address = getListenAddress(networkInterfaceName);
         final ByteArrayMessageNettyEventServerFactory factory = new 
ByteArrayMessageNettyEventServerFactory(getLogger(),
-                address, port, protocol, messageDemarcatorBytes, 
receiveBufferSize, syslogEvents);
+                address, port, transportProtocol, messageDemarcatorBytes, 
receiveBufferSize, syslogEvents);
         factory.setThreadNamePrefix(String.format("%s[%s]", 
ListenSyslog.class.getSimpleName(), getIdentifier()));
         final int maxConnections = 
context.getProperty(MAX_CONNECTIONS).asLong().intValue();
         factory.setWorkerThreads(maxConnections);
@@ -305,7 +297,7 @@ public class ListenSyslog extends AbstractSyslogProcessor {
         factory.setSocketKeepAlive(socketKeepAlive);
 
         final SSLContextService sslContextService = 
context.getProperty(SSL_CONTEXT_SERVICE).asControllerService(SSLContextService.class);
-        if (sslContextService != null) {
+        if (sslContextService != null && 
TCP_VALUE.getValue().equals(protocol)) {
             final SSLContext sslContext = sslContextService.createContext();
             ClientAuth clientAuth = ClientAuth.REQUIRED;
             final PropertyValue clientAuthProperty = 
context.getProperty(CLIENT_AUTH);
diff --git 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestListenSyslog.java
 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestListenSyslog.java
index 603e4192f0..02ef0d2c3e 100644
--- 
a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestListenSyslog.java
+++ 
b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestListenSyslog.java
@@ -24,8 +24,6 @@ import org.apache.nifi.flowfile.attributes.CoreAttributes;
 import org.apache.nifi.provenance.ProvenanceEventRecord;
 import org.apache.nifi.provenance.ProvenanceEventType;
 import org.apache.nifi.remote.io.socket.NetworkUtils;
-import org.apache.nifi.reporting.InitializationException;
-import org.apache.nifi.ssl.RestrictedSSLContextService;
 import org.apache.nifi.syslog.attributes.SyslogAttributes;
 import org.apache.nifi.util.MockFlowFile;
 import org.apache.nifi.util.TestRunner;
@@ -42,8 +40,6 @@ import java.util.List;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 public class TestListenSyslog {
     private static final String PRIORITY = "34";
@@ -76,22 +72,6 @@ public class TestListenSyslog {
         processor.shutdownEventServer();
     }
 
-    @Test
-    public void testUdpSslContextServiceInvalid() throws 
InitializationException {
-        runner.setProperty(ListenSyslog.PROTOCOL, 
TransportProtocol.UDP.toString());
-        final int port = NetworkUtils.getAvailableUdpPort();
-        runner.setProperty(ListenSyslog.PORT, Integer.toString(port));
-
-        final RestrictedSSLContextService sslContextService = 
mock(RestrictedSSLContextService.class);
-        final String identifier = RestrictedSSLContextService.class.getName();
-        when(sslContextService.getIdentifier()).thenReturn(identifier);
-        runner.addControllerService(identifier, sslContextService);
-        runner.enableControllerService(sslContextService);
-        runner.setProperty(ListenSyslog.SSL_CONTEXT_SERVICE, identifier);
-
-        runner.assertNotValid();
-    }
-
     @Test
     public void testRunTcp() throws Exception {
         final int port = NetworkUtils.getAvailableTcpPort();

Reply via email to