Search in sources :

Example 1 with EndpointUtil.getOAuth2Service

use of org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getOAuth2Service in project identity-inbound-auth-oauth by wso2-extensions.

the class OAuth2AuthzEndpoint method handleFailedAuthentication.

private Response handleFailedAuthentication(OAuthMessage oAuthMessage, OAuth2Parameters oauth2Params, AuthenticationResult authnResult) throws URISyntaxException {
    OAuthErrorDTO oAuthErrorDTO = EndpointUtil.getOAuth2Service().handleAuthenticationFailure(oauth2Params);
    OAuthProblemException oauthException = buildOAuthProblemException(authnResult, oAuthErrorDTO);
    return handleFailedState(oAuthMessage, oauth2Params, oauthException);
}
Also used : OAuthProblemException(org.apache.oltu.oauth2.common.exception.OAuthProblemException) OAuthErrorDTO(org.wso2.carbon.identity.oauth.dto.OAuthErrorDTO)

Example 2 with EndpointUtil.getOAuth2Service

use of org.wso2.carbon.identity.oauth.endpoint.util.EndpointUtil.getOAuth2Service in project identity-inbound-auth-oauth by wso2-extensions.

the class OAuth2AuthzEndpoint method handleDeniedConsent.

private Response handleDeniedConsent(OAuthMessage oAuthMessage) throws OAuthSystemException, URISyntaxException {
    OAuth2Parameters oauth2Params = getOauth2Params(oAuthMessage);
    OpenIDConnectUserRPStore.getInstance().putUserRPToStore(getLoggedInUser(oAuthMessage), getOauth2Params(oAuthMessage).getApplicationName(), false, oauth2Params.getClientId());
    OAuthErrorDTO oAuthErrorDTO = EndpointUtil.getOAuth2Service().handleUserConsentDenial(oauth2Params);
    OAuthProblemException consentDenialException = buildConsentDenialException(oAuthErrorDTO);
    String denyResponse = EndpointUtil.getErrorRedirectURL(oAuthMessage.getRequest(), consentDenialException, oauth2Params);
    if (StringUtils.equals(oauth2Params.getResponseMode(), RESPONSE_MODE_FORM_POST)) {
        return handleFailedState(oAuthMessage, oauth2Params, consentDenialException);
    }
    return Response.status(HttpServletResponse.SC_FOUND).location(new URI(denyResponse)).build();
}
Also used : OAuth2Parameters(org.wso2.carbon.identity.oauth2.model.OAuth2Parameters) OAuthProblemException(org.apache.oltu.oauth2.common.exception.OAuthProblemException) OAuthErrorDTO(org.wso2.carbon.identity.oauth.dto.OAuthErrorDTO) URI(java.net.URI) REDIRECT_URI(org.wso2.carbon.identity.oauth.common.OAuthConstants.OAuth20Params.REDIRECT_URI)

Aggregations

OAuthProblemException (org.apache.oltu.oauth2.common.exception.OAuthProblemException)2 OAuthErrorDTO (org.wso2.carbon.identity.oauth.dto.OAuthErrorDTO)2 URI (java.net.URI)1 REDIRECT_URI (org.wso2.carbon.identity.oauth.common.OAuthConstants.OAuth20Params.REDIRECT_URI)1 OAuth2Parameters (org.wso2.carbon.identity.oauth2.model.OAuth2Parameters)1