source: src/main/java/edu/gjoko/schedlr/config/AppAuthenticationFailureHandler.java@ 77205be

Last change on this file since 77205be was 77205be, checked in by gjoko kostadinov <gjokokostadinov@…>, 6 months ago

Add entire code

  • Property mode set to 100755
File size: 1.2 KB
Line 
1package edu.gjoko.schedlr.config;
2
3import org.apache.commons.logging.Log;
4import org.apache.commons.logging.LogFactory;
5import org.springframework.security.authentication.BadCredentialsException;
6import org.springframework.security.authentication.InternalAuthenticationServiceException;
7import org.springframework.security.core.AuthenticationException;
8import org.springframework.security.web.authentication.AuthenticationFailureHandler;
9
10import javax.servlet.ServletException;
11import javax.servlet.http.HttpServletRequest;
12import javax.servlet.http.HttpServletResponse;
13import java.io.IOException;
14
15public class AppAuthenticationFailureHandler implements AuthenticationFailureHandler {
16
17 protected Log logger = LogFactory.getLog(this.getClass());
18 @Override
19 public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
20 if (exception instanceof InternalAuthenticationServiceException) {
21 response.sendRedirect(request.getContextPath() + "/login?error=notApproved");
22 } else if (exception instanceof BadCredentialsException) {
23 response.sendRedirect(request.getContextPath() + "/login?error=badCredentials");
24 }
25 }
26}
Note: See TracBrowser for help on using the repository browser.