Skip to content

Commit

Permalink
Merge branch 'master' into chrjohn-tls13-test
Browse files Browse the repository at this point in the history
  • Loading branch information
chrjohn authored Jan 17, 2025
2 parents 7b3cacd + 9e81970 commit 30f6154
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 88 deletions.
18 changes: 9 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<slf4j.version>2.0.16</slf4j.version>
<mockito-core.version>4.11.0</mockito-core.version>
<hamcrest.version>3.0</hamcrest.version>
<junit.jupiter.version>5.11.2</junit.jupiter.version>
<junit.jupiter.version>5.11.4</junit.jupiter.version>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<mainClass/>
Expand All @@ -75,10 +75,10 @@
<maven-resources-plugin-version>3.3.1</maven-resources-plugin-version>
<maven-compiler-plugin-version>3.13.0</maven-compiler-plugin-version>
<maven-jar-plugin-version>3.4.2</maven-jar-plugin-version>
<maven-surefire-plugin-version>3.5.1</maven-surefire-plugin-version>
<maven-pmd-plugin-version>3.25.0</maven-pmd-plugin-version>
<maven-surefire-plugin-version>3.5.2</maven-surefire-plugin-version>
<maven-pmd-plugin-version>3.26.0</maven-pmd-plugin-version>
<maven-source-plugin-version>3.3.1</maven-source-plugin-version>
<maven-javadoc-plugin-version>3.10.1</maven-javadoc-plugin-version>
<maven-javadoc-plugin-version>3.11.2</maven-javadoc-plugin-version>
<maven-shade-plugin-version>3.6.0</maven-shade-plugin-version>
<maven-assembly-plugin-version>3.7.1</maven-assembly-plugin-version>
<maven-bundle-plugin-version>5.1.9</maven-bundle-plugin-version>
Expand All @@ -88,7 +88,7 @@
<build-helper-maven-plugin-version>3.6.0</build-helper-maven-plugin-version>
<maven-shared-utils.version>3.4.2</maven-shared-utils.version>
<file-management.version>3.0.0</file-management.version>
<maven-plugin-annotations.version>3.15.0</maven-plugin-annotations.version>
<maven-plugin-annotations.version>3.15.1</maven-plugin-annotations.version>
<maven-plugin-testing-harness.version>3.3.0</maven-plugin-testing-harness.version>
<plantuml-maven-plugin-version>1.2</plantuml-maven-plugin-version>
<plantuml-version>8059</plantuml-version>
Expand All @@ -97,8 +97,8 @@
<fix-orchestra.repository.version>1.7.3</fix-orchestra.repository.version>
<docgen.version>1.6.8</docgen.version>
<jaxb.version>4.0.2</jaxb.version>
<apache.mina.version>2.2.3</apache.mina.version>
<commons.io.version>2.17.0</commons.io.version>
<apache.mina.version>2.2.4</apache.mina.version>
<commons.io.version>2.18.0</commons.io.version>
<orchestra.file>OrchestraFIXLatest.xml</orchestra.file>
<org.quickfixj.orchestra.tools.version>1.0.2</org.quickfixj.orchestra.tools.version>
<proxool.version>0.9.1</proxool.version>
Expand Down Expand Up @@ -458,11 +458,11 @@
</plugin>
<plugin>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.8.1</version>
<version>3.9.0</version>
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.15.0</version>
<version>3.15.1</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion quickfixj-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@
</plugin>
<plugin>
<artifactId>maven-jxr-plugin</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
</plugin>
</plugins>
</reporting>
Expand Down
2 changes: 1 addition & 1 deletion quickfixj-codegenerator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.15.0</version>
<version>3.15.1</version>
<configuration>
<goalPrefix>quickfixj-codegenerator</goalPrefix>
</configuration>
Expand Down
4 changes: 2 additions & 2 deletions quickfixj-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-example</artifactId>
<version>4.1.114.Final</version>
<version>4.1.116.Final</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -249,7 +249,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>3.5.0</version>
<version>3.6.0</version>
</plugin>
</plugins>
</reporting>
Expand Down
12 changes: 6 additions & 6 deletions quickfixj-core/src/main/java/quickfix/CompositeLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public void clear() {
for (Log log : logs) {
try {
log.clear();
} catch (Throwable e) {
} catch (Exception e) {
handleError(e);
}
}
}

