From 0f9e9644bb7db12dc054dce13d136996fd511fe8 Mon Sep 17 00:00:00 2001 From: Marcin Date: Wed, 1 Jan 2025 21:33:30 +0100 Subject: [PATCH] post mina custom ssl filter removal --- .../java/quickfix/mina/CustomSslFilter.java | 35 ------------------- .../mina/acceptor/AbstractSocketAcceptor.java | 3 +- .../mina/initiator/IoSessionInitiator.java | 9 ++--- 3 files changed, 4 insertions(+), 43 deletions(-) delete mode 100644 quickfixj-core/src/main/java/quickfix/mina/CustomSslFilter.java diff --git a/quickfixj-core/src/main/java/quickfix/mina/CustomSslFilter.java b/quickfixj-core/src/main/java/quickfix/mina/CustomSslFilter.java deleted file mode 100644 index 7092d6134d..0000000000 --- a/quickfixj-core/src/main/java/quickfix/mina/CustomSslFilter.java +++ /dev/null @@ -1,35 +0,0 @@ -package quickfix.mina; - -import org.apache.mina.core.filterchain.IoFilterChain; -import org.apache.mina.core.session.IoSession; -import org.apache.mina.filter.ssl.SslFilter; - -import javax.net.ssl.SSLContext; - -/** - * Temporary {@link SslFilter} wrapper that prevents auto connect for initiators. - */ -public class CustomSslFilter extends SslFilter { - - private static final boolean DEFAULT_AUTO_START = true; - - private final boolean autoStart; - - public CustomSslFilter(SSLContext sslContext) { - this(sslContext, DEFAULT_AUTO_START); - } - - public CustomSslFilter(SSLContext sslContext, boolean autoStart) { - super(sslContext); - this.autoStart = autoStart; - } - - @Override - public void onPostAdd(IoFilterChain parent, String name, NextFilter next) throws Exception { - IoSession session = parent.getSession(); - - if (session.isConnected() && autoStart) { - onConnected(next, session); - } - } -} diff --git a/quickfixj-core/src/main/java/quickfix/mina/acceptor/AbstractSocketAcceptor.java b/quickfixj-core/src/main/java/quickfix/mina/acceptor/AbstractSocketAcceptor.java index df0c18ff35..f9f418b5d6 100644 --- a/quickfixj-core/src/main/java/quickfix/mina/acceptor/AbstractSocketAcceptor.java +++ b/quickfixj-core/src/main/java/quickfix/mina/acceptor/AbstractSocketAcceptor.java @@ -40,7 +40,6 @@ import quickfix.SessionID; import quickfix.SessionSettings; import quickfix.mina.CompositeIoFilterChainBuilder; -import quickfix.mina.CustomSslFilter; import quickfix.mina.EventHandlingStrategy; import quickfix.mina.NetworkingOptions; import quickfix.mina.ProtocolFactory; @@ -135,7 +134,7 @@ private void installSSL(AcceptorSocketDescriptor descriptor, log.info("Installing SSL filter for {}", descriptor.getAddress()); SSLConfig sslConfig = descriptor.getSslConfig(); SSLContext sslContext = SSLContextFactory.getInstance(sslConfig); - SslFilter sslFilter = new CustomSslFilter(sslContext); + SslFilter sslFilter = new SslFilter(sslContext); sslFilter.setNeedClientAuth(sslConfig.isNeedClientAuth()); sslFilter.setEnabledCipherSuites(sslConfig.getEnabledCipherSuites() != null ? sslConfig.getEnabledCipherSuites() : SSLSupport.getDefaultCipherSuites(sslContext)); diff --git a/quickfixj-core/src/main/java/quickfix/mina/initiator/IoSessionInitiator.java b/quickfixj-core/src/main/java/quickfix/mina/initiator/IoSessionInitiator.java index 96436e0837..163a186ab5 100644 --- a/quickfixj-core/src/main/java/quickfix/mina/initiator/IoSessionInitiator.java +++ b/quickfixj-core/src/main/java/quickfix/mina/initiator/IoSessionInitiator.java @@ -34,7 +34,6 @@ import quickfix.SessionSettings; import quickfix.SystemTime; import quickfix.mina.CompositeIoFilterChainBuilder; -import quickfix.mina.CustomSslFilter; import quickfix.mina.EventHandlingStrategy; import quickfix.mina.NetworkingOptions; import quickfix.mina.ProtocolFactory; @@ -159,9 +158,8 @@ private void setupIoConnector() throws ConfigError, GeneralSecurityException { boolean hasProxy = proxyType != null && proxyPort > 0 && socketAddresses[nextSocketAddressIndex] instanceof InetSocketAddress; - SslFilter sslFilter = null; if (sslEnabled) { - sslFilter = installSslFilter(ioFilterChainBuilder); + installSslFilter(ioFilterChainBuilder); } ioFilterChainBuilder.addLast(FIXProtocolCodecFactory.FILTER_NAME, new ProtocolCodecFilter(new FIXProtocolCodecFactory())); @@ -192,17 +190,16 @@ private void setupIoConnector() throws ConfigError, GeneralSecurityException { ioConnector = newConnector; } - private SslFilter installSslFilter(CompositeIoFilterChainBuilder ioFilterChainBuilder) + private void installSslFilter(CompositeIoFilterChainBuilder ioFilterChainBuilder) throws GeneralSecurityException { final SSLContext sslContext = SSLContextFactory.getInstance(sslConfig); - final SslFilter sslFilter = new CustomSslFilter(sslContext, false); + final SslFilter sslFilter = new SslFilter(sslContext, false); sslFilter.setEnabledCipherSuites(sslConfig.getEnabledCipherSuites() != null ? sslConfig.getEnabledCipherSuites() : SSLSupport.getDefaultCipherSuites(sslContext)); sslFilter.setEnabledProtocols(sslConfig.getEnabledProtocols() != null ? sslConfig.getEnabledProtocols() : SSLSupport.getSupportedProtocols(sslContext)); sslFilter.setEndpointIdentificationAlgorithm(sslConfig.getEndpointIdentificationAlgorithm()); ioFilterChainBuilder.addLast(SSLSupport.FILTER_NAME, sslFilter); - return sslFilter; } @Override