org.springframework.security.web.authentication.logout.LogoutSuccessHandler Java Examples

The following examples show how to use org.springframework.security.web.authentication.logout.LogoutSuccessHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebSecurityConfig.java    From spring-security with Apache License 2.0 6 votes vote down vote up
@Bean
public LogoutSuccessHandler logoutSuccessHandler() {
    return new LogoutSuccessHandler() {
        /**
         * 处理登出成功的请求
         *
         * @param httpServletRequest
         * @param httpServletResponse
         * @param authentication
         * @throws IOException
         * @throws ServletException
         */
        @Override
        public void onLogoutSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
            httpServletResponse.setContentType("application/json;charset=utf-8");
            PrintWriter out = httpServletResponse.getWriter();
            out.write("{\"status\":\"success\",\"msg\":\"登出成功\"}");
            out.flush();
            out.close();
        }
    };
}
 
Example #2
Source File: WebSecurityConfig.java    From spring-security with Apache License 2.0 6 votes vote down vote up
@Bean
public LogoutSuccessHandler logoutSuccessHandler() {
    return new LogoutSuccessHandler() {
        /**
         * 处理登出成功的请求
         *
         * @param httpServletRequest
         * @param httpServletResponse
         * @param authentication
         * @throws IOException
         * @throws ServletException
         */
        @Override
        public void onLogoutSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
            httpServletResponse.setContentType("application/json;charset=utf-8");
            PrintWriter out = httpServletResponse.getWriter();
            out.write("{\"status\":\"success\",\"msg\":\"登出成功\"}");
            out.flush();
            out.close();
        }
    };
}
 
Example #3
Source File: WebSecurityConfig.java    From spring-security with Apache License 2.0 6 votes vote down vote up
@Bean
public LogoutSuccessHandler logoutSuccessHandler() {
    return new LogoutSuccessHandler() {
        /**
         * 处理登出成功的请求
         *
         * @param httpServletRequest
         * @param httpServletResponse
         * @param authentication
         * @throws IOException
         * @throws ServletException
         */
        @Override
        public void onLogoutSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
            httpServletResponse.setContentType("application/json;charset=utf-8");
            PrintWriter out = httpServletResponse.getWriter();
            out.write("{\"status\":\"success\",\"msg\":\"登出成功\"}");
            out.flush();
            out.close();
        }
    };
}
 
Example #4
Source File: SecurityConfig.java    From pizzeria with MIT License 6 votes vote down vote up
@Bean
public LogoutSuccessHandler logoutSuccessHandler() {
    ContentNegotiationStrategy contentNegotiationStrategy = new HeaderContentNegotiationStrategy();

    MediaTypeRequestMatcher jsonMediaTypeRequestMatcher = new MediaTypeRequestMatcher(contentNegotiationStrategy, MediaType.APPLICATION_JSON);
    jsonMediaTypeRequestMatcher.setUseEquals(true);

    LinkedHashMap<RequestMatcher, LogoutSuccessHandler> matcherToHandler = new LinkedHashMap<>();
    matcherToHandler.put(jsonMediaTypeRequestMatcher, new HttpStatusReturningLogoutSuccessHandler());

    DelegatingLogoutSuccessHandler delegatingLogoutSuccessHandler = new DelegatingLogoutSuccessHandler(matcherToHandler);

    SimpleUrlLogoutSuccessHandler simpleUrlLogoutSuccessHandler = new SimpleUrlLogoutSuccessHandler();
    simpleUrlLogoutSuccessHandler.setUseReferer(true);
    simpleUrlLogoutSuccessHandler.setDefaultTargetUrl("/");

    delegatingLogoutSuccessHandler.setDefaultLogoutSuccessHandler(simpleUrlLogoutSuccessHandler);

    return delegatingLogoutSuccessHandler;
}
 
Example #5
Source File: HodSecurity.java    From find with MIT License 6 votes vote down vote up
@SuppressWarnings("ProhibitedExceptionDeclared")
@Override
protected void configure(final HttpSecurity http) throws Exception {
    final AuthenticationEntryPoint ssoEntryPoint = new SsoAuthenticationEntryPoint(SsoController.SSO_PAGE);

    final SsoAuthenticationFilter<?> ssoAuthenticationFilter = new SsoAuthenticationFilter<>(SsoController.SSO_AUTHENTICATION_URI, EntityType.CombinedSso.INSTANCE);
    ssoAuthenticationFilter.setAuthenticationManager(authenticationManager());

    final LogoutSuccessHandler logoutSuccessHandler = new HodTokenLogoutSuccessHandler(SsoController.SSO_LOGOUT_PAGE, tokenRepository);

    http.regexMatcher("/public(/.*)?|/sso|/authenticate-sso|/api/authentication/.*|/logout")
        .csrf()
            .disable()
        .exceptionHandling()
            .authenticationEntryPoint(ssoEntryPoint)
            .accessDeniedPage(DispatcherServletConfiguration.AUTHENTICATION_ERROR_PATH)
            .and()
        .authorizeRequests()
            .antMatchers(FindController.APP_PATH + "/**").hasRole(FindRole.USER.name())
            .and()
        .logout()
            .logoutSuccessHandler(logoutSuccessHandler)
            .and()
        .addFilterAfter(ssoAuthenticationFilter, AbstractPreAuthenticatedProcessingFilter.class);
}
 
