Examples of AuthenticationFailureHandler


Examples of org.springframework.security.web.authentication.AuthenticationFailureHandler

    public void strategyFailureInvokesFailureHandler() throws Exception {
        SecurityContextRepository repo = mock(SecurityContextRepository.class);
        // repo will return false to containsContext()
        SessionAuthenticationStrategy strategy = mock(SessionAuthenticationStrategy.class);

        AuthenticationFailureHandler failureHandler = mock(AuthenticationFailureHandler.class);
        SessionManagementFilter filter = new SessionManagementFilter(repo);
        filter.setAuthenticationFailureHandler(failureHandler);
        filter.setSessionAuthenticationStrategy(strategy);
        HttpServletRequest request = new MockHttpServletRequest();
        HttpServletResponse response = new MockHttpServletResponse();
View Full Code Here

Examples of org.springframework.security.web.authentication.AuthenticationFailureHandler

  @Test
  public void filterUsesConfiguredFailureHandler() throws Exception {
    final Field failureHandlerField = AbstractAuthenticationProcessingFilter.class.getDeclaredField("failureHandler");
    ReflectionUtils.makeAccessible(failureHandlerField);
    AuthenticationFailureHandler failureHandler = (AuthenticationFailureHandler) ReflectionUtils.getField(failureHandlerField, filter);
    assertTrue("failure handler should be a simpleUrlFailureHandler", failureHandler instanceof SimpleUrlAuthenticationFailureHandler);

    final Field failureUrlField = SimpleUrlAuthenticationFailureHandler.class.getDeclaredField("defaultFailureUrl");
    ReflectionUtils.makeAccessible(failureUrlField);
    String failureUrl = (String) ReflectionUtils.getField(failureUrlField, failureHandler);
View Full Code Here

Examples of org.springframework.security.web.authentication.AuthenticationFailureHandler

  }

  @Override
  public void afterPropertiesSet() {
    super.afterPropertiesSet();
    setAuthenticationFailureHandler(new AuthenticationFailureHandler() {
      public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
          AuthenticationException exception) throws IOException, ServletException {
        if (exception instanceof BadCredentialsException) {
          exception = new BadCredentialsException(exception.getMessage(), new BadClientCredentialsException());
        }
View Full Code Here

Examples of org.springframework.security.web.authentication.AuthenticationFailureHandler

      throw new IllegalStateException("can't set alwaysUsePostLoginUrl on unknown successHandler, type is " + successHandler.getClass().getName());
    }
  }
 
  public void setPostFailureUrl(String postFailureUrl) {
    AuthenticationFailureHandler failureHandler = getFailureHandler();
    if (failureHandler instanceof SimpleUrlAuthenticationFailureHandler) {
      SimpleUrlAuthenticationFailureHandler h = (SimpleUrlAuthenticationFailureHandler) failureHandler;
      h.setDefaultFailureUrl(postFailureUrl);
    } else {
      throw new IllegalStateException("can't set postFailureUrl on unknown failureHandler, type is " + failureHandler.getClass().getName());
    }
  }
View Full Code Here

Examples of org.springframework.security.web.authentication.AuthenticationFailureHandler

      throw new IllegalStateException("can't set alwaysUsePostLoginUrl on unknown successHandler, type is " + successHandler.getClass().getName());
    }
  }
 
  public void setPostFailureUrl(String postFailureUrl) {
    AuthenticationFailureHandler failureHandler = getFailureHandler();
    if (failureHandler instanceof SimpleUrlAuthenticationFailureHandler) {
      SimpleUrlAuthenticationFailureHandler h = (SimpleUrlAuthenticationFailureHandler) failureHandler;
      h.setDefaultFailureUrl(postFailureUrl);
    } else {
      throw new IllegalStateException("can't set postFailureUrl on unknown failureHandler, type is " + failureHandler.getClass().getName());
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.