private void handleError(Throwable e) {
private void handleError(Exception e) {
if (rethrowException) {
throw new RuntimeException(e);
}
Expand All @@ -57,7 +57,7 @@ public void onIncoming(String message) {
for (Log log : logs) {
try {
log.onIncoming(message);
} catch (Throwable e) {
} catch (Exception e) {
handleError(e);
}
}
Expand All @@ -67,7 +67,7 @@ public void onOutgoing(String message) {
for (Log log : logs) {
try {
log.onOutgoing(message);
} catch (Throwable e) {
} catch (Exception e) {
defaultLog.error(e.getMessage() + ", continuing", e);
}
}
Expand All @@ -77,7 +77,7 @@ public void onEvent(String text) {
for (Log log : logs) {
try {
log.onEvent(text);
} catch (Throwable e) {
} catch (Exception e) {
handleError(e);
}
}
Expand All @@ -87,7 +87,7 @@ public void onErrorEvent(String text) {
for (Log log : logs) {
try {
log.onErrorEvent(text);
} catch (Throwable e) {
} catch (Exception e) {
handleError(e);
}
}
Expand Down
35 changes: 0 additions & 35 deletions quickfixj-core/src/main/java/quickfix/mina/CustomSslFilter.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
import org.junit.After;
import quickfix.mina.SocksProxyServer;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;

public class SSLCertificateTest {

Expand Down Expand Up @@ -191,8 +191,7 @@ public void shouldAuthenticateServerNameUsingServerCommonName() throws Exception

TestInitiator initiator = new TestInitiator(
createInitiatorSettings("single-session/empty.keystore", "single-session/client-cn.truststore",
CIPHER_SUITES_TLS, "TLSv1.3", "ZULU", "ALFA", Integer.toString(freePort), "JKS", "JKS"));

CIPHER_SUITES_TLS, "TLSv1.3", "ZULU", "ALFA", Integer.toString(freePort), "JKS", "JKS", "HTTPS"));
try {
initiator.start();

Expand Down Expand Up @@ -226,8 +225,8 @@ public void shouldAuthenticateServerNameUsingSNIExtension() throws Exception {

TestInitiator initiator = new TestInitiator(
createInitiatorSettings("single-session/empty.keystore", "single-session/client-sni.truststore",
CIPHER_SUITES_TLS, "TLSv1.3", "ZULU", "ALFA", Integer.toString(freePort), "JKS", "JKS"));

CIPHER_SUITES_TLS, "TLSv1.3", "ZULU", "ALFA", Integer.toString(freePort), "JKS", "JKS", "HTTPS"));
try {
initiator.start();

Expand Down Expand Up @@ -786,7 +785,7 @@ public void assertSslExceptionThrown() throws Exception {
assertSslExceptionThrown(null, null);
}

public void assertSslExceptionThrown(String errorMessage, Class<?> errorType) throws Exception {
public void assertSslExceptionThrown(String expectedErrorMessage, Class<?> expectedErrorType) throws Exception {
boolean reachedZero = exceptionThrownLatch.await(TIMEOUT_SECONDS, TimeUnit.SECONDS);

if (!reachedZero) {
Expand All @@ -795,12 +794,14 @@ public void assertSslExceptionThrown(String errorMessage, Class<?> errorType) th

Throwable throwable = exception.get();

if (errorMessage != null) {
assertEquals(errorMessage, throwable.getMessage());
if (expectedErrorMessage != null) {
String thrownErrorMessage = throwable.getMessage();
assertTrue("Thrown error message: " + thrownErrorMessage + " does not contain: " + expectedErrorMessage,
thrownErrorMessage != null && thrownErrorMessage.contains(expectedErrorMessage));
}

if (errorType != null) {
assertSame(errorType, throwable.getClass());
if (expectedErrorType != null) {
assertSame(expectedErrorType, throwable.getClass());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@

package quickfix.mina.ssl;

import junit.framework.TestCase;
import org.apache.mina.core.filterchain.IoFilterAdapter;
import org.apache.mina.core.session.IoSession;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import quickfix.ApplicationAdapter;
import quickfix.ConfigError;
import quickfix.DefaultMessageFactory;
import quickfix.FixVersions;
import quickfix.Initiator;
import quickfix.MemoryStoreFactory;
import quickfix.Session;
import quickfix.SessionID;
Expand All @@ -43,14 +43,20 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

public class SecureSocketTest extends TestCase {
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

public class SecureSocketTest {

private final Logger log = LoggerFactory.getLogger(getClass());
private final int transportProtocol = ProtocolFactory.SOCKET;

protected void setUp() throws Exception {
@Before
public void setUp() throws Exception {
SystemTime.setTimeSource(null);
}

@Test
public void testLogonWithBadCertificate() throws Exception {
ServerThread serverThread = new ServerThread("nonexistent", "pwd");
try {
Expand Down Expand Up @@ -85,10 +91,12 @@ public void exceptionCaught(NextFilter nextFilter, IoSession session, Throwable
}
}

@Test
public void testLogonWithDefaultCertificate() throws Exception {
doLogonTest(null, null);
}

@Test
public void testLogonWithCustomCertificate() throws Exception {
doLogonTest("test.keystore", "quickfixjtestpw");
}
Expand All @@ -103,6 +111,7 @@ public void testLogonWithCustomCertificate() throws Exception {
* so that it's not cached by another test so that there are no false failures.
* The test-client.keystore key store is just a copy of test.keystore under a different name.
*/
@Test
public void testLogonWithBadCertificateOnInitiatorSide() throws Exception {
SessionID clientSessionID = new SessionID(FixVersions.BEGINSTRING_FIX42, "TW", "ISLD");
SessionSettings settings = getClientSessionSettings(clientSessionID);
Expand Down Expand Up @@ -177,14 +186,8 @@ private void assertLoggedOn(ClientApplication clientApplication, Session clientS
}

private class ClientApplication extends ApplicationAdapter {
public CountDownLatch logonLatch;
private Initiator initiator;
private boolean stopAfterLogon;

//public void stopAfterLogon(Initiator initiator) {
// this.initiator = initiator;
// this.stopAfterLogon = true;
//}
public CountDownLatch logonLatch;

public void setUpLogonExpectation() {
logonLatch = new CountDownLatch(1);
Expand All @@ -195,14 +198,11 @@ public void onLogon(SessionID sessionId) {
log.info("Releasing logon latch");
logonLatch.countDown();
}
if (stopAfterLogon) {
log.info("Stopping after logon");
initiator.stop();
}
}
}

private class ServerThread extends Thread {

private final ATServer server;

public ServerThread(String keyStoreName, String keyStorePassword) {
Expand All @@ -223,5 +223,4 @@ public void waitForInitialization() throws InterruptedException {
server.waitForInitialization();
}
}

}

0 comments on commit 30f6154

Please sign in to comment.