} catch (OAuthServiceException ex) {
return createErrorResponse(params, redirectUri, OAuthConstants.ACCESS_DENIED);
}
if (redirectUri == null) {
OOBAuthorizationResponse oobResponse = new OOBAuthorizationResponse();
oobResponse.setClientId(client.getClientId());
oobResponse.setAuthorizationCode(grant.getCode());
oobResponse.setUserId(userSubject.getLogin());
oobResponse.setExpiresIn(grant.getExpiresIn());
return deliverOOBResponse(oobResponse);
} else {
// return the code by appending it as a query parameter to the redirect URI
UriBuilder ub = getRedirectUriBuilder(params.getFirst(OAuthConstants.STATE), redirectUri);
ub.queryParam(OAuthConstants.AUTHORIZATION_CODE_VALUE, grant.getCode());