Multitenancy example working on AS 7.1.1
This commit is contained in:
parent
380f5dfb4e
commit
28547b0620
2 changed files with 8 additions and 31 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright (C) 2014 Juraci Paixão Kröhling <juraci at kroehling.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<jboss:jboss
|
||||
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:jboss="http://www.jboss.com/xml/ns/javaee"
|
||||
xmlns:s="urn:security:1.1"
|
||||
version="3.1" impl-version="2.0">
|
||||
|
||||
<assembly-descriptor>
|
||||
<s:security>
|
||||
<ejb-name>*</ejb-name>
|
||||
<s:security-domain>keycloak</s:security-domain>
|
||||
</s:security>
|
||||
</assembly-descriptor>
|
||||
</jboss:jboss>
|
Loading…
Reference in a new issue