From ff286264e4472a62188ac3b0c4a1fb60c7faae44 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 23 Nov 2014 14:01:05 -0800 Subject: [PATCH 1/4] GUAC-340: Add Environment and LocalEnvironment, collectively replacing GuacamoleHome and GuacamoleProperties. Mark GuacamoleHome and GuacamoleProperties as deprecated. Remove use of deprecated classes within guacamole-ext. --- .../guacamole/environment/Environment.java | 134 ++++++++++++++ .../environment/LocalEnvironment.java | 164 ++++++++++++++++++ .../net/auth/simple/SimpleConnection.java | 11 +- .../guacamole/properties/GuacamoleHome.java | 13 ++ .../properties/GuacamoleProperties.java | 13 ++ 5 files changed, 331 insertions(+), 4 deletions(-) create mode 100644 guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/Environment.java create mode 100644 guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/LocalEnvironment.java diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/Environment.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/Environment.java new file mode 100644 index 000000000..8805c5173 --- /dev/null +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/Environment.java @@ -0,0 +1,134 @@ +/* + * Copyright (C) 2013 Glyptodon LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package org.glyptodon.guacamole.environment; + +import java.io.File; +import org.glyptodon.guacamole.GuacamoleException; +import org.glyptodon.guacamole.properties.BooleanGuacamoleProperty; +import org.glyptodon.guacamole.properties.GuacamoleProperty; +import org.glyptodon.guacamole.properties.IntegerGuacamoleProperty; +import org.glyptodon.guacamole.properties.StringGuacamoleProperty; + +/** + * The environment of an arbitrary Guacamole instance, describing available + * protocols, configuration parameters, and the GUACAMOLE_HOME directory. + * + * @author Michael Jumper + */ +public interface Environment { + + /** + * The hostname of the server where guacd (the Guacamole proxy server) is + * running. + */ + public static final StringGuacamoleProperty GUACD_HOSTNAME = new StringGuacamoleProperty() { + + @Override + public String getName() { return "guacd-hostname"; } + + }; + + /** + * The port that guacd (the Guacamole proxy server) is listening on. + */ + public static final IntegerGuacamoleProperty GUACD_PORT = new IntegerGuacamoleProperty() { + + @Override + public String getName() { return "guacd-port"; } + + }; + + /** + * Whether guacd requires SSL/TLS on connections. + */ + public static final BooleanGuacamoleProperty GUACD_SSL = new BooleanGuacamoleProperty() { + + @Override + public String getName() { return "guacd-ssl"; } + + }; + + /** + * Returns the Guacamole home directory as determined when this Environment + * object was created. The Guacamole home directory is found by checking, in + * order: the guacamole.home system property, the GUACAMOLE_HOME environment + * variable, and finally the .guacamole directory in the home directory of + * the user running the servlet container. + * + * @return The File representing the Guacamole home directory, which may + * or may not exist, and may turn out to not be a directory. + */ + public File getGuacamoleHome(); + + /** + * Given a GuacamoleProperty, parses and returns the value set for that + * property in guacamole.properties, if any. + * + * @param The type that the given property is parsed into. + * @param property The property to read from guacamole.properties. + * @return The parsed value of the property as read from + * guacamole.properties. + * @throws GuacamoleException If an error occurs while parsing the value + * for the given property in + * guacamole.properties. + */ + public Type getProperty(GuacamoleProperty property) + throws GuacamoleException; + + /** + * Given a GuacamoleProperty, parses and returns the value set for that + * property in guacamole.properties, if any. If no value is found, the + * provided default value is returned. + * + * @param The type that the given property is parsed into. + * @param property The property to read from guacamole.properties. + * @param defaultValue The value to return if no value was given in + * guacamole.properties. + * @return The parsed value of the property as read from + * guacamole.properties, or the provided default value if no value + * was found. + * @throws GuacamoleException If an error occurs while parsing the value + * for the given property in + * guacamole.properties. + */ + public Type getProperty(GuacamoleProperty property, + Type defaultValue) throws GuacamoleException; + + /** + * Given a GuacamoleProperty, parses and returns the value set for that + * property in guacamole.properties. An exception is thrown if the value + * is not provided. + * + * @param The type that the given property is parsed into. + * @param property The property to read from guacamole.properties. + * @return The parsed value of the property as read from + * guacamole.properties. + * @throws GuacamoleException If an error occurs while parsing the value + * for the given property in + * guacamole.properties, or if the property is + * not specified. + */ + public Type getRequiredProperty(GuacamoleProperty property) + throws GuacamoleException; + +} diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/LocalEnvironment.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/LocalEnvironment.java new file mode 100644 index 000000000..0fe2880dc --- /dev/null +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/LocalEnvironment.java @@ -0,0 +1,164 @@ +/* + * Copyright (C) 2013 Glyptodon LLC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package org.glyptodon.guacamole.environment; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; +import org.glyptodon.guacamole.GuacamoleException; +import org.glyptodon.guacamole.GuacamoleServerException; +import org.glyptodon.guacamole.properties.GuacamoleProperty; + +/** + * The environment of the locally-running Guacamole instance, describing + * available protocols, configuration parameters, and the GUACAMOLE_HOME + * directory. + * + * @author Michael Jumper + */ +public class LocalEnvironment implements Environment { + + /** + * All properties read from guacamole.properties. + */ + private final Properties properties; + + /** + * The location of GUACAMOLE_HOME, which may not truly exist. + */ + private final File guacHome; + + /** + * Creates a new Environment, initializing that environment based on the + * location of GUACAMOLE_HOME and the contents of guacamole.properties. + * + * @throws GuacamoleException If an error occurs while determining the + * environment of this Guacamole instance. + */ + public LocalEnvironment() throws GuacamoleException { + + properties = new Properties(); + guacHome = findGuacamoleHome(); + + try { + + InputStream stream; + + // If not a directory, load from classpath + if (!guacHome.isDirectory()) { + + // Read from classpath + stream = LocalEnvironment.class.getResourceAsStream("/guacamole.properties"); + if (stream == null) + throw new GuacamoleServerException( + "guacamole.properties not loaded from " + guacHome + + " (not a directory), and guacamole.properties could" + + " not be found as a resource in the classpath."); + + } + + // Otherwise, try to load from file + else + stream = new FileInputStream(new File(guacHome, "guacamole.properties")); + + // Load properties, always close stream + try { properties.load(stream); } + finally { stream.close(); } + + } + catch (IOException e) { + throw new GuacamoleServerException("Error reading guacamole.properties", e); + } + + } + + /** + * Locates the Guacamole home directory by checking, in order: + * the guacamole.home system property, the GUACAMOLE_HOME environment + * variable, and finally the .guacamole directory in the home directory of + * the user running the servlet container. + * + * @return The File representing the Guacamole home directory, which may + * or may not exist, and may turn out to not be a directory. + */ + private static File findGuacamoleHome() { + + // Attempt to find Guacamole home + File guacHome; + + // Use system property by default + String desiredDir = System.getProperty("guacamole.home"); + + // Failing that, try the GUACAMOLE_HOME environment variable + if (desiredDir == null) desiredDir = System.getenv("GUACAMOLE_HOME"); + + // If successful, use explicitly specified directory + if (desiredDir != null) + guacHome = new File(desiredDir); + + // If not explicitly specified, use ~/.guacamole + else + guacHome = new File(System.getProperty("user.home"), ".guacamole"); + + // Return discovered directory + return guacHome; + + } + + @Override + public File getGuacamoleHome() { + return guacHome; + } + + @Override + public Type getProperty(GuacamoleProperty property) throws GuacamoleException { + return property.parseValue(properties.getProperty(property.getName())); + } + + @Override + public Type getProperty(GuacamoleProperty property, + Type defaultValue) throws GuacamoleException { + + Type value = getProperty(property); + if (value == null) + return defaultValue; + + return value; + + } + + @Override + public Type getRequiredProperty(GuacamoleProperty property) + throws GuacamoleException { + + Type value = getProperty(property); + if (value == null) + throw new GuacamoleServerException("Property " + property.getName() + " is required."); + + return value; + + } + +} diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnection.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnection.java index b8f1fd327..5065ef5d7 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnection.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnection.java @@ -25,12 +25,13 @@ package org.glyptodon.guacamole.net.auth.simple; import java.util.Collections; import java.util.List; import org.glyptodon.guacamole.GuacamoleException; +import org.glyptodon.guacamole.environment.Environment; +import org.glyptodon.guacamole.environment.LocalEnvironment; import org.glyptodon.guacamole.net.GuacamoleSocket; import org.glyptodon.guacamole.net.InetGuacamoleSocket; import org.glyptodon.guacamole.net.SSLGuacamoleSocket; import org.glyptodon.guacamole.net.auth.AbstractConnection; import org.glyptodon.guacamole.net.auth.ConnectionRecord; -import org.glyptodon.guacamole.properties.GuacamoleProperties; import org.glyptodon.guacamole.protocol.ConfiguredGuacamoleSocket; import org.glyptodon.guacamole.protocol.GuacamoleClientInformation; import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; @@ -81,12 +82,14 @@ public class SimpleConnection extends AbstractConnection { public GuacamoleSocket connect(GuacamoleClientInformation info) throws GuacamoleException { + Environment env = new LocalEnvironment(); + // Get guacd connection parameters - String hostname = GuacamoleProperties.getProperty(GuacamoleProperties.GUACD_HOSTNAME); - int port = GuacamoleProperties.getProperty(GuacamoleProperties.GUACD_PORT); + String hostname = env.getProperty(Environment.GUACD_HOSTNAME); + int port = env.getProperty(Environment.GUACD_PORT); // If guacd requires SSL, use it - if (GuacamoleProperties.getProperty(GuacamoleProperties.GUACD_SSL, false)) + if (env.getProperty(Environment.GUACD_SSL, false)) return new ConfiguredGuacamoleSocket( new SSLGuacamoleSocket(hostname, port), config, info diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/properties/GuacamoleHome.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/properties/GuacamoleHome.java index a9a5165a4..b629183cd 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/properties/GuacamoleHome.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/properties/GuacamoleHome.java @@ -23,14 +23,27 @@ package org.glyptodon.guacamole.properties; import java.io.File; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Abstract representation of the Guacamole configuration directory. * + * @deprecated * @author Michael Jumper */ public class GuacamoleHome { + /** + * Logger for this class. + */ + private static final Logger logger = LoggerFactory.getLogger(GuacamoleHome.class); + + static { + // Warn about deprecation + logger.warn("GuacamoleHome is deprecated. Please use Environment instead."); + } + /** * GuacamoleHome is a utility class and cannot be instantiated. */ diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/properties/GuacamoleProperties.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/properties/GuacamoleProperties.java index 88925bd66..891667e05 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/properties/GuacamoleProperties.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/properties/GuacamoleProperties.java @@ -29,6 +29,8 @@ import java.io.InputStream; import java.util.Properties; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleServerException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Simple utility class for reading properties from the guacamole.properties @@ -39,10 +41,21 @@ import org.glyptodon.guacamole.GuacamoleServerException; * If none of those locations are possible, guacamole.properties will also * be read from the root of the classpath. * + * @deprecated * @author Michael Jumper */ public class GuacamoleProperties { + /** + * Logger for this class. + */ + private static final Logger logger = LoggerFactory.getLogger(GuacamoleProperties.class); + + static { + // Warn about deprecation + logger.warn("GuacamoleProperties is deprecated. Please use Environment instead."); + } + /** * GuacamoleProperties is a utility class and cannot be instantiated. */ From 49b91ebe5691157894eb7e0b8b34b1f08141dd26 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 23 Nov 2014 17:39:48 -0800 Subject: [PATCH 2/4] GUAC-340: Expose available protocols within Environment. --- .../guacamole/environment/Environment.java | 20 +++ .../environment/LocalEnvironment.java | 170 +++++++++++++++++- .../guacamole/protocols}/ProtocolInfo.java | 2 +- .../protocols}/ProtocolParameter.java | 2 +- .../protocols}/ProtocolParameterOption.java | 2 +- .../guacamole}/xml/DocumentHandler.java | 2 +- .../glyptodon/guacamole}/xml/TagHandler.java | 2 +- .../guacamole}/xml/package-info.java | 2 +- .../xml/protocol/OptionTagHandler.java | 6 +- .../xml/protocol/ParamTagHandler.java | 6 +- .../xml/protocol/ProtocolTagHandler.java | 6 +- .../guacamole}/xml/protocol/package-info.java | 2 +- .../glyptodon/guacamole}/protocols/rdp.xml | 4 +- .../glyptodon/guacamole}/protocols/ssh.xml | 0 .../glyptodon/guacamole}/protocols/telnet.xml | 2 +- .../glyptodon/guacamole}/protocols/vnc.xml | 0 .../BasicFileAuthenticationProvider.java | 2 +- .../net/basic/crud/protocols/List.java | 137 +------------- .../xml/user_mapping/AuthorizeTagHandler.java | 2 +- .../user_mapping/ConnectionTagHandler.java | 2 +- .../xml/user_mapping/ParamTagHandler.java | 2 +- .../xml/user_mapping/ProtocolTagHandler.java | 2 +- .../user_mapping/UserMappingTagHandler.java | 2 +- 23 files changed, 222 insertions(+), 155 deletions(-) rename {guacamole/src/main/java/org/glyptodon/guacamole/net/basic => guacamole-ext/src/main/java/org/glyptodon/guacamole/protocols}/ProtocolInfo.java (98%) rename {guacamole/src/main/java/org/glyptodon/guacamole/net/basic => guacamole-ext/src/main/java/org/glyptodon/guacamole/protocols}/ProtocolParameter.java (99%) rename {guacamole/src/main/java/org/glyptodon/guacamole/net/basic => guacamole-ext/src/main/java/org/glyptodon/guacamole/protocols}/ProtocolParameterOption.java (98%) rename {guacamole/src/main/java/org/glyptodon/guacamole/net/basic => guacamole-ext/src/main/java/org/glyptodon/guacamole}/xml/DocumentHandler.java (99%) rename {guacamole/src/main/java/org/glyptodon/guacamole/net/basic => guacamole-ext/src/main/java/org/glyptodon/guacamole}/xml/TagHandler.java (98%) rename {guacamole/src/main/java/org/glyptodon/guacamole/net/basic => guacamole-ext/src/main/java/org/glyptodon/guacamole}/xml/package-info.java (96%) rename {guacamole/src/main/java/org/glyptodon/guacamole/net/basic => guacamole-ext/src/main/java/org/glyptodon/guacamole}/xml/protocol/OptionTagHandler.java (92%) rename {guacamole/src/main/java/org/glyptodon/guacamole/net/basic => guacamole-ext/src/main/java/org/glyptodon/guacamole}/xml/protocol/ParamTagHandler.java (95%) rename {guacamole/src/main/java/org/glyptodon/guacamole/net/basic => guacamole-ext/src/main/java/org/glyptodon/guacamole}/xml/protocol/ProtocolTagHandler.java (93%) rename {guacamole/src/main/java/org/glyptodon/guacamole/net/basic => guacamole-ext/src/main/java/org/glyptodon/guacamole}/xml/protocol/package-info.java (95%) rename {guacamole/src/main/resources/net/sourceforge/guacamole/net => guacamole-ext/src/main/resources/org/glyptodon/guacamole}/protocols/rdp.xml (99%) rename {guacamole/src/main/resources/net/sourceforge/guacamole/net => guacamole-ext/src/main/resources/org/glyptodon/guacamole}/protocols/ssh.xml (100%) rename {guacamole/src/main/resources/net/sourceforge/guacamole/net => guacamole-ext/src/main/resources/org/glyptodon/guacamole}/protocols/telnet.xml (99%) rename {guacamole/src/main/resources/net/sourceforge/guacamole/net => guacamole-ext/src/main/resources/org/glyptodon/guacamole}/protocols/vnc.xml (100%) diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/Environment.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/Environment.java index 8805c5173..3882cbab3 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/Environment.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/Environment.java @@ -23,11 +23,13 @@ package org.glyptodon.guacamole.environment; import java.io.File; +import java.util.Map; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.properties.BooleanGuacamoleProperty; import org.glyptodon.guacamole.properties.GuacamoleProperty; import org.glyptodon.guacamole.properties.IntegerGuacamoleProperty; import org.glyptodon.guacamole.properties.StringGuacamoleProperty; +import org.glyptodon.guacamole.protocols.ProtocolInfo; /** * The environment of an arbitrary Guacamole instance, describing available @@ -80,6 +82,24 @@ public interface Environment { */ public File getGuacamoleHome(); + /** + * Returns a map of all available protocols, where each key is the name of + * that protocol as would be passed to guacd during connection. + * + * @return A map of all available protocols. + */ + public Map getProtocols(); + + /** + * Returns the protocol having the given name. The name must be the + * protocol name as would be passed to guacd during connection. + * + * @param name The name of the protocol. + * @return The protocol having the given name, or null if no such + * protocol is registered. + */ + public ProtocolInfo getProtocol(String name); + /** * Given a GuacamoleProperty, parses and returns the value set for that * property in guacamole.properties, if any. diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/LocalEnvironment.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/LocalEnvironment.java index 0fe2880dc..c96f0dd4d 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/LocalEnvironment.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/environment/LocalEnvironment.java @@ -22,14 +22,27 @@ package org.glyptodon.guacamole.environment; +import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; +import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; import java.util.Properties; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleServerException; import org.glyptodon.guacamole.properties.GuacamoleProperty; +import org.glyptodon.guacamole.protocols.ProtocolInfo; +import org.glyptodon.guacamole.xml.DocumentHandler; +import org.glyptodon.guacamole.xml.protocol.ProtocolTagHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.XMLReaderFactory; /** * The environment of the locally-running Guacamole instance, describing @@ -40,6 +53,17 @@ import org.glyptodon.guacamole.properties.GuacamoleProperty; */ public class LocalEnvironment implements Environment { + /** + * Logger for this class. + */ + private static final Logger logger = LoggerFactory.getLogger(LocalEnvironment.class); + + /** + * Array of all known protocol names. + */ + private static final String[] KNOWN_PROTOCOLS = new String[]{ + "vnc", "rdp", "ssh", "telnet"}; + /** * All properties read from guacamole.properties. */ @@ -50,6 +74,11 @@ public class LocalEnvironment implements Environment { */ private final File guacHome; + /** + * The map of all available protocols. + */ + private final Map availableProtocols; + /** * Creates a new Environment, initializing that environment based on the * location of GUACAMOLE_HOME and the contents of guacamole.properties. @@ -59,9 +88,11 @@ public class LocalEnvironment implements Environment { */ public LocalEnvironment() throws GuacamoleException { - properties = new Properties(); + // Determine location of GUACAMOLE_HOME guacHome = findGuacamoleHome(); + // Read properties + properties = new Properties(); try { InputStream stream; @@ -92,6 +123,9 @@ public class LocalEnvironment implements Environment { throw new GuacamoleServerException("Error reading guacamole.properties", e); } + // Read all protocols + availableProtocols = readProtocols(); + } /** @@ -127,6 +161,130 @@ public class LocalEnvironment implements Environment { } + /** + * Parses the given XML file, returning the parsed ProtocolInfo. + * + * @param input An input stream containing XML describing the parameters + * associated with a protocol supported by Guacamole. + * @return A new ProtocolInfo object which contains the parameters described + * by the XML file parsed. + * @throws GuacamoleException If an error occurs while parsing the XML file. + */ + private ProtocolInfo readProtocol(InputStream input) + throws GuacamoleException { + + // Parse document + try { + + // Get handler for root element + ProtocolTagHandler protocolTagHandler = + new ProtocolTagHandler(); + + // Set up document handler + DocumentHandler contentHandler = new DocumentHandler( + "protocol", protocolTagHandler); + + // Set up XML parser + XMLReader parser = XMLReaderFactory.createXMLReader(); + parser.setContentHandler(contentHandler); + + // Read and parse file + InputStream xml = new BufferedInputStream(input); + parser.parse(new InputSource(xml)); + xml.close(); + + // Return parsed protocol + return protocolTagHandler.asProtocolInfo(); + + } + catch (IOException e) { + throw new GuacamoleException("Error reading basic user mapping file.", e); + } + catch (SAXException e) { + throw new GuacamoleException("Error parsing basic user mapping XML.", e); + } + + } + + /** + * Reads through all pre-defined protocols and any protocols within the + * "protocols" subdirectory of GUACAMOLE_HOME, returning a map containing + * each of these protocols. The key of each entry will be the name of that + * protocol, as would be passed to guacd during connection. + * + * @return A map of all available protocols. + * @throws GuacamoleException If an error occurs while reading the various + * protocol XML files. + */ + private Map readProtocols() throws GuacamoleException { + + // Map of all available protocols + Map protocols = new HashMap(); + + // Get protcols directory + File protocol_directory = new File(getGuacamoleHome(), "protocols"); + + // Read protocols from directory if it exists + if (protocol_directory.isDirectory()) { + + // Get all XML files + File[] files = protocol_directory.listFiles( + new FilenameFilter() { + + @Override + public boolean accept(File file, String string) { + return string.endsWith(".xml"); + } + + } + ); + + // Load each protocol from each file + for (File file : files) { + + try { + + // Parse protocol + FileInputStream stream = new FileInputStream(file); + ProtocolInfo protocol = readProtocol(stream); + stream.close(); + + // Store protocol + protocols.put(protocol.getName(), protocol); + + } + catch (IOException e) { + logger.error("Unable to read connection parameter information from \"{}\": {}", file.getAbsolutePath(), e.getMessage()); + logger.debug("Error reading protocol XML.", e); + } + + } + + } + + // If known protocols are not already defined, read from classpath + for (String protocol : KNOWN_PROTOCOLS) { + + // If protocol not defined yet, attempt to load from classpath + if (!protocols.containsKey(protocol)) { + + InputStream stream = LocalEnvironment.class.getResourceAsStream( + "/org/glyptodon/guacamole/protocols/" + + protocol + ".xml"); + + // Parse XML if available + if (stream != null) + protocols.put(protocol, readProtocol(stream)); + + } + + } + + // Protocols map now fully populated + return protocols; + + } + @Override public File getGuacamoleHome() { return guacHome; @@ -161,4 +319,14 @@ public class LocalEnvironment implements Environment { } + @Override + public Map getProtocols() { + return availableProtocols; + } + + @Override + public ProtocolInfo getProtocol(String name) { + return availableProtocols.get(name); + } + } diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/ProtocolInfo.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/protocols/ProtocolInfo.java similarity index 98% rename from guacamole/src/main/java/org/glyptodon/guacamole/net/basic/ProtocolInfo.java rename to guacamole-ext/src/main/java/org/glyptodon/guacamole/protocols/ProtocolInfo.java index 3c2497175..ad3b5e7d4 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/ProtocolInfo.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/protocols/ProtocolInfo.java @@ -20,7 +20,7 @@ * THE SOFTWARE. */ -package org.glyptodon.guacamole.net.basic; +package org.glyptodon.guacamole.protocols; import java.util.ArrayList; import java.util.Collection; diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/ProtocolParameter.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/protocols/ProtocolParameter.java similarity index 99% rename from guacamole/src/main/java/org/glyptodon/guacamole/net/basic/ProtocolParameter.java rename to guacamole-ext/src/main/java/org/glyptodon/guacamole/protocols/ProtocolParameter.java index 48307387a..40b59a497 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/ProtocolParameter.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/protocols/ProtocolParameter.java @@ -20,7 +20,7 @@ * THE SOFTWARE. */ -package org.glyptodon.guacamole.net.basic; +package org.glyptodon.guacamole.protocols; import java.util.ArrayList; import java.util.Collection; diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/ProtocolParameterOption.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/protocols/ProtocolParameterOption.java similarity index 98% rename from guacamole/src/main/java/org/glyptodon/guacamole/net/basic/ProtocolParameterOption.java rename to guacamole-ext/src/main/java/org/glyptodon/guacamole/protocols/ProtocolParameterOption.java index 2027046ec..52d233a16 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/ProtocolParameterOption.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/protocols/ProtocolParameterOption.java @@ -20,7 +20,7 @@ * THE SOFTWARE. */ -package org.glyptodon.guacamole.net.basic; +package org.glyptodon.guacamole.protocols; /** * Describes an available legal value for an enumerated protocol parameter. diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/DocumentHandler.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/DocumentHandler.java similarity index 99% rename from guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/DocumentHandler.java rename to guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/DocumentHandler.java index c63c1b403..7f16a9916 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/DocumentHandler.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/DocumentHandler.java @@ -20,7 +20,7 @@ * THE SOFTWARE. */ -package org.glyptodon.guacamole.net.basic.xml; +package org.glyptodon.guacamole.xml; import java.util.Deque; import java.util.LinkedList; diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/TagHandler.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/TagHandler.java similarity index 98% rename from guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/TagHandler.java rename to guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/TagHandler.java index 88fed7bd6..b8904998d 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/TagHandler.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/TagHandler.java @@ -20,7 +20,7 @@ * THE SOFTWARE. */ -package org.glyptodon.guacamole.net.basic.xml; +package org.glyptodon.guacamole.xml; import org.xml.sax.Attributes; import org.xml.sax.SAXException; diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/package-info.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/package-info.java similarity index 96% rename from guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/package-info.java rename to guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/package-info.java index 91b6a3a6d..4b6d1562b 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/package-info.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/package-info.java @@ -24,5 +24,5 @@ * Classes driving the SAX-based XML parser used by the Guacamole web * application. */ -package org.glyptodon.guacamole.net.basic.xml; +package org.glyptodon.guacamole.xml; diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/protocol/OptionTagHandler.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/protocol/OptionTagHandler.java similarity index 92% rename from guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/protocol/OptionTagHandler.java rename to guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/protocol/OptionTagHandler.java index b05fac4f4..ce4299081 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/protocol/OptionTagHandler.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/protocol/OptionTagHandler.java @@ -20,10 +20,10 @@ * THE SOFTWARE. */ -package org.glyptodon.guacamole.net.basic.xml.protocol; +package org.glyptodon.guacamole.xml.protocol; -import org.glyptodon.guacamole.net.basic.ProtocolParameterOption; -import org.glyptodon.guacamole.net.basic.xml.TagHandler; +import org.glyptodon.guacamole.protocols.ProtocolParameterOption; +import org.glyptodon.guacamole.xml.TagHandler; import org.xml.sax.Attributes; import org.xml.sax.SAXException; diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/protocol/ParamTagHandler.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/protocol/ParamTagHandler.java similarity index 95% rename from guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/protocol/ParamTagHandler.java rename to guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/protocol/ParamTagHandler.java index 26336432e..cb59c04ed 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/protocol/ParamTagHandler.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/protocol/ParamTagHandler.java @@ -20,10 +20,10 @@ * THE SOFTWARE. */ -package org.glyptodon.guacamole.net.basic.xml.protocol; +package org.glyptodon.guacamole.xml.protocol; -import org.glyptodon.guacamole.net.basic.ProtocolParameter; -import org.glyptodon.guacamole.net.basic.xml.TagHandler; +import org.glyptodon.guacamole.protocols.ProtocolParameter; +import org.glyptodon.guacamole.xml.TagHandler; import org.xml.sax.Attributes; import org.xml.sax.SAXException; diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/protocol/ProtocolTagHandler.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/protocol/ProtocolTagHandler.java similarity index 93% rename from guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/protocol/ProtocolTagHandler.java rename to guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/protocol/ProtocolTagHandler.java index 601e485a7..562784509 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/protocol/ProtocolTagHandler.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/protocol/ProtocolTagHandler.java @@ -20,10 +20,10 @@ * THE SOFTWARE. */ -package org.glyptodon.guacamole.net.basic.xml.protocol; +package org.glyptodon.guacamole.xml.protocol; -import org.glyptodon.guacamole.net.basic.ProtocolInfo; -import org.glyptodon.guacamole.net.basic.xml.TagHandler; +import org.glyptodon.guacamole.protocols.ProtocolInfo; +import org.glyptodon.guacamole.xml.TagHandler; import org.xml.sax.Attributes; import org.xml.sax.SAXException; diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/protocol/package-info.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/protocol/package-info.java similarity index 95% rename from guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/protocol/package-info.java rename to guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/protocol/package-info.java index dba3f1b79..021d7b82d 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/protocol/package-info.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/xml/protocol/package-info.java @@ -24,5 +24,5 @@ * Classes related to parsing XML files which describe the parameters of a * protocol. */ -package org.glyptodon.guacamole.net.basic.xml.protocol; +package org.glyptodon.guacamole.xml.protocol; diff --git a/guacamole/src/main/resources/net/sourceforge/guacamole/net/protocols/rdp.xml b/guacamole-ext/src/main/resources/org/glyptodon/guacamole/protocols/rdp.xml similarity index 99% rename from guacamole/src/main/resources/net/sourceforge/guacamole/net/protocols/rdp.xml rename to guacamole-ext/src/main/resources/org/glyptodon/guacamole/protocols/rdp.xml index 7bd39404f..5904fb965 100644 --- a/guacamole/src/main/resources/net/sourceforge/guacamole/net/protocols/rdp.xml +++ b/guacamole-ext/src/main/resources/org/glyptodon/guacamole/protocols/rdp.xml @@ -40,10 +40,10 @@ - + - + diff --git a/guacamole/src/main/resources/net/sourceforge/guacamole/net/protocols/ssh.xml b/guacamole-ext/src/main/resources/org/glyptodon/guacamole/protocols/ssh.xml similarity index 100% rename from guacamole/src/main/resources/net/sourceforge/guacamole/net/protocols/ssh.xml rename to guacamole-ext/src/main/resources/org/glyptodon/guacamole/protocols/ssh.xml diff --git a/guacamole/src/main/resources/net/sourceforge/guacamole/net/protocols/telnet.xml b/guacamole-ext/src/main/resources/org/glyptodon/guacamole/protocols/telnet.xml similarity index 99% rename from guacamole/src/main/resources/net/sourceforge/guacamole/net/protocols/telnet.xml rename to guacamole-ext/src/main/resources/org/glyptodon/guacamole/protocols/telnet.xml index fe797436b..984b9caa1 100644 --- a/guacamole/src/main/resources/net/sourceforge/guacamole/net/protocols/telnet.xml +++ b/guacamole-ext/src/main/resources/org/glyptodon/guacamole/protocols/telnet.xml @@ -8,7 +8,7 @@ - + diff --git a/guacamole/src/main/resources/net/sourceforge/guacamole/net/protocols/vnc.xml b/guacamole-ext/src/main/resources/org/glyptodon/guacamole/protocols/vnc.xml similarity index 100% rename from guacamole/src/main/resources/net/sourceforge/guacamole/net/protocols/vnc.xml rename to guacamole-ext/src/main/resources/org/glyptodon/guacamole/protocols/vnc.xml diff --git a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/BasicFileAuthenticationProvider.java b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/BasicFileAuthenticationProvider.java index 0614d52e1..5cedcaa79 100644 --- a/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/BasicFileAuthenticationProvider.java +++ b/guacamole/src/main/java/net/sourceforge/guacamole/net/basic/BasicFileAuthenticationProvider.java @@ -33,7 +33,7 @@ import org.glyptodon.guacamole.net.auth.Credentials; import org.glyptodon.guacamole.net.auth.simple.SimpleAuthenticationProvider; import org.glyptodon.guacamole.net.basic.auth.Authorization; import org.glyptodon.guacamole.net.basic.auth.UserMapping; -import org.glyptodon.guacamole.net.basic.xml.DocumentHandler; +import org.glyptodon.guacamole.xml.DocumentHandler; import org.glyptodon.guacamole.net.basic.xml.user_mapping.UserMappingTagHandler; import org.glyptodon.guacamole.properties.FileGuacamoleProperty; import org.glyptodon.guacamole.properties.GuacamoleProperties; diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/crud/protocols/List.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/crud/protocols/List.java index 7efcf6b06..0c1bb1592 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/crud/protocols/List.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/crud/protocols/List.java @@ -22,13 +22,7 @@ package org.glyptodon.guacamole.net.basic.crud.protocols; -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FilenameFilter; import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -37,20 +31,15 @@ import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleServerException; +import org.glyptodon.guacamole.environment.Environment; +import org.glyptodon.guacamole.environment.LocalEnvironment; import org.glyptodon.guacamole.net.auth.UserContext; import org.glyptodon.guacamole.net.basic.RestrictedHttpServlet; -import org.glyptodon.guacamole.net.basic.ProtocolInfo; -import org.glyptodon.guacamole.net.basic.ProtocolParameter; -import org.glyptodon.guacamole.net.basic.ProtocolParameterOption; -import org.glyptodon.guacamole.net.basic.xml.DocumentHandler; -import org.glyptodon.guacamole.net.basic.xml.protocol.ProtocolTagHandler; -import org.glyptodon.guacamole.properties.GuacamoleHome; +import org.glyptodon.guacamole.protocols.ProtocolInfo; +import org.glyptodon.guacamole.protocols.ProtocolParameter; +import org.glyptodon.guacamole.protocols.ProtocolParameterOption; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLReaderFactory; /** * Simple HttpServlet which outputs XML containing a list of all visible @@ -65,57 +54,6 @@ public class List extends RestrictedHttpServlet { */ private Logger logger = LoggerFactory.getLogger(List.class); - /** - * Array of all known protocol names. - */ - private static final String[] KNOWN_PROTOCOLS = new String[]{ - "vnc", "rdp", "ssh", "telnet"}; - - /** - * Parses the given XML file, returning the parsed ProtocolInfo. - * - * @param input An input stream containing XML describing the parameters - * associated with a protocol supported by Guacamole. - * @return A new ProtocolInfo object which contains the parameters described - * by the XML file parsed. - * @throws GuacamoleException If an error occurs while parsing the XML file. - */ - private ProtocolInfo getProtocol(InputStream input) - throws GuacamoleException { - - // Parse document - try { - - // Get handler for root element - ProtocolTagHandler protocolTagHandler = - new ProtocolTagHandler(); - - // Set up document handler - DocumentHandler contentHandler = new DocumentHandler( - "protocol", protocolTagHandler); - - // Set up XML parser - XMLReader parser = XMLReaderFactory.createXMLReader(); - parser.setContentHandler(contentHandler); - - // Read and parse file - InputStream xml = new BufferedInputStream(input); - parser.parse(new InputSource(xml)); - xml.close(); - - // Return parsed protocol - return protocolTagHandler.asProtocolInfo(); - - } - catch (IOException e) { - throw new GuacamoleException("Error reading basic user mapping file.", e); - } - catch (SAXException e) { - throw new GuacamoleException("Error parsing basic user mapping XML.", e); - } - - } - /** * Given an XML stream and a fully-populated ProtocolInfo object, writes * out the corresponding protocol XML describing all available parameters. @@ -217,68 +155,9 @@ public class List extends RestrictedHttpServlet { // Set encoding response.setCharacterEncoding("UTF-8"); - // Map of all available protocols - Map protocols = new HashMap(); - - // Get protcols directory - File protocol_directory = new File(GuacamoleHome.getDirectory(), - "protocols"); - - // Read protocols from directory if it exists - if (protocol_directory.isDirectory()) { - - // Get all XML files - File[] files = protocol_directory.listFiles( - new FilenameFilter() { - - @Override - public boolean accept(File file, String string) { - return string.endsWith(".xml"); - } - - } - ); - - // Load each protocol from each file - for (File file : files) { - - try { - - // Parse protocol - FileInputStream stream = new FileInputStream(file); - ProtocolInfo protocol = getProtocol(stream); - stream.close(); - - // Store protocol - protocols.put(protocol.getName(), protocol); - - } - catch (IOException e) { - logger.error("Unable to read connection parameter information from \"{}\": {}", file.getAbsolutePath(), e.getMessage()); - logger.debug("Error reading protocol XML.", e); - } - - } - - } - - // If known protocols are not already defined, read from classpath - for (String protocol : KNOWN_PROTOCOLS) { - - // If protocol not defined yet, attempt to load from classpath - if (!protocols.containsKey(protocol)) { - - InputStream stream = List.class.getResourceAsStream( - "/net/sourceforge/guacamole/net/protocols/" - + protocol + ".xml"); - - // Parse XML if available - if (stream != null) - protocols.put(protocol, getProtocol(stream)); - - } - - } + // Retrieve map of all available protocols + Environment env = new LocalEnvironment(); + Map protocols = env.getProtocols(); // Write actual XML try { diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/AuthorizeTagHandler.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/AuthorizeTagHandler.java index b2fd3fa51..18e224378 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/AuthorizeTagHandler.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/AuthorizeTagHandler.java @@ -24,7 +24,7 @@ package org.glyptodon.guacamole.net.basic.xml.user_mapping; import org.glyptodon.guacamole.net.basic.auth.Authorization; import org.glyptodon.guacamole.net.basic.auth.UserMapping; -import org.glyptodon.guacamole.net.basic.xml.TagHandler; +import org.glyptodon.guacamole.xml.TagHandler; import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; import org.xml.sax.Attributes; import org.xml.sax.SAXException; diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/ConnectionTagHandler.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/ConnectionTagHandler.java index 14d07bb95..7473b7316 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/ConnectionTagHandler.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/ConnectionTagHandler.java @@ -23,7 +23,7 @@ package org.glyptodon.guacamole.net.basic.xml.user_mapping; import org.glyptodon.guacamole.net.basic.auth.Authorization; -import org.glyptodon.guacamole.net.basic.xml.TagHandler; +import org.glyptodon.guacamole.xml.TagHandler; import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; import org.xml.sax.Attributes; import org.xml.sax.SAXException; diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/ParamTagHandler.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/ParamTagHandler.java index a58783836..afc990ca8 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/ParamTagHandler.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/ParamTagHandler.java @@ -22,7 +22,7 @@ package org.glyptodon.guacamole.net.basic.xml.user_mapping; -import org.glyptodon.guacamole.net.basic.xml.TagHandler; +import org.glyptodon.guacamole.xml.TagHandler; import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; import org.xml.sax.Attributes; import org.xml.sax.SAXException; diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/ProtocolTagHandler.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/ProtocolTagHandler.java index f97323884..14a5758d0 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/ProtocolTagHandler.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/ProtocolTagHandler.java @@ -22,7 +22,7 @@ package org.glyptodon.guacamole.net.basic.xml.user_mapping; -import org.glyptodon.guacamole.net.basic.xml.TagHandler; +import org.glyptodon.guacamole.xml.TagHandler; import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; import org.xml.sax.Attributes; import org.xml.sax.SAXException; diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/UserMappingTagHandler.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/UserMappingTagHandler.java index 42960a33b..250f494c6 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/UserMappingTagHandler.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/xml/user_mapping/UserMappingTagHandler.java @@ -23,7 +23,7 @@ package org.glyptodon.guacamole.net.basic.xml.user_mapping; import org.glyptodon.guacamole.net.basic.auth.UserMapping; -import org.glyptodon.guacamole.net.basic.xml.TagHandler; +import org.glyptodon.guacamole.xml.TagHandler; import org.xml.sax.Attributes; import org.xml.sax.SAXException; From d9fcec314ac95f6cb4786fc6300e5d42b50f7e1b Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 28 Nov 2014 19:37:53 -0800 Subject: [PATCH 3/4] GUAC-930: Add Swedish keymap to known parameter values. --- .../src/main/resources/org/glyptodon/guacamole/protocols/rdp.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/guacamole-ext/src/main/resources/org/glyptodon/guacamole/protocols/rdp.xml b/guacamole-ext/src/main/resources/org/glyptodon/guacamole/protocols/rdp.xml index 5904fb965..d31ab3ec2 100644 --- a/guacamole-ext/src/main/resources/org/glyptodon/guacamole/protocols/rdp.xml +++ b/guacamole-ext/src/main/resources/org/glyptodon/guacamole/protocols/rdp.xml @@ -23,6 +23,7 @@ + From 71e445952de2c9c3b7c5757eb9514cc446de9cd8 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 9 Dec 2014 20:53:06 -0800 Subject: [PATCH 4/4] GUAC-933: Do not set parent identifier to the string "null". --- .../guacamole/net/auth/mysql/MySQLConnection.java | 8 +++++++- .../guacamole/net/auth/mysql/MySQLConnectionGroup.java | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnection.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnection.java index 66879cf4a..d0b95f073 100644 --- a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnection.java +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnection.java @@ -103,7 +103,13 @@ public class MySQLConnection extends AbstractConnection { */ public void setParentID(Integer parentID) { this.parentID = parentID; - this.setParentIdentifier(String.valueOf(parentID)); + + // Translate to string identifier + if (parentID != null) + this.setParentIdentifier(String.valueOf(parentID)); + else + this.setParentIdentifier(null); + } /** diff --git a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnectionGroup.java b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnectionGroup.java index aabd40ab3..cc879f818 100644 --- a/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnectionGroup.java +++ b/extensions/guacamole-auth-mysql/src/main/java/net/sourceforge/guacamole/net/auth/mysql/MySQLConnectionGroup.java @@ -124,7 +124,13 @@ public class MySQLConnectionGroup extends AbstractConnectionGroup { */ public void setParentID(Integer parentID) { this.parentID = parentID; - this.setParentIdentifier(String.valueOf(parentID)); + + // Translate to string identifier + if (parentID != null) + this.setParentIdentifier(String.valueOf(parentID)); + else + this.setParentIdentifier(null); + } /**