From 15717cc152140d01e129a40a3f42c7166707288d Mon Sep 17 00:00:00 2001 From: stianst Date: Tue, 12 Mar 2024 08:36:06 +0100 Subject: [PATCH] Remove deprecated cookie code Closes #26813 Signed-off-by: stianst --- docs/documentation/release_notes/index.adoc | 3 ++ .../release_notes/topics/25_0_0.adoc | 7 +++ .../java/org/keycloak/http/HttpCookie.java | 52 ------------------- .../java/org/keycloak/http/HttpResponse.java | 11 ---- .../locale/LocaleSelectorProvider.java | 2 - 5 files changed, 10 insertions(+), 65 deletions(-) create mode 100644 docs/documentation/release_notes/topics/25_0_0.adoc delete mode 100644 server-spi/src/main/java/org/keycloak/http/HttpCookie.java diff --git a/docs/documentation/release_notes/index.adoc b/docs/documentation/release_notes/index.adoc index 0480468bfa..b1242446d2 100644 --- a/docs/documentation/release_notes/index.adoc +++ b/docs/documentation/release_notes/index.adoc @@ -13,6 +13,9 @@ include::topics/templates/document-attributes.adoc[] :release_header_latest_link: {releasenotes_link_latest} include::topics/templates/release-header.adoc[] +== {project_name_full} 25.0.0 +include::topics/25_0_0.adoc[leveloffset=2] + == {project_name_full} 24.0.1 include::topics/24_0_1.adoc[leveloffset=2] diff --git a/docs/documentation/release_notes/topics/25_0_0.adoc b/docs/documentation/release_notes/topics/25_0_0.adoc new file mode 100644 index 0000000000..a2f306da4c --- /dev/null +++ b/docs/documentation/release_notes/topics/25_0_0.adoc @@ -0,0 +1,7 @@ += Deprecated cookie methods removed + +The following methods for setting custom cookies have been removed: + +* `LocaleSelectorProvider.KEYCLOAK_LOCALE` - replaced by `CookieType.LOCALE` +* `HttpCookie` - replaced by `NewCookie.Builder` +* `HttpResponse.setCookieIfAbsent(HttpCookie cookie)` - replaced by `HttpResponse.setCookieIfAbsent(NewCookie cookie)` \ No newline at end of file diff --git a/server-spi/src/main/java/org/keycloak/http/HttpCookie.java b/server-spi/src/main/java/org/keycloak/http/HttpCookie.java deleted file mode 100644 index a142ab29ca..0000000000 --- a/server-spi/src/main/java/org/keycloak/http/HttpCookie.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2023 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.http; - -import jakarta.ws.rs.core.NewCookie; -import jakarta.ws.rs.ext.RuntimeDelegate; -import org.keycloak.common.util.ServerCookie.SameSiteAttributeValue; - -/** - * An extension of {@link javax.ws.rs.core.Cookie} in order to support additional - * fields and behavior. - * - * @deprecated This class will be removed in the future. Please use {@link jakarta.ws.rs.core.NewCookie.Builder} - */ -@Deprecated(since = "24.0.0", forRemoval = true) -public final class HttpCookie extends NewCookie { - - public HttpCookie(int version, String name, String value, String path, String domain, String comment, int maxAge, boolean secure, boolean httpOnly, SameSiteAttributeValue sameSite) { - super(name, value, path, domain, version, comment, maxAge, null, secure, httpOnly, convertSameSite(sameSite)); - } - - private static SameSite convertSameSite(SameSiteAttributeValue sameSiteAttributeValue) { - if (sameSiteAttributeValue == null) { - return null; - } - switch (sameSiteAttributeValue) { - case NONE: return SameSite.NONE; - case LAX: return SameSite.LAX; - case STRICT: return SameSite.STRICT; - } - throw new IllegalArgumentException("Unknown SameSite value " + sameSiteAttributeValue); - } - - public String toHeaderValue() { - return RuntimeDelegate.getInstance().createHeaderDelegate(NewCookie.class).toString(this); - } -} diff --git a/server-spi/src/main/java/org/keycloak/http/HttpResponse.java b/server-spi/src/main/java/org/keycloak/http/HttpResponse.java index 359de398aa..6353d3dcee 100644 --- a/server-spi/src/main/java/org/keycloak/http/HttpResponse.java +++ b/server-spi/src/main/java/org/keycloak/http/HttpResponse.java @@ -60,15 +60,4 @@ public interface HttpResponse { */ void setCookieIfAbsent(NewCookie cookie); - /** - * Sets a new cookie only if not yet set. - * @deprecated This method will be removed in the future. Please use {@link jakarta.ws.rs.core.NewCookie.Builder} - * - * @param cookie the cookie - */ - @Deprecated(since = "24.0.0", forRemoval = true) - default void setCookieIfAbsent(HttpCookie cookie) { - setCookieIfAbsent((NewCookie) cookie); - } - } diff --git a/server-spi/src/main/java/org/keycloak/locale/LocaleSelectorProvider.java b/server-spi/src/main/java/org/keycloak/locale/LocaleSelectorProvider.java index 36641593f4..a17db7189a 100644 --- a/server-spi/src/main/java/org/keycloak/locale/LocaleSelectorProvider.java +++ b/server-spi/src/main/java/org/keycloak/locale/LocaleSelectorProvider.java @@ -24,8 +24,6 @@ import java.util.Locale; public interface LocaleSelectorProvider extends Provider { - @Deprecated(since = "24.0.0", forRemoval = true) - String LOCALE_COOKIE = "KEYCLOAK_LOCALE"; String KC_LOCALE_PARAM = "kc_locale"; String CLIENT_REQUEST_LOCALE = "locale_client_requested";