📄 usercheck.java
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name: UserCheck.java
package com.laoer.bbscs.web.servlet;
import com.laoer.bbscs.bean.*;
import com.laoer.bbscs.business.IBoardsService;
import com.laoer.bbscs.business.service.BoardList;
import com.laoer.bbscs.sys.*;
import com.laoer.comm.util.DES;
import com.laoer.comm.util.Util;
import java.util.HashMap;
import javax.servlet.http.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.support.AbstractApplicationContext;
public class UserCheck
{
private static final Log logger;
private static final String PASS_USERNAME_KEY = "PASS_USERNAME";
private static final String PASS_USERNAME_DES_KEY = "PASS_USERNAME_DES";
private static final String BBSCS_USERNAME_KEY = "BBSCS_USERNAME";
private static final String BBSCS_USERNAME_DES_KEY = "BBSCS_USERNAME_DES";
private static final String BBSCS_NICKNAME_KEY = "NK";
private static final String BBSCS_ID_KEY = "ID";
private static final String BBSCS_ACTTIME_KEY = "AT";
private static final String BBSCS_SPUERADMIN_KEY = "SA";
private static final String BBSCS_MANAGER_KEY = "M";
private static final String BBSCS_BOARD_KEY = "B";
private static final String BBSCS_BOARDMASTER_KEY = "BM";
private static final String BBSCS_BULLETIN_KEY = "BU";
private static final String BBSCS_USERADMIN_KEY = "UA";
private static final String BBSCS_GUEST_KEY = "GU";
private static final String BBSCS_HPOWER_KEY = "H";
private static final String BBSCS_FORUMPERNUM_KEY = "FN";
private static final String BBSCS_POSTPERNUM_KEY = "PN";
private static final String BBSCS_TIMEZONE_KEY = "TZ";
private static final String BBSCS_AI_KEY = "AI";
private SysInfo si;
private Boards bs;
private IBoardsService ibs;
private HttpServletRequest request;
private HttpServletResponse response;
private String username;
private String usernamedes;
private String nickname;
private long id;
private long activeTime;
private short superAdmin;
private short manager;
private short board;
private short boardMaster;
private short bulletin;
private short userAdmin;
private short guest;
private DES des;
private short power;
private boolean mainMaster;
private boolean assiMaster;
private boolean hideMaster;
private int formPerNum;
private int postPerNum;
private long bid;
private boolean bmaster;
private String timeZone;
private String authCode;
private String pusername;
private String pusernamedes;
static Class class$com$laoer$bbscs$web$servlet$UserCheck; /* synthetic field */
public UserCheck()
{
username = "";
usernamedes = "";
nickname = "";
id = 0L;
activeTime = 0L;
superAdmin = 0;
manager = 0;
board = 0;
boardMaster = 0;
bulletin = 0;
userAdmin = 0;
guest = 1;
power = 0;
mainMaster = false;
assiMaster = false;
hideMaster = false;
formPerNum = 20;
postPerNum = 10;
bid = 0L;
bmaster = false;
timeZone = "GMT+08:00";
authCode = "";
pusername = "";
pusernamedes = "";
}
public UserCheck(HttpServletRequest request, HttpServletResponse response)
{
username = "";
usernamedes = "";
nickname = "";
id = 0L;
activeTime = 0L;
superAdmin = 0;
manager = 0;
board = 0;
boardMaster = 0;
bulletin = 0;
userAdmin = 0;
guest = 1;
power = 0;
mainMaster = false;
assiMaster = false;
hideMaster = false;
formPerNum = 20;
postPerNum = 10;
bid = 0L;
bmaster = false;
timeZone = "GMT+08:00";
authCode = "";
pusername = "";
pusernamedes = "";
this.request = request;
this.response = response;
si = SysInfo.getInstance();
try
{
des = new DES(DES._DESede);
}
catch(Exception ex)
{
logger.error("UserCheck(HttpServletRequest request, HttpServletResponse response, ServletContext sc)" + ex);
}
getCookies(request, response);
}
public UserCheck(HttpServletRequest request, HttpServletResponse response, long bid)
{
username = "";
usernamedes = "";
nickname = "";
id = 0L;
activeTime = 0L;
superAdmin = 0;
manager = 0;
board = 0;
boardMaster = 0;
bulletin = 0;
userAdmin = 0;
guest = 1;
power = 0;
mainMaster = false;
assiMaster = false;
hideMaster = false;
formPerNum = 20;
postPerNum = 10;
this.bid = 0L;
bmaster = false;
timeZone = "GMT+08:00";
authCode = "";
pusername = "";
pusernamedes = "";
this.request = request;
this.response = response;
si = SysInfo.getInstance();
this.bid = bid;
try
{
des = new DES(DES._DESede);
}
catch(Exception ex)
{
logger.error("UserCheck(HttpServletRequest request, HttpServletResponse response,ServletContext sc, long bid):" + ex);
}
getCookies(request, response);
BoardList boardList = (BoardList)AppContext.getInstance().getAppContext().getBean("boradList");
bs = (Boards)boardList.getBoardsHm().get(new Long(bid));
if(!isGuest() && bs != null)
{
ibs = (IBoardsService)AppContext.getInstance().getAppContext().getBean("boardsService");
bmaster = bs.getBoard().getBmaster().equals(username);
mainMaster = ibs.isMainMaster(bs, username);
assiMaster = ibs.isAssiMaster(bs, username);
hideMaster = ibs.isHideMaster(bs, username);
}
}
public void getCookies(HttpServletRequest request, HttpServletResponse response)
{
Cookie cookies[] = request.getCookies();
Cookie sCookie = null;
try
{
if(cookies != null && cookies.length > 0)
{
for(int i = 0; i < cookies.length; i++)
{
sCookie = cookies[i];
if(si.getUsepass().equals("y"))
{
if(sCookie.getName().equals("PASS_USERNAME"))
{
username = sCookie.getValue();
pusername = sCookie.getValue();
}
if(sCookie.getName().equals("PASS_USERNAME_DES") && !Util.nullOrBlank(sCookie.getValue()))
{
byte buf[] = Util.base64decodebyte(sCookie.getValue());
byte dec[] = des.decode(buf, Util.base64decodebyte(si.getCookiekey()));
usernamedes = new String(dec);
pusernamedes = usernamedes;
}
} else
{
if(sCookie.getName().equals("BBSCS_USERNAME"))
username = sCookie.getValue();
if(sCookie.getName().equals("BBSCS_USERNAME_DES"))
{
byte buf[] = Util.base64decodebyte(sCookie.getValue());
byte dec[] = des.decode(buf, Util.base64decodebyte(si.getCookiekey()));
usernamedes = new String(dec);
}
}
if(sCookie.getName().equals("ID"))
{
byte buf[] = Util.base64decodebyte(sCookie.getValue());
byte dec[] = des.decode(buf, Util.base64decodebyte(si.getCookiekey()));
id = Long.parseLong(new String(dec));
}
if(sCookie.getName().equals("NK"))
nickname = Util.base64decode(sCookie.getValue());
if(sCookie.getName().equals("AT"))
activeTime = Long.parseLong(sCookie.getValue());
if(sCookie.getName().equals("SA"))
{
byte buf[] = Util.base64decodebyte(sCookie.getValue());
byte dec[] = des.decode(buf, Util.base64decodebyte(si.getCookiekey()));
superAdmin = SysUtil.getCookieValue(new String(dec), Constant.PERFIX[0], (short)0);
}
if(sCookie.getName().equals("M"))
{
byte buf[] = Util.base64decodebyte(sCookie.getValue());
byte dec[] = des.decode(buf, Util.base64decodebyte(si.getCookiekey()));
manager = SysUtil.getCookieValue(new String(dec), Constant.PERFIX[1], (short)0);
}
if(sCookie.getName().equals("B"))
{
byte buf[] = Util.base64decodebyte(sCookie.getValue());
byte dec[] = des.decode(buf, Util.base64decodebyte(si.getCookiekey()));
board = SysUtil.getCookieValue(new String(dec), Constant.PERFIX[2], (short)0);
}
if(sCookie.getName().equals("BM"))
{
byte buf[] = Util.base64decodebyte(sCookie.getValue());
byte dec[] = des.decode(buf, Util.base64decodebyte(si.getCookiekey()));
boardMaster = SysUtil.getCookieValue(new String(dec), Constant.PERFIX[3], (short)0);
}
if(sCookie.getName().equals("BU"))
{
byte buf[] = Util.base64decodebyte(sCookie.getValue());
byte dec[] = des.decode(buf, Util.base64decodebyte(si.getCookiekey()));
bulletin = SysUtil.getCookieValue(new String(dec), Constant.PERFIX[4], (short)0);
}
if(sCookie.getName().equals("UA"))
{
byte buf[] = Util.base64decodebyte(sCookie.getValue());
byte dec[] = des.decode(buf, Util.base64decodebyte(si.getCookiekey()));
userAdmin = SysUtil.getCookieValue(new String(dec), Constant.PERFIX[5], (short)0);
}
if(sCookie.getName().equals("GU"))
{
byte buf[] = Util.base64decodebyte(sCookie.getValue());
byte dec[] = des.decode(buf, Util.base64decodebyte(si.getCookiekey()));
guest = SysUtil.getCookieValue(new String(dec), Constant.PERFIX[6], (short)1);
}
if(sCookie.getName().equals("H"))
{
byte buf[] = Util.base64decodebyte(sCookie.getValue());
byte dec[] = des.decode(buf, Util.base64decodebyte(si.getCookiekey()));
power = SysUtil.getCookieValue(new String(dec), Constant.PERFIX[7], (short)0);
}
if(sCookie.getName().equals("FN"))
formPerNum = Integer.parseInt(sCookie.getValue());
if(sCookie.getName().equals("PN"))
postPerNum = Integer.parseInt(sCookie.getValue());
if(sCookie.getName().equals("TZ"))
timeZone = Util.base64decode(sCookie.getValue());
if(sCookie.getName().equals("AI"))
authCode = sCookie.getValue();
}
if(si.getUsepass().equals("y"))
{
if(Util.nullOrBlank(username) && Util.nullOrBlank(usernamedes))
{
for(int i = 0; i < cookies.length; i++)
{
sCookie = cookies[i];
if(sCookie.getName().equals("BBSCS_USERNAME"))
username = sCookie.getValue();
if(sCookie.getName().equals("BBSCS_USERNAME_DES"))
{
byte buf[] = Util.base64decodebyte(sCookie.getValue());
byte dec[] = des.decode(buf, Util.base64decodebyte(si.getCookiekey()));
usernamedes = new String(dec);
}
}
}
if(!Util.nullOrBlank(username) && !Util.nullOrBlank(usernamedes) && guest == 1)
{
for(int i = 0; i < cookies.length; i++)
{
sCookie = cookies[i];
if(sCookie.getName().equals("BBSCS_USERNAME"))
username = sCookie.getValue();
}
}
}
}
if(guest == -1)
guest = 1;
}
catch(Exception e)
{
username = "";
usernamedes = "";
logger.error("getCookies(HttpServletRequest request,HttpServletResponse response)" + e);
}
}
public void addUCookies(String username, String nickname, short guest)
{
this.username = username;
addC("BBSCS_USERNAME", username);
this.nickname = nickname;
addC("NK", Util.base64Encode(nickname));
this.guest = guest;
addDES("GU", Constant.PERFIX[6] + guest);
activeTime = SysUtil.getLongTime();
addC("AT", String.valueOf(activeTime));
}
public void addUCookies(String username, String nickname, short guest, int maxage)
{
this.username = username;
addC("BBSCS_USERNAME", username, maxage);
this.nickname = nickname;
addC("NK", Util.base64Encode(nickname), maxage);
this.guest = guest;
addDES("GU", Constant.PERFIX[6] + guest, maxage);
activeTime = SysUtil.getLongTime();
addC("AT", String.valueOf(activeTime), maxage);
}
public void addUCookiesActiveTime()
{
activeTime = SysUtil.getLongTime();
addC("AT", String.valueOf(activeTime));
}
public void addAuthCode()
{
authCode = Util.genNumPassword(4);
addC("AI", authCode);
}
public void addCookies(UserInfo ui)
{
try
{
id = ui.getId().intValue();
addDES("ID", String.valueOf(ui.getId().longValue()));
if(!si.getUsepass().equals("y"))
{
username = ui.getUsername();
addC("BBSCS_USERNAME", ui.getUsername());
usernamedes = ui.getUsername();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -