use of org.mule.runtime.module.tls.internal.DefaultTlsContextFactory in project mule by mulesoft.
the class DefaultTlsContextFactoryObjectFactory method doGetObject.
@Override
public DefaultTlsContextFactory doGetObject() throws Exception {
DefaultTlsContextFactory tlsContextFactory = new DefaultTlsContextFactory(getAnnotations());
tlsContextFactory.setName(name);
tlsContextFactory.setEnabledProtocols(enabledProtocols);
tlsContextFactory.setEnabledCipherSuites(enabledCipherSuites);
if (keyStore != null) {
tlsContextFactory.setKeyAlias(keyStore.getAlias());
tlsContextFactory.setKeyPassword(keyStore.getKeyPassword());
if (keyStore.getPath() != null) {
tlsContextFactory.setKeyStorePath(keyStore.getPath());
}
tlsContextFactory.setKeyStorePassword(keyStore.getPassword());
if (keyStore.getType() != null) {
tlsContextFactory.setKeyStoreType(keyStore.getType());
}
if (keyStore.getAlgorithm() != null) {
tlsContextFactory.setKeyManagerAlgorithm(keyStore.getAlgorithm());
}
}
if (trustStore != null) {
if (trustStore.getPath() != null) {
tlsContextFactory.setTrustStorePath(trustStore.getPath());
}
tlsContextFactory.setTrustStorePassword(trustStore.getPassword());
if (trustStore.getType() != null) {
tlsContextFactory.setTrustStoreType(trustStore.getType());
}
if (trustStore.getAlgorithm() != null) {
tlsContextFactory.setTrustManagerAlgorithm(trustStore.getAlgorithm());
}
tlsContextFactory.setTrustStoreInsecure(trustStore.isInsecure());
}
if (revocationCheck != null) {
tlsContextFactory.setRevocationCheck(revocationCheck);
}
return tlsContextFactory;
}
use of org.mule.runtime.module.tls.internal.DefaultTlsContextFactory in project mule by mulesoft.
the class DefaultTlsContextFactoryTestCase method defaultIncludesTls12Ciphers.
@Test
public void defaultIncludesTls12Ciphers() throws Exception {
DefaultTlsContextFactory tlsContextFactory = new DefaultTlsContextFactory(emptyMap());
tlsContextFactory.initialise();
SSLSocketFactory defaultFactory = tlsContextFactory.createSslContext().getSocketFactory();
SSLContext tls12Context = SSLContext.getInstance("TLSv1.2");
tls12Context.init(null, null, null);
SSLSocketFactory tls12Factory = tls12Context.getSocketFactory();
assertThat(defaultFactory.getDefaultCipherSuites(), arrayContainingInAnyOrder(tls12Factory.getDefaultCipherSuites()));
}
use of org.mule.runtime.module.tls.internal.DefaultTlsContextFactory in project mule by mulesoft.
the class DefaultTlsContextFactoryTestCase method failIfCipherSuitesDoNotMatchConfigFile.
@Test
public void failIfCipherSuitesDoNotMatchConfigFile() throws Exception {
DefaultTlsContextFactory tlsContextFactory = new DefaultTlsContextFactory(emptyMap());
tlsContextFactory.setEnabledCipherSuites("SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA");
expectedException.expect(InitialisationException.class);
expectedException.expectMessage(containsString("cipher suites are invalid"));
tlsContextFactory.initialise();
}
use of org.mule.runtime.module.tls.internal.DefaultTlsContextFactory in project mule by mulesoft.
the class DefaultTlsContextFactoryTestCase method overrideConfigFile.
@Test
public void overrideConfigFile() throws Exception {
DefaultTlsContextFactory tlsContextFactory = new DefaultTlsContextFactory(emptyMap());
tlsContextFactory.setEnabledCipherSuites("TLS_DHE_DSS_WITH_AES_128_CBC_SHA");
tlsContextFactory.setEnabledProtocols("TLSv1.1");
tlsContextFactory.initialise();
String[] enabledCipherSuites = tlsContextFactory.getEnabledCipherSuites();
assertThat(enabledCipherSuites.length, is(1));
assertThat(enabledCipherSuites, is(arrayContaining("TLS_DHE_DSS_WITH_AES_128_CBC_SHA")));
String[] enabledProtocols = tlsContextFactory.getEnabledProtocols();
assertThat(enabledProtocols.length, is(1));
assertThat(enabledProtocols, is(arrayContaining("TLSv1.1")));
}
use of org.mule.runtime.module.tls.internal.DefaultTlsContextFactory in project mule by mulesoft.
the class DefaultTlsContextFactoryTestCase method failIfProtocolsDoNotMatchConfigFile.
@Test
public void failIfProtocolsDoNotMatchConfigFile() throws Exception {
DefaultTlsContextFactory tlsContextFactory = new DefaultTlsContextFactory(emptyMap());
tlsContextFactory.setEnabledProtocols("TLSv1,SSLv3");
expectedException.expect(InitialisationException.class);
expectedException.expectMessage(containsString("protocols are invalid"));
tlsContextFactory.initialise();
}
Aggregations