private GuacamoleSocket getUnconfiguredGuacamoleSocket(
            GuacamoleProxyConfiguration proxyConfig,
            Runnable socketClosedCallback) throws GuacamoleException {

        // Select socket type depending on desired encryption
        switch (proxyConfig.getEncryptionMethod()) {

            // Use SSL if requested
            case SSL:
                return new ManagedSSLGuacamoleSocket(
                    proxyConfig.getHostname(),
                    proxyConfig.getPort(),
                    socketClosedCallback
                );

            // Use straight TCP if unencrypted
            case NONE:
                return new ManagedInetGuacamoleSocket(
                    proxyConfig.getHostname(),
                    proxyConfig.getPort(),
                    socketClosedCallback
                );

        }

        // Bail out if encryption method is unknown
        throw new GuacamoleServerException("Unimplemented encryption method.");

    }
Returns an unconfigured GuacamoleSocket that is already connected to
guacd as specified in guacamole.properties, using SSL if necessary.

@param proxyConfig
    The configuration information to use when connecting to guacd.

@param socketClosedCallback
    The callback which should be invoked whenever the returned socket
    closes.

@return
    An unconfigured GuacamoleSocket, already connected to guacd.

@throws GuacamoleException 
    If an error occurs while connecting to guacd, or while parsing
    guacd-related properties.
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/AbstractGuacamoleTunnelService.java