Search in sources :

Example 1 with WebServerFactoryCustomizer

use of org.springframework.boot.web.server.WebServerFactoryCustomizer in project keycloak by keycloak.

the class KeycloakAutoConfiguration method getKeycloakContainerCustomizer.

@Bean
public WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> getKeycloakContainerCustomizer() {
    return new WebServerFactoryCustomizer<ConfigurableServletWebServerFactory>() {

        @Override
        public void customize(ConfigurableServletWebServerFactory configurableServletWebServerFactory) {
            if (configurableServletWebServerFactory instanceof TomcatServletWebServerFactory) {
                TomcatServletWebServerFactory container = (TomcatServletWebServerFactory) configurableServletWebServerFactory;
                container.addContextValves(new KeycloakAuthenticatorValve());
                container.addContextCustomizers(tomcatKeycloakContextCustomizer());
            } else if (configurableServletWebServerFactory instanceof UndertowServletWebServerFactory) {
                UndertowServletWebServerFactory container = (UndertowServletWebServerFactory) configurableServletWebServerFactory;
                container.addDeploymentInfoCustomizers(undertowKeycloakContextCustomizer());
            } else if (configurableServletWebServerFactory instanceof JettyServletWebServerFactory) {
                JettyServletWebServerFactory container = (JettyServletWebServerFactory) configurableServletWebServerFactory;
                container.addServerCustomizers(jettyKeycloakServerCustomizer());
            }
        }
    };
}
Also used : KeycloakAuthenticatorValve(org.keycloak.adapters.tomcat.KeycloakAuthenticatorValve) ConfigurableServletWebServerFactory(org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory) TomcatServletWebServerFactory(org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory) UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) JettyServletWebServerFactory(org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory) WebServerFactoryCustomizer(org.springframework.boot.web.server.WebServerFactoryCustomizer) Bean(org.springframework.context.annotation.Bean)

Example 2 with WebServerFactoryCustomizer

use of org.springframework.boot.web.server.WebServerFactoryCustomizer in project joinfaces by joinfaces.

the class UndertowAutoConfiguration method jsfUndertowFactoryCustomizer.

@Bean
public WebServerFactoryCustomizer<UndertowServletWebServerFactory> jsfUndertowFactoryCustomizer() {
    return factory -> factory.addDeploymentInfoCustomizers(deploymentInfo -> {
        AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
            ClassLoader jsfClassLoader = new URLClassLoader(new URL[0], this.getClass().getClassLoader());
            deploymentInfo.setClassLoader(jsfClassLoader);
            deploymentInfo.setResourceManager(new ClassPathResourceManager(jsfClassLoader, this.undertowProperties.getClassPathResource()));
            return null;
        });
        log.info("Setting Undertow classLoader to {} directory", this.undertowProperties.getClassPathResource());
    });
}
Also used : ClassPathResourceManager(io.undertow.server.handlers.resource.ClassPathResourceManager) ConditionalOnClass(org.springframework.boot.autoconfigure.condition.ConditionalOnClass) URL(java.net.URL) RequiredArgsConstructor(lombok.RequiredArgsConstructor) WebServerFactoryCustomizer(org.springframework.boot.web.server.WebServerFactoryCustomizer) ConfigureListener(com.sun.faces.config.ConfigureListener) PrivilegedAction(java.security.PrivilegedAction) Undertow(io.undertow.Undertow) Configuration(org.springframework.context.annotation.Configuration) URLClassLoader(java.net.URLClassLoader) Slf4j(lombok.extern.slf4j.Slf4j) EnableConfigurationProperties(org.springframework.boot.context.properties.EnableConfigurationProperties) UndertowServletWebServerFactory(org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory) Bean(org.springframework.context.annotation.Bean) AccessController(java.security.AccessController) ConditionalOnWebApplication(org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication) URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) ClassPathResourceManager(io.undertow.server.handlers.resource.ClassPathResourceManager) URL(java.net.URL) Bean(org.springframework.context.annotation.Bean)

Aggregations

UndertowServletWebServerFactory (org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory)2 WebServerFactoryCustomizer (org.springframework.boot.web.server.WebServerFactoryCustomizer)2 Bean (org.springframework.context.annotation.Bean)2 ConfigureListener (com.sun.faces.config.ConfigureListener)1 Undertow (io.undertow.Undertow)1 ClassPathResourceManager (io.undertow.server.handlers.resource.ClassPathResourceManager)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 AccessController (java.security.AccessController)1 PrivilegedAction (java.security.PrivilegedAction)1 RequiredArgsConstructor (lombok.RequiredArgsConstructor)1 Slf4j (lombok.extern.slf4j.Slf4j)1 KeycloakAuthenticatorValve (org.keycloak.adapters.tomcat.KeycloakAuthenticatorValve)1 ConditionalOnClass (org.springframework.boot.autoconfigure.condition.ConditionalOnClass)1 ConditionalOnWebApplication (org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication)1 EnableConfigurationProperties (org.springframework.boot.context.properties.EnableConfigurationProperties)1 JettyServletWebServerFactory (org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory)1 TomcatServletWebServerFactory (org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory)1 ConfigurableServletWebServerFactory (org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory)1 Configuration (org.springframework.context.annotation.Configuration)1