INT-2868 Fix SSL Key Store Resource Handling
Documentation indicates that the keystore and truststore arguments can be resource patterns (file:..., classpath:..., etc) but the code always used a ClasspathResource. Use a PathMatchingResourcePatternResolver to interpret the pattern correctly. Add tests.
This commit is contained in:
committed by
Gunnar Hillert
parent
df6a8dee04
commit
b48bed486f
@@ -71,7 +71,7 @@
|
||||
/>
|
||||
|
||||
<bean id="sslContextSupport" class="org.springframework.integration.ip.tcp.connection.support.DefaultTcpSSLContextSupport">
|
||||
<constructor-arg value="test.ks"/>
|
||||
<constructor-arg value="classpath:test.ks"/>
|
||||
<constructor-arg value="test.truststore.ks"/>
|
||||
<constructor-arg value="secret"/>
|
||||
<constructor-arg value="secret"/>
|
||||
|
||||
@@ -33,6 +33,8 @@ import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.core.io.UrlResource;
|
||||
import org.springframework.core.serializer.Deserializer;
|
||||
import org.springframework.core.serializer.Serializer;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
@@ -54,6 +56,8 @@ import org.springframework.integration.ip.tcp.connection.TcpNetServerConnectionF
|
||||
import org.springframework.integration.ip.tcp.connection.TcpNioClientConnectionFactory;
|
||||
import org.springframework.integration.ip.tcp.connection.TcpNioServerConnectionFactory;
|
||||
import org.springframework.integration.ip.tcp.connection.support.DefaultTcpNetSSLSocketFactorySupport;
|
||||
import org.springframework.integration.ip.tcp.connection.support.DefaultTcpSSLContextSupport;
|
||||
import org.springframework.integration.ip.tcp.connection.support.TcpSSLContextSupport;
|
||||
import org.springframework.integration.ip.tcp.connection.support.TcpSocketFactorySupport;
|
||||
import org.springframework.integration.ip.tcp.connection.support.TcpSocketSupport;
|
||||
import org.springframework.integration.ip.udp.DatagramPacketMessageMapper;
|
||||
@@ -248,6 +252,9 @@ public class ParserUnitTests {
|
||||
@Autowired
|
||||
TcpSocketSupport socketSupport;
|
||||
|
||||
@Autowired
|
||||
TcpSSLContextSupport contextSupport;
|
||||
|
||||
private static volatile int adviceCalled;
|
||||
|
||||
@Test
|
||||
@@ -302,6 +309,15 @@ public class ParserUnitTests {
|
||||
Object socketSupport = TestUtils.getPropertyValue(cfS1, "tcpSocketFactorySupport");
|
||||
assertTrue(socketSupport instanceof DefaultTcpNetSSLSocketFactorySupport);
|
||||
assertNotNull(TestUtils.getPropertyValue(socketSupport, "sslContext"));
|
||||
|
||||
TcpSSLContextSupport contextSupport = TestUtils.getPropertyValue(cfS1, "tcpSocketFactorySupport.sslContextSupport", TcpSSLContextSupport.class);
|
||||
assertSame(contextSupport, this.contextSupport);
|
||||
assertTrue(TestUtils.getPropertyValue(contextSupport, "keyStore") instanceof ClassPathResource);
|
||||
assertTrue(TestUtils.getPropertyValue(contextSupport, "trustStore") instanceof ClassPathResource);
|
||||
|
||||
contextSupport = new DefaultTcpSSLContextSupport("http:foo", "file:bar", "", "");
|
||||
assertTrue(TestUtils.getPropertyValue(contextSupport, "keyStore") instanceof UrlResource);
|
||||
assertTrue(TestUtils.getPropertyValue(contextSupport, "trustStore") instanceof UrlResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user