赞
踩
package com.bizviva.binding;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.bizviva.bizcrm.ClientPlatform;
public class BindFilter implements Filter {
public static final String onlinereg =
"/binding/onlinereg/reg.do";
public static final String onlinereginclude =
"/binding/onlinereg/displaySellerRegister.do";
public static final String binding =
"/binding/onlinereg/binding.do";
public static final String SubBind =
"/binding/onlinereg/SubBind.do";
public static final String login =
"/common/member/login.do";
public static final String waiting =
"/binding/remote/waitReg.do";
static int MEMBER_STATUS_NO = 1;
static int MEMBER_STATUS_YES = 0;
public void destroy() {
}
public void doFilter(ServletRequest request,
ServletResponse response,
FilterChain
chain) throws IOException, ServletException {
HttpServletRequest req =
(HttpServletRequest) request;
HttpServletResponse res =
(HttpServletResponse) response;
String path =
req.getContextPath();
String file
=req.getServletPath();
if
(file.endsWith("/index.html") || file.endsWith(".do")){
}else{
chain.doFilter(request,
response);
return;
}
String site = req.getScheme() +
"://" + req.getServerName() + ":"
+
req.getServerPort() + path;
System.out.println("site===>>>"+site
+ " file " + file);
int MEMBER_ID = 0;
int MEMBER_STATUS = -1; // 0未开通
1开通 -1未申请 -2申请没通过
String uri =
req.getRequestURI();
System.out.println("request
uri:" + uri);
// 检测本地是否 有这个标识
try {
MEMBER_ID =
ClientPlatform.getConfig().getInt("client.memberId");
} catch (Exception e) {
MEMBER_ID =
-1;
}
try {
MEMBER_STATUS
= ClientPlatform.getConfig().getInt(
"client.memberStatus");
} catch (Exception e) {
MEMBER_STATUS
= -1;
}
if (MEMBER_ID <=
0) { // 未申请注册
if
(uri.endsWith(login) | uri.endsWith(waiting)) { // 如果进入登录页面
跳转
String
tmpPath = req.getContextPath();
tmpPath
= tmpPath.concat(binding);
//site
+= binding;
System.out.println("tmpPath==>>"
+tmpPath);
res.sendRedirect(tmpPath);
} else
{
chain.doFilter(request,
response);
}
} else if (MEMBER_ID
> 0) { // 已申请注册
if
(MEMBER_STATUS == MEMBER_STATUS_YES) { // 绑定成功
chain.doFilter(request,
response);
} else { //
注册 等待审批
//
远程注册了, 并且 还没开通
if
(!uri.endsWith(waiting)) {
System.out.println("query
audit status...."+req.getServerName());
String
tmpPath = req.getContextPath();
tmpPath
= tmpPath.concat(waiting);
System.out.println("waiting
Path==>>" +tmpPath);
res.sendRedirect(tmpPath); return;
}
else {
chain.doFilter(request,
response);
}
}
}
}
public void init(FilterConfig config) throws
ServletException {
}
public static int getMEMBER_STATUS_NO()
{
return MEMBER_STATUS_NO;
}
public int getMEMBER_STATUS_YES() {
return MEMBER_STATUS_YES;
}
public void setMEMBER_STATUS_YES(int
member_status_yes) {
MEMBER_STATUS_YES =
member_status_yes;
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。