Search in sources :

Example 1 with DefaultAuthenticationRedirectStrategy

use of org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy in project cas by apereo.

the class AbstractSamlProfileHandlerController method issueAuthenticationRequestRedirect.

/**
     * Redirect request for authentication.
     *
     * @param pair     the pair
     * @param request  the request
     * @param response the response
     * @throws Exception the exception
     */
protected void issueAuthenticationRequestRedirect(final Pair<? extends SignableSAMLObject, MessageContext> pair, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    final AuthnRequest authnRequest = AuthnRequest.class.cast(pair.getLeft());
    final String serviceUrl = constructServiceUrl(request, response, pair);
    LOGGER.debug("Created service url [{}]", serviceUrl);
    final String initialUrl = CommonUtils.constructRedirectUrl(this.loginUrl, CasProtocolConstants.PARAMETER_SERVICE, serviceUrl, authnRequest.isForceAuthn(), authnRequest.isPassive());
    final String urlToRedirectTo = buildRedirectUrlByRequestedAuthnContext(initialUrl, authnRequest, request);
    LOGGER.debug("Redirecting SAML authN request to [{}]", urlToRedirectTo);
    final AuthenticationRedirectStrategy authenticationRedirectStrategy = new DefaultAuthenticationRedirectStrategy();
    authenticationRedirectStrategy.redirect(request, response, urlToRedirectTo);
}
Also used : DefaultAuthenticationRedirectStrategy(org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy) AuthnRequest(org.opensaml.saml.saml2.core.AuthnRequest) DefaultAuthenticationRedirectStrategy(org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy) AuthenticationRedirectStrategy(org.jasig.cas.client.authentication.AuthenticationRedirectStrategy)

Example 2 with DefaultAuthenticationRedirectStrategy

use of org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy in project cas by apereo.

the class WSFederationValidateRequestController method redirectToIdentityProvider.

private void redirectToIdentityProvider(final WSFederationRequest fedRequest, final HttpServletResponse response, final HttpServletRequest request, final WSFederationRegisteredService service) {
    try {
        final String serviceUrl = constructServiceUrl(request, response, fedRequest);
        LOGGER.debug("Created service url [{}] mapped to [{}]", serviceUrl, service);
        final boolean renew = shouldRenewAuthentication(fedRequest, request);
        final String initialUrl = CommonUtils.constructRedirectUrl(casProperties.getServer().getLoginUrl(), CasProtocolConstants.PARAMETER_SERVICE, serviceUrl, renew, false);
        LOGGER.debug("Redirecting authN request to [{}]", initialUrl);
        final AuthenticationRedirectStrategy authenticationRedirectStrategy = new DefaultAuthenticationRedirectStrategy();
        authenticationRedirectStrategy.redirect(request, response, initialUrl);
    } catch (final Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : DefaultAuthenticationRedirectStrategy(org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy) DefaultAuthenticationRedirectStrategy(org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy) AuthenticationRedirectStrategy(org.jasig.cas.client.authentication.AuthenticationRedirectStrategy) UnauthorizedAuthenticationException(org.apereo.cas.authentication.adaptive.UnauthorizedAuthenticationException)

Example 3 with DefaultAuthenticationRedirectStrategy

use of org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy in project cas by apereo.

the class WSFederationValidateRequestController method handleLogoutRequest.

private void handleLogoutRequest(final WSFederationRequest fedRequest, final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    String logoutUrl = casProperties.getServer().getLogoutUrl();
    if (StringUtils.isNotBlank(fedRequest.getWreply())) {
        final Service service = webApplicationServiceFactory.createService(fedRequest.getWreply());
        final WSFederationRegisteredService registeredService = getWsFederationRegisteredService(service);
        LOGGER.debug("Invoking logout operation for request [{}], redirecting next to [{}] matched against [{}]", fedRequest, fedRequest.getWreply(), registeredService);
        final String logoutParam = casProperties.getLogout().getRedirectParameter();
        logoutUrl = logoutUrl.concat("?").concat(logoutParam).concat("=").concat(service.getId());
    }
    final AuthenticationRedirectStrategy authenticationRedirectStrategy = new DefaultAuthenticationRedirectStrategy();
    authenticationRedirectStrategy.redirect(request, response, logoutUrl);
}
Also used : DefaultAuthenticationRedirectStrategy(org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy) DefaultAuthenticationRedirectStrategy(org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy) AuthenticationRedirectStrategy(org.jasig.cas.client.authentication.AuthenticationRedirectStrategy) WSFederationRegisteredService(org.apereo.cas.ws.idp.services.WSFederationRegisteredService) WebApplicationService(org.apereo.cas.authentication.principal.WebApplicationService) WSFederationRegisteredService(org.apereo.cas.ws.idp.services.WSFederationRegisteredService) Service(org.apereo.cas.authentication.principal.Service)

Aggregations

AuthenticationRedirectStrategy (org.jasig.cas.client.authentication.AuthenticationRedirectStrategy)3 DefaultAuthenticationRedirectStrategy (org.jasig.cas.client.authentication.DefaultAuthenticationRedirectStrategy)3 UnauthorizedAuthenticationException (org.apereo.cas.authentication.adaptive.UnauthorizedAuthenticationException)1 Service (org.apereo.cas.authentication.principal.Service)1 WebApplicationService (org.apereo.cas.authentication.principal.WebApplicationService)1 WSFederationRegisteredService (org.apereo.cas.ws.idp.services.WSFederationRegisteredService)1 AuthnRequest (org.opensaml.saml.saml2.core.AuthnRequest)1