List of usage examples for org.springframework.security.web.authentication AuthenticationFailureHandler AuthenticationFailureHandler
AuthenticationFailureHandler
From source file:org.mitre.openid.connect.assertion.JWTBearerClientAssertionTokenEndpointFilter.java
@Override public void afterPropertiesSet() { super.afterPropertiesSet(); setAuthenticationFailureHandler(new AuthenticationFailureHandler() { @Override/* w w w . j av a 2 s .com*/ public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException { if (exception instanceof BadCredentialsException) { exception = new BadCredentialsException(exception.getMessage(), new BadClientCredentialsException()); } authenticationEntryPoint.commence(request, response, exception); } }); setAuthenticationSuccessHandler(new AuthenticationSuccessHandler() { @Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException { // no-op - just allow filter chain to continue to token endpoint } }); }
From source file:org.osiam.security.helper.FBClientCredentialsTokenEndpointFilter.java
@Override /**//from w w w .j a va2s .c o m * Sets the handler, failed -> BadCredentialsException, success -> just continue. */ 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 = // NOSONAR new BadCredentialsException(exception.getMessage(), new BadClientCredentialsException()); } authenticationEntryPoint.commence(request, response, exception); } }); setAuthenticationSuccessHandler(new MyAuthenticationSuccessHandler()); }
From source file:org.glassmaker.spring.oauth.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); }//from w w w . j a va2 s . c o m }); }
From source file:com.iservport.auth.SecurityWebConfig.java
/** * Intercepta erros de autenticao.//w w w . ja va 2 s . c o m */ @Bean public AuthenticationFailureHandler authenticationFailureHandler() { return new AuthenticationFailureHandler() { @Override public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException { String exceptionToken = exception.getMessage().trim().toLowerCase().replace(" ", ""); int type = 0; if (exceptionToken.contains("badcredentials")) { type = 1; } else if (exceptionToken.contains("unabletoextractvaliduser")) { type = 2; } response.sendRedirect(request.getContextPath() + "/login/error?type=" + type); } }; }