From 3e32bd116b4763b6b51f9966617fdb5cdcfaf244 Mon Sep 17 00:00:00 2001 From: Bill Burke Date: Mon, 12 May 2014 15:35:54 -0400 Subject: [PATCH] aerogear demo update --- .../app/src/main/webapp/WEB-INF/web.xml | 10 +++++ .../app/src/main/webapp/admin/admin.html | 1 + .../aerogear-ups/auth-server/pom.xml | 11 +++++ .../ups/security/UpsSecurityApplication.java | 40 +++++++++++++++++++ .../src/main/webapp/WEB-INF/testrealm.json | 23 +++++++++++ .../src/main/webapp/WEB-INF/web.xml | 2 +- 6 files changed, 86 insertions(+), 1 deletion(-) create mode 100755 project-integrations/aerogear-ups/app/src/main/webapp/admin/admin.html create mode 100755 project-integrations/aerogear-ups/auth-server/src/main/java/org/aerogear/ups/security/UpsSecurityApplication.java diff --git a/project-integrations/aerogear-ups/app/src/main/webapp/WEB-INF/web.xml b/project-integrations/aerogear-ups/app/src/main/webapp/WEB-INF/web.xml index af91ffa36e..1be2b565ec 100755 --- a/project-integrations/aerogear-ups/app/src/main/webapp/WEB-INF/web.xml +++ b/project-integrations/aerogear-ups/app/src/main/webapp/WEB-INF/web.xml @@ -21,6 +21,16 @@ + + + AdminConsole + /admin/* + + + admin + + + Database diff --git a/project-integrations/aerogear-ups/app/src/main/webapp/admin/admin.html b/project-integrations/aerogear-ups/app/src/main/webapp/admin/admin.html new file mode 100755 index 0000000000..8102dc0e3d --- /dev/null +++ b/project-integrations/aerogear-ups/app/src/main/webapp/admin/admin.html @@ -0,0 +1 @@ +

This would be the admin page for the UPS admin console.

\ No newline at end of file diff --git a/project-integrations/aerogear-ups/auth-server/pom.xml b/project-integrations/aerogear-ups/auth-server/pom.xml index 6ac1405b48..5dba72bb2d 100755 --- a/project-integrations/aerogear-ups/auth-server/pom.xml +++ b/project-integrations/aerogear-ups/auth-server/pom.xml @@ -135,6 +135,17 @@ keycloak-timer-basic ${project.version} + + org.keycloak + keycloak-export-import-api + ${project.version} + + + org.keycloak + keycloak-export-import-impl + ${project.version} + + org.jboss.spec.javax.servlet diff --git a/project-integrations/aerogear-ups/auth-server/src/main/java/org/aerogear/ups/security/UpsSecurityApplication.java b/project-integrations/aerogear-ups/auth-server/src/main/java/org/aerogear/ups/security/UpsSecurityApplication.java new file mode 100755 index 0000000000..eddeace54d --- /dev/null +++ b/project-integrations/aerogear-ups/auth-server/src/main/java/org/aerogear/ups/security/UpsSecurityApplication.java @@ -0,0 +1,40 @@ +package org.aerogear.ups.security; + +import org.jboss.resteasy.core.Dispatcher; +import org.keycloak.models.KeycloakSession; +import org.keycloak.models.RealmModel; +import org.keycloak.models.UserModel; +import org.keycloak.services.managers.RealmManager; +import org.keycloak.services.resources.KeycloakApplication; + +import javax.servlet.ServletContext; +import javax.ws.rs.core.Context; + +/** + * @author Bill Burke + * @version $Revision: 1 $ + */ +public class UpsSecurityApplication extends KeycloakApplication { + public UpsSecurityApplication(@Context ServletContext context, @Context Dispatcher dispatcher) { + super(context, dispatcher); + } + + @Override + protected void setupDefaultRealm(String contextPath) { + super.setupDefaultRealm(contextPath); + KeycloakSession session = factory.createSession(); + session.getTransaction().begin(); + + // disable master realm by deleting the admin user. + try { + RealmManager manager = new RealmManager(session); + RealmModel master = manager.getKeycloakAdminstrationRealm(); + UserModel admin = master.getUser("admin"); + if (admin != null) master.removeUser(admin.getLoginName()); + session.getTransaction().commit(); + } finally { + session.close(); + } + + } +} diff --git a/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/testrealm.json b/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/testrealm.json index bc2d8f708a..bcbd7ad8eb 100755 --- a/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/testrealm.json +++ b/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/testrealm.json @@ -20,6 +20,19 @@ { "type" : "password", "value" : "password" } ] + }, + { + "username" : "admin", + "enabled": true, + "firstName": "Bill", + "lastName": "Burke", + "credentials" : [ + { "type" : "password", + "value" : "admin" } + ], + "requiredActions": [ + "UPDATE_PASSWORD" + ] } ], "roles" : { @@ -38,6 +51,10 @@ { "username": "bburke@redhat.com", "roles": ["user"] + }, + { + "username": "admin", + "roles": ["user", "admin"] } ], "scopeMappings": [ @@ -64,6 +81,12 @@ "username": "bburke@redhat.com", "roles": ["manage-account"] } + ], + "demo-realm": [ + { + "username": "admin", + "roles": ["realm-admin"] + } ] } diff --git a/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/web.xml b/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/web.xml index 048c39d08c..bb58ec087b 100755 --- a/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/web.xml +++ b/project-integrations/aerogear-ups/auth-server/src/main/webapp/WEB-INF/web.xml @@ -16,7 +16,7 @@ org.jboss.resteasy.plugins.server.servlet.HttpServlet30Dispatcher javax.ws.rs.Application - org.keycloak.services.resources.KeycloakApplication + org.aerogear.ups.security.UpsSecurityApplication resteasy.servlet.mapping.prefix