diff --git a/client-registration/cli/src/main/java/org/keycloak/client/registration/cli/ClientRegistrationCLI.java b/client-registration/cli/src/main/java/org/keycloak/client/registration/cli/ClientRegistrationCLI.java index 986faac648..e76648bbf7 100644 --- a/client-registration/cli/src/main/java/org/keycloak/client/registration/cli/ClientRegistrationCLI.java +++ b/client-registration/cli/src/main/java/org/keycloak/client/registration/cli/ClientRegistrationCLI.java @@ -57,6 +57,8 @@ public class ClientRegistrationCLI { .create(); aeshConsole.start(); + + /* if (args.length > 0) { CommandContainer command = registry.getCommand(args[0], null); diff --git a/core/src/main/java/org/keycloak/representations/idm/CredentialRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/CredentialRepresentation.java index 1e57dbcc9e..6ad9715805 100755 --- a/core/src/main/java/org/keycloak/representations/idm/CredentialRepresentation.java +++ b/core/src/main/java/org/keycloak/representations/idm/CredentialRepresentation.java @@ -29,7 +29,7 @@ public class CredentialRepresentation { private Integer period; // only used when updating a credential. Might set required action - protected boolean temporary; + protected Boolean temporary; public String getType() { return type; @@ -79,11 +79,11 @@ public class CredentialRepresentation { this.hashIterations = hashIterations; } - public boolean isTemporary() { + public Boolean isTemporary() { return temporary; } - public void setTemporary(boolean temporary) { + public void setTemporary(Boolean temporary) { this.temporary = temporary; } diff --git a/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java index 00785cf710..9b76490279 100755 --- a/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java +++ b/core/src/main/java/org/keycloak/representations/idm/RealmRepresentation.java @@ -84,7 +84,6 @@ public class RealmRepresentation { private List identityProviders; private List identityProviderMappers; private List protocolMappers; - private Boolean identityFederationEnabled; protected Boolean internationalizationEnabled; protected Set supportedLocales; protected String defaultLocale; @@ -613,10 +612,6 @@ public class RealmRepresentation { identityProviders.add(identityProviderRepresentation); } - public boolean isIdentityFederationEnabled() { - return identityProviders != null && !identityProviders.isEmpty(); - } - public List getProtocolMappers() { return protocolMappers; } diff --git a/core/src/main/java/org/keycloak/representations/idm/UserRepresentation.java b/core/src/main/java/org/keycloak/representations/idm/UserRepresentation.java index 8635014c11..0990a4e6ea 100755 --- a/core/src/main/java/org/keycloak/representations/idm/UserRepresentation.java +++ b/core/src/main/java/org/keycloak/representations/idm/UserRepresentation.java @@ -17,9 +17,9 @@ public class UserRepresentation { protected String id; protected Long createdTimestamp; protected String username; - protected boolean enabled; - protected boolean totp; - protected boolean emailVerified; + protected Boolean enabled; + protected Boolean totp; + protected Boolean emailVerified; protected String firstName; protected String lastName; protected String email; @@ -98,27 +98,27 @@ public class UserRepresentation { this.username = username; } - public boolean isEnabled() { + public Boolean isEnabled() { return enabled; } - public void setEnabled(boolean enabled) { + public void setEnabled(Boolean enabled) { this.enabled = enabled; } - public boolean isTotp() { + public Boolean isTotp() { return totp; } - public void setTotp(boolean totp) { + public void setTotp(Boolean totp) { this.totp = totp; } - public boolean isEmailVerified() { + public Boolean isEmailVerified() { return emailVerified; } - public void setEmailVerified(boolean emailVerified) { + public void setEmailVerified(Boolean emailVerified) { this.emailVerified = emailVerified; } diff --git a/core/src/main/java/org/keycloak/util/JsonSerialization.java b/core/src/main/java/org/keycloak/util/JsonSerialization.java index a1a93ba1cc..19df33f0c4 100755 --- a/core/src/main/java/org/keycloak/util/JsonSerialization.java +++ b/core/src/main/java/org/keycloak/util/JsonSerialization.java @@ -3,6 +3,7 @@ package org.keycloak.util; import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.SerializationConfig; import org.codehaus.jackson.map.annotate.JsonSerialize; +import org.codehaus.jackson.type.TypeReference; import java.io.IOException; import java.io.InputStream; @@ -27,7 +28,10 @@ public class JsonSerialization { public static void writeValueToStream(OutputStream os, Object obj) throws IOException { mapper.writeValue(os, obj); + } + public static void writeValuePrettyToStream(OutputStream os, Object obj) throws IOException { + prettyMapper.writeValue(os, obj); } public static String writeValueAsPrettyString(Object obj) throws IOException { @@ -53,6 +57,10 @@ public class JsonSerialization { return readValue(bytes, type, false); } + public static T readValue(InputStream bytes, TypeReference type) throws IOException { + return mapper.readValue(bytes, type); + } + public static T readValue(InputStream bytes, Class type, boolean replaceSystemProperties) throws IOException { if (replaceSystemProperties) { return sysPropertiesAwareMapper.readValue(bytes, type); diff --git a/distribution/feature-packs/server-feature-pack/pom.xml b/distribution/feature-packs/server-feature-pack/pom.xml index 0f5dd37ff9..6f05056bf9 100644 --- a/distribution/feature-packs/server-feature-pack/pom.xml +++ b/distribution/feature-packs/server-feature-pack/pom.xml @@ -36,19 +36,27 @@ keycloak-dependencies-server-all pom + + org.keycloak + keycloak-wildfly-adduser + org.keycloak keycloak-wildfly-extensions org.keycloak - keycloak-wf9-server-subsystem + keycloak-wildfly-server-subsystem org.wildfly wildfly-feature-pack zip + + org.jboss.aesh + aesh + diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/content/bin/add-user.bat b/distribution/feature-packs/server-feature-pack/src/main/resources/content/bin/add-user.bat new file mode 100644 index 0000000000..dca1136b6e --- /dev/null +++ b/distribution/feature-packs/server-feature-pack/src/main/resources/content/bin/add-user.bat @@ -0,0 +1,73 @@ +@echo off +rem ------------------------------------------------------------------------- +rem Add User script for Windows +rem ------------------------------------------------------------------------- +rem +rem A simple utility for adding new users to the properties file used +rem for domain management authentication out of the box. + +rem $Id$ + +@if not "%ECHO%" == "" echo %ECHO% +@if "%OS%" == "Windows_NT" setlocal + +if "%OS%" == "Windows_NT" ( + set "DIRNAME=%~dp0%" +) else ( + set DIRNAME=.\ +) + +pushd "%DIRNAME%.." +set "RESOLVED_JBOSS_HOME=%CD%" +popd + +if "x%JBOSS_HOME%" == "x" ( + set "JBOSS_HOME=%RESOLVED_JBOSS_HOME%" +) + +pushd "%JBOSS_HOME%" +set "SANITIZED_JBOSS_HOME=%CD%" +popd + +if /i "%RESOLVED_JBOSS_HOME%" NEQ "%SANITIZED_JBOSS_HOME%" ( + echo. + echo WARNING: The JBOSS_HOME ^("%SANITIZED_JBOSS_HOME%"^) that this script uses points to a different installation than the one that this script resides in ^("%RESOLVED_JBOSS_HOME%"^). Unpredictable results may occur. + echo. + echo JBOSS_HOME: "%JBOSS_HOME%" + echo. +) + +rem Setup JBoss specific properties +if "x%JAVA_HOME%" == "x" ( + set JAVA=java + echo JAVA_HOME is not set. Unexpected results may occur. + echo Set JAVA_HOME to the directory of your local JDK to avoid this message. +) else ( + set "JAVA=%JAVA_HOME%\bin\java" +) + +rem Find jboss-modules.jar, or we can't continue +if exist "%JBOSS_HOME%\jboss-modules.jar" ( + set "RUNJAR=%JBOSS_HOME%\jboss-modules.jar" +) else ( + echo Could not locate "%JBOSS_HOME%\jboss-modules.jar". + echo Please check that you are in the bin directory when running this script. + goto END +) + +rem Set default module root paths +if "x%JBOSS_MODULEPATH%" == "x" ( + set "JBOSS_MODULEPATH=%JBOSS_HOME%\modules" +) + +rem Uncomment to override standalone and domain user location +rem set "JAVA_OPTS=%JAVA_OPTS% -Djboss.server.config.user.dir=..\standalone\configuration -Djboss.domain.config.user.dir=..\domain\configuration" + +"%JAVA%" %JAVA_OPTS% ^ + -jar "%JBOSS_HOME%\jboss-modules.jar" ^ + -mp "%JBOSS_MODULEPATH%" ^ + org.keycloak.keycloak-wildfly-adduser ^ + %* + +:END +if "x%NOPAUSE%" == "x" pause diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/content/bin/add-user.sh b/distribution/feature-packs/server-feature-pack/src/main/resources/content/bin/add-user.sh new file mode 100755 index 0000000000..1f6dfff9cd --- /dev/null +++ b/distribution/feature-packs/server-feature-pack/src/main/resources/content/bin/add-user.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +# Add User Utility +# +# A simple utility for adding new users to the properties file used +# for domain management authentication out of the box. +# + +DIRNAME=`dirname "$0"` + +# OS specific support (must be 'true' or 'false'). +cygwin=false; +if [ `uname|grep -i CYGWIN` ]; then + cygwin=true; +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$JBOSS_HOME" ] && + JBOSS_HOME=`cygpath --unix "$JBOSS_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$JAVAC_JAR" ] && + JAVAC_JAR=`cygpath --unix "$JAVAC_JAR"` +fi + +# Setup JBOSS_HOME +RESOLVED_JBOSS_HOME=`cd "$DIRNAME/.."; pwd` +if [ "x$JBOSS_HOME" = "x" ]; then + # get the full path (without any relative bits) + JBOSS_HOME=$RESOLVED_JBOSS_HOME +else + SANITIZED_JBOSS_HOME=`cd "$JBOSS_HOME"; pwd` + if [ "$RESOLVED_JBOSS_HOME" != "$SANITIZED_JBOSS_HOME" ]; then + echo "WARNING: The JBOSS_HOME ($SANITIZED_JBOSS_HOME) that this script uses points to a different installation than the one that this script resides in ($RESOLVED_JBOSS_HOME). Unpredictable results may occur." + echo "" + fi +fi +export JBOSS_HOME + +# Setup the JVM +if [ "x$JAVA" = "x" ]; then + if [ "x$JAVA_HOME" != "x" ]; then + JAVA="$JAVA_HOME/bin/java" + else + JAVA="java" + fi +fi + +if [ "x$JBOSS_MODULEPATH" = "x" ]; then + JBOSS_MODULEPATH="$JBOSS_HOME/modules" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + JBOSS_HOME=`cygpath --path --windows "$JBOSS_HOME"` + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + JBOSS_MODULEPATH=`cygpath --path --windows "$JBOSS_MODULEPATH"` +fi + +# Sample JPDA settings for remote socket debugging +#JAVA_OPTS="$JAVA_OPTS -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=y" +# Uncomment to override standalone and domain user location +#JAVA_OPTS="$JAVA_OPTS -Djboss.server.config.user.dir=../standalone/configuration -Djboss.domain.config.user.dir=../domain/configuration" + +JAVA_OPTS="$JAVA_OPTS" + +eval \"$JAVA\" $JAVA_OPTS \ + -jar \""$JBOSS_HOME"/jboss-modules.jar\" \ + -mp \""${JBOSS_MODULEPATH}"\" \ + org.keycloak.keycloak-wildfly-adduser \ + '"$@"' diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/jboss/aesh/0.65/module.xml b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/jboss/aesh/0.65/module.xml new file mode 100644 index 0000000000..4166dbd45a --- /dev/null +++ b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/jboss/aesh/0.65/module.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-server-subsystem/main/module.xml b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-server-subsystem/main/module.xml index d6e7d81f6a..8002aa2ff7 100644 --- a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-server-subsystem/main/module.xml +++ b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-server-subsystem/main/module.xml @@ -29,6 +29,6 @@ - + diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-wildfly-adduser/main/module.xml b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-wildfly-adduser/main/module.xml new file mode 100755 index 0000000000..d27499be9a --- /dev/null +++ b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-wildfly-adduser/main/module.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-wf9-server-subsystem/main/module.xml b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-wildfly-server-subsystem/main/module.xml similarity index 94% rename from distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-wf9-server-subsystem/main/module.xml rename to distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-wildfly-server-subsystem/main/module.xml index 6748cb4237..d816b79c61 100644 --- a/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-wf9-server-subsystem/main/module.xml +++ b/distribution/feature-packs/server-feature-pack/src/main/resources/modules/system/layers/base/org/keycloak/keycloak-wildfly-server-subsystem/main/module.xml @@ -22,11 +22,11 @@ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. --> - + - + diff --git a/distribution/server-overlay/eap6/eap6-server-modules/build.xml b/distribution/server-overlay/eap6/eap6-server-modules/build.xml index 9f60836a8f..e8086dc37a 100755 --- a/distribution/server-overlay/eap6/eap6-server-modules/build.xml +++ b/distribution/server-overlay/eap6/eap6-server-modules/build.xml @@ -274,8 +274,8 @@ - - + + diff --git a/distribution/server-overlay/eap6/eap6-server-modules/pom.xml b/distribution/server-overlay/eap6/eap6-server-modules/pom.xml index 91b2969ae7..b3225fdc58 100755 --- a/distribution/server-overlay/eap6/eap6-server-modules/pom.xml +++ b/distribution/server-overlay/eap6/eap6-server-modules/pom.xml @@ -32,7 +32,7 @@ org.keycloak - keycloak-as7-server-subsystem + keycloak-eap6-server-subsystem org.keycloak diff --git a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-as7-server-subsystem/main/module.xml b/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-eap6-server-subsystem/main/module.xml similarity index 98% rename from distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-as7-server-subsystem/main/module.xml rename to distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-eap6-server-subsystem/main/module.xml index d061e08ff0..c628f4898d 100755 --- a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-as7-server-subsystem/main/module.xml +++ b/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-eap6-server-subsystem/main/module.xml @@ -22,7 +22,7 @@ ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org. --> - + diff --git a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-as7-server-subsystem/main/server-war/WEB-INF/jboss-deployment-structure.xml b/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-eap6-server-subsystem/main/server-war/WEB-INF/jboss-deployment-structure.xml similarity index 100% rename from distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-as7-server-subsystem/main/server-war/WEB-INF/jboss-deployment-structure.xml rename to distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-eap6-server-subsystem/main/server-war/WEB-INF/jboss-deployment-structure.xml diff --git a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-as7-server-subsystem/main/server-war/WEB-INF/web.xml b/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-eap6-server-subsystem/main/server-war/WEB-INF/web.xml similarity index 100% rename from distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-as7-server-subsystem/main/server-war/WEB-INF/web.xml rename to distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-eap6-server-subsystem/main/server-war/WEB-INF/web.xml diff --git a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-server-subsystem/main/module.xml b/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-server-subsystem/main/module.xml index 90939b029a..4829258f65 100755 --- a/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-server-subsystem/main/module.xml +++ b/distribution/server-overlay/eap6/eap6-server-modules/src/main/resources/modules/org/keycloak/keycloak-server-subsystem/main/module.xml @@ -30,6 +30,6 @@ - + diff --git a/docbook/auth-server-docs/reference/en/en-US/master.xml b/docbook/auth-server-docs/reference/en/en-US/master.xml index 16a8601228..d6bf5ff1a8 100755 --- a/docbook/auth-server-docs/reference/en/en-US/master.xml +++ b/docbook/auth-server-docs/reference/en/en-US/master.xml @@ -37,7 +37,6 @@ - diff --git a/docbook/auth-server-docs/reference/en/en-US/modules/admin-recovery.xml b/docbook/auth-server-docs/reference/en/en-US/modules/admin-recovery.xml deleted file mode 100755 index 941284805f..0000000000 --- a/docbook/auth-server-docs/reference/en/en-US/modules/admin-recovery.xml +++ /dev/null @@ -1,15 +0,0 @@ - - Recovering the Master Admin User - - It is possible for the "admin" user in the master realm to become inoperable. This may be because it was - accidentally deleted, its role mappings were removed, or the password was simply forgotten. - - - To recover the master admin user, just start the server with the following system properties: - - Then you can log in to the master admin account with your temporary password. You will then be - prompted to immediately change this password. - - \ No newline at end of file diff --git a/docbook/auth-server-docs/reference/en/en-US/modules/server-installation.xml b/docbook/auth-server-docs/reference/en/en-US/modules/server-installation.xml index 78d9a4b3d6..01ad7e6c4a 100755 --- a/docbook/auth-server-docs/reference/en/en-US/modules/server-installation.xml +++ b/docbook/auth-server-docs/reference/en/en-US/modules/server-installation.xml @@ -127,6 +127,25 @@ cd <WILDFLY_HOME>/bin +
+ Admin User + + To access the admin console you need an account to login. Currently, there's a default account added + with the username admin and password admin. You will be required + to change the password on first login. We are planning on removing the built-in account soon and will + instead have an initial step to create the user. + + + You can also create a user with the add-user script found in bin. + This script will create a temporary file with the details of the user, which are imported at startup. + To add a user with this script run: + -p +]]> + Then restart the server. + +
+
Relational Database Configuration diff --git a/integration/as7-eap6/pom.xml b/integration/as7-eap6/pom.xml index e1bca6a1e9..52a1053163 100755 --- a/integration/as7-eap6/pom.xml +++ b/integration/as7-eap6/pom.xml @@ -17,6 +17,5 @@ as7-adapter-spi as7-adapter as7-subsystem - as7-server-subsystem \ No newline at end of file diff --git a/integration/wildfly/pom.xml b/integration/wildfly/pom.xml index 141cd87b5e..3afdcc6bea 100644 --- a/integration/wildfly/pom.xml +++ b/integration/wildfly/pom.xml @@ -15,9 +15,7 @@ wildfly-adapter - wildfly-extensions wf8-subsystem wf9-subsystem - wf9-server-subsystem \ No newline at end of file diff --git a/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java b/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java index 3916fd16a7..dd82098242 100755 --- a/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java +++ b/model/api/src/main/java/org/keycloak/models/utils/RepresentationToModel.java @@ -996,14 +996,14 @@ public class RepresentationToModel { // Import users just to user storage. Don't federate UserModel user = session.userStorage().addUser(newRealm, userRep.getId(), userRep.getUsername(), false, false); - user.setEnabled(userRep.isEnabled()); + user.setEnabled(userRep.isEnabled() != null && userRep.isEnabled()); user.setCreatedTimestamp(userRep.getCreatedTimestamp()); user.setEmail(userRep.getEmail()); - user.setEmailVerified(userRep.isEmailVerified()); + if (userRep.isEmailVerified() != null) user.setEmailVerified(userRep.isEmailVerified()); user.setFirstName(userRep.getFirstName()); user.setLastName(userRep.getLastName()); user.setFederationLink(userRep.getFederationLink()); - user.setOtpEnabled(userRep.isTotp()); + if (userRep.isTotp() != null) user.setOtpEnabled(userRep.isTotp()); if (userRep.getAttributes() != null) { for (Map.Entry entry : userRep.getAttributes().entrySet()) { Object value = entry.getValue(); diff --git a/pom.xml b/pom.xml index c137e5904b..62ae25c7e4 100755 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ 1.2.17 1.3.1b 1.5.1 - 0.66 + 0.65.1 1.4 7.5.Final @@ -154,6 +154,7 @@ timer export-import util + wildfly @@ -827,7 +828,7 @@ org.keycloak - keycloak-as7-server-subsystem + keycloak-eap6-server-subsystem ${project.version} @@ -842,7 +843,7 @@ org.keycloak - keycloak-wf9-server-subsystem + keycloak-wildfly-server-subsystem ${project.version} @@ -945,6 +946,11 @@ keycloak-wildfly-adapter ${project.version} + + org.keycloak + keycloak-wildfly-adduser + ${project.version} + org.keycloak keycloak-wildfly-extensions diff --git a/services/src/main/java/org/keycloak/exportimport/ExportImportManager.java b/services/src/main/java/org/keycloak/exportimport/ExportImportManager.java index 89dc0970d5..cedcbddf50 100644 --- a/services/src/main/java/org/keycloak/exportimport/ExportImportManager.java +++ b/services/src/main/java/org/keycloak/exportimport/ExportImportManager.java @@ -60,7 +60,8 @@ public class ExportImportManager { // Check if master realm was exported. If it's not, then it needs to be created before other realms are imported if (!importProvider.isMasterRealmExported()) { - new ApplianceBootstrap().bootstrap(sessionFactory, contextPath); + ApplianceBootstrap.setupDefaultRealm(sessionFactory, contextPath); + ApplianceBootstrap.setupDefaultUser(sessionFactory); } importProvider.importModel(sessionFactory, strategy); @@ -69,7 +70,8 @@ public class ExportImportManager { if (!realmName.equals(Config.getAdminRealm())) { // Check if master realm exists. If it's not, then it needs to be created before other realm is imported - new ApplianceBootstrap().bootstrap(sessionFactory, contextPath); + ApplianceBootstrap.setupDefaultRealm(sessionFactory, contextPath); + ApplianceBootstrap.setupDefaultUser(sessionFactory); } importProvider.importRealm(sessionFactory, realmName, strategy); diff --git a/services/src/main/java/org/keycloak/offlineconfig/AdminRecovery.java b/services/src/main/java/org/keycloak/offlineconfig/AdminRecovery.java deleted file mode 100644 index cb775b1b5f..0000000000 --- a/services/src/main/java/org/keycloak/offlineconfig/AdminRecovery.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2015 Red Hat Inc. and/or its affiliates and other contributors - * as indicated by the @author tags. All rights reserved. - * - * 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. - */ - -package org.keycloak.offlineconfig; - -import org.jboss.logging.Logger; -import org.keycloak.Config; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.KeycloakSessionFactory; -import org.keycloak.models.RealmModel; -import org.keycloak.models.RealmProvider; -import org.keycloak.models.UserModel; -import org.keycloak.models.UserProvider; -import org.keycloak.services.managers.ApplianceBootstrap; - -/** - * Static utility class that performs recovery on the master admin account. - * - * @author Stan Silvert ssilvert@redhat.com (C) 2015 Red Hat Inc. - */ -public class AdminRecovery { - private static final Logger log = Logger.getLogger(AdminRecovery.class); - - public static final String RECOVER_ADMIN_ACCOUNT = "keycloak.recover-admin"; - public static final String TEMP_ADMIN_PASSWORD = "keycloak.temp-admin-password"; - - // Don't allow instances - private AdminRecovery() {} - - public static void recover(KeycloakSessionFactory sessionFactory) { - if (!needRecovery()) return; - - KeycloakSession session = sessionFactory.create(); - - session.getTransaction().begin(); - try { - doRecover(session, getTempAdminPassword()); - session.getTransaction().commit(); - log.info("*******************************"); - log.info("Recovered Master Admin account."); - log.info("*******************************"); - } finally { - session.close(); - System.clearProperty(RECOVER_ADMIN_ACCOUNT); - System.clearProperty(TEMP_ADMIN_PASSWORD); - } - } - - private static boolean needRecovery() { - String strNeedRecovery = System.getProperty(RECOVER_ADMIN_ACCOUNT, "false"); - return Boolean.parseBoolean(strNeedRecovery); - } - - private static String getTempAdminPassword() { - String tempAdminPassword = System.getProperty(TEMP_ADMIN_PASSWORD); - if ((tempAdminPassword == null) || tempAdminPassword.isEmpty()) { - throw new OfflineConfigException("Must provide temporary admin password to recover admin account."); - } - return tempAdminPassword; - } - - private static void doRecover(KeycloakSession session, String tempAdminPassword) { - RealmProvider realmProvider = session.realms(); - UserProvider userProvider = session.users(); - - String adminRealmName = Config.getAdminRealm(); - RealmModel realm = realmProvider.getRealmByName(adminRealmName); - UserModel adminUser = userProvider.getUserByUsername("admin", realm); - - if (adminUser == null) { - adminUser = userProvider.addUser(realm, "admin"); - } - - ApplianceBootstrap.setupAdminUser(session, realm, adminUser, tempAdminPassword); - } -} diff --git a/services/src/main/java/org/keycloak/offlineconfig/OfflineConfigException.java b/services/src/main/java/org/keycloak/offlineconfig/OfflineConfigException.java deleted file mode 100644 index 09a4a5ca6d..0000000000 --- a/services/src/main/java/org/keycloak/offlineconfig/OfflineConfigException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2015 Red Hat Inc. and/or its affiliates and other contributors - * as indicated by the @author tags. All rights reserved. - * - * 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. - */ - -package org.keycloak.offlineconfig; - -/** - * Runtime exception thrown when an offline configuration fails. Offline - * configuration is defined as any configuration done before the Keycloak Server - * starts accepting requests. - * - * @author Stan Silvert ssilvert@redhat.com (C) 2015 Red Hat Inc. - */ -public class OfflineConfigException extends IllegalStateException { - - public OfflineConfigException(String msg) { - super(msg); - } -} diff --git a/services/src/main/java/org/keycloak/services/managers/ApplianceBootstrap.java b/services/src/main/java/org/keycloak/services/managers/ApplianceBootstrap.java index 5178cec882..0fa1b92807 100755 --- a/services/src/main/java/org/keycloak/services/managers/ApplianceBootstrap.java +++ b/services/src/main/java/org/keycloak/services/managers/ApplianceBootstrap.java @@ -23,62 +23,71 @@ public class ApplianceBootstrap { private static final Logger logger = Logger.getLogger(ApplianceBootstrap.class); - public void bootstrap(KeycloakSessionFactory sessionFactory, String contextPath) { + public static boolean setupDefaultRealm(KeycloakSessionFactory sessionFactory, String contextPath) { KeycloakSession session = sessionFactory.create(); session.getTransaction().begin(); try { - bootstrap(session, contextPath); + String adminRealmName = Config.getAdminRealm(); + if (session.realms().getRealm(adminRealmName) != null) { + return false; + } + + logger.info("Initializing " + adminRealmName + " realm"); + + RealmManager manager = new RealmManager(session); + manager.setContextPath(contextPath); + RealmModel realm = manager.createRealm(adminRealmName, adminRealmName); + realm.setName(adminRealmName); + realm.setEnabled(true); + realm.addRequiredCredential(CredentialRepresentation.PASSWORD); + realm.setSsoSessionIdleTimeout(1800); + realm.setAccessTokenLifespan(60); + realm.setSsoSessionMaxLifespan(36000); + realm.setOfflineSessionIdleTimeout(Constants.DEFAULT_OFFLINE_SESSION_IDLE_TIMEOUT); + realm.setAccessCodeLifespan(60); + realm.setAccessCodeLifespanUserAction(300); + realm.setAccessCodeLifespanLogin(1800); + realm.setSslRequired(SslRequired.EXTERNAL); + realm.setRegistrationAllowed(false); + realm.setRegistrationEmailAsUsername(false); + KeycloakModelUtils.generateRealmKeys(realm); + session.getTransaction().commit(); + return true; } finally { session.close(); } } - public void bootstrap(KeycloakSession session, String contextPath) { - String adminRealmName = Config.getAdminRealm(); - if (session.realms().getRealm(adminRealmName) != null) { - return; - } + public static boolean setupDefaultUser(KeycloakSessionFactory sessionFactory) { + KeycloakSession session = sessionFactory.create(); + session.getTransaction().begin(); - logger.info("Initializing " + adminRealmName + " realm"); + try { + RealmModel realm = session.realms().getRealm(Config.getAdminRealm()); + if (session.users().getUserByUsername("admin", realm) == null) { + UserModel adminUser = session.users().addUser(realm, "admin"); - RealmManager manager = new RealmManager(session); - manager.setContextPath(contextPath); - RealmModel realm = manager.createRealm(adminRealmName, adminRealmName); - realm.setName(adminRealmName); - realm.setEnabled(true); - realm.addRequiredCredential(CredentialRepresentation.PASSWORD); - realm.setSsoSessionIdleTimeout(1800); - realm.setAccessTokenLifespan(60); - realm.setSsoSessionMaxLifespan(36000); - realm.setOfflineSessionIdleTimeout(Constants.DEFAULT_OFFLINE_SESSION_IDLE_TIMEOUT); - realm.setAccessCodeLifespan(60); - realm.setAccessCodeLifespanUserAction(300); - realm.setAccessCodeLifespanLogin(1800); - realm.setSslRequired(SslRequired.EXTERNAL); - realm.setRegistrationAllowed(false); - realm.setRegistrationEmailAsUsername(false); - KeycloakModelUtils.generateRealmKeys(realm); + adminUser.setEnabled(true); + UserCredentialModel usrCredModel = new UserCredentialModel(); + usrCredModel.setType(UserCredentialModel.PASSWORD); + usrCredModel.setValue("admin"); + session.users().updateCredential(realm, adminUser, usrCredModel); + adminUser.addRequiredAction(UserModel.RequiredAction.UPDATE_PASSWORD); - UserModel adminUser = session.users().addUser(realm, "admin"); - setupAdminUser(session, realm, adminUser, "admin"); - } + RoleModel adminRole = realm.getRole(AdminRoles.ADMIN); + adminUser.grantRole(adminRole); - public static void setupAdminUser(KeycloakSession session, RealmModel realm, UserModel adminUser, String password) { - adminUser.setEnabled(true); - UserCredentialModel usrCredModel = new UserCredentialModel(); - usrCredModel.setType(UserCredentialModel.PASSWORD); - usrCredModel.setValue(password); - session.users().updateCredential(realm, adminUser, usrCredModel); - adminUser.addRequiredAction(UserModel.RequiredAction.UPDATE_PASSWORD); - - RoleModel adminRole = realm.getRole(AdminRoles.ADMIN); - adminUser.grantRole(adminRole); - - ClientModel accountApp = realm.getClientNameMap().get(Constants.ACCOUNT_MANAGEMENT_CLIENT_ID); - for (String r : accountApp.getDefaultRoles()) { - adminUser.grantRole(accountApp.getRole(r)); + ClientModel accountApp = realm.getClientNameMap().get(Constants.ACCOUNT_MANAGEMENT_CLIENT_ID); + for (String r : accountApp.getDefaultRoles()) { + adminUser.grantRole(accountApp.getRole(r)); + } + } + session.getTransaction().commit(); + return true; + } finally { + session.close(); } } 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 a07999d6c1..125b6eeec6 100755 --- a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java +++ b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java @@ -2,6 +2,7 @@ package org.keycloak.services.resources; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; +import org.codehaus.jackson.type.TypeReference; import org.jboss.logging.Logger; import org.jboss.resteasy.core.Dispatcher; import org.jboss.resteasy.spi.ResteasyProviderFactory; @@ -11,9 +12,11 @@ import org.keycloak.migration.MigrationModelManager; import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSessionFactory; import org.keycloak.models.RealmModel; +import org.keycloak.models.UserModel; import org.keycloak.models.utils.PostMigrationEvent; -import org.keycloak.offlineconfig.AdminRecovery; +import org.keycloak.models.utils.RepresentationToModel; import org.keycloak.representations.idm.RealmRepresentation; +import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.services.DefaultKeycloakSessionFactory; import org.keycloak.services.managers.ApplianceBootstrap; import org.keycloak.services.managers.BruteForceProtector; @@ -36,10 +39,7 @@ import javax.ws.rs.core.UriInfo; import java.io.*; import java.net.URI; import java.net.URL; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; -import java.util.StringTokenizer; +import java.util.*; /** * @author Bill Burke @@ -81,7 +81,7 @@ public class KeycloakApplication extends Application { singletons.add(new ObjectMapperResolver(Boolean.parseBoolean(System.getProperty("keycloak.jsonPrettyPrint", "false")))); - setupDefaultRealm(context.getContextPath()); + boolean defaultRealmCreated = ApplianceBootstrap.setupDefaultRealm(sessionFactory, context.getContextPath()); migrateModel(); sessionFactory.publish(new PostMigrationEvent()); @@ -89,7 +89,11 @@ public class KeycloakApplication extends Application { new ExportImportManager().checkExportImport(this.sessionFactory, context.getContextPath()); importRealms(context); - AdminRecovery.recover(sessionFactory); + importAddUser(); + + if (defaultRealmCreated) { + ApplianceBootstrap.setupDefaultUser(sessionFactory); + } setupScheduledTasks(sessionFactory); } @@ -153,10 +157,6 @@ public class KeycloakApplication extends Application { } } - protected void setupDefaultRealm(String contextPath) { - new ApplianceBootstrap().bootstrap(sessionFactory, contextPath); - } - public static KeycloakSessionFactory createSessionFactory() { DefaultKeycloakSessionFactory factory = new DefaultKeycloakSessionFactory(); factory.init(); @@ -254,6 +254,44 @@ public class KeycloakApplication extends Application { } } + public void importAddUser() { + String configDir = System.getProperty("jboss.server.config.dir"); + if (configDir != null) { + File addUserFile = new File(configDir + File.separator + "keycloak-add-user.json"); + if (addUserFile.isFile()) { + log.info("Importing users from '" + addUserFile + "'"); + + KeycloakSession session = sessionFactory.create(); + try { + session.getTransaction().begin(); + + List realms = JsonSerialization.readValue(new FileInputStream(addUserFile), new TypeReference>() {}); + for (RealmRepresentation r : realms) { + RealmModel realm = session.realms().getRealmByName(r.getRealm()); + if (realm == null) { + throw new Exception("Realm '" + r.getRealm() + "' not found"); + } + + for (UserRepresentation u : r.getUsers()) { + RepresentationToModel.createUser(session, realm, u, realm.getClientNameMap()); + } + } + + session.getTransaction().commit(); + + if (!addUserFile.delete()) { + log.error("Failed to delete '" + addUserFile + "'"); + } + } catch (Throwable t) { + session.getTransaction().rollback(); + log.error("Failed to import users from '" + addUserFile + "'", t); + } finally { + session.close(); + } + } + } + } + private static T loadJson(InputStream is, Class type) { try { return JsonSerialization.readValue(is, type); diff --git a/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java b/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java index a85c9d2bfd..202861049b 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/UsersResource.java @@ -148,7 +148,7 @@ public class UsersResource { attrsToRemove = Collections.emptySet(); } - if (rep.isEnabled()) { + if (rep.isEnabled() != null && rep.isEnabled()) { UsernameLoginFailureModel failureModel = session.sessions().getUserLoginFailure(realm, rep.getUsername()); if (failureModel != null) { failureModel.clearFailures(); @@ -219,9 +219,9 @@ public class UsersResource { user.setFirstName(rep.getFirstName()); user.setLastName(rep.getLastName()); - user.setEnabled(rep.isEnabled()); - user.setOtpEnabled(rep.isTotp()); - user.setEmailVerified(rep.isEmailVerified()); + if (rep.isEnabled() != null) user.setEnabled(rep.isEnabled()); + if (rep.isTotp() != null) user.setOtpEnabled(rep.isTotp()); + if (rep.isEmailVerified() != null) user.setEmailVerified(rep.isEmailVerified()); List reqActions = rep.getRequiredActions(); @@ -708,7 +708,7 @@ public class UsersResource { } catch (ModelReadOnlyException mre) { throw new BadRequestException("Can't reset password as account is read only"); } - if (pass.isTemporary()) user.addRequiredAction(UserModel.RequiredAction.UPDATE_PASSWORD); + if (pass.isTemporary() != null && pass.isTemporary()) user.addRequiredAction(UserModel.RequiredAction.UPDATE_PASSWORD); adminEvent.operation(OperationType.ACTION).resourcePath(uriInfo).success(); } diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/users/UserAttributesForm.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/users/UserAttributesForm.java index 85b32e6b4c..e508e712d1 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/users/UserAttributesForm.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/users/UserAttributesForm.java @@ -130,8 +130,8 @@ public class UserAttributesForm extends Form { setEmail(user.getEmail()); setFirstName(user.getFirstName()); setLastName(user.getLastName()); - setEnabled(user.isEnabled()); - setEmailVerified(user.isEmailVerified()); + if (user.isEnabled() != null) setEnabled(user.isEnabled()); + if (user.isEmailVerified() != null) setEmailVerified(user.isEmailVerified()); setRequiredActions(user.getRequiredActions()); } diff --git a/testsuite/integration/pom.xml b/testsuite/integration/pom.xml index a14a006b78..2865040b35 100755 --- a/testsuite/integration/pom.xml +++ b/testsuite/integration/pom.xml @@ -31,6 +31,10 @@ org.keycloak keycloak-admin-client + + org.keycloak + keycloak-wildfly-adduser + log4j log4j diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/adduser/AddUserTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/adduser/AddUserTest.java new file mode 100644 index 0000000000..c3f68dbb8c --- /dev/null +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/adduser/AddUserTest.java @@ -0,0 +1,64 @@ +package org.keycloak.testsuite.adduser; + +import org.junit.*; +import org.junit.rules.TemporaryFolder; +import org.keycloak.admin.client.Keycloak; +import org.keycloak.models.Constants; +import org.keycloak.representations.idm.RealmRepresentation; +import org.keycloak.testsuite.KeycloakServer; +import org.keycloak.wildfly.adduser.AddUser; + +import java.io.File; +import java.io.IOException; + +/** + * @author Stian Thorgersen + */ +public class AddUserTest { + + @Rule + public TemporaryFolder folder = new TemporaryFolder(); + + private File dir; + + @Before + public void before() throws IOException { + dir = folder.newFolder(); + System.setProperty("jboss.server.config.user.dir", dir.getAbsolutePath()); + System.setProperty("jboss.server.config.dir", dir.getAbsolutePath()); + } + + @After + public void after() { + System.getProperties().remove("jboss.server.config.user.dir"); + System.getProperties().remove("jboss.server.config.dir"); + } + + @Test + public void addUserTest() throws Throwable { + AddUser.main(new String[]{"-u", "addusertest-admin", "-p", "password"}); + Assert.assertEquals(1, dir.listFiles().length); + + KeycloakServer server = new KeycloakServer(); + try { + server.start(); + + Keycloak keycloak = Keycloak.getInstance("http://localhost:8081/auth", "master", "addusertest-admin", "password", Constants.ADMIN_CONSOLE_CLIENT_ID); + keycloak.realms().findAll(); + + RealmRepresentation testRealm = new RealmRepresentation(); + testRealm.setEnabled(true); + testRealm.setId("test"); + testRealm.setRealm("test"); + + keycloak.realms().create(testRealm); + + keycloak.close(); + + Assert.assertEquals(0, dir.listFiles().length); + } finally { + server.stop(); + } + } + +} diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/offlineconfig/AdminRecoveryTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/offlineconfig/AdminRecoveryTest.java deleted file mode 100644 index 506a154a69..0000000000 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/offlineconfig/AdminRecoveryTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2015 Red Hat Inc. and/or its affiliates and other contributors - * as indicated by the @author tags. All rights reserved. - * - * 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. - */ - -package org.keycloak.testsuite.offlineconfig; - -import org.junit.After; -import org.junit.Assert; -import org.junit.ClassRule; -import org.junit.Rule; -import org.junit.Test; -import org.keycloak.models.KeycloakSession; -import org.keycloak.models.RealmModel; -import org.keycloak.models.UserCredentialModel; -import org.keycloak.models.UserCredentialValueModel; -import org.keycloak.models.UserModel; -import org.keycloak.models.UserModel.RequiredAction; -import org.keycloak.offlineconfig.AdminRecovery; -import org.keycloak.offlineconfig.OfflineConfigException; -import org.keycloak.services.managers.RealmManager; -import org.keycloak.testsuite.rule.KeycloakRule; -import org.keycloak.testsuite.rule.WebRule; - -/** - * Test the AdminRecovery class. - * - * @author Stan Silvert ssilvert@redhat.com (C) 2015 Red Hat Inc. - */ -public class AdminRecoveryTest { - @ClassRule - public static KeycloakRule keycloakRule = new KeycloakRule() { - - @Override - protected void after() { - - // Need to reset admin user to default password and remove required action to not break next tests - update(new KeycloakSetup() { - - @Override - public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) { - UserModel adminUser = session.users().getUserByUsername("admin", adminstrationRealm); - UserCredentialModel password = UserCredentialModel.password("admin"); - adminUser.updateCredential(password); - - adminUser.removeRequiredAction(UserModel.RequiredAction.UPDATE_PASSWORD); - } - }); - - super.after(); - } - }; - - @Rule - public WebRule webRule = new WebRule(this); - - // Verifies that system properties were cleared at the end of recovery - @After - public void verifySysPropsCleared() { - Assert.assertNull(System.getProperty(AdminRecovery.RECOVER_ADMIN_ACCOUNT)); - Assert.assertNull(System.getProperty(AdminRecovery.TEMP_ADMIN_PASSWORD)); - } - - @Test - public void testAdminDeletedRecovery() { - KeycloakSession session = keycloakRule.startSession(); - RealmModel masterRealm = session.realms().getRealmByName("master"); - UserModel adminUser = session.users().getUserByUsername("admin", masterRealm); - session.users().removeUser(masterRealm, adminUser); - adminUser = session.users().getUserByUsername("admin", masterRealm); - keycloakRule.stopSession(session, true); - - Assert.assertNull(adminUser); - - doAdminRecovery(session); - - session = keycloakRule.startSession(); - adminUser = session.users().getUserByUsername("admin", masterRealm); - Assert.assertNotNull(adminUser); - Assert.assertTrue(adminUser.getRequiredActions().contains(RequiredAction.UPDATE_PASSWORD.toString())); - } - - @Test - public void testAdminPasswordRecovery() { - KeycloakSession session = keycloakRule.startSession(); - RealmModel masterRealm = session.realms().getRealmByName("master"); - UserModel adminUser = session.users().getUserByUsername("admin", masterRealm); - UserCredentialValueModel password = adminUser.getCredentialsDirectly().get(0); - password.setValue("forgotten-password"); - adminUser.updateCredentialDirectly(password); - keycloakRule.stopSession(session, true); - - Assert.assertEquals("forgotten-password", getAdminPassword()); - - doAdminRecovery(session); - - Assert.assertNotEquals("forgotten-password", getAdminPassword()); - } - - @Test(expected = OfflineConfigException.class) - public void testAdminRecoveryWithoutPassword() { - KeycloakSession session = keycloakRule.startSession(); - System.setProperty(AdminRecovery.RECOVER_ADMIN_ACCOUNT, "true"); - AdminRecovery.recover(session.getKeycloakSessionFactory()); - } - - private void doAdminRecovery(KeycloakSession session) { - System.setProperty(AdminRecovery.RECOVER_ADMIN_ACCOUNT, "true"); - System.setProperty(AdminRecovery.TEMP_ADMIN_PASSWORD, "foo"); - AdminRecovery.recover(session.getKeycloakSessionFactory()); - } - - private String getAdminPassword() { - KeycloakSession session = keycloakRule.startSession(); - RealmModel masterRealm = session.realms().getRealmByName("master"); - UserModel adminUser = session.users().getUserByUsername("admin", masterRealm); - UserCredentialValueModel password = adminUser.getCredentialsDirectly().get(0); - keycloakRule.stopSession(session, true); - return password.getValue(); - } -} diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/rule/KeycloakRule.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/rule/KeycloakRule.java index 74df6c814f..8fc4cd6fab 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/rule/KeycloakRule.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/rule/KeycloakRule.java @@ -22,6 +22,8 @@ package org.keycloak.testsuite.rule; import org.junit.Assert; +import org.junit.Rule; +import org.junit.rules.TemporaryFolder; import org.keycloak.Config; import org.keycloak.models.KeycloakSession; import org.keycloak.models.RealmModel; diff --git a/wildfly/adduser/pom.xml b/wildfly/adduser/pom.xml new file mode 100755 index 0000000000..8a2bc8bb1c --- /dev/null +++ b/wildfly/adduser/pom.xml @@ -0,0 +1,54 @@ + + + + 4.0.0 + + + org.keycloak + keycloak-wildfly-parent + 1.7.0.Final-SNAPSHOT + + + keycloak-wildfly-adduser + Keycloak WildFly Add User Script + + jar + + + + org.keycloak + keycloak-model-api + + + org.keycloak + keycloak-common + + + org.keycloak + keycloak-core + + + org.wildfly.core + wildfly-domain-management + ${wildfly.core.version} + + + org.jboss.aesh + aesh + + + diff --git a/wildfly/adduser/src/main/java/org/keycloak/wildfly/adduser/AddUser.java b/wildfly/adduser/src/main/java/org/keycloak/wildfly/adduser/AddUser.java new file mode 100644 index 0000000000..7be53c6473 --- /dev/null +++ b/wildfly/adduser/src/main/java/org/keycloak/wildfly/adduser/AddUser.java @@ -0,0 +1,292 @@ +package org.keycloak.wildfly.adduser; + +import org.codehaus.jackson.type.TypeReference; +import org.jboss.aesh.cl.CommandDefinition; +import org.jboss.aesh.cl.Option; +import org.jboss.aesh.cl.parser.ParserGenerator; +import org.jboss.aesh.console.command.Command; +import org.jboss.aesh.console.command.CommandNotFoundException; +import org.jboss.aesh.console.command.CommandResult; +import org.jboss.aesh.console.command.container.CommandContainer; +import org.jboss.aesh.console.command.invocation.CommandInvocation; +import org.jboss.aesh.console.command.registry.AeshCommandRegistryBuilder; +import org.jboss.aesh.console.command.registry.CommandRegistry; +import org.keycloak.common.util.Base64; +import org.keycloak.models.Constants; +import org.keycloak.models.utils.Pbkdf2PasswordEncoder; +import org.keycloak.representations.idm.CredentialRepresentation; +import org.keycloak.representations.idm.RealmRepresentation; +import org.keycloak.representations.idm.UserRepresentation; +import org.keycloak.util.JsonSerialization; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; + +/** + * @author Stian Thorgersen + */ +public class AddUser { + + private static final String COMMAND_NAME = "add-user"; + private static final int DEFAULT_HASH_ITERATIONS = 100000; + + public static void main(String[] args) throws Exception { + AddUserCommand command = new AddUserCommand(); + try { + ParserGenerator.parseAndPopulate(command, COMMAND_NAME, args); + } catch (Exception e) { + System.err.println(e.getMessage()); + System.exit(1); + } + + if (command.isContainer()) { + List l = new LinkedList<>(Arrays.asList(args)); + l.remove("--container"); + args = l.toArray(new String[l.size()]); + + org.jboss.as.domain.management.security.adduser.AddUser.main(args); + } else if (command.isHelp()) { + printHelp(command); + } else { + try { + checkRequired(command, "user"); + checkRequired(command, "password"); + + File addUserFile = getAddUserFile(command); + + createUser(addUserFile, command.getRealm(), command.getUser(), command.getPassword(), command.getRoles(), command.getIterations()); + } catch (Exception e) { + System.err.println(e.getMessage()); + System.exit(1); + } + } + } + + private static File getAddUserFile(AddUserCommand command) throws Exception { + File configDir; + if (command.isDomain()) { + if (command.getDc() != null) { + configDir = new File(command.getDc()); + } else if (System.getProperty("jboss.domain.config.user.dir") != null) { + configDir = new File(System.getProperty("jboss.domain.config.user.dir")); + } else if (System.getenv("JBOSS_HOME") != null) { + configDir = new File(System.getenv("JBOSS_HOME") + File.separator + "domain" + File.separator + "configuration"); + } else { + throw new Exception("Could not find domain configuration directory"); + } + } else { + if (command.getSc() != null) { + configDir = new File(command.getSc()); + } else if (System.getProperty("jboss.server.config.user.dir") != null) { + configDir = new File(System.getProperty("jboss.server.config.user.dir")); + } else if (System.getenv("JBOSS_HOME") != null) { + configDir = new File(System.getenv("JBOSS_HOME") + File.separator + "standalone" + File.separator + "configuration"); + } else { + throw new Exception("Could not find standalone configuration directory"); + } + } + + if (!configDir.isDirectory()) { + throw new Exception("'" + configDir + "' does not exist or is not a directory"); + } + + File addUserFile = new File(configDir, "keycloak-add-user.json"); + return addUserFile; + } + + private static void createUser(File addUserFile, String realmName, String userName, String password, String rolesString, int iterations) throws Exception { + List realms; + if (addUserFile.isFile()) { + realms = JsonSerialization.readValue(new FileInputStream(addUserFile), new TypeReference>() {}); + } else { + realms = new LinkedList<>(); + } + + if (realmName == null) { + realmName = "master"; + } + + RealmRepresentation realm = null; + for (RealmRepresentation r : realms) { + if (r.getRealm().equals(realmName)) { + realm = r; + } + } + + if (realm == null) { + realm = new RealmRepresentation(); + realm.setRealm(realmName); + realms.add(realm); + realm.setUsers(new LinkedList()); + } + + for (UserRepresentation u : realm.getUsers()) { + if (u.getUsername().equals(userName)) { + throw new Exception("User with username '" + userName + "' already added to '" + addUserFile + "'"); + } + } + + UserRepresentation user = new UserRepresentation(); + user.setEnabled(true); + user.setUsername(userName); + user.setCredentials(new LinkedList()); + + byte[] salt = Pbkdf2PasswordEncoder.getSalt(); + iterations = iterations > 0 ? iterations : DEFAULT_HASH_ITERATIONS; + + CredentialRepresentation credentials = new CredentialRepresentation(); + credentials.setType(CredentialRepresentation.PASSWORD); + credentials.setHashIterations(iterations); + credentials.setSalt(Base64.encodeBytes(salt)); + credentials.setHashedSaltedValue(new Pbkdf2PasswordEncoder(salt).encode(password, iterations)); + + user.getCredentials().add(credentials); + + String[] roles; + if (rolesString != null) { + roles = rolesString.split(","); + } else { + if (realmName.equals("master")) { + roles = new String[] { "admin" }; + } else { + roles = new String[] { "realm-management/realm-admin" }; + } + } + + for (String r : roles) { + if (r.indexOf('/') != -1) { + String[] cr = r.split("/"); + String client = cr[0]; + String clientRole = cr[1]; + + if (user.getClientRoles() == null) { + user.setClientRoles(new HashMap>()); + } + + if (user.getClientRoles().get(client) == null) { + user.getClientRoles().put(client, new LinkedList()); + } + + user.getClientRoles().get(client).add(clientRole); + } else { + if (user.getRealmRoles() == null) { + user.setRealmRoles(new LinkedList()); + } + user.getRealmRoles().add(r); + } + } + + realm.getUsers().add(user); + + JsonSerialization.writeValuePrettyToStream(new FileOutputStream(addUserFile), realms); + System.out.println("Added '" + userName + "' to '" + addUserFile + "', restart server to load user"); + } + + private static void checkRequired(Command command, String field) throws Exception { + Method m = command.getClass().getMethod("get" + Character.toUpperCase(field.charAt(0)) + field.substring(1)); + if (m.invoke(command) == null) { + Option option = command.getClass().getDeclaredField(field).getAnnotation(Option.class); + String optionName; + if (option != null && option.shortName() != '\u0000') { + optionName = "-" + option.shortName() + ", --" + field; + } else { + optionName = "--" + field; + } + throw new Exception("Option: " + optionName + " is required"); + } + } + + private static void printHelp(Command command) throws CommandNotFoundException { + CommandRegistry registry = new AeshCommandRegistryBuilder().command(command).create(); + CommandContainer commandContainer = registry.getCommand(command.getClass().getAnnotation(CommandDefinition.class).name(), null); + String help = commandContainer.printHelp(null); + System.out.println(help); + } + + @CommandDefinition(name= COMMAND_NAME, description = "[options...]") + public static class AddUserCommand implements Command { + + @Option(shortName = 'r', hasValue = true, description = "Name of realm to add user to") + private String realm; + + @Option(shortName = 'u', hasValue = true, description = "Name of the user") + private String user; + + @Option(shortName = 'p', hasValue = true, description = "Password of the user") + private String password; + + @Option(hasValue = true, description = "Roles to add to the user") + private String roles; + + @Option(hasValue = true, description = "Hash iterations") + private int iterations; + + @Option(hasValue = false, description = "Enable domain mode") + private boolean domain; + + @Option(hasValue = false, description = "Add user to underlying container. For usage use '--container --help'") + private boolean container; + + @Option(hasValue = true, description = "Define the location of the server config directory") + private String sc; + + @Option(hasValue = true, description = "Define the location of the domain config directory") + private String dc; + + @Option(shortName = 'h', hasValue = false, description = "Display this help and exit") + private boolean help; + + @Override + public CommandResult execute(CommandInvocation commandInvocation) throws IOException, InterruptedException { + return CommandResult.SUCCESS; + } + + public String getRealm() { + return realm; + } + + public String getUser() { + return user; + } + + public String getPassword() { + return password; + } + + public String getRoles() { + return roles; + } + + public int getIterations() { + return iterations; + } + + public boolean isDomain() { + return domain; + } + + public boolean isContainer() { + return container; + } + + public String getSc() { + return sc; + } + + public String getDc() { + return dc; + } + + public boolean isHelp() { + return help; + } + } + +} \ No newline at end of file diff --git a/integration/wildfly/wildfly-extensions/pom.xml b/wildfly/extensions/pom.xml similarity index 95% rename from integration/wildfly/wildfly-extensions/pom.xml rename to wildfly/extensions/pom.xml index 997feebcd0..82730408c4 100755 --- a/integration/wildfly/wildfly-extensions/pom.xml +++ b/wildfly/extensions/pom.xml @@ -19,9 +19,8 @@ org.keycloak - keycloak-parent + keycloak-wildfly-parent 1.7.0.Final-SNAPSHOT - ../../../pom.xml keycloak-wildfly-extensions diff --git a/integration/wildfly/wildfly-extensions/src/main/java/org/keycloak/provider/wildfly/ModuleProviderLoaderFactory.java b/wildfly/extensions/src/main/java/org/keycloak/provider/wildfly/ModuleProviderLoaderFactory.java similarity index 100% rename from integration/wildfly/wildfly-extensions/src/main/java/org/keycloak/provider/wildfly/ModuleProviderLoaderFactory.java rename to wildfly/extensions/src/main/java/org/keycloak/provider/wildfly/ModuleProviderLoaderFactory.java diff --git a/integration/wildfly/wildfly-extensions/src/main/java/org/keycloak/provider/wildfly/ModuleThemeProviderFactory.java b/wildfly/extensions/src/main/java/org/keycloak/provider/wildfly/ModuleThemeProviderFactory.java similarity index 100% rename from integration/wildfly/wildfly-extensions/src/main/java/org/keycloak/provider/wildfly/ModuleThemeProviderFactory.java rename to wildfly/extensions/src/main/java/org/keycloak/provider/wildfly/ModuleThemeProviderFactory.java diff --git a/integration/wildfly/wildfly-extensions/src/main/resources/META-INF/services/org.keycloak.freemarker.ThemeProviderFactory b/wildfly/extensions/src/main/resources/META-INF/services/org.keycloak.freemarker.ThemeProviderFactory similarity index 100% rename from integration/wildfly/wildfly-extensions/src/main/resources/META-INF/services/org.keycloak.freemarker.ThemeProviderFactory rename to wildfly/extensions/src/main/resources/META-INF/services/org.keycloak.freemarker.ThemeProviderFactory diff --git a/integration/wildfly/wildfly-extensions/src/main/resources/META-INF/services/org.keycloak.provider.ProviderLoaderFactory b/wildfly/extensions/src/main/resources/META-INF/services/org.keycloak.provider.ProviderLoaderFactory similarity index 100% rename from integration/wildfly/wildfly-extensions/src/main/resources/META-INF/services/org.keycloak.provider.ProviderLoaderFactory rename to wildfly/extensions/src/main/resources/META-INF/services/org.keycloak.provider.ProviderLoaderFactory diff --git a/wildfly/pom.xml b/wildfly/pom.xml new file mode 100755 index 0000000000..0d24ee8d06 --- /dev/null +++ b/wildfly/pom.xml @@ -0,0 +1,22 @@ + + + keycloak-parent + org.keycloak + 1.7.0.Final-SNAPSHOT + + + Keycloak WildFly Integration + + 4.0.0 + + keycloak-wildfly-parent + pom + + + adduser + extensions + server-subsystem + server-eap6-subsystem + + diff --git a/integration/as7-eap6/as7-server-subsystem/pom.xml b/wildfly/server-eap6-subsystem/pom.xml similarity index 94% rename from integration/as7-eap6/as7-server-subsystem/pom.xml rename to wildfly/server-eap6-subsystem/pom.xml index 4ef9d5d7cc..a8f2e51f33 100755 --- a/integration/as7-eap6/as7-server-subsystem/pom.xml +++ b/wildfly/server-eap6-subsystem/pom.xml @@ -19,13 +19,12 @@ org.keycloak - keycloak-parent + keycloak-wildfly-parent 1.7.0.Final-SNAPSHOT - ../../../pom.xml - keycloak-as7-server-subsystem - Keycloak AS7 / EAP 6 Server Subsystem + keycloak-eap6-server-subsystem + Keycloak EAP 6 Server Subsystem jar diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakAdapterConfigService.java b/wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakAdapterConfigService.java similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakAdapterConfigService.java rename to wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakAdapterConfigService.java diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakExtension.java b/wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakExtension.java similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakExtension.java rename to wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakExtension.java diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakServerDeploymentProcessor.java b/wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakServerDeploymentProcessor.java similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakServerDeploymentProcessor.java rename to wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakServerDeploymentProcessor.java diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemAdd.java b/wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemAdd.java similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemAdd.java rename to wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemAdd.java diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemDefinition.java b/wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemDefinition.java similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemDefinition.java rename to wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemDefinition.java diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemParser.java b/wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemParser.java similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemParser.java rename to wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemParser.java diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemRemoveHandler.java b/wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemRemoveHandler.java similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemRemoveHandler.java rename to wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemRemoveHandler.java diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemWriteAttributeHandler.java b/wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemWriteAttributeHandler.java similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemWriteAttributeHandler.java rename to wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/KeycloakSubsystemWriteAttributeHandler.java diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/ServerUtil.java b/wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/ServerUtil.java similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/as7/ServerUtil.java rename to wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/as7/ServerUtil.java diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakLogger.java b/wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakLogger.java similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakLogger.java rename to wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakLogger.java diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakMessages.java b/wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakMessages.java similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakMessages.java rename to wildfly/server-eap6-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakMessages.java diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension b/wildfly/server-eap6-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension rename to wildfly/server-eap6-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/resources/org/keycloak/subsystem/server/as7/LocalDescriptions.properties b/wildfly/server-eap6-subsystem/src/main/resources/org/keycloak/subsystem/server/as7/LocalDescriptions.properties similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/resources/org/keycloak/subsystem/server/as7/LocalDescriptions.properties rename to wildfly/server-eap6-subsystem/src/main/resources/org/keycloak/subsystem/server/as7/LocalDescriptions.properties diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/resources/schema/wildfly-keycloak-server_1_1.xsd b/wildfly/server-eap6-subsystem/src/main/resources/schema/wildfly-keycloak-server_1_1.xsd similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/resources/schema/wildfly-keycloak-server_1_1.xsd rename to wildfly/server-eap6-subsystem/src/main/resources/schema/wildfly-keycloak-server_1_1.xsd diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/resources/subsystem-templates/keycloak-datasources.xml b/wildfly/server-eap6-subsystem/src/main/resources/subsystem-templates/keycloak-datasources.xml similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/resources/subsystem-templates/keycloak-datasources.xml rename to wildfly/server-eap6-subsystem/src/main/resources/subsystem-templates/keycloak-datasources.xml diff --git a/integration/as7-eap6/as7-server-subsystem/src/main/resources/subsystem-templates/keycloak-server.xml b/wildfly/server-eap6-subsystem/src/main/resources/subsystem-templates/keycloak-server.xml similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/main/resources/subsystem-templates/keycloak-server.xml rename to wildfly/server-eap6-subsystem/src/main/resources/subsystem-templates/keycloak-server.xml diff --git a/integration/as7-eap6/as7-server-subsystem/src/test/resources/org/keycloak/subsystem/server/extension/keycloak-server-1.1.xml b/wildfly/server-eap6-subsystem/src/test/resources/org/keycloak/subsystem/server/extension/keycloak-server-1.1.xml similarity index 100% rename from integration/as7-eap6/as7-server-subsystem/src/test/resources/org/keycloak/subsystem/server/extension/keycloak-server-1.1.xml rename to wildfly/server-eap6-subsystem/src/test/resources/org/keycloak/subsystem/server/extension/keycloak-server-1.1.xml diff --git a/integration/wildfly/wf9-server-subsystem/pom.xml b/wildfly/server-subsystem/pom.xml similarity index 89% rename from integration/wildfly/wf9-server-subsystem/pom.xml rename to wildfly/server-subsystem/pom.xml index 7d59fc14cb..5aa082e4da 100755 --- a/integration/wildfly/wf9-server-subsystem/pom.xml +++ b/wildfly/server-subsystem/pom.xml @@ -19,13 +19,12 @@ org.keycloak - keycloak-parent + keycloak-wildfly-parent 1.7.0.Final-SNAPSHOT - ../../../pom.xml - keycloak-wf9-server-subsystem - Keycloak Wildfly 9 Server Subsystem + keycloak-wildfly-server-subsystem + Keycloak WildFly Server Subsystem jar @@ -96,11 +95,5 @@ junit test - - - org.keycloak - keycloak-wildfly-adapter - ${project.version} - diff --git a/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakAdapterConfigService.java b/wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakAdapterConfigService.java similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakAdapterConfigService.java rename to wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakAdapterConfigService.java diff --git a/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakExtension.java b/wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakExtension.java similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakExtension.java rename to wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakExtension.java diff --git a/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakServerDeploymentProcessor.java b/wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakServerDeploymentProcessor.java similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakServerDeploymentProcessor.java rename to wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakServerDeploymentProcessor.java diff --git a/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemAdd.java b/wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemAdd.java similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemAdd.java rename to wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemAdd.java diff --git a/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemDefinition.java b/wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemDefinition.java similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemDefinition.java rename to wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemDefinition.java diff --git a/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemParser.java b/wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemParser.java similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemParser.java rename to wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemParser.java diff --git a/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemRemoveHandler.java b/wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemRemoveHandler.java similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemRemoveHandler.java rename to wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemRemoveHandler.java diff --git a/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemWriteAttributeHandler.java b/wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemWriteAttributeHandler.java similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemWriteAttributeHandler.java rename to wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/KeycloakSubsystemWriteAttributeHandler.java diff --git a/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/ServerUtil.java b/wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/ServerUtil.java similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/ServerUtil.java rename to wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/extension/ServerUtil.java diff --git a/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakLogger.java b/wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakLogger.java similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakLogger.java rename to wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakLogger.java diff --git a/integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakMessages.java b/wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakMessages.java similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakMessages.java rename to wildfly/server-subsystem/src/main/java/org/keycloak/subsystem/server/logging/KeycloakMessages.java diff --git a/integration/wildfly/wf9-server-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension b/wildfly/server-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension rename to wildfly/server-subsystem/src/main/resources/META-INF/services/org.jboss.as.controller.Extension diff --git a/integration/wildfly/wf9-server-subsystem/src/main/resources/org/keycloak/subsystem/server/extension/LocalDescriptions.properties b/wildfly/server-subsystem/src/main/resources/org/keycloak/subsystem/server/extension/LocalDescriptions.properties similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/resources/org/keycloak/subsystem/server/extension/LocalDescriptions.properties rename to wildfly/server-subsystem/src/main/resources/org/keycloak/subsystem/server/extension/LocalDescriptions.properties diff --git a/integration/wildfly/wf9-server-subsystem/src/main/resources/schema/wildfly-keycloak-server_1_1.xsd b/wildfly/server-subsystem/src/main/resources/schema/wildfly-keycloak-server_1_1.xsd similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/resources/schema/wildfly-keycloak-server_1_1.xsd rename to wildfly/server-subsystem/src/main/resources/schema/wildfly-keycloak-server_1_1.xsd diff --git a/integration/wildfly/wf9-server-subsystem/src/main/resources/subsystem-templates/keycloak-datasources.xml b/wildfly/server-subsystem/src/main/resources/subsystem-templates/keycloak-datasources.xml similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/resources/subsystem-templates/keycloak-datasources.xml rename to wildfly/server-subsystem/src/main/resources/subsystem-templates/keycloak-datasources.xml diff --git a/integration/wildfly/wf9-server-subsystem/src/main/resources/subsystem-templates/keycloak-infinispan.xml b/wildfly/server-subsystem/src/main/resources/subsystem-templates/keycloak-infinispan.xml similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/resources/subsystem-templates/keycloak-infinispan.xml rename to wildfly/server-subsystem/src/main/resources/subsystem-templates/keycloak-infinispan.xml diff --git a/integration/wildfly/wf9-server-subsystem/src/main/resources/subsystem-templates/keycloak-server.xml b/wildfly/server-subsystem/src/main/resources/subsystem-templates/keycloak-server.xml similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/main/resources/subsystem-templates/keycloak-server.xml rename to wildfly/server-subsystem/src/main/resources/subsystem-templates/keycloak-server.xml diff --git a/integration/wildfly/wf9-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 similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/test/java/org/keycloak/subsystem/server/extension/SubsystemParsingTestCase.java rename to wildfly/server-subsystem/src/test/java/org/keycloak/subsystem/server/extension/SubsystemParsingTestCase.java diff --git a/integration/wildfly/wf9-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 similarity index 100% rename from integration/wildfly/wf9-server-subsystem/src/test/resources/org/keycloak/subsystem/server/extension/keycloak-server-1.1.xml rename to wildfly/server-subsystem/src/test/resources/org/keycloak/subsystem/server/extension/keycloak-server-1.1.xml