/**t
* 过滤请求
* @param request 请求
* @param response 响应
* @param filterChain 过滤器链
* @throws IOException IOException
* @throws ServletException ServletException
*/
//stop check
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) throws IOException, ServletException
{
HttpServletRequest httpRequest = (HttpServletRequest)request;
HttpServletResponse httpResponse = (HttpServletResponse)response;
String requestAction = httpRequest.getRequestURI()
.substring(httpRequest.getContextPath().length());
String basePath = httpRequest.getScheme() + "://"
+ request.getLocalAddr() + ":" + request.getLocalPort()
+ httpRequest.getContextPath();
httpResponse.addHeader("P3P", "CP=CAO PSA OUR");
if (null != excludeList && !excludeList.isEmpty())
{
for (String temp : excludeList)
{
if (!temp.startsWith("/"))
{
temp = (new StringBuilder()).append("/")
.append(temp)
.toString();
}
if (requestAction.startsWith(temp))
{
filterChain.doFilter(request, response);
return;
}
}
}
Agent agent = null;
agent = (Agent)DataContextHolder.getDataContext()
.getContext(Constants.LOGIN_AGENT, DataContext.SCOPE_SESSION);
if (agent == null)
{
httpResponse.setStatus(Constants.NUM_1000);
httpResponse.sendRedirect(basePath + "/timeOut.jsp");
return;
}
filterChain.doFilter(request, response);
}
/**
* 初始化过滤器
* @param config 过滤器配置
* @throws ServletException ServletException
*/
//stop check
public void init(FilterConfig config) throws ServletException
{
String excludeActions = config.getInitParameter("exclude.actions");
if (excludeActions != null)
{
String temp[] = excludeActions.split(".action");
if (temp != null && temp.length > 0)
{
for (int i = 0; i < temp.length; i++)
{
if (null != temp[i] && !"".equals(temp[i]))
{
int beginIndex = temp[i].indexOf("/");
String str = (new StringBuilder()).append(temp[i].substring(beginIndex))
.append(".action")
.toString();
excludeList.add(str);
}
}
}
}
}
* 过滤请求
* @param request 请求
* @param response 响应
* @param filterChain 过滤器链
* @throws IOException IOException
* @throws ServletException ServletException
*/
//stop check
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain filterChain) throws IOException, ServletException
{
HttpServletRequest httpRequest = (HttpServletRequest)request;
HttpServletResponse httpResponse = (HttpServletResponse)response;
String requestAction = httpRequest.getRequestURI()
.substring(httpRequest.getContextPath().length());
String basePath = httpRequest.getScheme() + "://"
+ request.getLocalAddr() + ":" + request.getLocalPort()
+ httpRequest.getContextPath();
httpResponse.addHeader("P3P", "CP=CAO PSA OUR");
if (null != excludeList && !excludeList.isEmpty())
{
for (String temp : excludeList)
{
if (!temp.startsWith("/"))
{
temp = (new StringBuilder()).append("/")
.append(temp)
.toString();
}
if (requestAction.startsWith(temp))
{
filterChain.doFilter(request, response);
return;
}
}
}
Agent agent = null;
agent = (Agent)DataContextHolder.getDataContext()
.getContext(Constants.LOGIN_AGENT, DataContext.SCOPE_SESSION);
if (agent == null)
{
httpResponse.setStatus(Constants.NUM_1000);
httpResponse.sendRedirect(basePath + "/timeOut.jsp");
return;
}
filterChain.doFilter(request, response);
}
/**
* 初始化过滤器
* @param config 过滤器配置
* @throws ServletException ServletException
*/
//stop check
public void init(FilterConfig config) throws ServletException
{
String excludeActions = config.getInitParameter("exclude.actions");
if (excludeActions != null)
{
String temp[] = excludeActions.split(".action");
if (temp != null && temp.length > 0)
{
for (int i = 0; i < temp.length; i++)
{
if (null != temp[i] && !"".equals(temp[i]))
{
int beginIndex = temp[i].indexOf("/");
String str = (new StringBuilder()).append(temp[i].substring(beginIndex))
.append(".action")
.toString();
excludeList.add(str);
}
}
}
}
}