From 28547b0620e8fcfe7ce5bab6ef1e5240705cdec6 Mon Sep 17 00:00:00 2001 From: mposolda Date: Mon, 3 Nov 2014 10:41:49 +0100 Subject: [PATCH] Multitenancy example working on AS 7.1.1 --- .../PathBasedKeycloakConfigResolver.java | 8 +++++ .../src/main/webapp/WEB-INF/jboss-ejb3.xml | 31 ------------------- 2 files changed, 8 insertions(+), 31 deletions(-) delete mode 100644 examples/multi-tenant/src/main/webapp/WEB-INF/jboss-ejb3.xml diff --git a/examples/multi-tenant/src/main/java/org/keycloak/example/multitenant/control/PathBasedKeycloakConfigResolver.java b/examples/multi-tenant/src/main/java/org/keycloak/example/multitenant/control/PathBasedKeycloakConfigResolver.java index 4aa2fea2d0..44f7e78a1d 100644 --- a/examples/multi-tenant/src/main/java/org/keycloak/example/multitenant/control/PathBasedKeycloakConfigResolver.java +++ b/examples/multi-tenant/src/main/java/org/keycloak/example/multitenant/control/PathBasedKeycloakConfigResolver.java @@ -37,6 +37,11 @@ public class PathBasedKeycloakConfigResolver implements KeycloakConfigResolver { @Override public KeycloakDeployment resolve(HttpFacade.Request request) { String path = request.getURI(); + int multitenantIndex = path.indexOf("multitenant/"); + if (multitenantIndex == -1) { + throw new IllegalStateException("Not able to resolve realm from the request path!"); + } + String realm = path.substring(path.indexOf("multitenant/")).split("/")[1]; if (realm.contains("?")) { realm = realm.split("\\?")[0]; @@ -46,6 +51,9 @@ public class PathBasedKeycloakConfigResolver implements KeycloakConfigResolver { if (null == deployment) { // not found on the simple cache, try to load it from the file system InputStream is = getClass().getResourceAsStream("/" + realm + "-keycloak.json"); + if (is == null) { + throw new IllegalStateException("Not able to find the file /" + realm + "-keycloak.json"); + } deployment = KeycloakDeploymentBuilder.build(is); cache.put(realm, deployment); } diff --git a/examples/multi-tenant/src/main/webapp/WEB-INF/jboss-ejb3.xml b/examples/multi-tenant/src/main/webapp/WEB-INF/jboss-ejb3.xml deleted file mode 100644 index 1693f7acbc..0000000000 --- a/examples/multi-tenant/src/main/webapp/WEB-INF/jboss-ejb3.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - * - keycloak - - - \ No newline at end of file