Java 类org.springframework.security.web.authentication.AuthenticationFailureHandler 实例源码

项目:hotel_shop    文件:SecurityConfig.java   
public AuthenticationFailureHandler failureLogin(){
    AuthenticationFailureHandler handler = new AuthenticationFailureHandler() {

        @Override
        public void onAuthenticationFailure(HttpServletRequest arg0,
                HttpServletResponse arg1, AuthenticationException arg2)
                throws IOException, ServletException {

            System.out.println("SecurityConfig.failureLogin()#httpservletrequest\n"
                    + ReflectionToStringBuilder.toString(arg0, ToStringStyle.SIMPLE_STYLE)
                    + "\n----------------"
                    + "\ngetQueryString: " + arg0.getQueryString()
                    + "\ngetRequestURI: " + arg0.getRequestURI()
                    + "\ngetServletPath: " + arg0.getServletPath()
                    + "\ngetRequestURL: " + arg0.getRequestURL()
                    + "\n\n"
            );

             arg1.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
             arg1.sendRedirect("login");  

        }
    }; 

    return handler;
}
项目:users-service    文件:JwtTokenAuthenticationProcessingFilter.java   
public JwtTokenAuthenticationProcessingFilter(
    AuthenticationFailureHandler failureHandler,
    TokenExtractor tokenExtractor,
    RequestMatcher matcher) {

    super(matcher);
    this.failureHandler = failureHandler;
    this.tokenExtractor = tokenExtractor;
}
项目:sns-todo    文件:FormLoginSecurityConfig.java   
@Bean
public AuthenticationFailureHandler authenticationFailureHandler() {
    ExceptionMappingAuthenticationFailureHandler failureHandler = new ExceptionMappingAuthenticationFailureHandler();
    Map<String, String> failureUrlMap = new HashMap<>();
    failureUrlMap.put(BadCredentialsException.class.getName(), LoginAuthenticationFailureHandler.PASS_ERROR_URL);
    failureUrlMap.put(CaptchaException.class.getName(), LoginAuthenticationFailureHandler.CODE_ERROR_URL);
    failureUrlMap.put(AccountExpiredException.class.getName(), LoginAuthenticationFailureHandler.EXPIRED_URL);
    failureUrlMap.put(LockedException.class.getName(), LoginAuthenticationFailureHandler.LOCKED_URL);
    failureUrlMap.put(DisabledException.class.getName(), LoginAuthenticationFailureHandler.DISABLED_URL);
    failureHandler.setExceptionMappings(failureUrlMap);
    return failureHandler;
}
项目:kinota-server    文件:AgentLoginProcessingFilter.java   
public AgentLoginProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
                      AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
    super(defaultProcessUrl);
    this.successHandler = successHandler;
    this.failureHandler = failureHandler;
    this.objectMapper = mapper;
}
项目:kinota-server    文件:JwtTokenAuthenticationProcessingFilter.java   
@Autowired
public JwtTokenAuthenticationProcessingFilter(RequestMatcher matcher, AuthenticationFailureHandler failureHandler,
                                              JwtTokenUtil jwtTokenUtil) {
    super(matcher);
    this.failureHandler = failureHandler;
    this.jwtTokenUtil = jwtTokenUtil;
}
项目:DiscussionPortal    文件:AuthenticationHandler.java   
protected AuthenticationFailureHandler failureHandler() {
    return new AuthenticationFailureHandler() {
        @Override
        public void onAuthenticationFailure(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
            httpServletResponse.getWriter().append("Authentication failure");
            httpServletResponse.setStatus(401);
        }
    };
}
项目:OpenLRW    文件:AjaxLoginProcessingFilter.java   
public AjaxLoginProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler, 
        AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
    super(defaultProcessUrl);
    this.successHandler = successHandler;
    this.failureHandler = failureHandler;
    this.objectMapper = mapper;
}
项目:OpenLRW    文件:JwtTokenAuthenticationProcessingFilter.java   
@Autowired
public JwtTokenAuthenticationProcessingFilter(AuthenticationFailureHandler failureHandler, 
        TokenExtractor tokenExtractor, RequestMatcher matcher) {
    super(matcher);
    this.failureHandler = failureHandler;
    this.tokenExtractor = tokenExtractor;
}
项目:OpenLRW    文件:AdminUserProcessingFilter.java   
public AdminUserProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
    AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
  super(defaultProcessUrl);
  this.successHandler = successHandler;
  this.failureHandler = failureHandler;
  this.objectMapper = mapper;
}
项目:infotaf    文件:AjaxLoginProcessingFilter.java   
public AjaxLoginProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler, 
        AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
    super(defaultProcessUrl);
    this.successHandler = successHandler;
    this.failureHandler = failureHandler;
    this.objectMapper = mapper;
}
项目:infotaf    文件:JwtTokenAuthenticationProcessingFilter.java   
@Autowired
public JwtTokenAuthenticationProcessingFilter(AuthenticationFailureHandler failureHandler, 
        TokenExtractor tokenExtractor, RequestMatcher matcher) {
    super(matcher);
    this.failureHandler = failureHandler;
    this.tokenExtractor = tokenExtractor;
}
项目:iotplatform    文件:RefreshTokenProcessingFilter.java   
public RefreshTokenProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
    AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
  super(defaultProcessUrl);
  this.successHandler = successHandler;
  this.failureHandler = failureHandler;
  this.objectMapper = mapper;
}
项目:iotplatform    文件:JwtTokenAuthenticationProcessingFilter.java   
@Autowired
public JwtTokenAuthenticationProcessingFilter(AuthenticationFailureHandler failureHandler,
    TokenExtractor tokenExtractor, RequestMatcher matcher) {
  super(matcher);
  this.failureHandler = failureHandler;
  this.tokenExtractor = tokenExtractor;
}
项目:iotplatform    文件:RestPublicLoginProcessingFilter.java   
public RestPublicLoginProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
    AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
  super(defaultProcessUrl);
  this.successHandler = successHandler;
  this.failureHandler = failureHandler;
  this.objectMapper = mapper;
}
项目:iotplatform    文件:RestLoginProcessingFilter.java   
public RestLoginProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
    AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
  super(defaultProcessUrl);
  this.successHandler = successHandler;
  this.failureHandler = failureHandler;
  this.objectMapper = mapper;
}
项目:oma-riista-web    文件:OneTimePasswordFilterConfigurer.java   
public OneTimePasswordFilterConfigurer(final String loginProcessingUrl,
                                       AuthenticationSuccessHandler successHandler,
                                       AuthenticationFailureHandler failureHandler,
                                       AuthenticationEntryPoint entryPoint) {
    this.authFilter = new OneTimePasswordAuthenticationFilter(loginProcessingUrl);
    this.authFilter.setRequiresAuthenticationRequestMatcher(new AntPathRequestMatcher(loginProcessingUrl, "POST"));
    this.authFilter.setAuthenticationSuccessHandler(successHandler);
    this.authFilter.setAuthenticationFailureHandler(failureHandler);
    this.authFilter.setAllowSessionCreation(true);
    this.authenticationEntryPoint = entryPoint;
}
项目:thingsboard    文件:RefreshTokenProcessingFilter.java   
public RefreshTokenProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
                                    AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
    super(defaultProcessUrl);
    this.successHandler = successHandler;
    this.failureHandler = failureHandler;
    this.objectMapper = mapper;
}
项目:thingsboard    文件:JwtTokenAuthenticationProcessingFilter.java   
@Autowired
public JwtTokenAuthenticationProcessingFilter(AuthenticationFailureHandler failureHandler,
                                              TokenExtractor tokenExtractor, RequestMatcher matcher) {
    super(matcher);
    this.failureHandler = failureHandler;
    this.tokenExtractor = tokenExtractor;
}
项目:thingsboard    文件:RestPublicLoginProcessingFilter.java   
public RestPublicLoginProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
                                 AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
    super(defaultProcessUrl);
    this.successHandler = successHandler;
    this.failureHandler = failureHandler;
    this.objectMapper = mapper;
}
项目:thingsboard    文件:RestLoginProcessingFilter.java   
public RestLoginProcessingFilter(String defaultProcessUrl, AuthenticationSuccessHandler successHandler,
                                 AuthenticationFailureHandler failureHandler, ObjectMapper mapper) {
    super(defaultProcessUrl);
    this.successHandler = successHandler;
    this.failureHandler = failureHandler;
    this.objectMapper = mapper;
}
项目:stateless-rest-jwtcookie-demo    文件:SecurityInternalConfig.java   
/**
 * Failed login handler, returning a 401 code instead of a login page
 *
 * @return
 */
