//拦截
if ( logger.isDebugEnabled() ) {
logger.debug(
"<com.ibmmt.staffmanager.web.action.LoginAction.execute()登陆失败");
}
return (actionMapping.findForward("errorpage"));
}
//struts中配置
<forward name="errorpage" path="/adminsys/authmng/common/errorpage.jsp" />
//具体方法中
public LoginPurviewVO login(String IP, String strStaffId, String strPassword) throws
StaffManagerException {
LoginPurviewVO loginPurviewVo = new LoginPurviewVO();
Staff staff = null;
try {
staff = getStaff(strStaffId);
GetLogger().info(staff);
if (null == staff) {
this.writeAccessLog(strStaffId, IP, loginPurviewVo.getLoginTime(), -4);
throw new StaffManagerException("系统中无[" + strStaffId +
"]用户的登录信息,请检查你的用户名称是否正确!");
}
loginPurviewVo.setRoles(staff.getRolesList());
Set funcSet = staff.getFunctions();
System.out.println(funcSet.size()+"权限----");
if (funcSet != null) {
Hashtable funcs = loginPurviewVo.getFunctions();
System.out.println(loginPurviewVo.getFunctions().size()+"权限-2222222---");
for (Iterator iter = funcSet.iterator(); iter.hasNext(); ) {
Object item = (Object) iter.next();
Function func = (Function) item;
GetLogger().debug("+++++++++++++++++++++FunctionName-->" +
func.getName() +
"++++++++++++++++++++++++++++++++++++++++++");
String name = func.getName();
System.out.println(loginPurviewVo.getFunctions().size()+"--fff--"+name);
name = name == null ? "" : name;
funcs.put(func.getId(), name);
}
}
System.out.println(loginPurviewVo.getFunctions().size()+"权限-333333---");
Hashtable staffAllFuncs = this.getStaffAllFuncs(strStaffId,
loginPurviewVo.getRoles(),
loginPurviewVo.getFunctions());
System.out.println(staffAllFuncs.size()+"权限-1111---");
loginPurviewVo.setStaffAllFuncs(staffAllFuncs);
loginPurviewVo.setUserID(staff.getId());
loginPurviewVo.setUserName(staff.getName());
loginPurviewVo.setDepartmentID(staff.getDeptId());
}
catch (Exception ex) {
GetLogger().error("查询用户发生异常:", ex);
staff = null;
this.writeAccessLog(strStaffId, IP, loginPurviewVo.getLoginTime(), 0);
throw new StaffManagerException("查询用户发生异常");
}
if (null != staff) {
if (staff.getStaffPass().equals(strPassword)) {
if (LoginValidate(staff.getStatusFlag(), staff.getEffTime(),
staff.getExpTime())) {
if (false &&
(staff.getLoginFlag() != null && staff.getLoginFlag().equals("1")
&& staff.getLoginIp() != null &&
staff.getLoginIp().length() > 0
&& !staff.getLoginIp().equals(IP))) {
loginPurviewVo.setLoginErrorCode( -2);
GetLogger().info("-----[" + staff.getId() + "]重复登录-----");
String strHostID = staff.getLoginIp();
staff = null;
this.writeAccessLog(strStaffId, IP, loginPurviewVo.getLoginTime(),
-2);
throw new StaffManagerException("重复登录![此工号已经在IP=" + strHostID +
"机器登录]");
}
else {
loginPurviewVo.setLoginErrorCode(1);
loginPurviewVo.setIP(IP);
staff.setLoginFlag("1");
staff.setLoginIp(IP);
// updateStaffForLogin(staff);
// this.writeAccessLog(strStaffId, IP, loginPurviewVo.getLoginTime(), 1);
}
}
else {
loginPurviewVo.setLoginErrorCode( -3);
GetLogger().info("[" + staff.getId() + "]你的工号已经失效.");
staff = null;
this.writeAccessLog(strStaffId, IP, loginPurviewVo.getLoginTime(), -3);
throw new StaffManagerException("你的工号已经失效,不能登录,请和系统管理员联系。");
}
}
else {
loginPurviewVo.setLoginErrorCode( -1);
GetLogger().info("[" + staff.getId() + "]密码不正确!");
staff = null;
this.writeAccessLog(strStaffId, IP, loginPurviewVo.getLoginTime(), -1);
throw new StaffManagerException("密码不正确111!");
}
}
GetLogger().debug("Login error code = " + loginPurviewVo.getLoginErrorCode());
staff = null;
return loginPurviewVo;
}