Replaced HttpCookie with NewCookie.Builder

Closes #27846

Signed-off-by: Tomas Kyjovsky <tkyjovsk@redhat.com>
This commit is contained in:
Tomáš Kyjovský 2024-03-13 11:20:53 +01:00 committed by GitHub
parent 343479d29d
commit f4126395e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,7 +17,6 @@
package org.keycloak.examples.authenticator;
import org.keycloak.http.HttpCookie;
import org.keycloak.http.HttpResponse;
import org.keycloak.authentication.AuthenticationFlowContext;
import org.keycloak.authentication.AuthenticationFlowError;
@ -34,6 +33,7 @@ import org.keycloak.models.UserModel;
import jakarta.ws.rs.core.Cookie;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.NewCookie;
import jakarta.ws.rs.core.Response;
import java.net.URI;
import java.util.Collections;
@ -96,7 +96,16 @@ public class SecretQuestionAuthenticator implements Authenticator, CredentialVal
public void addCookie(AuthenticationFlowContext context, String name, String value, String path, String domain, String comment, int maxAge, boolean secure, boolean httpOnly) {
HttpResponse response = context.getSession().getContext().getHttpResponse();
response.setCookieIfAbsent(new HttpCookie(1, name, value, path, domain, comment, maxAge, secure, httpOnly, null));
response.setCookieIfAbsent(new NewCookie.Builder(name)
.version(1)
.path(path)
.domain(domain)
.comment(comment)
.maxAge(maxAge)
.secure(secure)
.httpOnly(httpOnly)
.sameSite(null)
.build());
}