Search in sources :

Example 1 with KeycloakAuthenticatorValve

use of org.keycloak.adapters.tomcat.KeycloakAuthenticatorValve 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)

Aggregations

KeycloakAuthenticatorValve (org.keycloak.adapters.tomcat.KeycloakAuthenticatorValve)1 JettyServletWebServerFactory (org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory)1 TomcatServletWebServerFactory (org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory)1 UndertowServletWebServerFactory (org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory)1 WebServerFactoryCustomizer (org.springframework.boot.web.server.WebServerFactoryCustomizer)1 ConfigurableServletWebServerFactory (org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory)1 Bean (org.springframework.context.annotation.Bean)1