From ef442cae926c428bf706abe49666ae5fe654b4c2 Mon Sep 17 00:00:00 2001 From: Stan Silvert Date: Wed, 17 Aug 2016 15:18:13 -0400 Subject: [PATCH] KEYCLOAK-3196: Create single place to declare default keycloak subsystem config. --- distribution/demo-dist/pom.xml | 25 +++++ .../demo-dist/src/main/xslt/standalone.xsl | 95 ++++--------------- .../cli/keycloak-install-ha.cli | 4 +- .../server-overlay/cli/keycloak-install.cli | 5 +- wildfly/server-subsystem/pom.xml | 17 +++- .../default-server-subsys-config.properties | 67 +++++++++++++ .../server/extension/JsonConfigConverter.java | 2 +- .../keycloak-server-default-config.xml | 1 + .../subsystem-templates/keycloak-server.xml | 63 +----------- .../extension/SubsystemParsingTestCase.java | 1 + .../server/extension/keycloak-server-1.1.xml | 80 +--------------- 11 files changed, 137 insertions(+), 223 deletions(-) create mode 100644 wildfly/server-subsystem/src/main/config/default-server-subsys-config.properties create mode 100644 wildfly/server-subsystem/src/main/resources/default-config/keycloak-server-default-config.xml diff --git a/distribution/demo-dist/pom.xml b/distribution/demo-dist/pom.xml index 187d62dcec..71a5a1a1ed 100755 --- a/distribution/demo-dist/pom.xml +++ b/distribution/demo-dist/pom.xml @@ -202,6 +202,31 @@ + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack + compile + + unpack + + + + + org.keycloak + keycloak-wildfly-server-subsystem + ${project.version} + jar + default-config/*.xml + + + + + + diff --git a/distribution/demo-dist/src/main/xslt/standalone.xsl b/distribution/demo-dist/src/main/xslt/standalone.xsl index db2247c43e..855efc0c56 100755 --- a/distribution/demo-dist/src/main/xslt/standalone.xsl +++ b/distribution/demo-dist/src/main/xslt/standalone.xsl @@ -1,19 +1,19 @@ +~ Copyright 2016 Red Hat, Inc. and/or its affiliates +~ and other contributors as indicated by the @author tags. +~ +~ Licensed under the Apache License, Version 2.0 (the "License"); +~ you may not use this file except in compliance with the License. +~ You may obtain a copy of the License at +~ +~ http://www.apache.org/licenses/LICENSE-2.0 +~ +~ Unless required by applicable law or agreed to in writing, software +~ distributed under the License is distributed on an "AS IS" BASIS, +~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +~ See the License for the specific language governing permissions and +~ limitations under the License. +--> - + jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE h2 @@ -57,68 +57,7 @@ - - auth - - classpath:${jboss.home.dir}/providers/* - - master - 900 - - 2592000 - true - true - ${jboss.home.dir}/themes - - - jpa - - - - - - - - jpa - - - jpa - - - - - - jpa - - - jpa - - - basic - - - - - - - - - - - - - - - - - default - - - - - - - + diff --git a/distribution/server-overlay/cli/keycloak-install-ha.cli b/distribution/server-overlay/cli/keycloak-install-ha.cli index f52bbc050a..ddcefc460b 100644 --- a/distribution/server-overlay/cli/keycloak-install-ha.cli +++ b/distribution/server-overlay/cli/keycloak-install-ha.cli @@ -1,5 +1,5 @@ embed-server --server-config=standalone-ha.xml -/subsystem=datasources/data-source=KeycloakDS/:add(connection-url="jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE",driver-name=h2,jndi-name=java:jboss/datasources/KeycloakDS,password=sa,user-name=sa,use-java-context=true) +/subsystem=datasources/data-source=KeycloakDS/:add(connection-url="jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE",jta=false,driver-name=h2,jndi-name=java:jboss/datasources/KeycloakDS,password=sa,user-name=sa,use-java-context=true) /subsystem=infinispan/cache-container=keycloak:add(jndi-name="infinispan/Keycloak") /subsystem=infinispan/cache-container=keycloak/transport=TRANSPORT:add(lock-timeout=60000) /subsystem=infinispan/cache-container=keycloak/invalidation-cache=realms:add(mode="SYNC") @@ -30,3 +30,5 @@ embed-server --server-config=standalone-ha.xml /subsystem=keycloak-server/spi=realmCache/provider=default/:add(enabled=true) /subsystem=keycloak-server/spi=connectionsInfinispan/:add(default-provider=default) /subsystem=keycloak-server/spi=connectionsInfinispan/provider=default/:add(properties={cacheContainer => "java:comp/env/infinispan/Keycloak"},enabled=true) +/subsystem=keycloak-server/spi=jta-lookup/:add +/subsystem=keycloak-server/spi=jta-lookup/provider=jboss/:add(enabled=true) diff --git a/distribution/server-overlay/cli/keycloak-install.cli b/distribution/server-overlay/cli/keycloak-install.cli index c3ca492b8a..c89859d38c 100644 --- a/distribution/server-overlay/cli/keycloak-install.cli +++ b/distribution/server-overlay/cli/keycloak-install.cli @@ -1,5 +1,5 @@ embed-server --server-config=standalone.xml -/subsystem=datasources/data-source=KeycloakDS/:add(connection-url="jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE",driver-name=h2,jndi-name=java:jboss/datasources/KeycloakDS,password=sa,user-name=sa,use-java-context=true) +/subsystem=datasources/data-source=KeycloakDS/:add(connection-url="jdbc:h2:${jboss.server.data.dir}/keycloak;AUTO_SERVER=TRUE",jta=false,driver-name=h2,jndi-name=java:jboss/datasources/KeycloakDS,password=sa,user-name=sa,use-java-context=true) /subsystem=infinispan/cache-container=keycloak:add(jndi-name="infinispan/Keycloak") /subsystem=infinispan/cache-container=keycloak/local-cache=realms:add() /subsystem=infinispan/cache-container=keycloak/local-cache=users:add() @@ -30,3 +30,6 @@ embed-server --server-config=standalone.xml /subsystem=keycloak-server/spi=realmCache/provider=default/:add(enabled=true) /subsystem=keycloak-server/spi=connectionsInfinispan/:add(default-provider=default) /subsystem=keycloak-server/spi=connectionsInfinispan/provider=default/:add(properties={cacheContainer => "java:comp/env/infinispan/Keycloak"},enabled=true) +/subsystem=keycloak-server/spi=jta-lookup/:add +/subsystem=keycloak-server/spi=jta-lookup/provider=jboss/:add(enabled=true) + diff --git a/wildfly/server-subsystem/pom.xml b/wildfly/server-subsystem/pom.xml index db0f3cac78..05b0fc0c0b 100755 --- a/wildfly/server-subsystem/pom.xml +++ b/wildfly/server-subsystem/pom.xml @@ -47,8 +47,23 @@ **/*TestCase.java - + + + src/main/config/default-server-subsys-config.properties + + + + src/main/resources + true + + + + + src/test/resources + true + + diff --git a/wildfly/server-subsystem/src/main/config/default-server-subsys-config.properties b/wildfly/server-subsystem/src/main/config/default-server-subsys-config.properties new file mode 100644 index 0000000000..afdebe22a9 --- /dev/null +++ b/wildfly/server-subsystem/src/main/config/default-server-subsys-config.properties @@ -0,0 +1,67 @@ +keycloak.server.subsys.default.config=\ +\ + auth\ + \ + classpath:${jboss.home.dir}/providers/*\ + \ + master\ + 900\ + \ + 2592000\ + true\ + true\ + ${jboss.home.dir}/themes\ + \ + \ + jpa\ + \ + \ + \ + \ + \ + \ + \ + jpa\ + \ + \ + jpa\ + \ + \ + \ + \ + \ + jpa\ + \ + \ + jpa\ + \ + \ + basic\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + default\ + \ + \ + \ + \ + \ + \ + \ + ${keycloak.jta.lookup.provider:jboss}\ + \ + \ +\ \ No newline at end of file diff --git a/wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/JsonConfigConverter.java b/wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/JsonConfigConverter.java index 95010cc073..aa4d3f578d 100644 --- a/wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/JsonConfigConverter.java +++ b/wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/JsonConfigConverter.java @@ -47,7 +47,7 @@ import static org.keycloak.subsystem.server.extension.ThemeResourceDefinition.WE */ public class JsonConfigConverter { - private static final List NON_SPI_LIST = new ArrayList(); + private static final List NON_SPI_LIST = new ArrayList<>(); static { NON_SPI_LIST.add("providers"); diff --git a/wildfly/server-subsystem/src/main/resources/default-config/keycloak-server-default-config.xml b/wildfly/server-subsystem/src/main/resources/default-config/keycloak-server-default-config.xml new file mode 100644 index 0000000000..e5206116c6 --- /dev/null +++ b/wildfly/server-subsystem/src/main/resources/default-config/keycloak-server-default-config.xml @@ -0,0 +1 @@ +${keycloak.server.subsys.default.config} \ No newline at end of file diff --git a/wildfly/server-subsystem/src/main/resources/subsystem-templates/keycloak-server.xml b/wildfly/server-subsystem/src/main/resources/subsystem-templates/keycloak-server.xml index f2d4cd6ae7..67bf03e733 100644 --- a/wildfly/server-subsystem/src/main/resources/subsystem-templates/keycloak-server.xml +++ b/wildfly/server-subsystem/src/main/resources/subsystem-templates/keycloak-server.xml @@ -19,66 +19,5 @@ org.keycloak.keycloak-server-subsystem - - auth - - classpath:${jboss.home.dir}/providers/* - - master - 900 - - 2592000 - true - true - ${jboss.home.dir}/themes - - - jpa - - - - - - - - jpa - - - jpa - - - - - - jpa - - - jpa - - - basic - - - - - - - - - - - - - - - - - default - - - - - - - + ${keycloak.server.subsys.default.config} diff --git a/wildfly/server-subsystem/src/test/java/org/keycloak/subsystem/server/extension/SubsystemParsingTestCase.java b/wildfly/server-subsystem/src/test/java/org/keycloak/subsystem/server/extension/SubsystemParsingTestCase.java index ade4a0574c..0bc41106dd 100755 --- a/wildfly/server-subsystem/src/test/java/org/keycloak/subsystem/server/extension/SubsystemParsingTestCase.java +++ b/wildfly/server-subsystem/src/test/java/org/keycloak/subsystem/server/extension/SubsystemParsingTestCase.java @@ -41,6 +41,7 @@ public class SubsystemParsingTestCase extends AbstractSubsystemBaseTest { protected Properties getResolvedProperties() { Properties properties = new Properties(); properties.put("jboss.home.dir", System.getProperty("java.io.tmpdir")); + properties.put("keycloak.jta.lookup.provider", "jboss"); return properties; } diff --git a/wildfly/server-subsystem/src/test/resources/org/keycloak/subsystem/server/extension/keycloak-server-1.1.xml b/wildfly/server-subsystem/src/test/resources/org/keycloak/subsystem/server/extension/keycloak-server-1.1.xml index 290d8b7760..e5206116c6 100644 --- a/wildfly/server-subsystem/src/test/resources/org/keycloak/subsystem/server/extension/keycloak-server-1.1.xml +++ b/wildfly/server-subsystem/src/test/resources/org/keycloak/subsystem/server/extension/keycloak-server-1.1.xml @@ -1,79 +1 @@ - - - - auth - - classpath:${jboss.home.dir}/providers/* - - master - 900 - - 2592000 - true - true - ${jboss.home.dir}/themes - - - jpa - - - - - - - - jpa - - - jpa - - - - - - jpa - - - jpa - - - basic - - - - - - - - - - - - - - - - - default - - - - - - - \ No newline at end of file +${keycloak.server.subsys.default.config} \ No newline at end of file