[KEYCLOAK-11282] - Properly resolve config resolver
Co-authored-by: mhajas <mhajas@redhat.com>
This commit is contained in:
parent
56d1ab19a8
commit
84d099e48f
4 changed files with 14 additions and 11 deletions
|
@ -21,7 +21,6 @@ import io.undertow.servlet.api.DeploymentInfo;
|
|||
import io.undertow.servlet.api.SecurityInfo.EmptyRoleSemantic;
|
||||
import io.undertow.servlet.api.WebResourceCollection;
|
||||
import org.apache.catalina.Context;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.tomcat.util.descriptor.web.LoginConfig;
|
||||
import org.apache.tomcat.util.descriptor.web.SecurityCollection;
|
||||
import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
|
||||
|
@ -34,7 +33,6 @@ import org.eclipse.jetty.server.handler.HandlerList;
|
|||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||
import org.eclipse.jetty.util.security.Constraint;
|
||||
import org.eclipse.jetty.webapp.WebAppContext;
|
||||
import org.keycloak.adapters.KeycloakDeploymentBuilder;
|
||||
import org.keycloak.adapters.jetty.KeycloakJettyAuthenticator;
|
||||
import org.keycloak.adapters.undertow.KeycloakServletExtension;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -54,9 +52,9 @@ public class KeycloakBaseSpringBootConfiguration {
|
|||
protected KeycloakSpringBootProperties keycloakProperties;
|
||||
|
||||
@Autowired
|
||||
public void setKeycloakSpringBootProperties(KeycloakSpringBootProperties keycloakProperties, KeycloakSpringBootConfigResolver resolver) {
|
||||
public void setKeycloakSpringBootProperties(KeycloakSpringBootProperties keycloakProperties) {
|
||||
this.keycloakProperties = keycloakProperties;
|
||||
resolver.setAdapterConfig(keycloakProperties);
|
||||
KeycloakSpringBootConfigResolverWrapper.setAdapterConfig(keycloakProperties);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.springframework.context.ApplicationContext;
|
|||
public class KeycloakSpringBootConfigResolverWrapper extends KeycloakSpringConfigResolverWrapper {
|
||||
|
||||
private static ApplicationContext context;
|
||||
private static KeycloakSpringBootProperties adapterConfig;
|
||||
|
||||
public KeycloakSpringBootConfigResolverWrapper() {
|
||||
super(new KeycloakSpringBootConfigResolver());
|
||||
|
@ -40,9 +41,16 @@ public class KeycloakSpringBootConfigResolverWrapper extends KeycloakSpringConfi
|
|||
setDelegate(context.getBean(KeycloakConfigResolver.class));
|
||||
} catch (NoSuchBeanDefinitionException ignore) {
|
||||
}
|
||||
if (getDelegate() instanceof KeycloakSpringBootConfigResolver) {
|
||||
KeycloakSpringBootConfigResolver.class.cast(getDelegate()).setAdapterConfig(adapterConfig);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setApplicationContext(ApplicationContext context) {
|
||||
KeycloakSpringBootConfigResolverWrapper.context = context;
|
||||
}
|
||||
|
||||
public static void setAdapterConfig(KeycloakSpringBootProperties adapterConfig) {
|
||||
KeycloakSpringBootConfigResolverWrapper.adapterConfig = adapterConfig;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,13 +49,6 @@ public class KeycloakAutoConfiguration extends KeycloakBaseSpringBootConfigurati
|
|||
|
||||
private KeycloakSpringBootProperties keycloakProperties;
|
||||
|
||||
@Autowired
|
||||
public void setKeycloakSpringBootProperties(KeycloakSpringBootProperties keycloakProperties, KeycloakSpringBootConfigResolver resolver) {
|
||||
this.keycloakProperties = keycloakProperties;
|
||||
resolver.setAdapterConfig(keycloakProperties);
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public EmbeddedServletContainerCustomizer getKeycloakContainerCustomizer() {
|
||||
return new EmbeddedServletContainerCustomizer() {
|
||||
|
|
|
@ -43,4 +43,8 @@ public class KeycloakSpringConfigResolverWrapper implements KeycloakConfigResolv
|
|||
protected void setDelegate(KeycloakConfigResolver delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
protected KeycloakConfigResolver getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue