Read keycloak-sever.json from <JBOSS_HOME>/standalone/configuration if it exists
This commit is contained in:
parent
c2075af7f7
commit
59440840fe
5 changed files with 33 additions and 7 deletions
|
@ -38,6 +38,13 @@
|
||||||
<exclude>keycloak-ds.xml</exclude>
|
<exclude>keycloak-ds.xml</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<directory>${project.build.directory}/unpacked/deployments/auth-server.war/WEB-INF/classes/META-INF</directory>
|
||||||
|
<outputDirectory>keycloak/standalone/configuration</outputDirectory>
|
||||||
|
<includes>
|
||||||
|
<include>keycloak-server.json</include>
|
||||||
|
</includes>
|
||||||
|
</fileSet>
|
||||||
<fileSet>
|
<fileSet>
|
||||||
<directory>${project.build.directory}/unpacked/themes</directory>
|
<directory>${project.build.directory}/unpacked/themes</directory>
|
||||||
<outputDirectory>keycloak/standalone/configuration/themes</outputDirectory>
|
<outputDirectory>keycloak/standalone/configuration/themes</outputDirectory>
|
||||||
|
|
|
@ -19,5 +19,12 @@
|
||||||
</includes>
|
</includes>
|
||||||
<outputDirectory>deployments</outputDirectory>
|
<outputDirectory>deployments</outputDirectory>
|
||||||
</fileSet>
|
</fileSet>
|
||||||
|
<fileSet>
|
||||||
|
<directory>${project.build.directory}/unpacked/deployments/auth-server.war/WEB-INF/classes/META-INF</directory>
|
||||||
|
<outputDirectory>configuration</outputDirectory>
|
||||||
|
<includes>
|
||||||
|
<include>keycloak-server.json</include>
|
||||||
|
</includes>
|
||||||
|
</fileSet>
|
||||||
</fileSets>
|
</fileSets>
|
||||||
</assembly>
|
</assembly>
|
||||||
|
|
|
@ -33,7 +33,6 @@ public class DefaultProviderSessionFactory implements ProviderSessionFactory {
|
||||||
ProviderFactory factory = loadProviderFactory(spi, provider);
|
ProviderFactory factory = loadProviderFactory(spi, provider);
|
||||||
Config.Scope scope = Config.scope(spi.getName(), provider);
|
Config.Scope scope = Config.scope(spi.getName(), provider);
|
||||||
factory.init(scope);
|
factory.init(scope);
|
||||||
log.debug("Initialized " + factory.getClass().getName() + " (config = " + scope + ")");
|
|
||||||
|
|
||||||
factories.put(factory.getId(), factory);
|
factories.put(factory.getId(), factory);
|
||||||
|
|
||||||
|
@ -42,7 +41,6 @@ public class DefaultProviderSessionFactory implements ProviderSessionFactory {
|
||||||
for (ProviderFactory factory : ServiceLoader.load(spi.getProviderFactoryClass())) {
|
for (ProviderFactory factory : ServiceLoader.load(spi.getProviderFactoryClass())) {
|
||||||
Config.Scope scope = Config.scope(spi.getName(), factory.getId());
|
Config.Scope scope = Config.scope(spi.getName(), factory.getId());
|
||||||
factory.init(scope);
|
factory.init(scope);
|
||||||
log.debug("Initialized " + factory.getClass().getName() + " (config = " + scope + ")");
|
|
||||||
|
|
||||||
factories.put(factory.getId(), factory);
|
factories.put(factory.getId(), factory);
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,19 @@ public class KeycloakApplication extends Application {
|
||||||
|
|
||||||
protected void loadConfig() {
|
protected void loadConfig() {
|
||||||
try {
|
try {
|
||||||
URL config = Thread.currentThread().getContextClassLoader().getResource("META-INF/keycloak-server.json");
|
URL config = null;
|
||||||
|
|
||||||
|
String configDir = System.getProperty("jboss.server.config.dir");
|
||||||
|
if (configDir != null) {
|
||||||
|
File f = new File(configDir + File.separator + "keycloak-server.json");
|
||||||
|
if (f.isFile()) {
|
||||||
|
config = f.toURI().toURL();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config == null) {
|
||||||
|
config = Thread.currentThread().getContextClassLoader().getResource("META-INF/keycloak-server.json");
|
||||||
|
}
|
||||||
|
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
JsonNode node = new ObjectMapper().readTree(config);
|
JsonNode node = new ObjectMapper().readTree(config);
|
||||||
|
@ -116,6 +128,8 @@ public class KeycloakApplication extends Application {
|
||||||
|
|
||||||
log.info("Loaded config from " + config);
|
log.info("Loaded config from " + config);
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
log.warn("Config 'keycloak-server.json' not found");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("Failed to load config", e);
|
throw new RuntimeException("Failed to load config", e);
|
||||||
|
|
|
@ -74,11 +74,11 @@ public class JsonConfigProvider implements Config.ConfigProvider {
|
||||||
if (n == null) {
|
if (n == null) {
|
||||||
return null;
|
return null;
|
||||||
} else if (n.isArray()) {
|
} else if (n.isArray()) {
|
||||||
ArrayList<String> l = new ArrayList<String>();
|
String[] a = new String[n.size()];
|
||||||
for (JsonNode e : n) {
|
for (int i = 0; i < a.length; i++) {
|
||||||
l.add(StringPropertyReplacer.replaceProperties(e.getTextValue()));
|
a[i] = StringPropertyReplacer.replaceProperties(n.get(i).getTextValue());
|
||||||
}
|
}
|
||||||
return (String[]) l.toArray();
|
return a;
|
||||||
} else {
|
} else {
|
||||||
return new String[] { StringPropertyReplacer.replaceProperties(n.getTextValue()) };
|
return new String[] { StringPropertyReplacer.replaceProperties(n.getTextValue()) };
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue