Last change
on this file was 77205be, checked in by gjoko kostadinov <gjokokostadinov@…>, 11 months ago |
Add entire code
|
-
Property mode
set to
100755
|
File size:
1.2 KB
|
Line | |
---|
1 | package edu.gjoko.schedlr.config;
|
---|
2 |
|
---|
3 | import org.apache.commons.logging.Log;
|
---|
4 | import org.apache.commons.logging.LogFactory;
|
---|
5 | import org.springframework.security.authentication.BadCredentialsException;
|
---|
6 | import org.springframework.security.authentication.InternalAuthenticationServiceException;
|
---|
7 | import org.springframework.security.core.AuthenticationException;
|
---|
8 | import org.springframework.security.web.authentication.AuthenticationFailureHandler;
|
---|
9 |
|
---|
10 | import javax.servlet.ServletException;
|
---|
11 | import javax.servlet.http.HttpServletRequest;
|
---|
12 | import javax.servlet.http.HttpServletResponse;
|
---|
13 | import java.io.IOException;
|
---|
14 |
|
---|
15 | public 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.