Skip to content

Commit

Permalink
Move PAR request validation logic before authenticaiton validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Akila94 committed Nov 13, 2024
1 parent 287d591 commit 1c66202
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,6 @@ public Response parPost(@Context HttpServletRequest request, @Context HttpServle
OAuthClientAuthnContext clientAuthnContext = (OAuthClientAuthnContext)
request.getAttribute(CLIENT_AUTHENTICATION_CONTEXT);

// Check if the client authentication is successful
if (!clientAuthnContext.isAuthenticated()) {
// create error response
PushAuthErrorResponse errorResponse = pushAuthRequestValidator
.createErrorResponse(HttpServletResponse.SC_UNAUTHORIZED,
clientAuthnContext.getErrorCode(), clientAuthnContext.getErrorMessage());
return Response.status(errorResponse.getHttpStatusCode())
.entity(errorResponse.getPayload()).build();
}

try {
paramMap = pushAuthRequestValidator.validateParams(request, (Map<String, List<String>>) parameterMap);
} catch (PushAuthRequestValidatorException exception) {
Expand All @@ -113,7 +103,17 @@ public Response parPost(@Context HttpServletRequest request, @Context HttpServle
.createErrorResponse(exception.getHttpStatusCode(), exception.getErrorCode(),
exception.getErrorDescription());
return Response.status(errorResponse.getHttpStatusCode() != 0 ?
errorResponse.getHttpStatusCode() : exception.getHttpStatusCode())
errorResponse.getHttpStatusCode() : exception.getHttpStatusCode())
.entity(errorResponse.getPayload()).build();
}

// Check if the client authentication is successful
if (!clientAuthnContext.isAuthenticated()) {
// create error response
PushAuthErrorResponse errorResponse = pushAuthRequestValidator
.createErrorResponse(HttpServletResponse.SC_UNAUTHORIZED,
clientAuthnContext.getErrorCode(), clientAuthnContext.getErrorMessage());
return Response.status(errorResponse.getHttpStatusCode())
.entity(errorResponse.getPayload()).build();
}

Expand Down

0 comments on commit 1c66202

Please sign in to comment.