Example usage for org.springframework.security.web.authentication SimpleUrlAuthenticationSuccessHandler setUseReferer

List of usage examples for org.springframework.security.web.authentication SimpleUrlAuthenticationSuccessHandler setUseReferer

Introduction

In this page you can find the example usage for org.springframework.security.web.authentication SimpleUrlAuthenticationSuccessHandler setUseReferer.

Prototype

public void setUseReferer(boolean useReferer) 

Source Link

Document

If set to true the Referer header will be used (if available).

Usage

From source file:cn.edu.zjnu.acm.judge.config.SecurityConfiguration.java

@Override
protected void configure(HttpSecurity http) throws Exception {
    SimpleUrlAuthenticationSuccessHandler simpleUrlAuthenticationSuccessHandler = new JudgeAuthenticationSuccessHandler(
            "/");
    simpleUrlAuthenticationSuccessHandler.setUseReferer(false);
    simpleUrlAuthenticationSuccessHandler.setTargetUrlParameter("url");
    DefaultRedirectStrategy defaultRedirectStrategy = new DefaultRedirectStrategy();

    simpleUrlAuthenticationSuccessHandler.setRedirectStrategy(defaultRedirectStrategy);

    SimpleUrlLogoutSuccessHandler simpleUrlLogoutSuccessHandler = new SimpleUrlLogoutSuccessHandler();
    simpleUrlLogoutSuccessHandler.setUseReferer(true);

    // @formatter:off
    http.authorizeRequests().antMatchers(ckfinder.getServlet().getPath()).hasAnyRole("ADMIN").and().csrf()
            .disable().exceptionHandling().authenticationEntryPoint(authenticationEntryPoint()).and()
            .formLogin().loginPage("/login").usernameParameter("user_id1").passwordParameter("password1")
            .successHandler(simpleUrlAuthenticationSuccessHandler).failureHandler(failureHandler()).permitAll()
            .and().headers().cacheControl().disable().httpStrictTransportSecurity().disable().frameOptions()
            .sameOrigin().and().logout().logoutUrl("/logout")
            .logoutSuccessHandler(simpleUrlLogoutSuccessHandler).permitAll().and().rememberMe()
            .rememberMeParameter("rememberMe").tokenRepository(persistentTokenRepository).and().requestCache()
            .requestCache(new NullRequestCache()).and().servletApi();
    // @formatter:on
}