diff --git a/jans-auth-server/server/src/main/java/io/jans/as/server/authorize/ws/rs/AuthorizeRestWebService.java b/jans-auth-server/server/src/main/java/io/jans/as/server/authorize/ws/rs/AuthorizeRestWebService.java index 9ebc7e41791..de81e110fc9 100644 --- a/jans-auth-server/server/src/main/java/io/jans/as/server/authorize/ws/rs/AuthorizeRestWebService.java +++ b/jans-auth-server/server/src/main/java/io/jans/as/server/authorize/ws/rs/AuthorizeRestWebService.java @@ -190,6 +190,7 @@ Response requestAuthorizationPost( @QueryParam("code_challenge_method") String codeChallengeMethod, @QueryParam(AuthorizeRequestParam.CUSTOM_RESPONSE_HEADERS) String customResponseHeaders, @QueryParam("claims") String claims, + @QueryParam("auth_req_id") String authReqId, @Context HttpServletRequest httpRequest, @Context HttpServletResponse httpResponse, @Context SecurityContext securityContext); diff --git a/jans-auth-server/server/src/main/java/io/jans/as/server/authorize/ws/rs/AuthorizeRestWebServiceImpl.java b/jans-auth-server/server/src/main/java/io/jans/as/server/authorize/ws/rs/AuthorizeRestWebServiceImpl.java index 23f7e2d8ead..84fc6383377 100644 --- a/jans-auth-server/server/src/main/java/io/jans/as/server/authorize/ws/rs/AuthorizeRestWebServiceImpl.java +++ b/jans-auth-server/server/src/main/java/io/jans/as/server/authorize/ws/rs/AuthorizeRestWebServiceImpl.java @@ -193,10 +193,37 @@ public Response requestAuthorizationGet( String sessionId, String originHeaders, String codeChallenge, String codeChallengeMethod, String customResponseHeaders, String claims, String authReqId, HttpServletRequest httpRequest, HttpServletResponse httpResponse, SecurityContext securityContext) { - return requestAuthorization(scope, responseType, clientId, redirectUri, state, responseMode, nonce, display, - prompt, maxAge, uiLocales, idTokenHint, loginHint, acrValues, amrValues, request, requestUri, - sessionId, HttpMethod.GET, originHeaders, codeChallenge, codeChallengeMethod, - customResponseHeaders, claims, authReqId, httpRequest, httpResponse, securityContext); + + AuthzRequest authzRequest = new AuthzRequest(); + authzRequest.setScope(scope); + authzRequest.setResponseType(responseType); + authzRequest.setClientId(clientId); + authzRequest.setRedirectUri(redirectUri); + authzRequest.setState(state); + authzRequest.setResponseMode(responseMode); + authzRequest.setNonce(nonce); + authzRequest.setDisplay(display); + authzRequest.setPrompt(prompt); + authzRequest.setMaxAge(maxAge); + authzRequest.setUiLocales(uiLocales); + authzRequest.setIdTokenHint(idTokenHint); + authzRequest.setLoginHint(loginHint); + authzRequest.setAcrValues(acrValues); + authzRequest.setAmrValues(amrValues); + authzRequest.setRequest(request); + authzRequest.setRequestUri(requestUri); + authzRequest.setSessionId(sessionId); + authzRequest.setOriginHeaders(originHeaders); + authzRequest.setCodeChallenge(codeChallenge); + authzRequest.setCodeChallengeMethod(codeChallengeMethod); + authzRequest.setCustomResponseHeaders(customResponseHeaders); + authzRequest.setClaims(claims); + authzRequest.setAuthReqId(authReqId); + authzRequest.setHttpRequest(httpRequest); + authzRequest.setHttpResponse(httpResponse); + authzRequest.setSecurityContext(securityContext); + + return requestAuthorization(authzRequest); } @Override @@ -205,21 +232,42 @@ public Response requestAuthorizationPost( String nonce, String display, String prompt, Integer maxAge, String uiLocales, String idTokenHint, String loginHint, String acrValues, String amrValues, String request, String requestUri, String sessionId, String originHeaders, - String codeChallenge, String codeChallengeMethod, String customResponseHeaders, String claims, + String codeChallenge, String codeChallengeMethod, String customResponseHeaders, String claims, String authReqId, HttpServletRequest httpRequest, HttpServletResponse httpResponse, SecurityContext securityContext) { - return requestAuthorization(scope, responseType, clientId, redirectUri, state, responseMode, nonce, display, - prompt, maxAge, uiLocales, idTokenHint, loginHint, acrValues, amrValues, request, requestUri, - sessionId, HttpMethod.POST, originHeaders, codeChallenge, codeChallengeMethod, - customResponseHeaders, claims, null, httpRequest, httpResponse, securityContext); + + AuthzRequest authzRequest = new AuthzRequest(); + authzRequest.setScope(scope); + authzRequest.setResponseType(responseType); + authzRequest.setClientId(clientId); + authzRequest.setRedirectUri(redirectUri); + authzRequest.setState(state); + authzRequest.setResponseMode(responseMode); + authzRequest.setNonce(nonce); + authzRequest.setDisplay(display); + authzRequest.setPrompt(prompt); + authzRequest.setMaxAge(maxAge); + authzRequest.setUiLocales(uiLocales); + authzRequest.setIdTokenHint(idTokenHint); + authzRequest.setLoginHint(loginHint); + authzRequest.setAcrValues(acrValues); + authzRequest.setAmrValues(amrValues); + authzRequest.setRequest(request); + authzRequest.setRequestUri(requestUri); + authzRequest.setSessionId(sessionId); + authzRequest.setOriginHeaders(originHeaders); + authzRequest.setCodeChallenge(codeChallenge); + authzRequest.setCodeChallengeMethod(codeChallengeMethod); + authzRequest.setCustomResponseHeaders(customResponseHeaders); + authzRequest.setClaims(claims); + authzRequest.setAuthReqId(authReqId); + authzRequest.setHttpRequest(httpRequest); + authzRequest.setHttpResponse(httpResponse); + authzRequest.setSecurityContext(securityContext); + + return requestAuthorization(authzRequest); } - private Response requestAuthorization( - String scope, String responseType, String clientId, String redirectUri, String state, String respMode, - String nonce, String display, String prompt, Integer maxAge, String uiLocalesStr, String idTokenHint, - String loginHint, String acrValuesStr, String amrValuesStr, String request, String requestUri, - String sessionId, String method, String originHeaders, String codeChallenge, String codeChallengeMethod, - String customRespHeaders, String claims, String authReqId, - HttpServletRequest httpRequest, HttpServletResponse httpResponse, SecurityContext securityContext) { + private Response requestAuthorization(AuthzRequest authzRequest) { scope = ServerUtil.urlDecode(scope); // it may be encoded in uma case String tokenBindingHeader = httpRequest.getHeader("Sec-Token-Binding"); diff --git a/jans-auth-server/server/src/main/java/io/jans/as/server/authorize/ws/rs/AuthzRequest.java b/jans-auth-server/server/src/main/java/io/jans/as/server/authorize/ws/rs/AuthzRequest.java new file mode 100644 index 00000000000..35d1d42c2b7 --- /dev/null +++ b/jans-auth-server/server/src/main/java/io/jans/as/server/authorize/ws/rs/AuthzRequest.java @@ -0,0 +1,288 @@ +package io.jans.as.server.authorize.ws.rs; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.ws.rs.core.SecurityContext; + +/** + * @author Yuriy Zabrovarnyy + */ +public class AuthzRequest { + + private String scope; + private String responseType; + private String clientId; + private String redirectUri; + private String state; + private String responseMode; + private String nonce; + private String display; + private String prompt; + private Integer maxAge; + private String uiLocales; + private String idTokenHint; + private String loginHint; + private String acrValues; + private String amrValues; + private String request; + private String requestUri; + private String sessionId; + private String originHeaders; + private String codeChallenge; + private String codeChallengeMethod; + private String customResponseHeaders; + private String claims; + private String authReqId; + private HttpServletRequest httpRequest; + private HttpServletResponse httpResponse; + private SecurityContext securityContext; + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + public String getResponseType() { + return responseType; + } + + public void setResponseType(String responseType) { + this.responseType = responseType; + } + + public String getClientId() { + return clientId; + } + + public void setClientId(String clientId) { + this.clientId = clientId; + } + + public String getRedirectUri() { + return redirectUri; + } + + public void setRedirectUri(String redirectUri) { + this.redirectUri = redirectUri; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getResponseMode() { + return responseMode; + } + + public void setResponseMode(String responseMode) { + this.responseMode = responseMode; + } + + public String getNonce() { + return nonce; + } + + public void setNonce(String nonce) { + this.nonce = nonce; + } + + public String getDisplay() { + return display; + } + + public void setDisplay(String display) { + this.display = display; + } + + public String getPrompt() { + return prompt; + } + + public void setPrompt(String prompt) { + this.prompt = prompt; + } + + public Integer getMaxAge() { + return maxAge; + } + + public void setMaxAge(Integer maxAge) { + this.maxAge = maxAge; + } + + public String getUiLocales() { + return uiLocales; + } + + public void setUiLocales(String uiLocales) { + this.uiLocales = uiLocales; + } + + public String getIdTokenHint() { + return idTokenHint; + } + + public void setIdTokenHint(String idTokenHint) { + this.idTokenHint = idTokenHint; + } + + public String getLoginHint() { + return loginHint; + } + + public void setLoginHint(String loginHint) { + this.loginHint = loginHint; + } + + public String getAcrValues() { + return acrValues; + } + + public void setAcrValues(String acrValues) { + this.acrValues = acrValues; + } + + public String getAmrValues() { + return amrValues; + } + + public void setAmrValues(String amrValues) { + this.amrValues = amrValues; + } + + public String getRequest() { + return request; + } + + public void setRequest(String request) { + this.request = request; + } + + public String getRequestUri() { + return requestUri; + } + + public void setRequestUri(String requestUri) { + this.requestUri = requestUri; + } + + public String getSessionId() { + return sessionId; + } + + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + public String getOriginHeaders() { + return originHeaders; + } + + public void setOriginHeaders(String originHeaders) { + this.originHeaders = originHeaders; + } + + public String getCodeChallenge() { + return codeChallenge; + } + + public void setCodeChallenge(String codeChallenge) { + this.codeChallenge = codeChallenge; + } + + public String getCodeChallengeMethod() { + return codeChallengeMethod; + } + + public void setCodeChallengeMethod(String codeChallengeMethod) { + this.codeChallengeMethod = codeChallengeMethod; + } + + public String getCustomResponseHeaders() { + return customResponseHeaders; + } + + public void setCustomResponseHeaders(String customResponseHeaders) { + this.customResponseHeaders = customResponseHeaders; + } + + public String getClaims() { + return claims; + } + + public void setClaims(String claims) { + this.claims = claims; + } + + public String getAuthReqId() { + return authReqId; + } + + public void setAuthReqId(String authReqId) { + this.authReqId = authReqId; + } + + public HttpServletRequest getHttpRequest() { + return httpRequest; + } + + public void setHttpRequest(HttpServletRequest httpRequest) { + this.httpRequest = httpRequest; + } + + public HttpServletResponse getHttpResponse() { + return httpResponse; + } + + public void setHttpResponse(HttpServletResponse httpResponse) { + this.httpResponse = httpResponse; + } + + public SecurityContext getSecurityContext() { + return securityContext; + } + + public void setSecurityContext(SecurityContext securityContext) { + this.securityContext = securityContext; + } + + @Override + public String toString() { + return "AuthzRequest{" + + "scope='" + scope + '\'' + + ", responseType='" + responseType + '\'' + + ", clientId='" + clientId + '\'' + + ", redirectUri='" + redirectUri + '\'' + + ", state='" + state + '\'' + + ", responseMode='" + responseMode + '\'' + + ", nonce='" + nonce + '\'' + + ", display='" + display + '\'' + + ", prompt='" + prompt + '\'' + + ", maxAge=" + maxAge + + ", uiLocales='" + uiLocales + '\'' + + ", idTokenHint='" + idTokenHint + '\'' + + ", loginHint='" + loginHint + '\'' + + ", acrValues='" + acrValues + '\'' + + ", amrValues='" + amrValues + '\'' + + ", request='" + request + '\'' + + ", requestUri='" + requestUri + '\'' + + ", sessionId='" + sessionId + '\'' + + ", originHeaders='" + originHeaders + '\'' + + ", codeChallenge='" + codeChallenge + '\'' + + ", codeChallengeMethod='" + codeChallengeMethod + '\'' + + ", customResponseHeaders='" + customResponseHeaders + '\'' + + ", claims='" + claims + '\'' + + ", authReqId='" + authReqId + '\'' + + ", httpRequest=" + httpRequest + + ", httpResponse=" + httpResponse + + ", securityContext=" + securityContext + + '}'; + } +}