GUAC-919: Use minutes for timeout value.

This commit is contained in:
Michael Jumper
2014-11-03 01:11:20 -08:00
parent 44d924f1f9
commit 9821c38bb8
2 changed files with 8 additions and 7 deletions

View File

@@ -24,7 +24,7 @@ package org.glyptodon.guacamole.net.basic.properties;
import org.glyptodon.guacamole.properties.BooleanGuacamoleProperty;
import org.glyptodon.guacamole.properties.FileGuacamoleProperty;
import org.glyptodon.guacamole.properties.LongGuacamoleProperty;
import org.glyptodon.guacamole.properties.IntegerGuacamoleProperty;
/**
* Properties used by the default Guacamole web application.
@@ -82,9 +82,9 @@ public class BasicGuacamoleProperties {
};
/**
* The session timeout for the API, in milliseconds.
* The session timeout for the API, in minutes.
*/
public static final LongGuacamoleProperty API_SESSION_TIMEOUT = new LongGuacamoleProperty() {
public static final IntegerGuacamoleProperty API_SESSION_TIMEOUT = new IntegerGuacamoleProperty() {
@Override
public String getName() { return "api-session-timeout"; }

View File

@@ -65,20 +65,21 @@ public class BasicTokenSessionMap implements TokenSessionMap {
*/
public BasicTokenSessionMap() {
long sessionTimeoutValue;
int sessionTimeoutValue;
// Read session timeout from guacamole.properties
try {
sessionTimeoutValue = GuacamoleProperties.getProperty(BasicGuacamoleProperties.API_SESSION_TIMEOUT, 3600000l);
sessionTimeoutValue = GuacamoleProperties.getProperty(BasicGuacamoleProperties.API_SESSION_TIMEOUT, 60);
}
catch (GuacamoleException e) {
logger.error("Unable to read guacamole.properties: {}", e.getMessage());
logger.debug("Error while reading session timeout value.", e);
sessionTimeoutValue = 3600000l;
sessionTimeoutValue = 60;
}
// Check for expired sessions every minute
executor.scheduleAtFixedRate(new SessionEvictionTask(sessionTimeoutValue), 1, 1, TimeUnit.MINUTES);
logger.info("Sessions will expire after {} minutes of inactivity.", sessionTimeoutValue);
executor.scheduleAtFixedRate(new SessionEvictionTask(sessionTimeoutValue * 60000l), 1, 1, TimeUnit.MINUTES);
}