From 5f04ce310aea28f764272cf1e64063b6ee3f58dc Mon Sep 17 00:00:00 2001 From: Dmitry Telegin Date: Tue, 20 Feb 2024 04:41:42 +0000 Subject: [PATCH] simplify OAuth2GrantType.Context creation --- .../protocol/oidc/grants/OAuth2GrantType.java | 18 ++++++++---------- .../protocol/oidc/endpoints/TokenEndpoint.java | 4 +--- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/server-spi-private/src/main/java/org/keycloak/protocol/oidc/grants/OAuth2GrantType.java b/server-spi-private/src/main/java/org/keycloak/protocol/oidc/grants/OAuth2GrantType.java index e5c245624d..3d62ca3314 100644 --- a/server-spi-private/src/main/java/org/keycloak/protocol/oidc/grants/OAuth2GrantType.java +++ b/server-spi-private/src/main/java/org/keycloak/protocol/oidc/grants/OAuth2GrantType.java @@ -90,19 +90,17 @@ public interface OAuth2GrantType extends Provider, ProviderFactory clientAuthAttributes, - HttpRequest request, HttpResponse response, HttpHeaders headers, MultivaluedMap formParams, - EventBuilder event, Cors cors, Object tokenManager, DPoP dPoP) { + public Context(KeycloakSession session, Object clientConfig, Map clientAuthAttributes, + MultivaluedMap formParams, EventBuilder event, Cors cors, Object tokenManager, DPoP dPoP) { this.session = session; - this.realm = realm; - this.client = client; + this.realm = session.getContext().getRealm(); + this.client = session.getContext().getClient(); this.clientConfig = clientConfig; - this.clientConnection = clientConnection; + this.clientConnection = session.getContext().getConnection(); this.clientAuthAttributes = clientAuthAttributes; - this.request = request; - this.response = response; - this.headers = headers; + this.request = session.getContext().getHttpRequest(); + this.response = session.getContext().getHttpResponse(); + this.headers = session.getContext().getRequestHeaders(); this.formParams = formParams; this.event = event; this.cors = cors; diff --git a/services/src/main/java/org/keycloak/protocol/oidc/endpoints/TokenEndpoint.java b/services/src/main/java/org/keycloak/protocol/oidc/endpoints/TokenEndpoint.java index 4abbed801c..ce6d784d7d 100644 --- a/services/src/main/java/org/keycloak/protocol/oidc/endpoints/TokenEndpoint.java +++ b/services/src/main/java/org/keycloak/protocol/oidc/endpoints/TokenEndpoint.java @@ -138,9 +138,7 @@ public class TokenEndpoint { checkParameterDuplicated(); } - context = new OAuth2GrantType.Context(session, realm, - client, clientConfig, clientConnection, clientAuthAttributes, - request, httpResponse, headers, formParams, event, cors, tokenManager, dPoP); + context = new OAuth2GrantType.Context(session, clientConfig, clientAuthAttributes, formParams, event, cors, tokenManager, dPoP); resolveGrantType(); grant.setContext(context);