org.apache.oltu.oauth2.common.message.OAuthResponse Java Examples
The following examples show how to use
org.apache.oltu.oauth2.common.message.OAuthResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OpenIDConnectUserEndpoint.java From carbon-identity with Apache License 2.0 | 6 votes |
/** * Build the error message response properly * * @param e * @return * @throws OAuthSystemException */ private Response handleError(UserInfoEndpointException e) throws OAuthSystemException { log.debug(e); OAuthResponse res = null; try { res = OAuthASResponse.errorResponse(HttpServletResponse.SC_BAD_REQUEST) .setError(e.getErrorCode()).setErrorDescription(e.getErrorMessage()) .buildJSONMessage(); } catch (OAuthSystemException e1) { log.error("Error while building the JSON message", e1); OAuthResponse response = OAuthASResponse.errorResponse(HttpServletResponse.SC_INTERNAL_SERVER_ERROR) .setError(OAuth2ErrorCodes.SERVER_ERROR) .setErrorDescription(e1.getMessage()).buildJSONMessage(); return Response.status(response.getResponseStatus()).entity(response.getBody()).build(); } return Response.status(res.getResponseStatus()).entity(res.getBody()).build(); }
Example #2
Source File: OAuthAuthorizationServlet.java From BIMserver with GNU Affero General Public License v3.0 | 6 votes |
private URI makeUrl(String redirectURI, OAuthAuthorizationCode oauthCode, OAuthAuthorizationResponseBuilder builder) throws OAuthSystemException, URISyntaxException { String siteAddress = getBimServer().getServerSettingsCache().getServerSettings().getSiteAddress(); OAuthAuthorizationResponseBuilder build = builder.location(redirectURI).setParam("address", siteAddress + "/json"); build.setParam("serviceaddress", siteAddress + "/services"); build.setParam("websocketUrl", siteAddress.replace("http://", "ws://").replace("https://", "wss://") + "/stream"); if (oauthCode.getAuthorization() instanceof SingleProjectAuthorization) { SingleProjectAuthorization singleProjectAuthorization = (SingleProjectAuthorization) oauthCode.getAuthorization(); build.setParam("poid", "" + singleProjectAuthorization.getProject().getOid()); } else if (oauthCode.getAuthorization() instanceof RunServiceAuthorization) { RunServiceAuthorization auth = (RunServiceAuthorization) oauthCode.getAuthorization(); build.setParam("soid", "" + auth.getService().getOid()); } final OAuthResponse response = build.buildQueryMessage(); String locationUri = response.getLocationUri(); URI url = new URI(locationUri); return url; }
Example #3
Source File: OAuth2TokenEndpoint.java From carbon-identity with Apache License 2.0 | 5 votes |
private Response handleBasicAuthFailure() throws OAuthSystemException { OAuthResponse response = OAuthASResponse.errorResponse(HttpServletResponse.SC_UNAUTHORIZED) .setError(OAuth2ErrorCodes.INVALID_CLIENT) .setErrorDescription("Client Authentication failed.").buildJSONMessage(); return Response.status(response.getResponseStatus()) .header(OAuthConstants.HTTP_RESP_HEADER_AUTHENTICATE, EndpointUtil.getRealmInfo()) .entity(response.getBody()).build(); }
Example #4
Source File: OAuth2TokenEndpoint.java From carbon-identity with Apache License 2.0 | 5 votes |
private Response handleServerError() throws OAuthSystemException { OAuthResponse response = OAuthASResponse.errorResponse(HttpServletResponse.SC_INTERNAL_SERVER_ERROR). setError(OAuth2ErrorCodes.SERVER_ERROR).setErrorDescription("Internal Server Error.").buildJSONMessage(); return Response.status(response.getResponseStatus()).header(OAuthConstants.HTTP_RESP_HEADER_AUTHENTICATE, EndpointUtil.getRealmInfo()).entity(response.getBody()).build(); }
Example #5
Source File: OAuth2TokenEndpoint.java From carbon-identity with Apache License 2.0 | 5 votes |
private Response handleSQLError() throws OAuthSystemException { OAuthResponse response = OAuthASResponse.errorResponse(HttpServletResponse.SC_BAD_GATEWAY). setError(OAuth2ErrorCodes.SERVER_ERROR).setErrorDescription("Service Unavailable Error.").buildJSONMessage(); return Response.status(response.getResponseStatus()).header(OAuthConstants.HTTP_RESP_HEADER_AUTHENTICATE, EndpointUtil.getRealmInfo()).entity(response.getBody()).build(); }