From 1e438cdc452709bfdf3c895006563ef570d5c776 Mon Sep 17 00:00:00 2001 From: Hynek Mlnarik Date: Fri, 18 May 2018 12:47:01 +0200 Subject: [PATCH] KEYCLOAK-7277 KEYCLOAK-7282 Tomcat 8/Pax Web integration --- adapters/oidc/fuse7/pom.xml | 1 + adapters/oidc/fuse7/tomcat8/pom.xml | 115 ++++++++++++++++++ .../tomcat/KeycloakAuthenticatorService.java | 41 +++++++ ...ops4j.pax.web.service.AuthenticatorService | 1 + .../features/src/main/resources/features.xml | 13 ++ 5 files changed, 171 insertions(+) create mode 100644 adapters/oidc/fuse7/tomcat8/pom.xml create mode 100644 adapters/oidc/fuse7/tomcat8/src/main/java/org/keycloak/adapters/osgi/tomcat/KeycloakAuthenticatorService.java create mode 100644 adapters/oidc/fuse7/tomcat8/src/main/resources/META-INF/services/org.ops4j.pax.web.service.AuthenticatorService diff --git a/adapters/oidc/fuse7/pom.xml b/adapters/oidc/fuse7/pom.xml index 6d90b8417f..28e3b6eaa2 100644 --- a/adapters/oidc/fuse7/pom.xml +++ b/adapters/oidc/fuse7/pom.xml @@ -39,6 +39,7 @@ camel-undertow jetty94 + tomcat8 undertow diff --git a/adapters/oidc/fuse7/tomcat8/pom.xml b/adapters/oidc/fuse7/tomcat8/pom.xml new file mode 100644 index 0000000000..be51f08e42 --- /dev/null +++ b/adapters/oidc/fuse7/tomcat8/pom.xml @@ -0,0 +1,115 @@ + + + + + + keycloak-fuse7-integration-pom + org.keycloak + 4.0.0.Beta3-SNAPSHOT + ../pom.xml + + 4.0.0 + + keycloak-pax-web-tomcat8 + Keycloak Fuse 7.0 Adapter - Tomcat 8 + bundle + + + + org.keycloak.adapters.osgi.tomcat.*;version="${project.version}" + + + !org.keycloak.adapters.osgi.tomcat, + org.keycloak.*;version="${project.version}", + *;resolution:=optional + + org.ops4j.pax.web.pax-web-tomcat + + + + + org.jboss.logging + jboss-logging + provided + + + org.ops4j.pax.web + pax-web-api + provided + + + + org.keycloak + keycloak-tomcat8-adapter + provided + + + org.apache.tomcat + tomcat-catalina + ${tomcat.version} + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + + + + + + maven-jar-plugin + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + + org.apache.felix + maven-bundle-plugin + true + + + bundle-manifest + process-classes + + manifest + + + + + + ${project.name} + ${project.groupId}.${project.artifactId} + ${keycloak.osgi.import} + ${keycloak.osgi.export} + ${keycloak.osgi.fragment} + + + + + + diff --git a/adapters/oidc/fuse7/tomcat8/src/main/java/org/keycloak/adapters/osgi/tomcat/KeycloakAuthenticatorService.java b/adapters/oidc/fuse7/tomcat8/src/main/java/org/keycloak/adapters/osgi/tomcat/KeycloakAuthenticatorService.java new file mode 100644 index 0000000000..04993b6c2c --- /dev/null +++ b/adapters/oidc/fuse7/tomcat8/src/main/java/org/keycloak/adapters/osgi/tomcat/KeycloakAuthenticatorService.java @@ -0,0 +1,41 @@ +/* + * Copyright 2018 Red Hat, Inc. and/or its affiliates + * and other contributors as indicated by the @author tags. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.keycloak.adapters.osgi.tomcat; + +import org.ops4j.pax.web.service.AuthenticatorService; + +/** + * + * @author hmlnarik + */ +public class KeycloakAuthenticatorService implements AuthenticatorService { + + @Override + public T getAuthenticatorService(String method, Class iface) { + if (method == null || iface != org.apache.catalina.Valve.class) { + return null; + } + + if ("KEYCLOAK".equalsIgnoreCase(method)) { + return iface.cast(new org.keycloak.adapters.tomcat.KeycloakAuthenticatorValve()); + } + + return null; + } + +} diff --git a/adapters/oidc/fuse7/tomcat8/src/main/resources/META-INF/services/org.ops4j.pax.web.service.AuthenticatorService b/adapters/oidc/fuse7/tomcat8/src/main/resources/META-INF/services/org.ops4j.pax.web.service.AuthenticatorService new file mode 100644 index 0000000000..19190807f4 --- /dev/null +++ b/adapters/oidc/fuse7/tomcat8/src/main/resources/META-INF/services/org.ops4j.pax.web.service.AuthenticatorService @@ -0,0 +1 @@ +org.keycloak.adapters.osgi.tomcat.KeycloakAuthenticatorService \ No newline at end of file diff --git a/distribution/adapters/osgi/features/src/main/resources/features.xml b/distribution/adapters/osgi/features/src/main/resources/features.xml index 8899b34af4..577214f0cf 100755 --- a/distribution/adapters/osgi/features/src/main/resources/features.xml +++ b/distribution/adapters/osgi/features/src/main/resources/features.xml @@ -86,6 +86,19 @@ mvn:org.keycloak/keycloak-camel-undertow/${project.version} + + +
The keycloak JAAS configuration
keycloak-adapter-core