Search in sources :

Example 1 with RedirectAction

use of org.pac4j.core.redirect.RedirectAction in project cas by apereo.

the class SAML2ClientLogoutAction method doExecute.

@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
    try {
        final HttpServletRequest request = WebUtils.getHttpServletRequest(requestContext);
        final HttpServletResponse response = WebUtils.getHttpServletResponse(requestContext);
        final J2EContext context = WebUtils.getPac4jJ2EContext(request, response);
        final SAML2Client client = clients.findClient(SAML2Client.class);
        if (client != null) {
            LOGGER.debug("Located SAML2 client [{}]", client);
            final RedirectAction action = client.getLogoutAction(context, null, null);
            LOGGER.debug("Preparing logout message to send is [{}]", action.getLocation());
            action.perform(context);
        }
    } catch (final Exception e) {
        LOGGER.warn(e.getMessage(), e);
    }
    return null;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) SAML2Client(org.pac4j.saml.client.SAML2Client) J2EContext(org.pac4j.core.context.J2EContext) RedirectAction(org.pac4j.core.redirect.RedirectAction)

Example 2 with RedirectAction

use of org.pac4j.core.redirect.RedirectAction in project cas by apereo.

the class OidcCasClientRedirectActionBuilder method build.

@Override
public RedirectAction build(final CasClient casClient, final WebContext context) {
    final Optional<Authentication> auth = oidcAuthorizationRequestSupport.isCasAuthenticationAvailable(context);
    auth.ifPresent(authentication -> oidcAuthorizationRequestSupport.configureClientForMaxAgeAuthorizationRequest(casClient, context, authentication));
    OidcAuthorizationRequestSupport.configureClientForPromptLoginAuthorizationRequest(casClient, context);
    OidcAuthorizationRequestSupport.configureClientForPromptNoneAuthorizationRequest(casClient, context);
    final RedirectAction action = super.build(casClient, context);
    LOGGER.debug("Final redirect action is [{}]", action);
    return action;
}
Also used : Authentication(org.apereo.cas.authentication.Authentication) RedirectAction(org.pac4j.core.redirect.RedirectAction)

Aggregations

RedirectAction (org.pac4j.core.redirect.RedirectAction)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Authentication (org.apereo.cas.authentication.Authentication)1 J2EContext (org.pac4j.core.context.J2EContext)1 SAML2Client (org.pac4j.saml.client.SAML2Client)1