Merge pull request #145 from patriot1burke/master

wildfly deployment structure.xml
This commit is contained in:
Bill Burke 2014-01-02 13:35:14 -08:00
commit d8ef13c133
11 changed files with 53 additions and 26 deletions

View file

@ -1,12 +1,11 @@
package org.keycloak.example.demo;
import org.keycloak.util.JsonSerialization;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.services.managers.ApplianceBootstrap;
import org.keycloak.services.managers.RealmManager;
import org.keycloak.services.resources.KeycloakApplication;
import org.keycloak.util.JsonSerialization;
import javax.servlet.ServletContext;
import javax.ws.rs.core.Context;
@ -22,8 +21,6 @@ public class DemoApplication extends KeycloakApplication {
super(servletContext);
KeycloakSession session = factory.createSession();
session.getTransaction().begin();
ApplianceBootstrap bootstrap = new ApplianceBootstrap();
bootstrap.bootstrap(session);
install(new RealmManager(session));
session.getTransaction().commit();
}

View file

@ -1,12 +1,11 @@
package org.keycloak.example.demo;
import org.keycloak.util.JsonSerialization;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.services.managers.ApplianceBootstrap;
import org.keycloak.services.managers.RealmManager;
import org.keycloak.services.resources.KeycloakApplication;
import org.keycloak.util.JsonSerialization;
import javax.servlet.ServletContext;
import javax.ws.rs.core.Context;
@ -22,8 +21,6 @@ public class DemoApplication extends KeycloakApplication {
super(servletContext);
KeycloakSession session = factory.createSession();
session.getTransaction().begin();
ApplianceBootstrap bootstrap = new ApplianceBootstrap();
bootstrap.bootstrap(session);
install(new RealmManager(session));
session.getTransaction().commit();
}

View file

@ -1,20 +1,30 @@
<jboss-deployment-structure>
<deployment>
<!--
<exclude-subsystems>
<subsystem name="jaxrs" />
</exclude-subsystems>
-->
<exclusions>
<!-- Exclude Version cxf of JBOSS -->
<module name="org.apache.cxf" />
<!-- Exclude JAVA EE of JBOSS (javax.ws..) => Add dependency javax.annotation -->
<module name="javaee.api" />
<module name="javax.ws.rs.api"/>
<!-- Exclude RestEasy conflict (javax.ws.rs.ext.RunDelegate) -->
<module name="org.codehaus.jackson.jackson-core-asl" />
<module name="org.jboss.resteasy.resteasy-atom-provider" />
<module name="org.jboss.resteasy.resteasy-cdi" />
<module name="org.jboss.resteasy.resteasy-jackson-provider" />
<module name="org.jboss.resteasy.resteasy-crypto" />
<module name="org.jboss.resteasy.resteasy-jaxb-provider" />
<module name="org.jboss.resteasy.resteasy-jaxrs" />
<module name="org.jboss.resteasy.resteasy-jackson-provider" />
<module name="org.jboss.resteasy.resteasy-jettison-provider" />
<module name="org.jboss.resteasy.resteasy-json-p-provider" />
<module name="org.jboss.resteasy.resteasy-jsapi" />
<module name="org.jboss.resteasy.resteasy-multipart-provider" />
<module name="org.jboss.resteasy.resteasy-validator-provider-11" />
<module name="org.jboss.resteasy.resteasy-yaml-provider" />
</exclusions>
</deployment>

View file

