From deeae748aa465e3789114a93eee251628f9d365b Mon Sep 17 00:00:00 2001 From: YuriyZ Date: Tue, 8 Nov 2022 15:40:00 +0200 Subject: [PATCH] fix(jans-auth-server): corrected regression made in token request #2921 (#2922) Fixes test failures on jenkins --- .../io/jans/as/client/ClientAuthnEnabler.java | 9 ++++++--- .../java/io/jans/as/client/TokenRequest.java | 17 +++-------------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/jans-auth-server/client/src/main/java/io/jans/as/client/ClientAuthnEnabler.java b/jans-auth-server/client/src/main/java/io/jans/as/client/ClientAuthnEnabler.java index 909ba4c86d6..ff94b478568 100644 --- a/jans-auth-server/client/src/main/java/io/jans/as/client/ClientAuthnEnabler.java +++ b/jans-auth-server/client/src/main/java/io/jans/as/client/ClientAuthnEnabler.java @@ -11,6 +11,7 @@ import jakarta.ws.rs.client.Invocation.Builder; import jakarta.ws.rs.core.Form; +import org.apache.commons.lang.StringUtils; /** @@ -45,10 +46,12 @@ public void exec(ClientAuthnRequest request) { if (request.getAuthenticationMethod() == AuthenticationMethod.CLIENT_SECRET_JWT || request.getAuthenticationMethod() == AuthenticationMethod.PRIVATE_KEY_JWT) { requestForm.param("client_assertion_type", ClientAssertionType.JWT_BEARER.toString()); - if (request.getClientAssertion() != null) { - requestForm.param("client_assertion", request.getClientAssertion()); + + final String clientAssertion = request.getClientAssertion(); + if (clientAssertion != null) { + requestForm.param("client_assertion", clientAssertion); } - if (request.getAuthUsername() != null && !request.getAuthUsername().isEmpty()) { + if (StringUtils.isNotBlank(request.getAuthUsername())) { requestForm.param("client_id", request.getAuthUsername()); } } diff --git a/jans-auth-server/client/src/main/java/io/jans/as/client/TokenRequest.java b/jans-auth-server/client/src/main/java/io/jans/as/client/TokenRequest.java index fbb5d553fa5..85bc1ab7c7d 100644 --- a/jans-auth-server/client/src/main/java/io/jans/as/client/TokenRequest.java +++ b/jans-auth-server/client/src/main/java/io/jans/as/client/TokenRequest.java @@ -38,7 +38,6 @@ public class TokenRequest extends ClientAuthnRequest { private String codeVerifier; private String authReqId; private String deviceCode; - private String audience; private String subjectToken; private String subjectTokenType; private String actorToken; @@ -109,16 +108,6 @@ public void setRequestedTokenType(String requestedTokenType) { this.requestedTokenType = requestedTokenType; } - @Override - public String getAudience() { - return audience; - } - - @Override - public void setAudience(String audience) { - this.audience = audience; - } - /** * Returns the grant type. * @@ -325,7 +314,7 @@ public String getQueryString() { builder.append("refresh_token", refreshToken); builder.append("auth_req_id", authReqId); builder.append("device_code", deviceCode); - builder.append("audience", audience); + builder.append("audience", getAudience()); builder.append("subject_token", subjectToken); builder.append("subject_token_type", subjectTokenType); builder.append("actor_token", actorToken); @@ -360,8 +349,8 @@ public Map getParameters() { if (username != null && !username.isEmpty()) { parameters.put("username", username); } - if (StringUtils.isNotBlank(audience)) { - parameters.put("audience", audience); + if (StringUtils.isNotBlank(getAudience())) { + parameters.put("audience", getAudience()); } if (StringUtils.isNotBlank(subjectToken)) { parameters.put("subject_token", subjectToken);