diff --git a/server/src/main/resources/META-INF/keycloak-server.json b/server/src/main/resources/META-INF/keycloak-server.json index d9249ddc17..9f0d03ea5d 100755 --- a/server/src/main/resources/META-INF/keycloak-server.json +++ b/server/src/main/resources/META-INF/keycloak-server.json @@ -15,19 +15,19 @@ }, "user": { - "provider": "${keycloak.user.provider:jpa}" + "provider": "jpa" }, "userSessions": { - "provider" : "${keycloak.userSessions.provider:mem}" + "provider" : "mem" }, "realmCache": { - "provider": "${keycloak.realm.cache.provider:mem}" + "provider": "mem" }, "userCache": { - "provider": "${keycloak.user.cache.provider:mem}", + "provider": "mem", "mem": { "maxSize": 20000 } @@ -68,11 +68,5 @@ "dataSource": "java:jboss/datasources/KeycloakDS", "databaseSchema": "update" } - }, - - "connectionsInfinispan": { - "default": { - "cacheContainer" : "java:jboss/infinispan/Keycloak" - } } } \ No newline at end of file diff --git a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java index d457c15630..a2d5a60d29 100755 --- a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java +++ b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java @@ -37,6 +37,8 @@ import java.io.InputStream; import java.net.URI; import java.net.URL; import java.util.HashSet; +import java.util.Map; +import java.util.Properties; import java.util.Set; import java.util.StringTokenizer; @@ -118,7 +120,14 @@ public class KeycloakApplication extends Application { if (config != null) { JsonNode node = new ObjectMapper().readTree(config); - Config.init(new JsonConfigProvider(node)); + + Properties properties = new Properties(); + properties.putAll(System.getProperties()); + for(Map.Entry e : System.getenv().entrySet()) { + properties.put("env." + e.getKey(), e.getValue()); + } + + Config.init(new JsonConfigProvider(node, properties)); log.info("Loaded config from " + config); return; diff --git a/services/src/main/java/org/keycloak/services/util/JsonConfigProvider.java b/services/src/main/java/org/keycloak/services/util/JsonConfigProvider.java index bf9194413e..6d1b8271e5 100755 --- a/services/src/main/java/org/keycloak/services/util/JsonConfigProvider.java +++ b/services/src/main/java/org/keycloak/services/util/JsonConfigProvider.java @@ -4,21 +4,26 @@ import org.codehaus.jackson.JsonNode; import org.keycloak.Config; import org.keycloak.util.StringPropertyReplacer; +import java.util.Properties; + /** * @author Stian Thorgersen */ public class JsonConfigProvider implements Config.ConfigProvider { + private Properties properties; + private JsonNode config; - public JsonConfigProvider(JsonNode config) { + public JsonConfigProvider(JsonNode config, Properties properties) { this.config = config; + this.properties = properties; } @Override public String getProvider(String spi) { JsonNode n = getNode(config, spi, "provider"); - return n != null ? StringPropertyReplacer.replaceProperties(n.getTextValue()) : null; + return n != null ? replaceProperties(n.getTextValue()) : null; } @Override @@ -40,6 +45,10 @@ public class JsonConfigProvider implements Config.ConfigProvider { return n; } + private String replaceProperties(String value) { + return StringPropertyReplacer.replaceProperties(value, properties); + } + public class JsonScope implements Config.Scope { private JsonNode config; @@ -62,7 +71,7 @@ public class JsonConfigProvider implements Config.ConfigProvider { if (n == null) { return defaultValue; } - return StringPropertyReplacer.replaceProperties(n.getTextValue()); + return replaceProperties(n.getTextValue()); } @Override @@ -77,11 +86,11 @@ public class JsonConfigProvider implements Config.ConfigProvider { } else if (n.isArray()) { String[] a = new String[n.size()]; for (int i = 0; i < a.length; i++) { - a[i] = StringPropertyReplacer.replaceProperties(n.get(i).getTextValue()); + a[i] = replaceProperties(n.get(i).getTextValue()); } return a; } else { - return new String[] { StringPropertyReplacer.replaceProperties(n.getTextValue()) }; + return new String[] { replaceProperties(n.getTextValue()) }; } } @@ -100,7 +109,7 @@ public class JsonConfigProvider implements Config.ConfigProvider { return defaultValue; } if (n.isTextual()) { - return Integer.parseInt(StringPropertyReplacer.replaceProperties(n.getTextValue())); + return Integer.parseInt(replaceProperties(n.getTextValue())); } else { return n.getIntValue(); } @@ -121,7 +130,7 @@ public class JsonConfigProvider implements Config.ConfigProvider { return defaultValue; } if (n.isTextual()) { - return Long.parseLong(StringPropertyReplacer.replaceProperties(n.getTextValue())); + return Long.parseLong(replaceProperties(n.getTextValue())); } else { return n.getLongValue(); } @@ -142,7 +151,7 @@ public class JsonConfigProvider implements Config.ConfigProvider { return defaultValue; } if (n.isTextual()) { - return Boolean.parseBoolean(StringPropertyReplacer.replaceProperties(n.getTextValue())); + return Boolean.parseBoolean(replaceProperties(n.getTextValue())); } else { return n.getBooleanValue(); } @@ -152,6 +161,7 @@ public class JsonConfigProvider implements Config.ConfigProvider { public Config.Scope scope(String... path) { return new JsonScope(getNode(config, path)); } + } }