Example usage for org.springframework.security.web.authentication AbstractAuthenticationProcessingFilter setAuthenticationSuccessHandler

List of usage examples for org.springframework.security.web.authentication AbstractAuthenticationProcessingFilter setAuthenticationSuccessHandler

Introduction

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

Prototype

public void setAuthenticationSuccessHandler(AuthenticationSuccessHandler successHandler) 

Source Link

Document

Sets the strategy used to handle a successful authentication.

Usage

From source file:org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilterTests.java

@Test
public void testStartupDetectsInvalidAuthenticationManager() throws Exception {
    AbstractAuthenticationProcessingFilter filter = new MockAuthenticationFilter();
    filter.setAuthenticationFailureHandler(failureHandler);
    successHandler.setDefaultTargetUrl("/");
    filter.setAuthenticationSuccessHandler(successHandler);
    filter.setFilterProcessesUrl("/login");

    try {/*from  ww  w .  jav a  2 s. c om*/
        filter.afterPropertiesSet();
        fail("Should have thrown IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
        assertThat(expected.getMessage()).isEqualTo("authenticationManager must be specified");
    }
}

From source file:org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilterTests.java

@Test
public void testStartupDetectsInvalidFilterProcessesUrl() throws Exception {
    AbstractAuthenticationProcessingFilter filter = new MockAuthenticationFilter();
    filter.setAuthenticationFailureHandler(failureHandler);
    filter.setAuthenticationManager(mock(AuthenticationManager.class));
    filter.setAuthenticationSuccessHandler(successHandler);

    try {/*from   w  w w .j  av a  2  s .  c o  m*/
        filter.setFilterProcessesUrl(null);
        fail("Should have thrown IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
        assertThat(expected.getMessage()).isEqualTo("Pattern cannot be null or empty");
    }
}