nikolas.laskaris 2016-06-30 14:36:52 +00:00
parent 3585efbcfe
commit 3cbc8fd0cf
3 changed files with 264 additions and 166 deletions

10
pom.xml
View File

@ -9,7 +9,7 @@
<groupId>org.gcube.applicationsupportlayer</groupId> <groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslcore</artifactId> <artifactId>aslcore</artifactId>
<version>4.6.3-SNAPSHOT</version> <version>5.0.0-SNAPSHOT</version>
<name>Application Support Layer Core</name> <name>Application Support Layer Core</name>
<description>Library supporting dissemination of gCube content with OAI-ORE</description> <description>Library supporting dissemination of gCube content with OAI-ORE</description>
@ -91,6 +91,14 @@
<version>2.3.0</version> <version>2.3.0</version>
</dependency> </dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>

View File

@ -3,9 +3,12 @@ package org.gcube.application.framework.core.session;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import javax.servlet.http.HttpSession;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
@ -28,7 +31,6 @@ import org.w3c.dom.NodeList;
//import org.gridforum.jgss.ExtendedGSSCredential; //import org.gridforum.jgss.ExtendedGSSCredential;
/** /**
* ASLSession is deprecated. Do all handling through HttpSession instead
* *
* @author Valia Tsagkalidou (NKUA) * @author Valia Tsagkalidou (NKUA)
*/ */
@ -37,22 +39,24 @@ public class ASLSession{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private HashMap<String, Object> innerSession; // private HashMap<String, Object> innerSession;
private long lastUsedTime; private HttpSession session;
private String externalSessionID;
private String username; // private long lastUsedTime;
private String parentScope; // private String externalSessionID;
private String scope; // private String username;
private String securityToken; // private String parentScope;
private HashMap<String, Notifier> notifiers; // private String scope;
String scopeName; // private String securityToken;
private ASLGroupModel groupModel; // private HashMap<String, Notifier> notifiers;
// String scopeName;
// private ASLGroupModel groupModel;
private boolean loggedIn = false; private boolean loggedIn = false;
private String userEmailAddress; // private String userEmailAddress;
private String fullName; // private String fullName;
private String avatarId; // private String avatarId;
private GenderType gender; // private GenderType gender;
private long sessionTimeout = -1; //if < 0, not set private long sessionTimeout = -1; //if < 0, not set
@ -67,23 +71,38 @@ public class ASLSession{
* @param externalSessionId the external id * @param externalSessionId the external id
* @param user the username * @param user the username
*/ */
ASLSession(String externalSessionId, String user) ASLSession(HttpSession session, String user)
{ {
innerSession = new HashMap<String, Object>(); this.session = session;
notifiers = new HashMap<String, Notifier>(); session.setAttribute("notifiers", new HashMap<String, Notifier>());
lastUsedTime = System.currentTimeMillis(); session.setAttribute("lastUsedTime", System.currentTimeMillis());
username = user; session.setAttribute("username", user);
externalSessionID = externalSessionId; session.setAttribute("groupModel", new ASLGroupModel());
groupModel = new ASLGroupModel();
// innerSession = new HashMap<String, Object>();
// notifiers = new HashMap<String, Notifier>();
// lastUsedTime = System.currentTimeMillis();
// username = user;
// externalSessionID = session.getId();
// groupModel = new ASLGroupModel();
} }
private void initializeAttributes() { private void initializeAttributes() {
for (String key:innerSession.keySet()) { Enumeration <String> sessAttrNames = session.getAttributeNames();
while(sessAttrNames.hasMoreElements()){
String key = sessAttrNames.nextElement();
if (key.equals("collectionsPresentableFields") || key.equals(SessionConstants.collectionsHierarchy)) { if (key.equals("collectionsPresentableFields") || key.equals(SessionConstants.collectionsHierarchy)) {
innerSession.remove(key); session.removeAttribute(key);
break; break;
} }
} }
//REPLACED BY ABOVE
// for (String key:innerSession.keySet()) {
// if (key.equals("collectionsPresentableFields") || key.equals(SessionConstants.collectionsHierarchy)) {
// innerSession.remove(key);
// break;
// }
// }
} }
/** /**
@ -95,6 +114,10 @@ public class ASLSession{
* @throws ParserConfigurationException * @throws ParserConfigurationException
*/ */
public long getSessionTimeoutMillis() throws IOException, ParserConfigurationException { public long getSessionTimeoutMillis() throws IOException, ParserConfigurationException {
return session.getMaxInactiveInterval() * 1000;
/*
if(sessionTimeout > 0) //means that is already set to a value ! if(sessionTimeout > 0) //means that is already set to a value !
return sessionTimeout; return sessionTimeout;
int timeoutMins; int timeoutMins;
@ -145,6 +168,7 @@ public class ASLSession{
sessionTimeout = timeoutMins * 60000; //in milliseconds sessionTimeout = timeoutMins * 60000; //in milliseconds
logger.info("Session Timeout is: " + sessionTimeout); logger.info("Session Timeout is: " + sessionTimeout);
return sessionTimeout; return sessionTimeout;
*/
} }
/** /**
@ -154,10 +178,13 @@ public class ASLSession{
* @return the new timeout in milliseconds * @return the new timeout in milliseconds
*/ */
public long increaseSessionTimeout(long milliseconds, boolean resetCounting){ public long increaseSessionTimeout(long milliseconds, boolean resetCounting){
if(resetCounting) int secs = (int)milliseconds/1000;
lastUsedTime = System.currentTimeMillis(); session.setMaxInactiveInterval(session.getMaxInactiveInterval() + secs);
sessionTimeout += milliseconds; return session.getMaxInactiveInterval()*1000;
return sessionTimeout; // if(resetCounting)
// lastUsedTime = System.currentTimeMillis();
// sessionTimeout += milliseconds;
// return sessionTimeout;
} }
@ -166,6 +193,14 @@ public class ASLSession{
*/ */
public boolean isValid() public boolean isValid()
{ {
try {
session.getCreationTime();
} catch (IllegalStateException ise) {
return false;
}
return true;
/*
long maxTime = -1; //it will never be -1 long maxTime = -1; //it will never be -1
try { try {
maxTime = getSessionTimeoutMillis(); maxTime = getSessionTimeoutMillis();
@ -174,15 +209,21 @@ public class ASLSession{
if((System.currentTimeMillis() - lastUsedTime) > maxTime) if((System.currentTimeMillis() - lastUsedTime) > maxTime)
return false; return false;
return true; return true;
*/
} }
/** /**
* SHOULD NOT BE USED
*
* @return whether the session is empty or not * @return whether the session is empty or not
*/ */
@Deprecated
public boolean isEmpty() public boolean isEmpty()
{ {
lastUsedTime = System.currentTimeMillis(); // lastUsedTime = System.currentTimeMillis();
return innerSession.isEmpty(); return getAttributeNames().isEmpty();
//REPLACED BY ABOVE
// return innerSession.isEmpty();
} }
/** /**
@ -191,8 +232,10 @@ public class ASLSession{
*/ */
public boolean hasAttribute(String name) public boolean hasAttribute(String name)
{ {
lastUsedTime = System.currentTimeMillis(); // lastUsedTime = System.currentTimeMillis();
return innerSession.containsKey(name); return (session.getAttribute(name)==null) ? false : true;
//REPLACED BY ABOVE
// return innerSession.containsKey(name);
} }
/** /**
@ -200,8 +243,14 @@ public class ASLSession{
*/ */
public Set<String> getAttributeNames() public Set<String> getAttributeNames()
{ {
lastUsedTime = System.currentTimeMillis(); // lastUsedTime = System.currentTimeMillis();
return innerSession.keySet(); Enumeration<String> names = session.getAttributeNames();
Set<String> output = new HashSet<String>();
while(names.hasMoreElements())
output.add(names.nextElement());
return output;
//REPLACED BY ABOVE
// return innerSession.keySet();
} }
/** /**
@ -213,12 +262,14 @@ public class ASLSession{
@Deprecated @Deprecated
public Object getAttribute(String name) public Object getAttribute(String name)
{ {
lastUsedTime = System.currentTimeMillis(); // lastUsedTime = System.currentTimeMillis();
return innerSession.get(name); return session.getAttribute(name);
//REPLACED BY ABOVE
// return innerSession.get(name);
} }
/** /**
* <b>ASLSession is deprecated. Should not store attributes here.</b> * <b>ASLSession is deprecated.</b>
* *
* @param name the name of the attribute * @param name the name of the attribute
* @param value the value of the attribute * @param value the value of the attribute
@ -226,17 +277,20 @@ public class ASLSession{
@Deprecated @Deprecated
public void setAttribute(String name, Object value) public void setAttribute(String name, Object value)
{ {
lastUsedTime = System.currentTimeMillis(); // lastUsedTime = System.currentTimeMillis();
innerSession.put(name, value); session.setAttribute(name, value);
//REPLACED BY ABOVE
// innerSession.put(name, value);
} }
public String getOriginalScopeName() { public String getOriginalScopeName() {
return scopeName; return (String) session.getAttribute("scopeName");
//return scopeName;
} }
/** /**
* *
* <b>ASLSession is deprecated. Should not store attributes here.</b> * <b>ASLSession is deprecated. </b>
* *
* *
* @param name the name of the attribute * @param name the name of the attribute
@ -245,23 +299,32 @@ public class ASLSession{
@Deprecated @Deprecated
public Object removeAttribute(String name) public Object removeAttribute(String name)
{ {
lastUsedTime = System.currentTimeMillis(); // lastUsedTime = System.currentTimeMillis();
return innerSession.remove(name); Object attr = session.getAttribute(name);
session.removeAttribute(name);
return attr;
//REPLACED BY ABOVE
// return innerSession.remove(name);
} }
/** /**
* DO NOT USE THIS
*
* Removes all the attributes from the session * Removes all the attributes from the session
*/ */
@Deprecated
public void removeAll() public void removeAll()
{ {
lastUsedTime = System.currentTimeMillis(); // lastUsedTime = System.currentTimeMillis();
innerSession.clear(); for(String name : getAttributeNames())
session.removeAttribute(name);
//REPLACED BY ABOVE
// innerSession.clear();
} }
public String getParentScope(){ public String getParentScope(){
ScopeBean bean = new ScopeBean(getScope()); ScopeBean bean = new ScopeBean(getScope());
parentScope = bean.enclosingScope().toString(); return bean.enclosingScope().toString();
return parentScope;
} }
/** /**
@ -269,85 +332,65 @@ public class ASLSession{
*/ */
public void invalidate() public void invalidate()
{ {
long maxTime = -1; //it will never be -1 session.setMaxInactiveInterval(0);
try {
maxTime = getSessionTimeoutMillis();
} catch (Exception e) { e.printStackTrace();}
lastUsedTime = System.currentTimeMillis() - maxTime - 120000; // 2 minutes excessive // long maxTime = -1; //it will never be -1
// try {
// maxTime = getSessionTimeoutMillis();
// } catch (Exception e) { e.printStackTrace();}
//
// lastUsedTime = System.currentTimeMillis() - maxTime - 120000; // 2 minutes excessive
} }
/**
* @return the credential
*/
/*
DO NOT FORGET TO COMMENT OUT THIS WHEN THE NEW SECURITY MODEL IS AVAILABLE
public ExtendedGSSCredential getCredential() {
return credential;
}
*/
/** /**
* @return the external session id (passed to the constructor) * @return the external session id (passed to the constructor)
*/ */
public String getExternalSessionID() { public String getExternalSessionID() {
return externalSessionID; return session.getId();
// return externalSessionID;
} }
/** /**
* @return the username * @return the username
*/ */
public String getUsername() { public String getUsername() {
return username; return (String)session.getAttribute("username");
// return username;
} }
/** /**
* @return the scope * @return the scope
*/ */
public String getScope() { public String getScope() {
if(scope==null) String scp = (String)session.getAttribute("scope");
if(scp==null)
logger.debug("Scope is null, returning null"); logger.debug("Scope is null, returning null");
return scope; return scp;
} }
/** /**
* @return the name of the scope (VRE) * @return the name of the scope (VRE)
*/ */
public String getScopeName(){ public String getScopeName(){
if(scope==null) String scp = (String)session.getAttribute("scope");
if(scp==null)
logger.debug("Scope is null, returning null"); logger.debug("Scope is null, returning null");
return scope; return scp;
} }
/** /**
* @param scope the scope name (VRE) * @param scope the scope name (VRE)
*/ */
public void setScope(String scope) { public void setScope(String scope) {
logger.info("The scope about to set is: " + scope); logger.info("The scope about to set is: " + scope);
lastUsedTime = System.currentTimeMillis(); // lastUsedTime = System.currentTimeMillis();
/* String previousScopeName = (String)session.getAttribute("scope");
String[] split = scope.trim().substring(1).split("/",2); session.setAttribute("scope", scope);
//Uncomment this and comment the line bellow for devsec session.setAttribute("scopeName", scope);
//String vo = "/" + split[0].toLowerCase();
String vo = "/" + split[0];
if(split.length > 1)
vo += "/" + split[1];
*/
// String currentScope = ScopeProvider.instance.get();
// logger.info("GCube scope returns: " + currentScope);
String previousScopeName = this.scopeName;
this.scope = scope;
this.scopeName = scope;
ScopeProvider.instance.set(scope); ScopeProvider.instance.set(scope);
/* DO NOT FORGET TO ADD THIS WHEN THE NEW SECURITY MODEL IS AVAILABLE !
if(new PortalSecurityManager(this.scope).isSecurityEnabled())
this.credential = UserCredential.getCredential(username, scope);
*/
// get the attribute that indicates of log in has been done from the login portlet - or if the user logs in from a bookmark // get the attribute that indicates of log in has been done from the login portlet - or if the user logs in from a bookmark
if (loggedIn == true) { if (loggedIn == true) {
// don't log // don't log
@ -357,12 +400,13 @@ public class ASLSession{
logger.debug("Passing the logging because the variable was set"); logger.debug("Passing the logging because the variable was set");
return; return;
} }
if ((previousScopeName != null && !previousScopeName.equals(scopeName)) || previousScopeName == null) { if ((previousScopeName != null && !previousScopeName.equals((String)session.getAttribute("scope"))) || previousScopeName == null) {
logger.info("Logging the entrance"); logger.info("Logging the entrance");
innerSession.clear(); //TODO: Should do something with the below line
// innerSession.clear();
// ACCESS LOGGER // ACCESS LOGGER
LoginToVreAccessLogEntry loginEntry = new LoginToVreAccessLogEntry(); LoginToVreAccessLogEntry loginEntry = new LoginToVreAccessLogEntry();
accessLogger.logEntry(username, scope, loginEntry); accessLogger.logEntry((String)session.getAttribute("username"), scope, loginEntry);
} else } else
logger.debug("Passing the logging because the scope was the same"); logger.debug("Passing the logging because the scope was the same");
initializeAttributes(); initializeAttributes();
@ -370,18 +414,30 @@ public class ASLSession{
} }
@SuppressWarnings("unchecked")
private void addNotifier(String key, Notifier value){
((HashMap<String, Notifier>)session.getAttribute("notifiers")).put(key, value);
}
@SuppressWarnings("unchecked")
private Notifier getNotifier(String key){
return ((HashMap<String, Notifier>)session.getAttribute("notifiers")).get(key);
}
public void setSecurityToken(String token){ public void setSecurityToken(String token){
SecurityTokenProvider.instance.set(token); SecurityTokenProvider.instance.set(token);
this.securityToken = token; session.setAttribute("securityToken", token);
//REPLACED BY ABOVE
// this.securityToken = token;
} }
public void logUserLogin(String scope) { public void logUserLogin(String scope) {
innerSession.clear(); // innerSession.clear();
loggedIn = true; loggedIn = true;
// ACCESS LOGGER // ACCESS LOGGER
LoginToVreAccessLogEntry loginEntry = new LoginToVreAccessLogEntry(); LoginToVreAccessLogEntry loginEntry = new LoginToVreAccessLogEntry();
accessLogger.logEntry(username, scope, loginEntry); accessLogger.logEntry((String)session.getAttribute("username"), scope, loginEntry);
} }
/** /**
@ -390,14 +446,14 @@ public class ASLSession{
*/ */
public void waitNotification(String notification) throws InterruptedException public void waitNotification(String notification) throws InterruptedException
{ {
Notifier notifier = notifiers.get(notification); Notifier notifier = getNotifier(notification);
if(notifier == null) if(notifier == null)
{ {
notifier = new Notifier(); notifier = new Notifier();
notifiers.put(notification, notifier); addNotifier(notification, notifier);
} }
lastUsedTime = System.currentTimeMillis(); // lastUsedTime = System.currentTimeMillis();
notifier.waitNotification(); notifier.waitNotification();
} }
@ -407,63 +463,89 @@ public class ASLSession{
*/ */
public void notifyAllWaiting(String notification) throws InterruptedException public void notifyAllWaiting(String notification) throws InterruptedException
{ {
Notifier notifier = notifiers.get(notification); Notifier notifier = getNotifier(notification);
if(notifier == null) if(notifier == null)
{ {
notifier = new Notifier(); notifier = new Notifier();
notifiers.put(notification, notifier); addNotifier(notification, notifier);
} }
lastUsedTime = System.currentTimeMillis(); // lastUsedTime = System.currentTimeMillis();
notifier.notifyAllWaiting(); notifier.notifyAllWaiting();
} }
public void setGroupModelInfos(String groupName, long groupId) { public void setGroupModelInfos(String groupName, long groupId) {
groupModel.setGroupName(groupName); ASLGroupModel aslGM = ((ASLGroupModel)session.getAttribute("groupModel"));
groupModel.setGroupId(groupId); aslGM.setGroupName(groupName);
aslGM.setGroupId(groupId);
session.setAttribute("groupModel", aslGM);
//REPLACED BY ABOVE
// groupModel.setGroupName(groupName);
// groupModel.setGroupId(groupId);
} }
public long getGroupId() { public long getGroupId() {
return groupModel.getGroupId(); return ((ASLGroupModel)session.getAttribute("groupModel")).getGroupId();
//REPLACED BY ABOVE
// return groupModel.getGroupId();
} }
public String getGroupName() { public String getGroupName() {
return groupModel.getGroupName(); return ((ASLGroupModel)session.getAttribute("groupModel")).getGroupName();
//REPLACED BY ABOVE
// return groupModel.getGroupName();
} }
public void setUserEmailAddress(String email) { public void setUserEmailAddress(String email) {
this.userEmailAddress = email; session.setAttribute("userEmailAddress", email);
//REPLACED BY ABOVE
// this.userEmailAddress = email;
} }
public String getUserEmailAddress() { public String getUserEmailAddress() {
return this.userEmailAddress; return (String)session.getAttribute("userEmailAddress");
//REPLACED BY ABOVE
// return this.userEmailAddress;
} }
public void setUserFullName(String fullName) { public void setUserFullName(String fullName) {
this.fullName = fullName; session.setAttribute("fullName", fullName);
//REPLACED BY ABOVE
// this.fullName = fullName;
} }
public String getUserFullName() { public String getUserFullName() {
return this.fullName; return (String)session.getAttribute("fullName");
//REPLACED BY ABOVE
// return this.fullName;
} }
public void setUserAvatarId(String avatarId) { public void setUserAvatarId(String avatarId) {
this.avatarId = avatarId; session.setAttribute("avatarId", avatarId);
//REPLACED BY ABOVE
// this.avatarId = avatarId;
} }
public String getUserAvatarId() { public String getUserAvatarId() {
return this.avatarId; return (String)session.getAttribute("avatarId");
//REPLACED BY ABOVE
// return this.avatarId;
} }
public void setUserGender(GenderType gender) { public void setUserGender(GenderType gender) {
this.gender = gender; session.setAttribute("gender", gender);
//REPLACED BY ABOVE
// this.gender = gender;
} }
public GenderType getUserGender() { public GenderType getUserGender() {
return this.gender; return (GenderType)session.getAttribute("gender");
//REPLACED BY ABOVE
// return this.gender;
} }
public String getSecurityToken() { public String getSecurityToken() {
String securityToken = (String)session.getAttribute("securityToken");
logger.debug("Getting security token: " + securityToken+" in thread "+Thread.currentThread().getId()); logger.debug("Getting security token: " + securityToken+" in thread "+Thread.currentThread().getId());
return securityToken; return securityToken;
} }

View File

@ -5,6 +5,8 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
import javax.servlet.http.HttpSession;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -15,75 +17,81 @@ public class SessionManager {
/** The logger. */ /** The logger. */
private static final Logger logger = LoggerFactory.getLogger(SessionManager.class); private static final Logger logger = LoggerFactory.getLogger(SessionManager.class);
protected static Thread thread = new CleanSessionThread(); // protected static Thread thread = new CleanSessionThread();
protected static SessionManager sessionManager = new SessionManager(); protected static SessionManager sessionManager = new SessionManager();
protected HashMap<String, ASLSession> sessions; protected HashMap<String, ASLSession> sessions;
protected SessionManager() { protected SessionManager() {
sessions = new HashMap<String, ASLSession>(); sessions = new HashMap<String, ASLSession>();
thread.setDaemon(true); // thread.setDaemon(true);
thread.start(); // thread.start();
} }
public static SessionManager getInstance() { public static SessionManager getInstance() {
return sessionManager; return sessionManager;
} }
public void setASLSession(HttpSession userSession, String username){
ASLSession aslSession = new ASLSession(userSession, username);
sessions.put(userSession.getId() + "_" + username, aslSession);
}
public ASLSession getASLSession(String externalSessionID, String username) public ASLSession getASLSession(String externalSessionID, String username)
{ {
ASLSession session = sessions.get(externalSessionID + "_" + username); ASLSession session = sessions.get(externalSessionID + "_" + username);
if(session == null || !session.isValid() || !session.getUsername().equals(username)) // if(session == null || !session.isValid() || !session.getUsername().equals(username))
{ // {
session = new ASLSession(externalSessionID, username); // session = new ASLSession(externalSessionID, username);
sessions.put(externalSessionID + "_" + username, session); // sessions.put(externalSessionID + "_" + username, session);
} // }
if (session.getScope()!=null) //covers first helper's invocation // if (session.getScope()!=null) //covers first helper's invocation
ScopeProvider.instance.set(session.getScopeName()); // ScopeProvider.instance.set(session.getScopeName());
//
if (session.getSecurityToken()!=null){ // if (session.getSecurityToken()!=null){
logger.debug("Setting SecurityTokenProvider to: "+session.getSecurityToken()+" in thread "+Thread.currentThread().getId()); // logger.debug("Setting SecurityTokenProvider to: "+session.getSecurityToken()+" in thread "+Thread.currentThread().getId());
SecurityTokenProvider.instance.set(session.getSecurityToken()); // SecurityTokenProvider.instance.set(session.getSecurityToken());
} // }
return session; return session;
} }
@Override // @Override
protected void finalize() throws Throwable { // protected void finalize() throws Throwable {
thread.interrupt(); // thread.interrupt();
logger.debug(new Date(System.currentTimeMillis()) + " clean thread was interrupted"); // logger.debug(new Date(System.currentTimeMillis()) + " clean thread was interrupted");
thread.join(); // thread.join();
logger.debug(new Date(System.currentTimeMillis()) + " clean thread was joint"); // logger.debug(new Date(System.currentTimeMillis()) + " clean thread was joint");
super.finalize(); // super.finalize();
} // }
protected static class CleanSessionThread extends Thread // protected static class CleanSessionThread extends Thread
{ // {
public void run() // public void run()
{ // {
while(true) // while(true)
{ // {
try { // try {
Thread.sleep(300000); // Thread.sleep(300000);
} catch (InterruptedException e) { // } catch (InterruptedException e) {
logger.error("Exception:", e); // logger.error("Exception:", e);
logger.debug(new Date(System.currentTimeMillis()) + " clean thread was interrupted (in clean thread)"); // logger.debug(new Date(System.currentTimeMillis()) + " clean thread was interrupted (in clean thread)");
break; // break;
} // }
//TODO: cleanup invalid sessions: add locks... // //TODO: cleanup invalid sessions: add locks...
Set<String> keys = sessionManager.sessions.keySet(); // Set<String> keys = sessionManager.sessions.keySet();
Iterator<String> iter = keys.iterator(); // Iterator<String> iter = keys.iterator();
while(iter.hasNext()) // while(iter.hasNext())
{ // {
String extSessionID = iter.next(); // String extSessionID = iter.next();
if(!sessionManager.sessions.get(extSessionID).isValid()) // if(!sessionManager.sessions.get(extSessionID).isValid())
{ // {
sessionManager.sessions.remove(extSessionID); // sessionManager.sessions.remove(extSessionID);
} // }
} // }
} // }
logger.debug(new Date(System.currentTimeMillis()) + " clean thread was terminated"); // logger.debug(new Date(System.currentTimeMillis()) + " clean thread was terminated");
} // }
//
} // }
} }