📄 authenticationfilter.java
字号:
package com.longtime.wap.common.web;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.longtime.wap.common.WapConstant;
import com.longtime.wap.frame.common.FrameConstant;
import com.longtime.wap.frame.common.UserSessionVO;
/**
* 用户超过时限处理
*
* @author bulc
* @date Sep 4, 2007
*
*/
public class AuthenticationFilter implements Filter {
/**
* 超过时限处理
*/
public void destroy() {
}
/**
* 用户超过时限的处理
*
* @param req
* ServletRequest对象
* @param res
* ServletResponse对象
* @param doNext
* FilterChain对象
* @throws IOException
* IO异常
* @throws ServletException
* Servlet 异常
*/
public void doFilter(ServletRequest req, ServletResponse res,
FilterChain doNext) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
HttpSession session = request.getSession(Boolean.TRUE);
if (!session.isNew()
&& null == session.getAttribute(WapConstant.USER_SESSION)) {
request.setAttribute(FrameConstant.RELOGIN_MESSAGE,
"对不起,您没有登录或登录已超时,");
RequestDispatcher rd = request
.getRequestDispatcher("/frame/jsp/sessionTimeout.jsp");
rd.forward(request, response);
} else {
UserSessionVO us = (UserSessionVO) session
.getAttribute(WapConstant.USER_SESSION);
String path = request.getRequestURL().toString();
if (!path.contains("/frontIndex")
&& !path.contains("/registerUserView")
&& !path.contains("/registerUser")
&& !path.contains("/informationDetail")
&& !path.contains("/listBusinesses")
&& !path.contains("/listInformations")
&& !path.contains("/listUserPayment")
&& !path.contains("/findPassword")
&& !path.contains("/searchInformation")
&& !path.contains("/listUserPayment")) {
if (2 == us.getUserGroup()) {
RequestDispatcher rd = request
.getRequestDispatcher("/invalidation.jsp");
rd.forward(request, response);
} else {
doNext.doFilter(request, response);
}
} else {
doNext.doFilter(request, response);
}
}
}
/**
* 初始化
*
* @param filterConf
* FilterConfig对象
* @throws ServletException
* Servlet 异常
*/
public void init(FilterConfig filterConf) throws ServletException {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -