Read keycloak-sever.json from <JBOSS_HOME>/standalone/configuration if it exists

This commit is contained in:
Stian Thorgersen 2014-05-21 09:35:01 +01:00
parent c2075af7f7
commit 59440840fe
5 changed files with 33 additions and 7 deletions

View file

@ -38,6 +38,13 @@
<exclude>keycloak-ds.xml</exclude>
</excludes>
</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>
<directory>${project.build.directory}/unpacked/themes</directory>
<outputDirectory>keycloak/standalone/configuration/themes</outputDirectory>

View file

@ -19,5 +19,12 @@
</includes>
<outputDirectory>deployments</outputDirectory>
</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>
</assembly>

View file

@ -33,7 +33,6 @@ public class DefaultProviderSessionFactory implements ProviderSessionFactory {
ProviderFactory factory = loadProviderFactory(spi, provider);
Config.Scope scope = Config.scope(spi.getName(), provider);
factory.init(scope);
log.debug("Initialized " + factory.getClass().getName() + " (config = " + scope + ")");
factories.put(factory.getId(), factory);
@ -42,7 +41,6 @@ public class DefaultProviderSessionFactory implements ProviderSessionFactory {
for (ProviderFactory factory : ServiceLoader.load(spi.getProviderFactoryClass())) {
Config.Scope scope = Config.scope(spi.getName(), factory.getId());
factory.init(scope);
log.debug("Initialized " + factory.getClass().getName() + " (config = " + scope + ")");
factories.put(factory.getId(), factory);
}

View file

@ -108,7 +108,19 @@ public class KeycloakApplication extends Application {
protected void loadConfig() {
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) {
JsonNode node = new ObjectMapper().readTree(config);
@ -116,6 +128,8 @@ public class KeycloakApplication extends Application {
log.info("Loaded config from " + config);
return;
} else {
log.warn("Config 'keycloak-server.json' not found");
}
} catch (IOException e) {
throw new RuntimeException("Failed to load config", e);

View file

@ -74,11 +74,11 @@ public class JsonConfigProvider implements Config.ConfigProvider {
if (n == null) {
return null;
} else if (n.isArray()) {
ArrayList<String> l = new ArrayList<String>();
for (JsonNode e : n) {
l.add(StringPropertyReplacer.replaceProperties(e.getTextValue()));
String[] a = new String[n.size()];
for (int i = 0; i < a.length; i++) {
a[i] = StringPropertyReplacer.replaceProperties(n.get(i).getTextValue());
}
return (String[]) l.toArray();
return a;
} else {
return new String[] { StringPropertyReplacer.replaceProperties(n.getTextValue()) };
}