use of org.apache.oltu.oauth2.common.message.OAuthResponse.OAuthErrorResponseBuilder in project Kustvakt by KorAP.
the class OAuth2ResponseHandler method throwit.
public WebApplicationException throwit(OAuthProblemException e, String state) {
OAuthResponse oAuthResponse = null;
try {
OAuthErrorResponseBuilder builder = OAuthResponse.errorResponse(e.getResponseStatus()).error(e);
if (state != null && !state.isEmpty()) {
builder.setState(state);
}
oAuthResponse = builder.buildJSONMessage();
} catch (OAuthSystemException e1) {
throwit(e1, state);
}
Response r = createResponse(oAuthResponse);
return new WebApplicationException(r);
}
use of org.apache.oltu.oauth2.common.message.OAuthResponse.OAuthErrorResponseBuilder in project Kustvakt by KorAP.
the class OAuth2ResponseHandler method createOAuthResponse.
private OAuthResponse createOAuthResponse(KustvaktException e, int statusCode, String state) throws OAuthSystemException {
OAuthProblemException oAuthProblemException = OAuthProblemException.error(e.getEntity()).state(state).description(e.getMessage());
OAuthErrorResponseBuilder responseBuilder = OAuthResponse.errorResponse(statusCode).error(oAuthProblemException);
if (state != null && !state.isEmpty()) {
responseBuilder.setState(state);
}
URI redirectUri = e.getRedirectUri();
if (redirectUri != null) {
responseBuilder.location(redirectUri.toString());
return responseBuilder.buildQueryMessage();
}
return responseBuilder.buildJSONMessage();
}
Aggregations