Remove deprecated cookie code

Closes #26813

Signed-off-by: stianst <stianst@gmail.com>
This commit is contained in:
stianst 2024-03-12 08:36:06 +01:00 committed by Alexander Schwartz
parent c0731ac502
commit 15717cc152
5 changed files with 10 additions and 65 deletions

View file

@ -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]

View file

@ -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)`

View file

@ -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);
}
}

View file

@ -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);
}
}

View file

@ -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";