diff --git a/federation/ldap/pom.xml b/federation/ldap/pom.xml index c998ee7054..6d976016a8 100755 --- a/federation/ldap/pom.xml +++ b/federation/ldap/pom.xml @@ -61,11 +61,6 @@ keycloak-kerberos-federation provided - - org.jboss.resteasy - resteasy-core - provided - io.quarkus.resteasy.reactive resteasy-reactive-common diff --git a/model/jpa/pom.xml b/model/jpa/pom.xml index 19957d65b8..ac4e28f787 100755 --- a/model/jpa/pom.xml +++ b/model/jpa/pom.xml @@ -81,11 +81,6 @@ org.hibernate.orm hibernate-core - - org.jboss.resteasy - resteasy-core - provided - com.fasterxml.jackson.core jackson-databind diff --git a/model/storage-private/pom.xml b/model/storage-private/pom.xml index 5fc2834830..851e136ede 100644 --- a/model/storage-private/pom.xml +++ b/model/storage-private/pom.xml @@ -31,8 +31,8 @@ - org.jboss.resteasy - resteasy-core + io.quarkus.resteasy.reactive + resteasy-reactive-common provided diff --git a/model/storage-services/pom.xml b/model/storage-services/pom.xml index 761a8392f8..8d7acffc7f 100644 --- a/model/storage-services/pom.xml +++ b/model/storage-services/pom.xml @@ -43,10 +43,6 @@ hamcrest test - - org.jboss.resteasy - resteasy-core - io.quarkus.resteasy.reactive resteasy-reactive-common diff --git a/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/KeycloakProcessor.java b/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/KeycloakProcessor.java index aa01c545a3..9c2e7b39be 100644 --- a/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/KeycloakProcessor.java +++ b/quarkus/deployment/src/main/java/org/keycloak/quarkus/deployment/KeycloakProcessor.java @@ -46,7 +46,6 @@ import io.quarkus.resteasy.reactive.server.spi.MethodScannerBuildItem; import io.quarkus.runtime.configuration.ConfigurationException; import io.quarkus.runtime.configuration.ProfileManager; import io.quarkus.vertx.http.deployment.RouteBuildItem; -import io.quarkus.resteasy.reactive.spi.IgnoreStackMixingBuildItem; import io.smallrye.config.ConfigValue; import org.eclipse.microprofile.health.Readiness; import org.hibernate.cfg.AvailableSettings; @@ -61,7 +60,6 @@ import org.jboss.jandex.MethodInfo; import org.jboss.logging.Logger; import org.jboss.resteasy.reactive.server.model.HandlerChainCustomizer; import org.jboss.resteasy.reactive.server.processor.scanning.MethodScanner; -import org.jboss.resteasy.spi.ResteasyDeployment; import org.keycloak.Config; import org.keycloak.authentication.AuthenticatorSpi; import org.keycloak.authentication.authenticators.browser.DeployedScriptAuthenticatorFactory; @@ -208,11 +206,6 @@ class KeycloakProcessor { return new DeployedScriptSAMLProtocolMapper(metadata); } - @BuildStep - IgnoreStackMixingBuildItem getIgnoreStackMixing() { - return new IgnoreStackMixingBuildItem(); - } - @BuildStep FeatureBuildItem getFeature() { return new FeatureBuildItem("keycloak"); @@ -585,8 +578,8 @@ class KeycloakProcessor { } /** - * This will cause quarkus tu include specified modules in the jandex index. For example keycloak-services is needed as it includes - * most of the JAX-RS resources, which are required to register Resteasy builtin providers. See {@link ResteasyDeployment#isRegisterBuiltin()}. + * This will cause quarkus to include specified modules in the jandex index. For example keycloak-services is needed as it includes + * most of the JAX-RS resources, which are required to register Resteasy builtin providers. * Similar reason is liquibase * * @param indexDependencyBuildItemBuildProducer diff --git a/quarkus/runtime/pom.xml b/quarkus/runtime/pom.xml index 1b3049732c..0b5cf28e07 100644 --- a/quarkus/runtime/pom.xml +++ b/quarkus/runtime/pom.xml @@ -350,14 +350,14 @@ - - org.jboss.resteasy - resteasy-multipart-provider - org.jboss.logging commons-logging-jboss-logging + + commons-io + commons-io + com.webauthn4j webauthn4j-core @@ -541,25 +541,7 @@ org.jboss.resteasy - resteasy-core - - - log4j - log4j - - - org.slf4j - slf4j-api - - - org.slf4j - slf4j-simple - - - org.jboss.spec.javax.servlet - jboss-servlet-api_4.0_spec - - + resteasy-core-spi org.apache.commons diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/jaxrs/KeycloakSessionContextInjector.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/jaxrs/KeycloakSessionContextInjector.java deleted file mode 100644 index 54fef01299..0000000000 --- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/jaxrs/KeycloakSessionContextInjector.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright 2021 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.quarkus.runtime.integration.jaxrs; - -import jakarta.ws.rs.ext.Provider; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; - -import org.jboss.resteasy.spi.ContextInjector; -import org.keycloak.common.util.Resteasy; -import org.keycloak.models.KeycloakSession; -import org.keycloak.quarkus.runtime.integration.resteasy.ResteasyVertxProvider; - -/** - *

This {@link ContextInjector} allows injecting {@link KeycloakSession} to JAX-RS resources. - * - *

Due to the latest changes in Quarkus, the context map is cleared prior to dispatching to JAX-RS resources, so we need - * to delegate to the {@link ResteasyVertxProvider} provider the lookup of Keycloak contextual objects. - * - * @see ResteasyVertxProvider - * - * @author Pedro Igor - */ -@Provider -public class KeycloakSessionContextInjector implements ContextInjector { - @Override - public KeycloakSession resolve(Class rawType, Type genericType, Annotation[] annotations) { - return Resteasy.getContextData(KeycloakSession.class); - } -} diff --git a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/resteasy/ResteasyVertxProvider.java b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/resteasy/ResteasyVertxProvider.java index a67e043c79..3a4d190d20 100644 --- a/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/resteasy/ResteasyVertxProvider.java +++ b/quarkus/runtime/src/main/java/org/keycloak/quarkus/runtime/integration/resteasy/ResteasyVertxProvider.java @@ -20,16 +20,24 @@ package org.keycloak.quarkus.runtime.integration.resteasy; import io.quarkus.arc.Arc; import io.quarkus.vertx.http.runtime.CurrentVertxRequest; import io.vertx.ext.web.RoutingContext; -import org.jboss.resteasy.core.ResteasyContext; import org.keycloak.common.util.ResteasyProvider; +import java.util.HashMap; +import java.util.Map; import java.util.Optional; public class ResteasyVertxProvider implements ResteasyProvider { + private static final ThreadLocal, Object>> contextualData = new ThreadLocal, Object>>() { + @Override + protected Map, Object> initialValue() { + return new HashMap<>(); + }; + }; + @Override public R getContextData(Class type) { - R data = ResteasyContext.getContextData(type); + R data = (R) contextualData.get().get(type); if (data == null) { RoutingContext contextData = Optional.ofNullable(Arc.container()) @@ -48,7 +56,7 @@ public class ResteasyVertxProvider implements ResteasyProvider { @Override public void pushContext(Class type, Object instance) { - ResteasyContext.pushContext(type, instance); + contextualData.get().put(type, instance); } @Override @@ -58,7 +66,7 @@ public class ResteasyVertxProvider implements ResteasyProvider { @Override public void clearContextData() { - ResteasyContext.clearContextData(); + contextualData.remove(); } } diff --git a/quarkus/tests/integration/pom.xml b/quarkus/tests/integration/pom.xml index 7919b7582c..1876cbaa77 100644 --- a/quarkus/tests/integration/pom.xml +++ b/quarkus/tests/integration/pom.xml @@ -63,7 +63,6 @@ org.bouncycastle bcpkix-fips - ${bouncycastle.pkixfips.version} test diff --git a/server-spi-private/pom.xml b/server-spi-private/pom.xml index 7275d1c3ee..cafe657172 100755 --- a/server-spi-private/pom.xml +++ b/server-spi-private/pom.xml @@ -43,8 +43,8 @@ - org.jboss.resteasy - resteasy-core + io.quarkus.resteasy.reactive + resteasy-reactive-common provided diff --git a/server-spi/pom.xml b/server-spi/pom.xml index 1da428a4c8..3bc3dcb6d9 100755 --- a/server-spi/pom.xml +++ b/server-spi/pom.xml @@ -43,8 +43,8 @@ provided - org.jboss.resteasy - resteasy-core + io.quarkus.resteasy.reactive + resteasy-reactive-common provided diff --git a/server-spi/src/main/java/org/keycloak/models/KeycloakUriInfo.java b/server-spi/src/main/java/org/keycloak/models/KeycloakUriInfo.java index 3e9b0dd15f..7f98c582d4 100644 --- a/server-spi/src/main/java/org/keycloak/models/KeycloakUriInfo.java +++ b/server-spi/src/main/java/org/keycloak/models/KeycloakUriInfo.java @@ -19,7 +19,8 @@ package org.keycloak.models; import static org.keycloak.common.util.UriUtils.parseQueryParameters; import jakarta.ws.rs.core.MultivaluedHashMap; -import org.jboss.resteasy.spi.ResteasyUriBuilder; + +import org.jboss.resteasy.reactive.common.jaxrs.UriBuilderImpl; import org.keycloak.urls.HostnameProvider; import org.keycloak.urls.UrlType; @@ -117,7 +118,7 @@ public class KeycloakUriInfo implements UriInfo { to = this.getBaseUriBuilder().replaceQuery(null).path(uri.getPath()).replaceQuery(uri.getQuery()).fragment(uri.getFragment()).build(new Object[0]); } - return ResteasyUriBuilder.relativize(from, to); + return UriBuilderImpl.relativize(from, to); } @Override diff --git a/services/pom.xml b/services/pom.xml index 6b55ba7df6..42fe00efb8 100755 --- a/services/pom.xml +++ b/services/pom.xml @@ -102,8 +102,14 @@ true + org.jboss.resteasy resteasy-core + test + + + io.quarkus.resteasy.reactive + resteasy-reactive provided @@ -130,7 +136,7 @@ org.jboss.resteasy - resteasy-multipart-provider + resteasy-core-spi com.googlecode.owasp-java-html-sanitizer diff --git a/services/src/main/java/org/keycloak/authentication/authenticators/browser/UsernamePasswordForm.java b/services/src/main/java/org/keycloak/authentication/authenticators/browser/UsernamePasswordForm.java index 72afb561a6..e554a88710 100755 --- a/services/src/main/java/org/keycloak/authentication/authenticators/browser/UsernamePasswordForm.java +++ b/services/src/main/java/org/keycloak/authentication/authenticators/browser/UsernamePasswordForm.java @@ -17,7 +17,6 @@ package org.keycloak.authentication.authenticators.browser; -import org.jboss.resteasy.specimpl.MultivaluedMapImpl; import org.keycloak.authentication.AuthenticationFlowContext; import org.keycloak.authentication.Authenticator; import org.keycloak.forms.login.LoginFormsProvider; @@ -28,6 +27,7 @@ import org.keycloak.protocol.oidc.OIDCLoginProtocol; import org.keycloak.services.ServicesLogger; import org.keycloak.services.managers.AuthenticationManager; +import jakarta.ws.rs.core.MultivaluedHashMap; import jakarta.ws.rs.core.MultivaluedMap; import jakarta.ws.rs.core.Response; @@ -57,7 +57,7 @@ public class UsernamePasswordForm extends AbstractUsernameFormAuthenticator impl @Override public void authenticate(AuthenticationFlowContext context) { - MultivaluedMap formData = new MultivaluedMapImpl<>(); + MultivaluedMap formData = new MultivaluedHashMap<>(); String loginHint = context.getAuthenticationSession().getClientNote(OIDCLoginProtocol.LOGIN_HINT_PARAM); String rememberMeUsername = AuthenticationManager.getRememberMeUsername(context.getSession()); diff --git a/services/src/main/java/org/keycloak/protocol/docker/DockerAuthV2Protocol.java b/services/src/main/java/org/keycloak/protocol/docker/DockerAuthV2Protocol.java index 5319e9eddf..ccfc6d03ed 100644 --- a/services/src/main/java/org/keycloak/protocol/docker/DockerAuthV2Protocol.java +++ b/services/src/main/java/org/keycloak/protocol/docker/DockerAuthV2Protocol.java @@ -1,7 +1,7 @@ package org.keycloak.protocol.docker; import org.jboss.logging.Logger; -import org.jboss.resteasy.specimpl.ResponseBuilderImpl; +import org.jboss.resteasy.reactive.server.jaxrs.ResponseBuilderImpl; import org.keycloak.events.EventBuilder; import org.keycloak.events.EventType; import org.keycloak.jose.jws.JWSBuilder; diff --git a/services/src/main/java/org/keycloak/protocol/docker/DockerAuthenticator.java b/services/src/main/java/org/keycloak/protocol/docker/DockerAuthenticator.java index c38bc161f3..0f668ab21c 100644 --- a/services/src/main/java/org/keycloak/protocol/docker/DockerAuthenticator.java +++ b/services/src/main/java/org/keycloak/protocol/docker/DockerAuthenticator.java @@ -1,7 +1,7 @@ package org.keycloak.protocol.docker; import org.jboss.logging.Logger; -import org.jboss.resteasy.specimpl.ResponseBuilderImpl; +import org.jboss.resteasy.reactive.server.jaxrs.ResponseBuilderImpl; import org.keycloak.authentication.AuthenticationFlowContext; import org.keycloak.authentication.AuthenticationFlowError; import org.keycloak.events.Errors; diff --git a/services/src/main/java/org/keycloak/services/HttpRequestImpl.java b/services/src/main/java/org/keycloak/services/HttpRequestImpl.java index f7344e8c30..e955020724 100644 --- a/services/src/main/java/org/keycloak/services/HttpRequestImpl.java +++ b/services/src/main/java/org/keycloak/services/HttpRequestImpl.java @@ -18,13 +18,12 @@ package org.keycloak.services; import static jakarta.ws.rs.core.MediaType.MULTIPART_FORM_DATA_TYPE; -import static jakarta.ws.rs.core.MediaType.TEXT_PLAIN_TYPE; import java.io.IOException; -import java.io.InputStream; import java.security.cert.X509Certificate; -import java.util.List; -import java.util.Map; +import java.util.Collection; +import java.util.Map.Entry; + import jakarta.ws.rs.core.HttpHeaders; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.MultivaluedHashMap; @@ -32,9 +31,9 @@ import jakarta.ws.rs.core.MultivaluedMap; import jakarta.ws.rs.core.UriInfo; import jakarta.ws.rs.ext.MessageBodyReader; import jakarta.ws.rs.ext.Providers; -import org.jboss.resteasy.core.ResteasyContext; -import org.jboss.resteasy.plugins.providers.multipart.InputPart; -import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput; +import org.jboss.resteasy.reactive.server.multipart.FormValue; +import org.jboss.resteasy.reactive.server.multipart.MultipartFormDataInput; +import org.keycloak.common.util.Resteasy; import org.keycloak.http.FormPartValue; import org.keycloak.http.HttpRequest; @@ -75,7 +74,7 @@ public class HttpRequestImpl implements HttpRequest { return new MultivaluedHashMap<>(); } - Providers providers = ResteasyContext.getContextData(Providers.class); + Providers providers = Resteasy.getContextData(Providers.class); MessageBodyReader multiPartProvider = providers.getMessageBodyReader( MultipartFormDataInput.class, null, null, MULTIPART_FORM_DATA_TYPE); MultipartFormDataInput inputs = multiPartProvider @@ -83,14 +82,12 @@ public class HttpRequestImpl implements HttpRequest { delegate.getInputStream()); MultivaluedHashMap parts = new MultivaluedHashMap<>(); - for (Map.Entry> entry : inputs.getFormDataMap().entrySet()) { - for (InputPart value : entry.getValue()) { - MediaType valueMediaType = value.getMediaType(); - - if (TEXT_PLAIN_TYPE.isCompatible(valueMediaType)) { - parts.add(entry.getKey(), new FormPartValueImpl(value.getBodyAsString())); + for (Entry> entry : inputs.getValues().entrySet()) { + for (FormValue value : entry.getValue()) { + if (!value.isFileItem()) { + parts.add(entry.getKey(), new FormPartValueImpl(value.getValue())); } else { - parts.add(entry.getKey(), new FormPartValueImpl(value.getBody(InputStream.class, null))); + parts.add(entry.getKey(), new FormPartValueImpl(value.getFileItem().getInputStream())); } } }