Skip to content

Commit f5447cf

Browse files
authored
Merge pull request #635 from the-thing/634_-_mina_2.2.X_update
Apache MINA 2.2.3 update
2 parents 0b05c46 + 444c053 commit f5447cf

File tree

15 files changed

+205
-204
lines changed

15 files changed

+205
-204
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
<fix-orchestra.repository.version>1.6.8</fix-orchestra.repository.version>
102102
<docgen.version>1.6.8</docgen.version>
103103
<jaxb.version>2.3.3</jaxb.version>
104-
<apache.mina.version>2.1.6</apache.mina.version>
104+
<apache.mina.version>2.2.3</apache.mina.version>
105105
<commons.io.version>2.11.0</commons.io.version>
106106
<guava.version>32.0.0-jre</guava.version>
107107
<orchestra.file>OrchestraFIXLatest.xml</orchestra.file>

quickfixj-core/src/main/doc/usermanual/usage/configuration.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,12 @@ <H3>QuickFIX Settings</H3>
692692
<TD><a href="https://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html">Java default cipher suites</a></TD>
693693
</TR>
694694
<TR ALIGN="left" VALIGN="middle">
695-
<TD valign="top"> <I>UseSNI</I></TD>
696-
<TD>Configures the SSL engine to use Server Name Indication. This option is only useful to initiators.</TD>
697-
<TD>Y<BR>N</TD>
698-
<TD>N</TD>
695+
<TD valign="top"> <I>EndpointIdentificationAlgorithm</I></TD>
696+
<TD>Sets the endpoint identification algorithm. If the algorithm parameter is non-null, the endpoint identification/verification procedures must be handled during SSL/TLS handshaking. See
697+
<a href="https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#jssenames">Endpoint Identification
698+
Algorithm Names</a></TD>
699+
<TD></TD>
700+
<TD></TD>
699701
</TR>
700702

701703
<TR ALIGN="center" VALIGN="middle">

quickfixj-core/src/main/java/quickfix/mina/acceptor/AbstractSocketAcceptor.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.mina.core.buffer.SimpleBufferAllocator;
2424
import org.apache.mina.core.service.IoAcceptor;
2525
import org.apache.mina.filter.codec.ProtocolCodecFilter;
26+
import org.apache.mina.filter.ssl.SslFilter;
2627
import quickfix.Acceptor;
2728
import quickfix.Application;
2829
import quickfix.ConfigError;
@@ -45,7 +46,6 @@
4546
import quickfix.mina.message.FIXProtocolCodecFactory;
4647
import quickfix.mina.ssl.SSLConfig;
4748
import quickfix.mina.ssl.SSLContextFactory;
48-
import quickfix.mina.ssl.SSLFilter;
4949
import quickfix.mina.ssl.SSLSupport;
5050