Example #6
Source File: SecurityAutoConfiguration.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @return {@link LogoutSuccessHandler} bean
 */
@Bean
@ConditionalOnMissingBean
public LogoutSuccessHandler logoutSuccessHandler() {
    final SimpleUrlLogoutSuccessHandler simpleUrlLogoutSuccessHandler = new SimpleUrlLogoutSuccessHandler();
    simpleUrlLogoutSuccessHandler.setTargetUrlParameter("login");
    return simpleUrlLogoutSuccessHandler;
}
 
Example #7
Source File: SecurityConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public LogoutSuccessHandler logoutSuccessHandler() {
    return new CustomLogoutSuccessHandler();
}
 
Example #8
Source File: SecSecurityConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public LogoutSuccessHandler logoutSuccessHandler() {
    return new CustomLogoutSuccessHandler();
}
 
Example #9
Source File: ChannelSecSecurityConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public LogoutSuccessHandler logoutSuccessHandler() {
    return new CustomLogoutSuccessHandler();
}
 
Example #10
Source File: AuthConfig.java    From tutorials with MIT License 4 votes vote down vote up
@Bean
public LogoutSuccessHandler logoutSuccessHandler() {
    return new LogoutController();
}
 
Example #11
Source File: FederationLogoutFilter.java    From cxf-fediz with Apache License 2.0 4 votes vote down vote up
public FederationLogoutFilter(LogoutSuccessHandler logoutSuccessHandler, LogoutHandler... handlers) {
    super(logoutSuccessHandler, handlers);
}
 
Example #12
Source File: OidcUserManagementAutoConfiguration.java    From hawkbit with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @return the logout success handler for OpenID Connect
 */
@Bean
public LogoutSuccessHandler oidcLogoutSuccessHandler() {
    return new OidcLogoutSuccessHandler();
}
 
Example #13
Source File: SecurityConfiguration.java    From secure-rest-spring-tut with MIT License 4 votes vote down vote up
@Bean
public LogoutSuccessHandler logoutSuccessHandler() {
	return new RESTLogoutSuccessHandler();
}
 
Example #14
Source File: AppConfig.java    From auth0-spring-security-mvc-sample with MIT License 4 votes vote down vote up
@Bean
public LogoutSuccessHandler logoutSuccessHandler() {
    return new LogoutController();
}
 
Example #15
Source File: OpenApiSecurityConfigurer.java    From spring-backend-boilerplate with Apache License 2.0 4 votes vote down vote up
@Bean
public LogoutSuccessHandler logoutSuccessHandlerImpl() {
    return new LogoutSuccessHandlerRestImpl();
}
 
Example #16
Source File: SecurityConfiguration.java    From api-layer with Eclipse Public License 2.0 4 votes vote down vote up
@Bean
public LogoutSuccessHandler logoutSuccessHandler() {
    return new ApiCatalogLogoutSuccessHandler(authConfigurationProperties);
}
 
Example #17
Source File: WebSecurityBeanConfig.java    From webauthn4j-spring-security with Apache License 2.0 4 votes vote down vote up
@Bean
public LogoutSuccessHandler logoutSuccessHandler() {
    return new ForwardLogoutSuccessHandler("/api/status/200");
}
 
Example #18
Source File: WebSecurityBeanConfig.java    From webauthn4j-spring-security with Apache License 2.0 4 votes vote down vote up
@Bean
public LogoutSuccessHandler logoutSuccessHandler() {
    return new ForwardLogoutSuccessHandler("/api/status/200");
}
 
Example #19
Source File: SsoWebSecurityConfig.java    From syhthems-platform with MIT License 4 votes vote down vote up
@Bean
public LogoutSuccessHandler ssoCustomLogoutSuccessHandler() {
    return new CustomLogoutSuccessHandler();
}
 
Example #20
Source File: LogoutConfigurer.java    From spring-boot-security-saml with MIT License 2 votes vote down vote up
/**
 * Handler to be invoked upon successful logout. Overrides value set by {@link #defaultTargetURL(String)}.
 *
 * @param handler the handler to invoke upon successful logout.
 * @return this configurer for further customization
 */
public LogoutConfigurer successHandler(LogoutSuccessHandler handler) {
    successHandler = handler;
    return this;
}
 
Example #21
Source File: PcAuthorizationServerConfig.java    From paascloud-master with Apache License 2.0 2 votes vote down vote up
/**
 * 退出时的处理策略配置
 *
 * @return logout success handler
 */
@Bean
public LogoutSuccessHandler logoutSuccessHandler() {
	return new PcLogoutSuccessHandler();
}