response.setStatus(oauthResponse.getResponseStatus());
return oauthResponse.getBody();
}
// Attempt to get the third-party.
Application application = oAuth2MgmtService.getApplicationForClientId(oauthRequest.getClientId());
// If the third-party is unknown, reject the request.
if (application == null) {
// Create the OAuth response.
OAuthResponse oauthResponse = OAuthASResponse.errorResponse(HttpServletResponse.SC_BAD_REQUEST).setError
(OAuthError.CodeResponse.INVALID_REQUEST).setErrorDescription(
"The client ID is unknown: " + oauthRequest.getClientId()
).setState(oauthRequest.getState()).buildJSONMessage();
// Set the status and return the error message.
response.setStatus(oauthResponse.getResponseStatus());
return oauthResponse.getBody();
}
// Create the temporary code to be granted or rejected by the user.
AuthorizationCode code = oAuth2MgmtService.issueAuthorizationCode(application.getId(),
oauthRequest.getScopes(),
oauthRequest.getState());
// Set the redirect.
response.sendRedirect(OAuthASResponse.authorizationResponse(request, HttpServletResponse.SC_FOUND)