@BeforeClass @AfterClass public static void uninstallUrlStreamHandlerFactory() { ReflectionTestUtils.setField(TomcatURLStreamHandlerFactory.class, "instance", null); ReflectionTestUtils.setField(URL.class, "factory", null); }
/** * Configure Tomcat's {@link AbstractHttp11JsseProtocol} for SSL. * @param protocol the protocol * @param ssl the ssl details */ protected void configureSsl(AbstractHttp11JsseProtocol<?> protocol, Ssl ssl) { protocol.setSSLEnabled(true); protocol.setSslProtocol(ssl.getProtocol()); configureSslClientAuth(protocol, ssl); protocol.setKeystorePass(ssl.getKeyStorePassword()); protocol.setKeyPass(ssl.getKeyPassword()); protocol.setKeyAlias(ssl.getKeyAlias()); String ciphers = StringUtils.arrayToCommaDelimitedString(ssl.getCiphers()); protocol.setCiphers(StringUtils.hasText(ciphers) ? ciphers : null); if (ssl.getEnabledProtocols() != null) { try { for (SSLHostConfig sslHostConfig : protocol.findSslHostConfigs()) { sslHostConfig.setProtocols(StringUtils .arrayToCommaDelimitedString(ssl.getEnabledProtocols())); } } catch (NoSuchMethodError ex) { // Tomcat 8.0.x or earlier Assert.isTrue( protocol.setProperty("sslEnabledProtocols", StringUtils.arrayToCommaDelimitedString( ssl.getEnabledProtocols())), "Failed to set sslEnabledProtocols"); } } if (getSslStoreProvider() != null) { TomcatURLStreamHandlerFactory instance = TomcatURLStreamHandlerFactory .getInstance(); instance.addUserFactory( new SslStoreProviderUrlStreamHandlerFactory(getSslStoreProvider())); protocol.setKeystoreFile( SslStoreProviderUrlStreamHandlerFactory.KEY_STORE_URL); protocol.setTruststoreFile( SslStoreProviderUrlStreamHandlerFactory.TRUST_STORE_URL); } else { configureSslKeyStore(protocol, ssl); configureSslTrustStore(protocol, ssl); } }
@Override protected void initInternal() throws LifecycleException { TomcatURLStreamHandlerFactory.register(); }
public static void main(final String[] args) throws Exception { TomcatURLStreamHandlerFactory.disable(); new SpringApplicationBuilder(WebApi.class).run(args); }