Search in sources :

Example 86 with OAuthSystemException

use of org.apache.oltu.oauth2.common.exception.OAuthSystemException in project tesla by linking12.

the class OauthAuthorizeController method unsupportResponseType.

private void unsupportResponseType(OAuthAuthxRequest oauthRequest, HttpServletResponse response) throws OAuthSystemException {
    final String responseType = oauthRequest.getResponseType();
    LOG.debug("Unsupport response_type '{}' by client_id '{}'", responseType, oauthRequest.getClientId());
    OAuthResponse oAuthResponse = OAuthResponse.errorResponse(HttpServletResponse.SC_BAD_REQUEST).setError(OAuthError.CodeResponse.UNSUPPORTED_RESPONSE_TYPE).setErrorDescription("Unsupport response_type '" + responseType + "'").buildJSONMessage();
    WebUtils.writeOAuthJsonResponse(response, oAuthResponse);
}
Also used : OAuthResponse(org.apache.oltu.oauth2.common.message.OAuthResponse)

Example 87 with OAuthSystemException

use of org.apache.oltu.oauth2.common.exception.OAuthSystemException in project tesla by linking12.

the class OauthTokenController method authorize.

@RequestMapping("token")
public void authorize(HttpServletRequest request, HttpServletResponse response) throws OAuthSystemException {
    try {
        OAuthTokenxRequest tokenRequest = new OAuthTokenxRequest(request);
        OAuthTokenHandleDispatcher tokenHandleDispatcher = new OAuthTokenHandleDispatcher(tokenRequest, response);
        tokenHandleDispatcher.dispatch();
    } catch (OAuthProblemException e) {
        LOG.debug(e.getMessage(), e);
        OAuthResponse oAuthResponse = OAuthASResponse.errorResponse(HttpServletResponse.SC_FOUND).location(e.getRedirectUri()).error(e).buildJSONMessage();
        WebUtils.writeOAuthJsonResponse(response, oAuthResponse);
    }
}
Also used : OAuthProblemException(org.apache.oltu.oauth2.common.exception.OAuthProblemException) OAuthTokenxRequest(io.github.tesla.authz.controller.oauth2.OAuthTokenxRequest) OAuthTokenHandleDispatcher(io.github.tesla.authz.controller.oauth2.token.OAuthTokenHandleDispatcher) OAuthResponse(org.apache.oltu.oauth2.common.message.OAuthResponse) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 88 with OAuthSystemException

use of org.apache.oltu.oauth2.common.exception.OAuthSystemException in project tesla by linking12.

the class AbstractAuthorizeHandler method validateFailed.

protected boolean validateFailed() throws OAuthSystemException {
    AbstractClientDetailsValidator validator = getValidator();
    LOG.debug("Use [{}] validate client: {}", validator, oauthRequest.getClientId());
    final OAuthResponse oAuthResponse = validator.validate();
    return checkAndResponseValidateFailed(oAuthResponse);
}
Also used : AbstractClientDetailsValidator(io.github.tesla.authz.controller.oauth2.validator.AbstractClientDetailsValidator) OAuthResponse(org.apache.oltu.oauth2.common.message.OAuthResponse)

Example 89 with OAuthSystemException

use of org.apache.oltu.oauth2.common.exception.OAuthSystemException in project tesla by linking12.

the class AbstractAuthorizeHandler method responseApprovalDeny.

protected void responseApprovalDeny() throws IOException, OAuthSystemException {
    final OAuthResponse oAuthResponse = OAuthASResponse.errorResponse(HttpServletResponse.SC_FOUND).setError(OAuthError.CodeResponse.ACCESS_DENIED).setErrorDescription("User denied access").location(clientDetails().getRedirectUri()).setState(oauthRequest.getState()).buildQueryMessage();
    LOG.debug("'ACCESS_DENIED' response: {}", oAuthResponse);
    WebUtils.writeOAuthQueryResponse(response, oAuthResponse);
    final Subject subject = SecurityUtils.getSubject();
    subject.logout();
    LOG.debug("After 'ACCESS_DENIED' call logout. user: {}", subject.getPrincipal());
}
Also used : OAuthResponse(org.apache.oltu.oauth2.common.message.OAuthResponse) Subject(org.apache.shiro.subject.Subject)

Example 90 with OAuthSystemException

use of org.apache.oltu.oauth2.common.exception.OAuthSystemException in project tesla by linking12.

the class CodeAuthorizeHandler method handleResponse.

@Override
protected void handleResponse() throws OAuthSystemException, IOException {
    final ClientDetails clientDetails = clientDetails();
    final String authCode = oauthService.retrieveAuthCode(clientDetails);
    final OAuthResponse oAuthResponse = OAuthASResponse.authorizationResponse(oauthRequest.request(), HttpServletResponse.SC_OK).location(clientDetails.getRedirectUri()).setCode(authCode).buildQueryMessage();
    LOG.debug(" 'code' response: {}", oAuthResponse);
    WebUtils.writeOAuthQueryResponse(response, oAuthResponse);
}
Also used : ClientDetails(io.github.tesla.authz.domain.ClientDetails) OAuthResponse(org.apache.oltu.oauth2.common.message.OAuthResponse)

Aggregations

OAuthSystemException (org.apache.oltu.oauth2.common.exception.OAuthSystemException)100 OAuthClientRequest (org.apache.oltu.oauth2.client.request.OAuthClientRequest)55 OAuthProblemException (org.apache.oltu.oauth2.common.exception.OAuthProblemException)50 OAuthResponse (org.apache.oltu.oauth2.common.message.OAuthResponse)49 IOException (java.io.IOException)38 Request (okhttp3.Request)27 Response (okhttp3.Response)27 OAuthJSONAccessTokenResponse (org.apache.oltu.oauth2.client.response.OAuthJSONAccessTokenResponse)22 URI (java.net.URI)17 Builder (okhttp3.Request.Builder)17 OAuthBearerClientRequest (org.apache.oltu.oauth2.client.request.OAuthBearerClientRequest)17 Map (java.util.Map)15 TokenRequestBuilder (org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder)14 OAuthClientResponse (org.apache.oltu.oauth2.client.response.OAuthClientResponse)14 MediaType (okhttp3.MediaType)13 RequestBody (okhttp3.RequestBody)13 OAuthClient (org.apache.oltu.oauth2.client.OAuthClient)13 MD5Generator (org.apache.oltu.oauth2.as.issuer.MD5Generator)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)12 Path (javax.ws.rs.Path)11