Created
March 31, 2016 22:11
-
-
Save MafaldaLandeiro/def2280e05f26087c99b7a14fcc93041 to your computer and use it in GitHub Desktop.
Access denied exception handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package org.springSecurityLogin.exception; | |
| import java.io.IOException; | |
| import javax.servlet.ServletException; | |
| import javax.servlet.http.HttpServletRequest; | |
| import javax.servlet.http.HttpServletResponse; | |
| import org.springframework.security.access.AccessDeniedException; | |
| import org.springframework.security.web.access.AccessDeniedHandler; | |
| public class AccessDeniedExceptionHandler implements AccessDeniedHandler { | |
| private String errorPage; | |
| public AccessDeniedExceptionHandler() { | |
| } | |
| public AccessDeniedExceptionHandler(String errorPage) { | |
| this.errorPage = errorPage; | |
| } | |
| public String getErrorPage() { | |
| return errorPage; | |
| } | |
| public void setErrorPage(String errorPage) { | |
| this.errorPage = errorPage; | |
| } | |
| @Override | |
| public void handle(HttpServletRequest arg0, HttpServletResponse arg1, | |
| AccessDeniedException arg2) throws IOException, ServletException { | |
| arg1.sendRedirect(errorPage); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment