use of org.apache.catalina.connector.Connector in project tomcat by apache.
the class TestCustomSsl method testCustomSslImplementation.
@Test
public void testCustomSslImplementation() throws Exception {
TesterSupport.configureClientSsl();
Tomcat tomcat = getTomcatInstance();
Connector connector = tomcat.getConnector();
Assume.assumeFalse("This test is only for JSSE based SSL connectors", connector.getProtocolHandlerClassName().contains("Apr"));
connector.setProperty("sslImplementationName", "org.apache.tomcat.util.net.jsse.TesterBug50640SslImpl");
// This setting will break ssl configuration unless the custom
// implementation is used.
connector.setProperty(TesterBug50640SslImpl.PROPERTY_NAME, TesterBug50640SslImpl.PROPERTY_VALUE);
connector.setProperty("sslProtocol", "tls");
File keystoreFile = new File("test/org/apache/tomcat/util/net/localhost.jks");
connector.setAttribute("keystoreFile", keystoreFile.getAbsolutePath());
connector.setSecure(true);
connector.setProperty("SSLEnabled", "true");
File appDir = new File(getBuildDirectory(), "webapps/examples");
Context ctxt = tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
ctxt.addApplicationListener(WsContextListener.class.getName());
tomcat.start();
ByteChunk res = getUrl("https://localhost:" + getPort() + "/examples/servlets/servlet/HelloWorldExample");
assertTrue(res.toString().indexOf("<a href=\"../helloworld.html\">") > 0);
}
use of org.apache.catalina.connector.Connector in project spring-boot by spring-projects.
the class TomcatServletWebServerFactoryTests method uriEncoding.
@Test
public void uriEncoding() throws Exception {
TomcatServletWebServerFactory factory = getFactory();
factory.setUriEncoding(Charset.forName("US-ASCII"));
Tomcat tomcat = getTomcat(factory);
Connector connector = ((TomcatWebServer) this.webServer).getServiceConnectors().get(tomcat.getService())[0];
assertThat(connector.getURIEncoding()).isEqualTo("US-ASCII");
}
use of org.apache.catalina.connector.Connector in project spring-boot by spring-projects.
the class TomcatServletWebServerFactoryTests method sslEnabledProtocolsConfiguration.
@Test
public void sslEnabledProtocolsConfiguration() throws Exception {
Ssl ssl = getSsl(null, "password", "src/test/resources/test.jks");
ssl.setEnabledProtocols(new String[] { "TLSv1.2" });
ssl.setCiphers(new String[] { "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "BRAVO" });
TomcatServletWebServerFactory factory = getFactory();
factory.setSsl(ssl);
this.webServer = factory.getWebServer(sessionServletRegistration());
Tomcat tomcat = ((TomcatWebServer) this.webServer).getTomcat();
this.webServer.start();
Connector connector = tomcat.getConnector();
SSLHostConfig sslHostConfig = connector.getProtocolHandler().findSslHostConfigs()[0];
assertThat(sslHostConfig.getSslProtocol()).isEqualTo("TLS");
assertThat(sslHostConfig.getEnabledProtocols()).containsExactly("TLSv1.2");
}
use of org.apache.catalina.connector.Connector in project spring-boot by spring-projects.
the class TomcatServletWebServerFactoryTests method tomcatAdditionalConnectors.
@Test
public void tomcatAdditionalConnectors() throws Exception {
TomcatServletWebServerFactory factory = getFactory();
Connector[] listeners = new Connector[4];
for (int i = 0; i < listeners.length; i++) {
Connector connector = mock(Connector.class);
given(connector.getState()).willReturn(LifecycleState.STOPPED);
listeners[i] = connector;
}
factory.addAdditionalTomcatConnectors(listeners);
this.webServer = factory.getWebServer();
Map<Service, Connector[]> connectors = ((TomcatWebServer) this.webServer).getServiceConnectors();
assertThat(connectors.values().iterator().next().length).isEqualTo(listeners.length + 1);
}
use of org.apache.catalina.connector.Connector in project spring-boot by spring-projects.
the class TomcatServletWebServerFactoryTests method sslEnabledMultipleProtocolsConfiguration.
@Test
public void sslEnabledMultipleProtocolsConfiguration() throws Exception {
Ssl ssl = getSsl(null, "password", "src/test/resources/test.jks");
ssl.setEnabledProtocols(new String[] { "TLSv1.1", "TLSv1.2" });
ssl.setCiphers(new String[] { "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "BRAVO" });
TomcatServletWebServerFactory factory = getFactory();
factory.setSsl(ssl);
this.webServer = factory.getWebServer(sessionServletRegistration());
this.webServer.start();
Tomcat tomcat = ((TomcatWebServer) this.webServer).getTomcat();
Connector connector = tomcat.getConnector();
SSLHostConfig sslHostConfig = connector.getProtocolHandler().findSslHostConfigs()[0];
assertThat(sslHostConfig.getSslProtocol()).isEqualTo("TLS");
assertThat(sslHostConfig.getEnabledProtocols()).containsExactlyInAnyOrder("TLSv1.1", "TLSv1.2");
}
Aggregations