Search in sources :

Example 1 with OAuthAuthxRequest

use of io.github.tesla.authz.controller.oauth2.OAuthAuthxRequest in project tesla by linking12.

the class OauthAuthorizeController method authorize.

@RequestMapping("authorize")
public void authorize(HttpServletRequest request, HttpServletResponse response) throws OAuthSystemException, ServletException, IOException {
    try {
        OAuthAuthxRequest oauthRequest = new OAuthAuthxRequest(request);
        if (oauthRequest.isCode()) {
            CodeAuthorizeHandler codeAuthorizeHandler = new CodeAuthorizeHandler(oauthRequest, response);
            LOG.debug("Go to  response_type = 'code' handler: {}", codeAuthorizeHandler);
            codeAuthorizeHandler.handle();
        } else if (oauthRequest.isToken()) {
            TokenAuthorizeHandler tokenAuthorizeHandler = new TokenAuthorizeHandler(oauthRequest, response);
            LOG.debug("Go to response_type = 'token' handler: {}", tokenAuthorizeHandler);
            tokenAuthorizeHandler.handle();
        } else {
            unsupportResponseType(oauthRequest, response);
        }
    } 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) CodeAuthorizeHandler(io.github.tesla.authz.controller.oauth2.authorize.CodeAuthorizeHandler) TokenAuthorizeHandler(io.github.tesla.authz.controller.oauth2.authorize.TokenAuthorizeHandler) OAuthAuthxRequest(io.github.tesla.authz.controller.oauth2.OAuthAuthxRequest) OAuthResponse(org.apache.oltu.oauth2.common.message.OAuthResponse) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

OAuthAuthxRequest (io.github.tesla.authz.controller.oauth2.OAuthAuthxRequest)1 CodeAuthorizeHandler (io.github.tesla.authz.controller.oauth2.authorize.CodeAuthorizeHandler)1 TokenAuthorizeHandler (io.github.tesla.authz.controller.oauth2.authorize.TokenAuthorizeHandler)1 OAuthProblemException (org.apache.oltu.oauth2.common.exception.OAuthProblemException)1 OAuthResponse (org.apache.oltu.oauth2.common.message.OAuthResponse)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1