Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.quickfixj.jmx.JmxExporter;
import org.quickfixj.jmx.mbean.JmxSupport;
import org.quickfixj.jmx.mbean.session.SessionJmxExporter;
import org.quickfixj.jmx.openmbean.TabularDataAdapter;
import quickfix.SessionID;
import quickfix.mina.acceptor.AbstractSocketAcceptor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ public void sessionClosed(IoSession ioSession) {
if (quickFixSession != null) {
eventHandlingStrategy.onMessage(quickFixSession, EventHandlingStrategy.END_OF_STREAM);
}
} catch (Exception e) {
throw e;
} finally {
ioSession.removeAttribute(SessionConnector.QF_SESSION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import quickfix.mina.ProtocolFactory;
import quickfix.mina.SessionConnector;
import quickfix.mina.message.FIXProtocolCodecFactory;
import quickfix.mina.ssl.AcceptorSslFilter;
import quickfix.mina.ssl.SSLConfig;
import quickfix.mina.ssl.SSLContextFactory;
import quickfix.mina.ssl.SSLSupport;
Expand Down Expand Up @@ -134,7 +135,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 SslFilter(sslContext);
SslFilter sslFilter = new AcceptorSslFilter(sslContext);
sslFilter.setNeedClientAuth(sslConfig.isNeedClientAuth());
sslFilter.setEnabledCipherSuites(sslConfig.getEnabledCipherSuites() != null ? sslConfig.getEnabledCipherSuites()
: SSLSupport.getDefaultCipherSuites(sslContext));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package quickfix.mina.ssl;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.ssl.SslFilter;

import javax.net.ssl.SSLContext;

public final class AcceptorSslFilter extends SslFilter {

public AcceptorSslFilter(SSLContext sslContext) {
super(sslContext);
}

@Override
public void sessionClosed(NextFilter next, IoSession session) throws Exception {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("SERVER: Session {} closed", session);
}

onClose(next, session, true);
next.sessionClosed(session);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,14 @@ protected SSLEngine createEngine(IoSession session, InetSocketAddress addr) {

return sslEngine;
}

@Override
public void sessionClosed(NextFilter next, IoSession session) throws Exception {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("CLIENT: Session {} closed", session);
}

onClose(next, session, true);
next.sessionClosed(session);
}
}
27 changes: 27 additions & 0 deletions quickfixj-core/src/test/java/quickfix/mina/HttpProxyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,33 @@ public void shouldLoginBasicAuthWithSsl() throws ConfigError {
}
}

@Test
public void shouldLoginBasicAuthWithSslAndReconnect() throws ConfigError {
int port = proxyServer.getDestination().getPort();
SessionConnector acceptor = createAcceptor(port, true, "single-session/server.keystore");

try {
acceptor.start();

SessionConnector initiator = createInitiator(proxyServer.getPort(), port, PROXY_USERNAME, PROXY_PASSWORD, true, "single-session/client.truststore");

for (int i = 0; i < 2; i++) {
try {
initiator.start();
SessionUtil.assertLoggedOn(acceptor, new SessionID(FixVersions.BEGINSTRING_FIX44, "ALICE", "BOB"));
SessionUtil.assertLoggedOn(initiator, new SessionID(FixVersions.BEGINSTRING_FIX44, "BOB", "ALICE"));
SSLUtil.assertNotAuthenticated(acceptor, new SessionID(FixVersions.BEGINSTRING_FIX44, "ALICE", "BOB"), false);
SSLUtil.assertAuthenticated(initiator, new SessionID(FixVersions.BEGINSTRING_FIX44, "BOB", "ALICE"), new BigInteger("1448538842"));
assertTrue(proxyServer.getRecordedExceptions().isEmpty());
} finally {
initiator.stop();
}
}
} finally {
acceptor.stop();
}
}

@Test
public void shouldFailLoginBasicAuthWhenServerIsUntrusted() throws ConfigError {
int port = proxyServer.getDestination().getPort();
Expand Down
Loading