Search in sources :

Example 6 with SimpleUrlAuthenticationSuccessHandler

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

the class SwitchUserFilter method afterPropertiesSet.

// ~ Methods
// ========================================================================================================
@Override
public void afterPropertiesSet() {
    Assert.notNull(this.userDetailsService, "userDetailsService must be specified");
    Assert.isTrue(this.successHandler != null || this.targetUrl != null, "You must set either a successHandler or the targetUrl");
    if (this.targetUrl != null) {
        Assert.isNull(this.successHandler, "You cannot set both successHandler and targetUrl");
        this.successHandler = new SimpleUrlAuthenticationSuccessHandler(this.targetUrl);
    }
    if (this.failureHandler == null) {
        this.failureHandler = this.switchFailureUrl == null ? new SimpleUrlAuthenticationFailureHandler() : new SimpleUrlAuthenticationFailureHandler(this.switchFailureUrl);
    } else {
        Assert.isNull(this.switchFailureUrl, "You cannot set both a switchFailureUrl and a failureHandler");
    }
}
Also used : SimpleUrlAuthenticationSuccessHandler(org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler) SimpleUrlAuthenticationFailureHandler(org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler)

Aggregations

SimpleUrlAuthenticationSuccessHandler (org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler)6 FilterChain (javax.servlet.FilterChain)5 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)5 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)5 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)3 Authentication (org.springframework.security.core.Authentication)2 AuthenticationManager (org.springframework.security.authentication.AuthenticationManager)1 GrantedAuthority (org.springframework.security.core.GrantedAuthority)1 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)1 User (org.springframework.security.core.userdetails.User)1 UserDetails (org.springframework.security.core.userdetails.UserDetails)1 DefaultRedirectStrategy (org.springframework.security.web.DefaultRedirectStrategy)1 SimpleUrlAuthenticationFailureHandler (org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler)1