use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project spring-boot by spring-projects.
the class ServletWebServerFactoryAutoConfigurationTests method tomcatContextCustomizerBeanIsAddedToFactory.
@Test
void tomcatContextCustomizerBeanIsAddedToFactory() {
WebApplicationContextRunner runner = new WebApplicationContextRunner(AnnotationConfigServletWebServerApplicationContext::new).withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class)).withUserConfiguration(TomcatContextCustomizerConfiguration.class).withPropertyValues("server.port: 0");
runner.run((context) -> {
TomcatServletWebServerFactory factory = context.getBean(TomcatServletWebServerFactory.class);
TomcatContextCustomizer customizer = context.getBean("contextCustomizer", TomcatContextCustomizer.class);
assertThat(factory.getTomcatContextCustomizers()).contains(customizer);
then(customizer).should().customize(any(Context.class));
});
}
use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project midpoint by Evolveum.
the class TestMidPointSpringApplication method tomcatEmbeddedServletContainerFactory.
@Bean
public TomcatServletWebServerFactory tomcatEmbeddedServletContainerFactory() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.setPort(DEFAULT_PORT);
return tomcat;
}
use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project cas by apereo.
the class CasTomcatServletWebServerFactoryCustomizer method customize.
@Override
public void customize(final ConfigurableServletWebServerFactory factory) {
if (factory instanceof TomcatServletWebServerFactory) {
val tomcat = (TomcatServletWebServerFactory) factory;
configureAjp(tomcat);
configureHttp(tomcat);
configureHttpProxy(tomcat);
configureExtendedAccessLogValve(tomcat);
configureRewriteValve(tomcat);
configureSSLValve(tomcat);
configureBasicAuthn(tomcat);
finalizeConnectors(tomcat);
}
}
use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project kork by spinnaker.
the class TomcatConfiguration method containerCustomizer.
/**
* Setup multiple connectors: - an https connector requiring client auth that will service API
* requests - an http connector that will service legacy non-https requests
*/
@Bean
@ConditionalOnExpression("${server.ssl.enabled:false}")
WebServerFactoryCustomizer containerCustomizer(DefaultTomcatConnectorCustomizer defaultTomcatConnectorCustomizer, TomcatConfigurationProperties tomcatConfigurationProperties) {
System.setProperty("jdk.tls.rejectClientInitiatedRenegotiation", "true");
System.setProperty("jdk.tls.ephemeralDHKeySize", "2048");
return new WebServerFactoryCustomizer() {
@Override
public void customize(WebServerFactory factory) {
TomcatServletWebServerFactory tomcat = (TomcatServletWebServerFactory) factory;
// This will only handle the case where SSL is enabled on the main Tomcat connector
tomcat.addConnectorCustomizers(defaultTomcatConnectorCustomizer);
if (tomcatConfigurationProperties.getLegacyServerPort() > 0) {
log.info("Creating legacy connector on port {}", tomcatConfigurationProperties.getLegacyServerPort());
Connector httpConnector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
httpConnector.setScheme("http");
httpConnector.setPort(tomcatConfigurationProperties.getLegacyServerPort());
applyCompressionSettings(httpConnector, tomcat);
tomcat.addAdditionalTomcatConnectors(httpConnector);
}
if (tomcatConfigurationProperties.getApiPort() > 0) {
log.info("Creating api connector on port {}", tomcatConfigurationProperties.getApiPort());
Connector apiConnector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
apiConnector.setScheme("https");
apiConnector.setSecure(true);
apiConnector.setPort(tomcatConfigurationProperties.getApiPort());
applyCompressionSettings(apiConnector, tomcat);
Ssl ssl = defaultTomcatConnectorCustomizer.copySslConfigurationWithClientAuth(tomcat);
CustomizableTomcatServletWebServerFactory newFactory = new CustomizableTomcatServletWebServerFactory();
BeanUtils.copyProperties(tomcat, newFactory);
newFactory.setPort(tomcatConfigurationProperties.getApiPort());
newFactory.setSsl(ssl);
newFactory.customizeSslConnector(apiConnector);
defaultTomcatConnectorCustomizer.customize(apiConnector);
tomcat.addAdditionalTomcatConnectors(apiConnector);
}
}
};
}
use of org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory in project spring-boot by spring-projects.
the class EndpointWebMvcAutoConfigurationTests method tomcatManagementAccessLogUsesCustomPrefix.
@Test
public void tomcatManagementAccessLogUsesCustomPrefix() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, "management.port=" + ports.get().management);
this.applicationContext.register(TomcatWebServerConfig.class, RootConfig.class, EndpointConfig.class, DifferentPortConfig.class, BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class, ErrorMvcAutoConfiguration.class);
EnvironmentTestUtils.addEnvironment(this.applicationContext, "server.tomcat.accesslog.enabled: true");
this.applicationContext.refresh();
ApplicationContext managementContext = this.applicationContext.getBean(ManagementContextResolver.class).getApplicationContext();
ServletWebServerFactory factory = managementContext.getBean(ServletWebServerFactory.class);
assertThat(factory).isInstanceOf(TomcatServletWebServerFactory.class);
AccessLogValve accessLogValve = findAccessLogValve(((TomcatServletWebServerFactory) factory));
assertThat(accessLogValve).isNotNull();
assertThat(accessLogValve.getPrefix()).isEqualTo("management_access_log");
}
Aggregations