Search in sources :

Example 1 with LogoutSuccessHandler

use of org.springframework.security.web.authentication.logout.LogoutSuccessHandler in project kylo by Teradata.

the class CompositeLogoutSuccessHandler method onLogoutSuccess.

/* (non-Javadoc)
     * @see org.springframework.security.web.authentication.logout.LogoutSuccessHandler#onLogoutSuccess(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, org.springframework.security.core.Authentication)
     */
@Override
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
    IOException ioe = null;
    ServletException se = null;
    RuntimeException re = null;
    // Ensure all componentHandlers get called even though there is an exception thrown;
    for (LogoutSuccessHandler handler : this.componentHandlers) {
        try {
            handler.onLogoutSuccess(request, response, authentication);
        } catch (IOException e) {
            log.error("IOException thrown by a LogoutSuccessHandler after logout", e);
            if (ioe != null)
                ioe = e;
        } catch (ServletException e) {
            log.error("ServletException thrown by a LogoutSuccessHandler after logout", e);
            if (se != null)
                se = e;
        } catch (RuntimeException e) {
            log.error("RuntimeException thrown by a LogoutSuccessHandler after logout", e);
            if (re != null)
                re = e;
        }
    }
    // Throw one of the exceptions if any occurred.
    if (ioe != null)
        throw ioe;
    if (se != null)
        throw se;
    if (re != null)
        throw re;
}
Also used : ServletException(javax.servlet.ServletException) IOException(java.io.IOException) SimpleUrlLogoutSuccessHandler(org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler) LogoutSuccessHandler(org.springframework.security.web.authentication.logout.LogoutSuccessHandler)

Example 2 with LogoutSuccessHandler

use of org.springframework.security.web.authentication.logout.LogoutSuccessHandler in project spring-security by spring-projects.

the class LogoutConfigurer method getLogoutSuccessHandler.

/**
 * Gets the {@link LogoutSuccessHandler} if not null, otherwise creates a new
 * {@link SimpleUrlLogoutSuccessHandler} using the {@link #logoutSuccessUrl(String)}.
 * @return the {@link LogoutSuccessHandler} to use
 */
public LogoutSuccessHandler getLogoutSuccessHandler() {
    LogoutSuccessHandler handler = this.logoutSuccessHandler;
    if (handler == null) {
        handler = createDefaultSuccessHandler();
        this.logoutSuccessHandler = handler;
    }
    return handler;
}
Also used : SimpleUrlLogoutSuccessHandler(org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler) DelegatingLogoutSuccessHandler(org.springframework.security.web.authentication.logout.DelegatingLogoutSuccessHandler) LogoutSuccessHandler(org.springframework.security.web.authentication.logout.LogoutSuccessHandler)

Example 3 with LogoutSuccessHandler

use of org.springframework.security.web.authentication.logout.LogoutSuccessHandler in project spring-security by spring-projects.

the class Saml2LogoutConfigurerTests method saml2LogoutWhenCsrfDisabledAndNoAuthenticationThenFinalRedirect.

@Test
public void saml2LogoutWhenCsrfDisabledAndNoAuthenticationThenFinalRedirect() throws Exception {
    this.spring.register(Saml2LogoutCsrfDisabledConfig.class).autowire();
    this.mvc.perform(post("/logout"));
    LogoutSuccessHandler logoutSuccessHandler = this.spring.getContext().getBean(LogoutSuccessHandler.class);
    verify(logoutSuccessHandler).onLogoutSuccess(any(), any(), any());
}
Also used : LogoutSuccessHandler(org.springframework.security.web.authentication.logout.LogoutSuccessHandler) Test(org.junit.jupiter.api.Test)

Aggregations

LogoutSuccessHandler (org.springframework.security.web.authentication.logout.LogoutSuccessHandler)3 SimpleUrlLogoutSuccessHandler (org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler)2 IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1 Test (org.junit.jupiter.api.Test)1 DelegatingLogoutSuccessHandler (org.springframework.security.web.authentication.logout.DelegatingLogoutSuccessHandler)1