package ;
import ;
import ;
import ;
import org.;
import org.;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
/**
*
* 重写权限验证问题,登录失效后返回状态码
*
*/
public class ShiroFormAuthenticationFilter extends FormAuthenticationFilter {
Logger logger = ();
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
if (isLoginRequest(request, response)) {
if (isLoginSubmission(request, response)) {
if (()) {
("Login submission detected. Attempting to execute login.");
}
return executeLogin(request, response);
} else {
if (()) {
("Login page view.");
}
//allow them to see the login page ;)
return true;
}
} else {
HttpServletRequest req = (HttpServletRequest)request;
HttpServletResponse resp = (HttpServletResponse) response;
if(().equals(())) {
(());
return true;
}
if (()) {
("Attempting to access a path which requires authentication. Forwarding to the " +
"Authentication url [" + getLoginUrl() + "]");
}
//前端Ajax请求时requestHeader里面带一些参数,用于判断是否是前端的请求
String test= ("test");
if (test!= null || ("wkcheck") != null) {
//前端Ajax请求,则不会重定向
("Access-Control-Allow-Origin", ("Origin"));
("Access-Control-Allow-Credentials", "true");
("application/json; charset=utf-8");
("UTF-8");
PrintWriter out = ();
JSONObject result = new JSONObject();
("message", "登录失效");
("resultCode", 1000);
(result);
();
();
} else {
saveRequestAndRedirectToLogin(request, response);
}
return false;
}
}
}