GUACAMOLE-189: Refactor GuacamoleProxyConfiguration to guacamole-ext.

This commit is contained in:
Michael Jumper
2017-01-24 21:38:31 -08:00
parent 152de87dc2
commit 31b1b42ba6
10 changed files with 89 additions and 75 deletions

View File

@@ -22,6 +22,7 @@ package org.apache.guacamole.environment;
import java.io.File;
import java.util.Map;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration;
import org.apache.guacamole.properties.BooleanGuacamoleProperty;
import org.apache.guacamole.properties.GuacamoleProperty;
import org.apache.guacamole.properties.IntegerGuacamoleProperty;
@@ -146,4 +147,19 @@ public interface Environment {
public <Type> Type getRequiredProperty(GuacamoleProperty<Type> property)
throws GuacamoleException;
/**
* Returns the connection information which should be used, by default, to
* connect to guacd when establishing a remote desktop connection.
*
* @return
* The connection information which should be used, by default, to
* connect to guacd.
*
* @throws GuacamoleException
* If the the connection information for guacd cannot be
* retrieved.
*/
public GuacamoleProxyConfiguration getDefaultGuacamoleProxyConfiguration()
throws GuacamoleException;
}

View File

@@ -30,6 +30,7 @@ import java.util.Properties;
import org.codehaus.jackson.map.ObjectMapper;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.GuacamoleServerException;
import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration;
import org.apache.guacamole.properties.GuacamoleProperty;
import org.apache.guacamole.protocols.ProtocolInfo;
import org.slf4j.Logger;
@@ -53,6 +54,24 @@ public class LocalEnvironment implements Environment {
private static final String[] KNOWN_PROTOCOLS = new String[]{
"vnc", "rdp", "ssh", "telnet"};
/**
* The hostname to use when connecting to guacd if no hostname is provided
* within guacamole.properties.
*/
private static final String DEFAULT_GUACD_HOSTNAME = "localhost";
/**
* The port to use when connecting to guacd if no port is provided within
* guacamole.properties.
*/
private static final int DEFAULT_GUACD_PORT = 4822;
/**
* Whether SSL/TLS is enabled for connections to guacd if not specified
* within guacamole.properties.
*/
private static final boolean DEFAULT_GUACD_SSL = false;
/**
* All properties read from guacamole.properties.
*/
@@ -313,4 +332,17 @@ public class LocalEnvironment implements Environment {
return availableProtocols.get(name);
}
@Override
public GuacamoleProxyConfiguration getDefaultGuacamoleProxyConfiguration()
throws GuacamoleException {
// Parse guacd hostname/port/ssl properties
return new GuacamoleProxyConfiguration(
getProperty(Environment.GUACD_HOSTNAME, DEFAULT_GUACD_HOSTNAME),
getProperty(Environment.GUACD_PORT, DEFAULT_GUACD_PORT),
getProperty(Environment.GUACD_SSL, DEFAULT_GUACD_SSL)
);
}
}