diff --git a/examples/as7-eap-demo/server/pom.xml b/examples/as7-eap-demo/server/pom.xml
index 5c21e16d3e..3408aeaa76 100755
--- a/examples/as7-eap-demo/server/pom.xml
+++ b/examples/as7-eap-demo/server/pom.xml
@@ -15,6 +15,11 @@
+
+ org.jboss.resteasy
+ jose-jwt
+ provided
+
org.keycloak
keycloak-core
@@ -65,6 +70,11 @@
jaxrs-api
provided
+
+ com.h2database
+ h2
+ 1.3.161
+
junit
junit
diff --git a/examples/as7-eap-demo/server/src/main/java/org/keycloak/example/demo/DemoApplication.java b/examples/as7-eap-demo/server/src/main/java/org/keycloak/example/demo/DemoApplication.java
index cd483cd1ee..90043ace2d 100755
--- a/examples/as7-eap-demo/server/src/main/java/org/keycloak/example/demo/DemoApplication.java
+++ b/examples/as7-eap-demo/server/src/main/java/org/keycloak/example/demo/DemoApplication.java
@@ -1,13 +1,42 @@
package org.keycloak.example.demo;
+import org.jboss.resteasy.jwt.JsonSerialization;
+import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.services.managers.RealmManager;
import org.keycloak.services.models.RealmModel;
import org.keycloak.services.models.RequiredCredentialModel;
+import org.keycloak.services.models.relationships.RealmAdminRelationship;
+import org.keycloak.services.models.relationships.RequiredCredentialRelationship;
+import org.keycloak.services.models.relationships.ResourceRelationship;
+import org.keycloak.services.models.relationships.ScopeRelationship;
import org.keycloak.services.resources.KeycloakApplication;
import org.keycloak.services.resources.RegistrationService;
+import org.picketlink.idm.IdentitySession;
+import org.picketlink.idm.IdentitySessionFactory;
+import org.picketlink.idm.config.IdentityConfiguration;
+import org.picketlink.idm.config.IdentityConfigurationBuilder;
+import org.picketlink.idm.internal.DefaultIdentitySessionFactory;
+import org.picketlink.idm.jpa.internal.ResourceLocalJpaIdentitySessionHandler;
+import org.picketlink.idm.jpa.schema.CredentialObject;
+import org.picketlink.idm.jpa.schema.CredentialObjectAttribute;
+import org.picketlink.idm.jpa.schema.IdentityObject;
+import org.picketlink.idm.jpa.schema.IdentityObjectAttribute;
+import org.picketlink.idm.jpa.schema.PartitionObject;
+import org.picketlink.idm.jpa.schema.RelationshipIdentityObject;
+import org.picketlink.idm.jpa.schema.RelationshipObject;
+import org.picketlink.idm.jpa.schema.RelationshipObjectAttribute;
import org.picketlink.idm.model.Realm;
import org.picketlink.idm.model.SimpleRole;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Application;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashSet;
+import java.util.Set;
/**
* @author Bill Burke
* @version $Revision: 1 $
@@ -16,7 +45,13 @@ public class DemoApplication extends KeycloakApplication {
public DemoApplication() {
super();
-
+ IdentitySession session = factory.createIdentitySession();
+ session.getTransaction().begin();
+ RealmManager realmManager = new RealmManager(session);
+ if (realmManager.defaultRealm() == null) {
+ install(realmManager);
+ }
+ session.getTransaction().commit();
}
public void install(RealmManager manager) {
@@ -32,6 +67,31 @@ public class DemoApplication extends KeycloakApplication {
defaultRealm.updateRealm();
defaultRealm.addRequiredCredential(RequiredCredentialModel.PASSWORD);
defaultRealm.getIdm().add(new SimpleRole(RegistrationService.REALM_CREATOR_ROLE));
+
+ RealmRepresentation rep = loadJson("META-INF/testrealm.json");
+ RealmModel realm = manager.createRealm("demo", rep.getRealm());
+ manager.importRealm(rep, realm);
+
}
+ public static RealmRepresentation loadJson(String path)
+ {
+ InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ int c;
+ try {
+ while ( (c = is.read()) != -1)
+ {
+ os.write(c);
+ }
+ byte[] bytes = os.toByteArray();
+ //System.out.println(new String(bytes));
+
+ return JsonSerialization.fromBytes(RealmRepresentation.class, bytes);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
}
diff --git a/examples/as7-eap-demo/server/src/main/webapp/META-INF/persistence.xml b/examples/as7-eap-demo/server/src/main/webapp/META-INF/persistence.xml
new file mode 100755
index 0000000000..32b1acaa71
--- /dev/null
+++ b/examples/as7-eap-demo/server/src/main/webapp/META-INF/persistence.xml
@@ -0,0 +1,29 @@
+
+
+ org.hibernate.ejb.HibernatePersistence
+
+ org.picketlink.idm.jpa.schema.IdentityObject
+ org.picketlink.idm.jpa.schema.PartitionObject
+ org.picketlink.idm.jpa.schema.RelationshipObject
+ org.picketlink.idm.jpa.schema.RelationshipIdentityObject
+ org.picketlink.idm.jpa.schema.RelationshipIdentityWeakObject
+ org.picketlink.idm.jpa.schema.RelationshipObjectAttribute
+ org.picketlink.idm.jpa.schema.IdentityObjectAttribute
+ org.picketlink.idm.jpa.schema.CredentialObject
+ org.picketlink.idm.jpa.schema.CredentialObjectAttribute
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/as7-eap-demo/server/src/main/webapp/META-INF/testrealm.json b/examples/as7-eap-demo/server/src/main/webapp/META-INF/testrealm.json
new file mode 100755
index 0000000000..40e0fd35b1
--- /dev/null
+++ b/examples/as7-eap-demo/server/src/main/webapp/META-INF/testrealm.json
@@ -0,0 +1,101 @@
+{
+ "realm" : "demo",
+ "enabled" : true,
+ "tokenLifespan" : 6000,
+ "accessCodeLifespan" : 30,
+ "requiredCredentials" : [
+ {
+ "type" : "Password",
+ "input" : true,
+ "secret" : true
+ }
+ ],
+ "users" : [
+ {
+ "username" : "wburke",
+ "enabled" : true,
+ "attributes" : {
+ "email" : "bburke@redhat.com"
+ },
+ "credentials" : [
+ { "type" : "Password",
+ "value" : "userpassword" }
+ ]
+ },
+ {
+ "username" : "loginclient",
+ "enabled" : true,
+ "credentials" : [
+ { "type" : "Password",
+ "value" : "clientpassword" }
+ ]
+ },
+ {
+ "username" : "admin",
+ "enabled" : true,
+ "credentials" : [
+ { "type" : "Password",
+ "value" : "adminpassword" }
+ ]
+ },
+ {
+ "username" : "oauthclient",
+ "enabled" : true,
+ "credentials" : [
+ { "type" : "Password",
+ "value" : "clientpassword" }
+ ]
+ }
+ ],
+ "roleMappings" : [
+ {
+ "username" : "admin",
+ "roles" : ["admin"]
+ }
+ ],
+ "scopeMappings" : [
+ {
+ "username" : "loginclient",
+ "roles" : ["*"]
+ }
+ ],
+ "resources" : [
+ {
+ "name" : "Application",
+ "roles" : ["admin", "user"],
+ "roleMappings" : [
+ {
+ "username" : "wburke",
+ "roles" : ["user"]
+ },
+ {
+ "username" : "admin",
+ "roles" : ["admin"]
+ }
+ ],
+ "scopeMappings" : [
+ {
+ "username" : "oauthclient",
+ "roles" : ["user"]
+ }
+ ]
+ },
+ {
+ "name" : "OtherApp",
+ "roles" : ["admin", "user"],
+ "roleMappings" : [
+ {
+ "username" : "wburke",
+ "roles" : ["user"]
+ },
+ {
+ "username" : "admin",
+ "roles" : ["admin"]
+ }
+ ]
+ }
+
+ ]
+
+
+}
\ No newline at end of file
diff --git a/examples/as7-eap-demo/server/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/examples/as7-eap-demo/server/src/main/webapp/WEB-INF/jboss-deployment-structure.xml
new file mode 100755
index 0000000000..e551128261
--- /dev/null
+++ b/examples/as7-eap-demo/server/src/main/webapp/WEB-INF/jboss-deployment-structure.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/examples/as7-eap-demo/server/src/main/webapp/WEB-INF/web.xml b/examples/as7-eap-demo/server/src/main/webapp/WEB-INF/web.xml
index e2096d76c2..c6b4a52377 100755
--- a/examples/as7-eap-demo/server/src/main/webapp/WEB-INF/web.xml
+++ b/examples/as7-eap-demo/server/src/main/webapp/WEB-INF/web.xml
@@ -3,6 +3,26 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
+
+ Resteasy
+ org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher
+
+ javax.ws.rs.Application
+ org.keycloak.example.demo.DemoApplication
+
+
+ resteasy.servlet.mapping.prefix
+ /rest
+
+ 1
+ true
+
+
+
+ Resteasy
+ /rest/*
+
+