Fix embedded theme-resources lookup in Keycloak.X

Previously lookups for embedded theme-resources did not work for Keycloak.X because of a missing
`ClasspathThemeResourceProvider` registration.

This PR ensures that a `ClasspathThemeResourceProvider` is registered in Keycloak.X based deployments.

Added empty constructors to ClasspathThemeResourceProvider to enable dynamic instantiation by Quarkus.

Fixes #9653
This commit is contained in:
Thomas Darimont 2022-01-20 19:18:35 +01:00 committed by Pedro Igor
parent 510c482572
commit 438fc2865f
3 changed files with 24 additions and 1 deletions

View file

@ -421,7 +421,14 @@ class KeycloakProcessor {
Map<String, ProviderFactory> preConfiguredProviders) {
Config.init(new MicroProfileConfigProvider());
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
ProviderManager pm = new ProviderManager(KeycloakDeploymentInfo.create().services(), classLoader);
KeycloakDeploymentInfo keycloakDeploymentInfo = KeycloakDeploymentInfo.create()
.name("classpath")
.services()
// .themes() // handling of .jar based themes is already supported by Keycloak.x
.themeResources();
ProviderManager pm = new ProviderManager(keycloakDeploymentInfo, classLoader);
Map<Spi, Map<Class<? extends Provider>, Map<String, ProviderFactory>>> factories = new HashMap<>();
for (Spi spi : pm.loadSpis()) {

View file

@ -37,6 +37,10 @@ public class KeycloakDeploymentInfo {
return name;
}
/**
* Enables discovery of services via {@link java.util.ServiceLoader}.
* @return
*/
public KeycloakDeploymentInfo services() {
this.services = true;
return this;
@ -46,6 +50,10 @@ public class KeycloakDeploymentInfo {
return themes;
}
/**
* Enables discovery embedded themes.
* @return
*/
public KeycloakDeploymentInfo themes() {
this.themes = true;
return this;
@ -55,6 +63,10 @@ public class KeycloakDeploymentInfo {
return themeResources;
}
/**
* Enables discovery of embedded theme-resources.
* @return
*/
public KeycloakDeploymentInfo themeResources() {
themeResources = true;
return this;

View file

@ -22,6 +22,10 @@ public class ClasspathThemeResourceProviderFactory implements ThemeResourceProvi
private final String id;
private final ClassLoader classLoader;
public ClasspathThemeResourceProviderFactory() {
this("classpath", Thread.currentThread().getContextClassLoader());
}
public ClasspathThemeResourceProviderFactory(String id, ClassLoader classLoader) {
this.id = id;
this.classLoader = classLoader;