blob: 3b79c5d3027f64ccf56ab202b597b2e096bfd571 (
plain) (
tree)
|
|
package org.openslx.imagemaster.serversession;
import java.util.List;
import org.openslx.imagemaster.Globals;
import org.openslx.imagemaster.db.models.LocalSatellite;
/**
* Holds the session id of the server and manages the timeout.
*/
public class ServerSession
{
private static final long TIMEOUT = Long.valueOf( Globals.getSessionTimeoutServer() ) * 1000L;
private long timeOut = 0;
private final LocalSatellite serverUser;
public ServerSession(final LocalSatellite serverUser)
{
this.serverUser = serverUser;
this.timeOut = System.currentTimeMillis() + TIMEOUT;
}
public synchronized void refresh()
{
if ( timedOut() )
return; // Don't allow refreshing timed out session
this.timeOut = System.currentTimeMillis() + TIMEOUT;
}
public synchronized boolean timedOut()
{
return System.currentTimeMillis() > this.timeOut;
}
public String getOrganizationId()
{
return serverUser.organizationId;
}
public List<String> getAddresses()
{
return serverUser.addresses;
}
}
|