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

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

Introduction

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

Prototype

public void setAuthenticationFailureHandler(AuthenticationFailureHandler failureHandler) 

Source Link

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 w w w  .ja  va 2  s . c o m
        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.jav  a2  s.  co m*/
        filter.setFilterProcessesUrl(null);
        fail("Should have thrown IllegalArgumentException");
    } catch (IllegalArgumentException expected) {
        assertThat(expected.getMessage()).isEqualTo("Pattern cannot be null or empty");
    }
}