From c9f7bdef0de346af3698b5996af92b3919afbd7a Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 1 Mar 2015 23:43:25 -0800 Subject: [PATCH] GUAC-1101: Use SSL if requested. Use provided client information. --- .../AbstractGuacamoleSocketService.java | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/socket/AbstractGuacamoleSocketService.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/socket/AbstractGuacamoleSocketService.java index 465416ae5..084823684 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/socket/AbstractGuacamoleSocketService.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/socket/AbstractGuacamoleSocketService.java @@ -212,6 +212,35 @@ public abstract class AbstractGuacamoleSocketService implements GuacamoleSocketS connectionRecordMapper.insert(recordModel); } + + /** + * Returns an unconfigured GuacamoleSocket that is already connected to + * guacd as specified in guacamole.properties, using SSL if necessary. + * + * @return + * An unconfigured GuacamoleSocket, already connected to guacd. + * + * @throws GuacamoleException + * If an error occurs while connecting to guacd, or while parsing + * guacd-related properties. + */ + private GuacamoleSocket getUnconfiguredGuacamoleSocket() + throws GuacamoleException { + + // Use SSL if requested + if (environment.getProperty(Environment.GUACD_SSL, true)) + return new InetGuacamoleSocket( + environment.getRequiredProperty(Environment.GUACD_HOSTNAME), + environment.getRequiredProperty(Environment.GUACD_PORT) + ); + + // Otherwise, just use straight TCP + return new InetGuacamoleSocket( + environment.getRequiredProperty(Environment.GUACD_HOSTNAME), + environment.getRequiredProperty(Environment.GUACD_PORT) + ); + + } /** * Creates a socket for the given user which connects to the given @@ -251,7 +280,7 @@ public abstract class AbstractGuacamoleSocketService implements GuacamoleSocketS final AtomicBoolean released = new AtomicBoolean(false); final String identifier = connection.getIdentifier(); final String parentIdentifier = connection.getParentIdentifier(); - + // Return new socket try { @@ -261,11 +290,9 @@ public abstract class AbstractGuacamoleSocketService implements GuacamoleSocketS // Return newly-reserved connection return new ConfiguredGuacamoleSocket( - new InetGuacamoleSocket( - environment.getRequiredProperty(Environment.GUACD_HOSTNAME), - environment.getRequiredProperty(Environment.GUACD_PORT) - ), - getGuacamoleConfiguration(user, connection) + getUnconfiguredGuacamoleSocket(), + getGuacamoleConfiguration(user, connection), + info ) { @Override