@Bean
public AuthenticationFailureHandler failureHandler() {
    return new SimpleUrlAuthenticationFailureHandler() {
        @Override
        public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
            LOG.warn("LOGIN >>> authentication failure");
            response.sendError(HttpServletResponse.SC_UNAUTHORIZED, exception.getMessage());
        }
    };
}
项目:music-for-all-application    文件:SecurityConfig.java   
@Bean
public AuthenticationFailureHandler failureHandler() {

    final CustomAuthenticationFailureHandler authFailureHandler =
            new CustomAuthenticationFailureHandler();
    authFailureHandler.setDefaultFailureUrl("/welcome?error");
    return authFailureHandler;
}
项目:recaptcha-spring-boot-starter    文件:RecaptchaAuthenticationFilter.java   
@Override
public void setAuthenticationFailureHandler(AuthenticationFailureHandler failureHandler) {
    if (!LoginFailuresCountingHandler.class.isAssignableFrom(failureHandler.getClass())) {
        throw new IllegalArgumentException("Invalid login failure handler. Handler must be an instance of " + LoginFailuresCountingHandler.class.getName() + " but is " + failureHandler);
    }
    super.setAuthenticationFailureHandler(failureHandler);
}
项目:eHMP    文件:AjaxAuthenticationFailureHandlerTests.java   
@Before
public void setUp() throws Exception {
    mockRequest = new MockHttpServletRequest();
    mockRequest.addHeader("X-Requested-With", "XMLHttpRequest");

    mockResponse = new MockHttpServletResponse();

    delegateFailureHandler = mock(AuthenticationFailureHandler.class);

    ajaxAuthenticationFailureHandler = new AjaxAuthenticationFailureHandler(delegateFailureHandler);
}
项目:eHMP    文件:CprsSsoVistaAuthenticationFilterTests.java   
@Before
public void setUp() throws Exception {
    mockAuthenticationManager = mock(AuthenticationManager.class);
    mockFailureHandler = mock(AuthenticationFailureHandler.class);
    mockVistaAccountDao = mock(IVistaAccountDao.class);

    f = new CprsSsoVistaAuthenticationFilter();
    f.setFilterProcessesUrl("/welcome.jsp");
    f.setAuthenticationFailureHandler(mockFailureHandler);
    f.setAuthenticationManager(mockAuthenticationManager);
    f.setVistaAccountDao(mockVistaAccountDao);
    f.afterPropertiesSet();
}
项目:springfield    文件:UserFailureHandlerDetector.java   
@Override
public void afterPropertiesSet() throws Exception {
       try{
        Map<String,AuthenticationFailureHandler> beans = applicationContext.getBeansOfType(AuthenticationFailureHandler.class);

        for(AuthenticationFailureHandler h : beans.values()){
            if(! ClassUtils.isAssignableValue(getClass(), h)){
                this.handler = h;
                break;
            }
        }
       }catch(Exception e){
        logger.debug("", e);
       }
}
项目:glassmaker    文件:OAuth2AuthenticationProcessingFilter.java   
@Override
public void afterPropertiesSet() {
    super.afterPropertiesSet();

    ((SavedRequestAwareAuthenticationSuccessHandler) getSuccessHandler()).setAlwaysUseDefaultTargetUrl(false);

    setAuthenticationFailureHandler(new AuthenticationFailureHandler() {
        public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
            requestCache.saveRequest(request, response);
            authenticationEntryPoint.commence(request, response, exception);
        }
    });
}
项目:oauth-client-master    文件:AuthorizationServerBeanDefinitionParserTests.java   
@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);
  assertEquals("failure URL should be the configured url", "/oauth/confirm_access", failureUrl);
}
项目:loafer    文件:SecurityConfiguration.java   
@Bean
public AuthenticationFailureHandler authenticationFailureHandler() {
    return new AuthenticationFailureHandlerImpl();
}
项目:sporticus    文件:ConfigurationSecurity.java   
@Bean
public AuthenticationFailureHandler authenticationFailureHandler() {
    return new SimpleUrlAuthenticationFailureHandler();
}
项目:JenkinsHue    文件:SecurityConfiguration.java   
@Bean
public AuthenticationFailureHandler authenticationFailureHandler() {
    return (req, res, arg2) -> res.sendError(HttpServletResponse.SC_FORBIDDEN, "Access Denied");
}
项目:spring-backend-boilerplate    文件:OpenApiSecurityConfigurer.java   
@Bean
public AuthenticationFailureHandler authenticationFailureHandlerImpl() {
    return new AuthenticationFailureHandlerRestImpl();
}
项目:springuni-particles    文件:SecurityConfigurationSupport.java   
@Bean
public AuthenticationFailureHandler authenticationFailureHandler(ObjectMapper objectMapper) {
  return new DefaultAuthenticationFailureHandler(objectMapper);
}
项目:cfsummiteu2017    文件:UaaRelyingPartyFilter.java   
public AuthenticationFailureHandler getFailureHandler() {
    return failureHandler;
}
项目:cfsummiteu2017    文件:UaaRelyingPartyFilter.java   
public void setFailureHandler(AuthenticationFailureHandler failureHandler) {
    this.failureHandler = failureHandler;
}
项目:FCat    文件:WebSecurityConfig.java   
@Bean
public AuthenticationFailureHandler authenticationFailureHandler() {
  return new CustomAuthenticationFailureHandler();
}
项目:judge    文件:SecurityConfiguration.java   
private AuthenticationFailureHandler failureHandler() {
    final String defaultFailureUrl = "/login?error";
    RedirectStrategy redirectStrategy = new FailureRedirectStrategy();
    return (request, response, exception) -> redirectStrategy.sendRedirect(request, response, defaultFailureUrl);
}
项目:graviteeio-access-management    文件:OAuth2SecurityConfiguration.java   
@Bean
public AuthenticationFailureHandler authenticationFailureHandler() {
    return new ClientAwareAuthenticationFailureHandler("/login?error");
}
项目:todolist    文件:WebSecurityConfiguration.java   
@Bean
public AuthenticationFailureHandler authenticationFailureHandler() {
    return new UserNameCachingAuthenticationFailureHandler();
}
项目:entelect-spring-webapp-template    文件:SpringSecurityConfig.java   
@Bean
public AuthenticationFailureHandler loginFailureHandler() {
    return new LoginFailureHandler();
}