Search in sources :

Example 11 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 12 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)

Example 13 with OAuthSystemException

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

the class AbstractOAuthTokenHandler method validateFailed.

protected boolean validateFailed() throws OAuthSystemException {
    AbstractClientDetailsValidator validator = getValidator();
    LOG.debug("Use [{}] validate client: {}", validator, tokenRequest.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 14 with OAuthSystemException

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

the class ClientCredentialsTokenHandler method handleAfterValidation.

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

Example 15 with OAuthSystemException

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

the class PasswordTokenHandler method handleAfterValidation.

@Override
public void handleAfterValidation() throws OAuthProblemException, OAuthSystemException {
    AccessToken accessToken = oauthService.retrievePasswordAccessToken(clientDetails(), tokenRequest.getScopes(), tokenRequest.getUsername());
    final OAuthResponse tokenResponse = createTokenResponse(accessToken, false);
    LOG.debug("'password' response: {}", tokenResponse);
    WebUtils.writeOAuthJsonResponse(response, tokenResponse);
}
Also used : AccessToken(io.github.tesla.authz.domain.AccessToken) 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