Search in sources :

Example 16 with OAuthResponse

use of org.apache.oltu.oauth2.common.message.OAuthResponse 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 17 with OAuthResponse

use of org.apache.oltu.oauth2.common.message.OAuthResponse 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 18 with OAuthResponse

use of org.apache.oltu.oauth2.common.message.OAuthResponse 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 19 with OAuthResponse

use of org.apache.oltu.oauth2.common.message.OAuthResponse 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 20 with OAuthResponse

use of org.apache.oltu.oauth2.common.message.OAuthResponse 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)22 OAuthProblemException (org.apache.oltu.oauth2.common.exception.OAuthProblemException)10 MD5Generator (org.apache.oltu.oauth2.as.issuer.MD5Generator)6 OAuthIssuerImpl (org.apache.oltu.oauth2.as.issuer.OAuthIssuerImpl)5 OAuthSystemException (org.apache.oltu.oauth2.common.exception.OAuthSystemException)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 AccessToken (io.github.tesla.authz.domain.AccessToken)4 IOException (java.io.IOException)4 OAuthASResponse (org.apache.oltu.oauth2.as.response.OAuthASResponse)4 ClientDetails (io.github.tesla.authz.domain.ClientDetails)3 URI (java.net.URI)3 ServletException (javax.servlet.ServletException)3 OAuthIssuer (org.apache.oltu.oauth2.as.issuer.OAuthIssuer)3 OAuthAuthzRequest (org.apache.oltu.oauth2.as.request.OAuthAuthzRequest)3 OAuthTokenRequest (org.apache.oltu.oauth2.as.request.OAuthTokenRequest)3 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)3 DatabaseSession (org.bimserver.database.DatabaseSession)3 RunServiceAuthorization (org.bimserver.models.store.RunServiceAuthorization)3 AbstractClientDetailsValidator (io.github.tesla.authz.controller.oauth2.validator.AbstractClientDetailsValidator)2 PrintWriter (java.io.PrintWriter)2