mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 17:13:21 +00:00 
			
		
		
		
	GUACAMOLE-1: Refactor org.glyptodon package/groupId to org.apache.
This commit is contained in:
		| @@ -0,0 +1,57 @@ | ||||
| /* | ||||
|  * 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.apache.guacamole.properties; | ||||
|  | ||||
| import org.apache.guacamole.GuacamoleException; | ||||
| import org.apache.guacamole.GuacamoleServerException; | ||||
|  | ||||
| /** | ||||
|  * A GuacamoleProperty whose value is an boolean. Legal true values are "true", | ||||
|  * or "false". Case does not matter. | ||||
|  * | ||||
|  * @author Michael Jumper | ||||
|  */ | ||||
| public abstract class BooleanGuacamoleProperty implements GuacamoleProperty<Boolean> { | ||||
|  | ||||
|     @Override | ||||
|     public Boolean parseValue(String value) throws GuacamoleException { | ||||
|  | ||||
|         // If no property provided, return null. | ||||
|         if (value == null) | ||||
|             return null; | ||||
|  | ||||
|         // If "true", return true | ||||
|         if (value.equalsIgnoreCase("true")) | ||||
|             return true; | ||||
|  | ||||
|         // If "false", return false | ||||
|         if (value.equalsIgnoreCase("false")) | ||||
|             return false; | ||||
|  | ||||
|         // Otherwise, fail | ||||
|         throw new GuacamoleServerException("Property \"" + getName() | ||||
|                 + "\" must be either \"true\" or \"false\"."); | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,46 @@ | ||||
| /* | ||||
|  * 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.apache.guacamole.properties; | ||||
|  | ||||
| import java.io.File; | ||||
| import org.apache.guacamole.GuacamoleException; | ||||
|  | ||||
| /** | ||||
|  * A GuacamoleProperty whose value is a filename. | ||||
|  * | ||||
|  * @author Michael Jumper | ||||
|  */ | ||||
| public abstract class FileGuacamoleProperty implements GuacamoleProperty<File> { | ||||
|  | ||||
|     @Override | ||||
|     public File parseValue(String value) throws GuacamoleException { | ||||
|  | ||||
|         // If no property provided, return null. | ||||
|         if (value == null) | ||||
|             return null; | ||||
|  | ||||
|         return new File(value); | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,85 @@ | ||||
| /* | ||||
|  * 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.apache.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. | ||||
|      */ | ||||
|     private GuacamoleHome() {} | ||||
|  | ||||
|     /** | ||||
|      * Returns 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. | ||||
|      */ | ||||
|     public static File getDirectory() { | ||||
|  | ||||
|         // 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; | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,218 @@ | ||||
| /* | ||||
|  * 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.apache.guacamole.properties; | ||||
|  | ||||
| import java.io.File; | ||||
| import java.io.FileInputStream; | ||||
| import java.io.IOException; | ||||
| import java.io.InputStream; | ||||
| import java.util.Properties; | ||||
| import org.apache.guacamole.GuacamoleException; | ||||
| import org.apache.guacamole.GuacamoleServerException; | ||||
| import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | ||||
|  | ||||
| /** | ||||
|  * Simple utility class for reading properties from the guacamole.properties | ||||
|  * file. The guacamole.properties file is preferably located in the servlet | ||||
|  * container's user's home directory, in a subdirectory called .guacamole, or | ||||
|  * in the directory set by the system property: guacamole.home. | ||||
|  * | ||||
|  * 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. | ||||
|      */ | ||||
|     private GuacamoleProperties() {} | ||||
|  | ||||
|     /** | ||||
|      * 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"; } | ||||
|  | ||||
|     }; | ||||
|  | ||||
|     /** | ||||
|      * All properties read from guacamole.properties when this class was first | ||||
|      * used. | ||||
|      */ | ||||
|     private static final Properties properties; | ||||
|  | ||||
|     /** | ||||
|      * Any error encountered when reading guacamole.properties was last | ||||
|      * attempted. | ||||
|      */ | ||||
|     private static GuacamoleException exception; | ||||
|  | ||||
|     static { | ||||
|  | ||||
|         properties = new Properties(); | ||||
|  | ||||
|         try { | ||||
|  | ||||
|             // Attempt to find Guacamole home | ||||
|             File guacHome = GuacamoleHome.getDirectory(); | ||||
|  | ||||
|             InputStream stream; | ||||
|  | ||||
|             // If not a directory, load from classpath | ||||
|             if (!guacHome.isDirectory()) { | ||||
|  | ||||
|                 // Read from classpath | ||||
|                 stream = GuacamoleProperties.class.getResourceAsStream("/guacamole.properties"); | ||||
|                 if (stream == null) | ||||
|                     throw new IOException( | ||||
|                         "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) { | ||||
|             exception = new GuacamoleServerException("Error reading guacamole.properties", e); | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Given a GuacamoleProperty, parses and returns the value set for that | ||||
|      * property in guacamole.properties, if any. | ||||
|      * | ||||
|      * @param <Type> 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 static <Type> Type getProperty(GuacamoleProperty<Type> property) throws GuacamoleException { | ||||
|  | ||||
|         if (exception != null) | ||||
|             throw exception; | ||||
|  | ||||
|         return property.parseValue(properties.getProperty(property.getName())); | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 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 <Type> 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 static <Type> Type getProperty(GuacamoleProperty<Type> property, | ||||
|             Type defaultValue) throws GuacamoleException { | ||||
|  | ||||
|         Type value = getProperty(property); | ||||
|         if (value == null) | ||||
|             return defaultValue; | ||||
|  | ||||
|         return value; | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 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 <Type> 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 static <Type> Type getRequiredProperty(GuacamoleProperty<Type> property) | ||||
|             throws GuacamoleException { | ||||
|  | ||||
|         Type value = getProperty(property); | ||||
|         if (value == null) | ||||
|             throw new GuacamoleServerException("Property " + property.getName() + " is required."); | ||||
|  | ||||
|         return value; | ||||
|  | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,56 @@ | ||||
| /* | ||||
|  * 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.apache.guacamole.properties; | ||||
|  | ||||
| import org.apache.guacamole.GuacamoleException; | ||||
|  | ||||
| /** | ||||
|  * An abstract representation of a property in the guacamole.properties file, | ||||
|  * which parses into a specific type. | ||||
|  * | ||||
|  * @author Michael Jumper | ||||
|  * @param <Type> The type this GuacamoleProperty will parse into. | ||||
|  */ | ||||
| public interface GuacamoleProperty<Type> { | ||||
|  | ||||
|     /** | ||||
|      * Returns the name of the property in guacamole.properties that this | ||||
|      * GuacamoleProperty will parse. | ||||
|      * | ||||
|      * @return The name of the property in guacamole.properties that this | ||||
|      *         GuacamoleProperty will parse. | ||||
|      */ | ||||
|     public String getName(); | ||||
|  | ||||
|     /** | ||||
|      * Parses the given string value into the type associated with this | ||||
|      * GuacamoleProperty. | ||||
|      * | ||||
|      * @param value The string value to parse. | ||||
|      * @return The parsed value. | ||||
|      * @throws GuacamoleException If an error occurs while parsing the | ||||
|      *                            provided value. | ||||
|      */ | ||||
|     public Type parseValue(String value) throws GuacamoleException; | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,52 @@ | ||||
| /* | ||||
|  * 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.apache.guacamole.properties; | ||||
|  | ||||
| import org.apache.guacamole.GuacamoleException; | ||||
| import org.apache.guacamole.GuacamoleServerException; | ||||
|  | ||||
| /** | ||||
|  * A GuacamoleProperty whose value is an integer. | ||||
|  * | ||||
|  * @author Michael Jumper | ||||
|  */ | ||||
| public abstract class IntegerGuacamoleProperty implements GuacamoleProperty<Integer> { | ||||
|  | ||||
|     @Override | ||||
|     public Integer parseValue(String value) throws GuacamoleException { | ||||
|  | ||||
|         // If no property provided, return null. | ||||
|         if (value == null) | ||||
|             return null; | ||||
|  | ||||
|         try { | ||||
|             Integer integer = new Integer(value); | ||||
|             return integer; | ||||
|         } | ||||
|         catch (NumberFormatException e) { | ||||
|             throw new GuacamoleServerException("Property \"" + getName() + "\" must be an integer.", e); | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,52 @@ | ||||
| /* | ||||
|  * 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.apache.guacamole.properties; | ||||
|  | ||||
| import org.apache.guacamole.GuacamoleException; | ||||
| import org.apache.guacamole.GuacamoleServerException; | ||||
|  | ||||
| /** | ||||
|  * A GuacamoleProperty whose value is an long. | ||||
|  * | ||||
|  * @author James Muehlner | ||||
|  */ | ||||
| public abstract class LongGuacamoleProperty implements GuacamoleProperty<Long> { | ||||
|  | ||||
|     @Override | ||||
|     public Long parseValue(String value) throws GuacamoleException { | ||||
|  | ||||
|         // If no property provided, return null. | ||||
|         if (value == null) | ||||
|             return null; | ||||
|  | ||||
|         try { | ||||
|             Long longValue = new Long(value); | ||||
|             return longValue; | ||||
|         } | ||||
|         catch (NumberFormatException e) { | ||||
|             throw new GuacamoleServerException("Property \"" + getName() + "\" must be an long.", e); | ||||
|         } | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,39 @@ | ||||
| /* | ||||
|  * 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.apache.guacamole.properties; | ||||
|  | ||||
| import org.apache.guacamole.GuacamoleException; | ||||
|  | ||||
| /** | ||||
|  * A GuacamoleProperty whose value is a simple string. | ||||
|  * | ||||
|  * @author Michael Jumper | ||||
|  */ | ||||
| public abstract class StringGuacamoleProperty implements GuacamoleProperty<String> { | ||||
|  | ||||
|     @Override | ||||
|     public String parseValue(String value) throws GuacamoleException { | ||||
|         return value; | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,28 @@ | ||||
| /* | ||||
|  * 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. | ||||
|  */ | ||||
|  | ||||
| /** | ||||
|  * Provides classes for reading properties from the web-application-wide | ||||
|  * guacamole.properties file. | ||||
|  */ | ||||
| package org.apache.guacamole.properties; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user