use of j.cache.JCacheParams in project JFramework by gugumall.
the class SSOClient method findLoginStatusOfUserId.
/**
* 查找是否有给定参数所对应的登录信息
* @param globalSessionIdOrUid
* @return
*/
public static LoginStatus[] findLoginStatusOfUserId(String userId) {
_init();
if (userId == null || userId.equals(""))
return null;
try {
List temp = users.values(new JCacheParams(new LoginStatusFilter(userId)));
LoginStatus[] arr = new LoginStatus[temp.size()];
temp.toArray(arr);
return arr;
} catch (Exception e) {
log.log(e, Logger.LEVEL_ERROR);
}
return null;
}
use of j.cache.JCacheParams in project JFramework by gugumall.
the class SSOClient method findLoginStatusOfSessionId.
/**
* @param globalSessionId
* @return
*/
public static LoginStatus findLoginStatusOfSessionId(String globalSessionId) {
_init();
if (globalSessionId == null || globalSessionId.equals(""))
return null;
LoginStatus stat = null;
try {
stat = (LoginStatus) users.get(new JCacheParams(globalSessionId));
} catch (Exception e) {
log.log(e, Logger.LEVEL_ERROR);
}
return stat;
}
use of j.cache.JCacheParams in project JFramework by gugumall.
the class SSOClient method clearUserInformation.
/**
* @param loginStatus
* @throws Exception
*/
private static void clearUserInformation(LoginStatus loginStatus) throws Exception {
_init();
if (loginStatus != null) {
HttpSession session = SSOContext.getSession(loginStatus.getSessionId());
users.remove(new JCacheParams(loginStatus.getUserId()));
users.remove(new JCacheParams(loginStatus.getGlobalSessionId()));
if (session != null) {
removeLoginStatus(session);
removeCurrentUser(session);
session.removeAttribute(Constants.SSO_TIME);
session.removeAttribute(Constants.SSO_USER_ID);
session.removeAttribute(Constants.SSO_GLOBAL_SESSION_ID);
}
try {
SSOConfig.getAuthenticator().logout(session);
} catch (Exception e) {
log.log(e.getMessage(), Logger.LEVEL_WARNING);
}
if (loginStatus != null)
loginStatus = null;
}
}
use of j.cache.JCacheParams in project JFramework by gugumall.
the class DomainLimit method run.
/*
* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() {
JCacheParams params = new JCacheParams();
params.valueFilter = new OnlineRemover();
while (true) {
try {
Thread.sleep(5000);
} catch (Exception e) {
}
// 配置文件变动
try {
File configFile = new File(JProperties.getConfigPath() + "onlines.xml");
if (configLastModified < configFile.lastModified()) {
log.log("onlines.xml has been modified, so reload it.", -1);
load();
}
configFile = null;
} catch (Exception e) {
log.log(e, Logger.LEVEL_ERROR);
}
// 移除过期黑名单
for (int i = 0; i < blackIps.size(); i++) {
BlackIp bi = (BlackIp) blackIps.get(i);
if (bi.isTimeout()) {
blackIps.remove(i);
i--;
}
}
// 移除过期对象
long now = SysUtil.getNow();
List keys = onlines.listKeys();
for (int i = 0; i < keys.size(); i++) {
String key = (String) keys.get(i);
Online o = (Online) onlines.get(key);
if (o == null || now - o.getUpdateTime() > SSOConfig.getOnlineActiveTime() * 1000) {
onlines.remove(key);
}
}
keys.clear();
keys = null;
// 移除过期访问记录
keys = counts.listKeys();
for (int i = 0; i < keys.size(); i++) {
String ip = (String) keys.get(i);
RequestCount c = (RequestCount) counts.get(ip);
if (c == null || now - c.latestRequestTime > SSOConfig.getOnlineActiveTime() * 1000) {
// 5分钟
counts.remove(ip);
}
}
keys.clear();
keys = null;
}
}
use of j.cache.JCacheParams in project JFramework by gugumall.
the class OnlinesCluster method findBySessionId.
/**
* @param sessionId
* @return
*/
public static Online findBySessionId(String sessionId) {
JCacheParams params = new JCacheParams();
OnlineFilter filter = new OnlineFilter();
filter.setSessionId(sessionId);
params.valueFilter = filter;
try {
return (Online) onlines.get(params);
} catch (Exception e) {
log.log(e, Logger.LEVEL_ERROR);
return null;
}
}
Aggregations