@ -42,7 +42,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.2</version>
<version>${apache.httpcomponents.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

View file

@ -32,7 +32,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.2</version>
<version>${apache.httpcomponents.version}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>

View file

@ -30,7 +30,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.2</version>
<version>${apache.httpcomponents.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>

View file

@ -32,7 +32,7 @@
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.2</version>
<version>${apache.httpcomponents.version}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>

View file

@ -12,6 +12,7 @@
<packaging>pom</packaging>
<properties>
<apache.httpcomponents.version>4.1.2</apache.httpcomponents.version>
<resteasy.version>3.0.5.Final</resteasy.version>
<undertow.version>1.0.0.Beta28</undertow.version>
<picketlink.version>2.5.0.Beta6</picketlink.version>
@ -327,12 +328,11 @@
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!-- Keep this at 4.1.2 to make sure we're compatible with AS7 -->
<!-- the dependency seems to override Resteasy 3.0.5's dependeing on 4.2.1
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1.2</version>
<version>${apache.httpcomponents.version}</version>
</dependency>
-->
</dependencies>

View file

@ -1,13 +1,12 @@
package org.keycloak.server;
import org.jboss.resteasy.logging.Logger;
import org.keycloak.util.JsonSerialization;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.services.managers.ApplianceBootstrap;
import org.keycloak.services.managers.RealmManager;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.RealmModel;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.services.managers.RealmManager;
import org.keycloak.services.resources.KeycloakApplication;
import org.keycloak.util.JsonSerialization;
import javax.servlet.ServletContext;
import javax.ws.rs.core.Context;
@ -22,21 +21,19 @@ public class KeycloakServerApplication extends KeycloakApplication {
public KeycloakServerApplication(@Context ServletContext servletContext) throws FileNotFoundException {
super(servletContext);
KeycloakSession session = factory.createSession();
session.getTransaction().begin();
ApplianceBootstrap bootstrap = new ApplianceBootstrap();
bootstrap.bootstrap(session);
String importRealm = System.getProperty("keycloak.import");
if (importRealm != null) {
KeycloakSession session = factory.createSession();
session.getTransaction().begin();
RealmRepresentation rep = loadJson(new FileInputStream(importRealm), RealmRepresentation.class);
importRealm(session, rep);
session.getTransaction().commit();
}
session.getTransaction().commit();
}
public void importRealm(KeycloakSession session, RealmRepresentation rep ) {
public void importRealm(KeycloakSession session, RealmRepresentation rep) {
try {
RealmManager manager = new RealmManager(session);
@ -62,7 +59,7 @@ public class KeycloakServerApplication extends KeycloakApplication {
private static <T> T loadJson(InputStream is, Class<T> type) {
try {
return JsonSerialization.readValue(is, type);
return JsonSerialization.readValue(is, type);
} catch (IOException e) {
throw new RuntimeException("Failed to parse json", e);
}

View file

@ -4,6 +4,7 @@ import org.jboss.resteasy.logging.Logger;
import org.keycloak.models.ApplicationModel;
import org.keycloak.models.Constants;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.models.RealmModel;
import org.keycloak.models.RoleModel;
import org.keycloak.models.UserCredentialModel;
@ -20,6 +21,19 @@ public class ApplianceBootstrap {
private static final Logger logger = Logger.getLogger(ApplianceBootstrap.class);
public void bootstrap(KeycloakSessionFactory factory) {
KeycloakSession session = factory.createSession();
session.getTransaction().begin();
try {
bootstrap(session);
session.getTransaction().commit();
} finally {
session.close();
}
}
public void bootstrap(KeycloakSession session) {
if (session.getRealm(Constants.ADMIN_REALM) != null) {
return;

View file

@ -2,8 +2,13 @@ package org.keycloak.services.resources;
import org.jboss.resteasy.logging.Logger;
import org.keycloak.SkeletonKeyContextResolver;
import org.keycloak.models.Constants;
import org.keycloak.models.KeycloakSession;
import org.keycloak.models.KeycloakSessionFactory;
import org.keycloak.models.ModelProvider;
import org.keycloak.models.UserModel;
import org.keycloak.services.managers.ApplianceBootstrap;
import org.keycloak.services.managers.RealmManager;
import org.keycloak.services.managers.SocialRequestManager;
import org.keycloak.services.managers.TokenManager;
@ -43,8 +48,15 @@ public class KeycloakApplication extends Application {
singletons.add(new SocialResource(tokenManager, new SocialRequestManager()));
classes.add(SkeletonKeyContextResolver.class);
classes.add(QRCodeResource.class);
setupDefaultRealm();
}
protected void setupDefaultRealm() {
new ApplianceBootstrap().bootstrap(factory);
}
public static KeycloakSessionFactory createSessionFactory() {
ServiceLoader<ModelProvider> providers = ServiceLoader.load(ModelProvider.class);
String configuredProvider = System.getProperty(MODEL_PROVIDER);