From 68a9a4f6dcb0a873e9c9e15babaa7b12847ef799 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Wed, 5 Nov 2014 12:07:36 -0800 Subject: [PATCH] GUAC-919: Implement basic session invalidate(). --- .../guacamole/net/basic/GuacamoleSession.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/GuacamoleSession.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/GuacamoleSession.java index 9c1f28bd4..dcf3bd705 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/GuacamoleSession.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/GuacamoleSession.java @@ -26,7 +26,6 @@ import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Date; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.glyptodon.guacamole.GuacamoleException; @@ -35,6 +34,8 @@ import org.glyptodon.guacamole.net.auth.Credentials; import org.glyptodon.guacamole.net.auth.UserContext; import org.glyptodon.guacamole.net.basic.properties.BasicGuacamoleProperties; import org.glyptodon.guacamole.properties.GuacamoleProperties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Contains Guacamole-specific user information which is tied to the current @@ -44,6 +45,11 @@ import org.glyptodon.guacamole.properties.GuacamoleProperties; */ public class GuacamoleSession { + /** + * Logger for this class. + */ + private static final Logger logger = LoggerFactory.getLogger(GuacamoleSession.class); + /** * The credentials provided when the user logged in. */ @@ -234,5 +240,23 @@ public class GuacamoleSession { public long getLastAccessedTime() { return lastAccessedTime; } + + /** + * Closes all associated tunnels and prevents any further use of this + * session. + */ + public void invalidate() { + + // Close all associated tunnels, if possible + for (GuacamoleTunnel tunnel : tunnels.values()) { + try { + tunnel.close(); + } + catch (GuacamoleException e) { + logger.debug("Unable to close tunnel.", e); + } + } + + } }