5151
import javax.net.ssl.SSLContext;
@@ -132,10 +132,9 @@ private void installSSL(AcceptorSocketDescriptor descriptor,
132132
log.info("Installing SSL filter for {}", descriptor.getAddress());
133133
SSLConfig sslConfig = descriptor.getSslConfig();
134134
SSLContext sslContext = SSLContextFactory.getInstance(sslConfig);
135-
SSLFilter sslFilter = new SSLFilter(sslContext);
136-
sslFilter.setUseClientMode(false);
135+
SslFilter sslFilter = new SslFilter(sslContext);
137136
sslFilter.setNeedClientAuth(sslConfig.isNeedClientAuth());
138-
sslFilter.setCipherSuites(sslConfig.getEnabledCipherSuites() != null ? sslConfig.getEnabledCipherSuites()
137+
sslFilter.setEnabledCipherSuites(sslConfig.getEnabledCipherSuites() != null ? sslConfig.getEnabledCipherSuites()
139138
: SSLSupport.getDefaultCipherSuites(sslContext));
140139
sslFilter.setEnabledProtocols(sslConfig.getEnabledProtocols() != null ? sslConfig.getEnabledProtocols()
141140
: SSLSupport.getSupportedProtocols(sslContext));

quickfixj-core/src/main/java/quickfix/mina/initiator/InitiatorProxyIoHandler.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,12 @@
2222
import org.apache.mina.core.session.IoSession;
2323
import org.apache.mina.proxy.AbstractProxyIoHandler;
2424

25-
import quickfix.mina.ssl.SSLFilter;
26-
2725
class InitiatorProxyIoHandler extends AbstractProxyIoHandler {
2826
private final InitiatorIoHandler initiatorIoHandler;
29-
private final SSLFilter sslFilter;
3027

31-
InitiatorProxyIoHandler(InitiatorIoHandler initiatorIoHandler, SSLFilter sslFilter) {
28+
InitiatorProxyIoHandler(InitiatorIoHandler initiatorIoHandler) {
3229
super();
3330
this.initiatorIoHandler = initiatorIoHandler;
34-
this.sslFilter = sslFilter;
3531
}
3632

3733
@Override
@@ -60,9 +56,6 @@ public void exceptionCaught(IoSession ioSession, Throwable cause) throws Excepti
6056
}
6157

6258
@Override
63-
public void proxySessionOpened(IoSession ioSession) throws Exception {
64-
if (this.sslFilter != null) {
65-
this.sslFilter.initiateHandshake(ioSession);
66-
}
59+
public void proxySessionOpened(IoSession ioSession) {
6760
}
6861
}

quickfixj-core/src/main/java/quickfix/mina/initiator/IoSessionInitiator.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.mina.core.service.IoConnector;
2525
import org.apache.mina.core.session.IoSession;
2626
import org.apache.mina.filter.codec.ProtocolCodecFilter;
27+
import org.apache.mina.filter.ssl.SslFilter;
2728
import org.apache.mina.proxy.ProxyConnector;
2829
import org.apache.mina.transport.socket.SocketConnector;
2930
import quickfix.ConfigError;
@@ -40,7 +41,6 @@
4041
import quickfix.mina.message.FIXProtocolCodecFactory;
4142
import quickfix.mina.ssl.SSLConfig;
4243
import quickfix.mina.ssl.SSLContextFactory;
43-
import quickfix.mina.ssl.SSLFilter;
4444
import quickfix.mina.ssl.SSLSupport;
4545

4646
import javax.net.ssl.SSLContext;
@@ -153,9 +153,9 @@ private void setupIoConnector() throws ConfigError, GeneralSecurityException {
153153

154154
boolean hasProxy = proxyType != null && proxyPort > 0 && socketAddresses[nextSocketAddressIndex] instanceof InetSocketAddress;
155155

156-
SSLFilter sslFilter = null;
156+
SslFilter sslFilter = null;
157157
if (sslEnabled) {
158-
sslFilter = installSslFilter(ioFilterChainBuilder, !hasProxy);
158+
sslFilter = installSslFilter(ioFilterChainBuilder);
159159
}
160160

161161
ioFilterChainBuilder.addLast(FIXProtocolCodecFactory.FILTER_NAME, new ProtocolCodecFilter(new FIXProtocolCodecFactory()));
@@ -175,9 +175,7 @@ private void setupIoConnector() throws ConfigError, GeneralSecurityException {
175175
);
176176

177177
proxyConnector.setHandler(new InitiatorProxyIoHandler(
178-
new InitiatorIoHandler(fixSession, sessionSettings, networkingOptions, eventHandlingStrategy),
179-
sslFilter
180-
));
178+
new InitiatorIoHandler(fixSession, sessionSettings, networkingOptions, eventHandlingStrategy)));
181179

182180
newConnector = proxyConnector;
183181
}
@@ -188,16 +186,15 @@ private void setupIoConnector() throws ConfigError, GeneralSecurityException {
188186
ioConnector = newConnector;
189187
}
190188

191-
private SSLFilter installSslFilter(CompositeIoFilterChainBuilder ioFilterChainBuilder, boolean autoStart)
189+
private SslFilter installSslFilter(CompositeIoFilterChainBuilder ioFilterChainBuilder)
192190
throws GeneralSecurityException {
193191
final SSLContext sslContext = SSLContextFactory.getInstance(sslConfig);
194-
final SSLFilter sslFilter = new SSLFilter(sslContext, autoStart);
195-
sslFilter.setUseClientMode(true);
196-
sslFilter.setCipherSuites(sslConfig.getEnabledCipherSuites() != null ? sslConfig.getEnabledCipherSuites()
192+
final SslFilter sslFilter = new SslFilter(sslContext);
193+
sslFilter.setEnabledCipherSuites(sslConfig.getEnabledCipherSuites() != null ? sslConfig.getEnabledCipherSuites()
197194
: SSLSupport.getDefaultCipherSuites(sslContext));
198195
sslFilter.setEnabledProtocols(sslConfig.getEnabledProtocols() != null ? sslConfig.getEnabledProtocols()
199196
: SSLSupport.getSupportedProtocols(sslContext));
200-
sslFilter.setUseSNI(sslConfig.isUseSNI());
197+
sslFilter.setEndpointIdentificationAlgorithm(sslConfig.getEndpointIdentificationAlgorithm());
201198
ioFilterChainBuilder.addLast(SSLSupport.FILTER_NAME, sslFilter);
202199
return sslFilter;
203200
}

quickfixj-core/src/main/java/quickfix/mina/ssl/SSLConfig.java

Lines changed: 35 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package quickfix.mina.ssl;
2121

2222
import java.util.Arrays;
23+
import java.util.Objects;
2324

2425
/**
2526
* Groups together SSL related configuration.
@@ -36,58 +37,7 @@ public class SSLConfig {
3637
private String[] enabledProtocols;
3738
private String[] enabledCipherSuites;
3839
private boolean needClientAuth;
39-
private boolean useSNI;
40-
41-
@Override
42-
public boolean equals(Object obj) {
43-
if (this == obj)
44-
return true;
45-
if (obj == null)
46-
return false;
47-
if (getClass() != obj.getClass())
48-
return false;
49-
SSLConfig other = (SSLConfig) obj;
50-
if (!Arrays.equals(enabledCipherSuites, other.enabledCipherSuites))
51-
return false;
52-
if (!Arrays.equals(enabledProtocols, other.enabledProtocols))
53-
return false;
54-
if (keyManagerFactoryAlgorithm == null) {
55-
if (other.keyManagerFactoryAlgorithm != null)
56-
return false;
57-
} else if (!keyManagerFactoryAlgorithm.equals(other.keyManagerFactoryAlgorithm))
58-
return false;
59-
if (keyStoreName == null) {
60-
if (other.keyStoreName != null)
61-
return false;
62-
} else if (!keyStoreName.equals(other.keyStoreName))
63-
return false;
64-
if (!Arrays.equals(keyStorePassword, other.keyStorePassword))
65-
return false;
66-
if (keyStoreType == null) {
67-
if (other.keyStoreType != null)
68-
return false;
69-
} else if (!keyStoreType.equals(other.keyStoreType))
70-
return false;
71-
if (needClientAuth != other.needClientAuth)
72-
return false;
73-
if (trustManagerFactoryAlgorithm == null) {
74-
if (other.trustManagerFactoryAlgorithm != null)
75-
return false;
76-
} else if (!trustManagerFactoryAlgorithm.equals(other.trustManagerFactoryAlgorithm))
77-
return false;
78-
if (trustStoreName == null) {
79-
if (other.trustStoreName != null)
80-
return false;
81-
} else if (!trustStoreName.equals(other.trustStoreName))
82-
return false;
83-
if (!Arrays.equals(trustStorePassword, other.trustStorePassword))
84-
return false;
85-
if(useSNI != other.useSNI)
86-
return false;
87-
if (trustStoreType == null) {
88-
return other.trustStoreType == null;
89-
} else return trustStoreType.equals(other.trustStoreType);
90-
}
40+
private String endpointIdentificationAlgorithm;
9141

9242
public String[] getEnabledCipherSuites() {
9343
return enabledCipherSuites;
@@ -129,31 +79,12 @@ public String getTrustStoreType() {
12979
return trustStoreType;
13080
}
13181

132-
@Override
133-
public int hashCode() {
134-
final int prime = 31;
135-
int result = 1;
136-
result = prime * result + Arrays.hashCode(enabledCipherSuites);
137-
result = prime * result + Arrays.hashCode(enabledProtocols);
138-
result = prime * result + ((keyManagerFactoryAlgorithm == null) ? 0 : keyManagerFactoryAlgorithm.hashCode());
139-
result = prime * result + ((keyStoreName == null) ? 0 : keyStoreName.hashCode());
140-
result = prime * result + Arrays.hashCode(keyStorePassword);
141-
result = prime * result + ((keyStoreType == null) ? 0 : keyStoreType.hashCode());
142-
result = prime * result + (needClientAuth ? 1231 : 1237);
143-
result = prime * result
144-
+ ((trustManagerFactoryAlgorithm == null) ? 0 : trustManagerFactoryAlgorithm.hashCode());
145-
result = prime * result + ((trustStoreName == null) ? 0 : trustStoreName.hashCode());
146-
result = prime * result + Arrays.hashCode(trustStorePassword);
147-
result = prime * result + ((trustStoreType == null) ? 0 : trustStoreType.hashCode());
148-
return result;
149-
}
150-
15182
public boolean isNeedClientAuth() {
15283
return needClientAuth;
15384
}
15485

155-
public boolean isUseSNI() {
156-
return useSNI;
86+
public String getEndpointIdentificationAlgorithm() {
87+
return endpointIdentificationAlgorithm;
15788
}
15889

15990
public void setEnabledCipherSuites(String[] enabledCipherSuites) {
@@ -184,8 +115,8 @@ public void setNeedClientAuth(boolean needClientAuth) {
184115
this.needClientAuth = needClientAuth;
185116
}
186117

187-
public void setUseSNI(boolean useSNI) {
188-
this.useSNI = useSNI;
118+
public void setEndpointIdentificationAlgorithm(String endpointIdentificationAlgorithm) {
119+
this.endpointIdentificationAlgorithm = endpointIdentificationAlgorithm;
189120
}
190121

191122
public void setTrustManagerFactoryAlgorithm(String trustManagerFactoryAlgorithm) {
@@ -203,4 +134,33 @@ public void setTrustStorePassword(char[] trustStorePassword) {
203134
public void setTrustStoreType(String trustStoreType) {
204135
this.trustStoreType = trustStoreType;
205136
}
137+
138+
@Override
139+
public boolean equals(Object o) {
140+
if (this == o) return true;
141+
if (o == null || getClass() != o.getClass()) return false;
142+
SSLConfig sslConfig = (SSLConfig) o;
143+
return needClientAuth == sslConfig.needClientAuth &&
144+
Objects.equals(keyStoreName, sslConfig.keyStoreName) &&
145+
Arrays.equals(keyStorePassword, sslConfig.keyStorePassword) &&
146+
Objects.equals(keyManagerFactoryAlgorithm, sslConfig.keyManagerFactoryAlgorithm) &&
147+
Objects.equals(keyStoreType, sslConfig.keyStoreType) &&
148+
Objects.equals(trustStoreName, sslConfig.trustStoreName) &&
149+
Arrays.equals(trustStorePassword, sslConfig.trustStorePassword) &&
150+
Objects.equals(trustManagerFactoryAlgorithm, sslConfig.trustManagerFactoryAlgorithm) &&
151+
Objects.equals(trustStoreType, sslConfig.trustStoreType) &&
152+
Arrays.equals(enabledProtocols, sslConfig.enabledProtocols) &&
153+
Arrays.equals(enabledCipherSuites, sslConfig.enabledCipherSuites) &&
154+
Objects.equals(endpointIdentificationAlgorithm, sslConfig.endpointIdentificationAlgorithm);
155+
}
156+
157+
@Override
158+
public int hashCode() {
159+
int result = Objects.hash(keyStoreName, keyManagerFactoryAlgorithm, keyStoreType, trustStoreName, trustManagerFactoryAlgorithm, trustStoreType, needClientAuth, endpointIdentificationAlgorithm);
160+
result = 31 * result + Arrays.hashCode(keyStorePassword);
161+
result = 31 * result + Arrays.hashCode(trustStorePassword);
162+
result = 31 * result + Arrays.hashCode(enabledProtocols);
163+
result = 31 * result + Arrays.hashCode(enabledCipherSuites);
164+
return result;
165+
}
206166
}

quickfixj-core/src/main/java/quickfix/mina/ssl/SSLFilter.java

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)