欢迎进入Java社区论坛,与200万技术人员互动交流 >>进入
public void setFirstFailureTime(Date firstFailureTime) {
this.firstFailureTime = firstFailureTime;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public Date getLastLoginTime() {
return lastLoginTime;
}
public void setLastLoginTime(Date lastLoginTime) {
this.lastLoginTime = lastLoginTime;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}
三、监控线程UserConnectManage.java类
这是入侵检测的核心部分,主要实现具体的入侵检测、记录、判断用户信息、在线用户的刷新等功能,并提供其它应用程序使用本组件的调用接口。
package com.easyjf.web;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.apache.log4j.Logger;
/**
*
*
Title:用户入侵检测信息
*
Description:用于判断用户刷新情况检查,默认为10秒钟之内连续连接10次为超时
*
Copyright: Copyright (c) 2006
*
Company: www.easyjf.com
* @author 蔡世友
* @version 1.0
*/
public class UserConnectManage {
private static final Logger logger = (Logger) Logger.getLogger(UserConnectManage.class.getName());
private static int maxFailureTimes=10;//最大登录失败次数
private static long maxFailureInterval=10000;//毫秒,达到最大登录次数且在这个时间范围内
private static long waitInterval=60000;//失败后接受连接的等待时间,默认1分钟
private static int maxOnlineUser=200;//同时在线的最大数
private final static Map users=new HashMap();//使用ip+userName为key存放用户登录信息UserLoginAuth
private static Thread checkThread=null;
private static class CheckTimeOut implements Runnable{
private Thread parentThread;
public CheckTimeOut(Thread parentThread)
{
this.parentThread=parentThread;
synchronized(this){
if(checkThread==null){
checkThread= new Thread(this);
//System.out.println(“创建一个新线程!”);
checkThread.start();
}
}
}
[1][2][3][4]
只想到处流浪人生就像一场旅行,不必在乎目的地,