Search in sources :

Example 6 with OAuthSystemException

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

the class AuthorizationCodeTokenHandler method responseToken.

private void responseToken() throws OAuthSystemException {
    AccessToken accessToken = oauthService.retrieveAuthorizationCodeAccessToken(clientDetails(), tokenRequest.getCode());
    final OAuthResponse tokenResponse = createTokenResponse(accessToken, false);
    LOG.debug("'authorization_code' response: {}", tokenResponse);
    WebUtils.writeOAuthJsonResponse(response, tokenResponse);
}
Also used : AccessToken(io.github.tesla.authz.domain.AccessToken) OAuthResponse(org.apache.oltu.oauth2.common.message.OAuthResponse)

Example 7 with OAuthSystemException

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

the class RefreshTokenHandler method handleAfterValidation.

@Override
public void handleAfterValidation() throws OAuthProblemException, OAuthSystemException {
    final String refreshToken = tokenRequest.getRefreshToken();
    AccessToken accessToken = oauthService.changeAccessTokenByRefreshToken(refreshToken, tokenRequest.getClientId());
    final OAuthResponse tokenResponse = createTokenResponse(accessToken, false);
    LOG.debug("'refresh_token' response: {}", tokenResponse);
    WebUtils.writeOAuthJsonResponse(response, tokenResponse);
}
Also used : AccessToken(io.github.tesla.authz.domain.AccessToken) OAuthResponse(org.apache.oltu.oauth2.common.message.OAuthResponse)

Example 8 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 9 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 10 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)

Aggregations

OAuthResponse (org.apache.oltu.oauth2.common.message.OAuthResponse)13 AccessToken (io.github.tesla.authz.domain.AccessToken)4 ClientDetails (io.github.tesla.authz.domain.ClientDetails)3 OAuthProblemException (org.apache.oltu.oauth2.common.exception.OAuthProblemException)3 AbstractClientDetailsValidator (io.github.tesla.authz.controller.oauth2.validator.AbstractClientDetailsValidator)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 SQLiteException (android.database.sqlite.SQLiteException)1 TvdbException (com.battlelancer.seriesguide.thetvdbapi.TvdbException)1 OAuthAuthxRequest (io.github.tesla.authz.controller.oauth2.OAuthAuthxRequest)1 OAuthTokenxRequest (io.github.tesla.authz.controller.oauth2.OAuthTokenxRequest)1 CodeAuthorizeHandler (io.github.tesla.authz.controller.oauth2.authorize.CodeAuthorizeHandler)1 TokenAuthorizeHandler (io.github.tesla.authz.controller.oauth2.authorize.TokenAuthorizeHandler)1 OAuthTokenHandleDispatcher (io.github.tesla.authz.controller.oauth2.token.OAuthTokenHandleDispatcher)1 OAuthASResponse (org.apache.oltu.oauth2.as.response.OAuthASResponse)1 OAuthSystemException (org.apache.oltu.oauth2.common.exception.OAuthSystemException)1 Subject (org.apache.shiro.subject.Subject)1