mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 17:13:21 +00:00 
			
		
		
		
	GUAC-340: Expose available protocols within Environment.
This commit is contained in:
		| @@ -0,0 +1,102 @@ | ||||
| /* | ||||
|  * 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.protocols; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collection; | ||||
|  | ||||
| /** | ||||
|  * Describes a protocol and all parameters associated with it, as required by | ||||
|  * a protocol plugin for guacd. This class allows known parameters for a | ||||
|  * protocol to be exposed to the user as friendly fields. | ||||
|  * | ||||
|  * @author Michael Jumper | ||||
|  */ | ||||
| public class ProtocolInfo { | ||||
|  | ||||
|     /** | ||||
|      * The human-readable title associated with this protocol. | ||||
|      */ | ||||
|     private String title; | ||||
|  | ||||
|     /** | ||||
|      * The unique name associated with this protocol. | ||||
|      */ | ||||
|     private String name; | ||||
|  | ||||
|     /** | ||||
|      * A collection of all associated protocol parameters. | ||||
|      */ | ||||
|     private Collection<ProtocolParameter> parameters = | ||||
|             new ArrayList<ProtocolParameter>(); | ||||
|  | ||||
|     /** | ||||
|      * Returns the human-readable title associated with this protocol. | ||||
|      * | ||||
|      * @return The human-readable title associated with this protocol. | ||||
|      */ | ||||
|     public String getTitle() { | ||||
|         return title; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Sets the human-readable title associated with this protocol. | ||||
|      * | ||||
|      * @param title The human-readable title to associate with this protocol. | ||||
|      */ | ||||
|     public void setTitle(String title) { | ||||
|         this.title = title; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns the unique name of this protocol. The protocol name is the | ||||
|      * value required by the corresponding protocol plugin for guacd. | ||||
|      * | ||||
|      * @return The unique name of this protocol. | ||||
|      */ | ||||
|     public String getName() { | ||||
|         return name; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Sets the unique name of this protocol. The protocol name is the value | ||||
|      * required by the corresponding protocol plugin for guacd. | ||||
|      * | ||||
|      * @param name The unique name of this protocol. | ||||
|      */ | ||||
|     public void setName(String name) { | ||||
|         this.name = name; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns a mutable collection of the protocol parameters associated with | ||||
|      * this protocol. Changes to this collection affect the parameters exposed | ||||
|      * to the user. | ||||
|      * | ||||
|      * @return A mutable collection of protocol parameters. | ||||
|      */ | ||||
|     public Collection<ProtocolParameter> getParameters() { | ||||
|         return parameters; | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,192 @@ | ||||
| /* | ||||
|  * 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.protocols; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collection; | ||||
|  | ||||
| /** | ||||
|  * Represents a parameter of a protocol. | ||||
|  * | ||||
|  * @author Michael Jumper | ||||
|  */ | ||||
| public class ProtocolParameter { | ||||
|  | ||||
|     /** | ||||
|      * All possible types of protocol parameter. | ||||
|      */ | ||||
|     public enum Type { | ||||
|  | ||||
|         /** | ||||
|          * A text parameter, accepting arbitrary values. | ||||
|          */ | ||||
|         TEXT, | ||||
|  | ||||
|         /** | ||||
|          * A username parameter. This parameter type generally behaves | ||||
|          * identically to arbitrary text parameters, but has semantic | ||||
|          * differences. If credential pass-through is in use, the value for this | ||||
|          * parameter may be automatically provided using the credentials | ||||
|          * originally used by the user to authenticate. | ||||
|          */ | ||||
|         USERNAME, | ||||
|  | ||||
|         /** | ||||
|          * A password parameter, whose value is sensitive and must be hidden. If | ||||
|          * credential pass-through is in use, the value for this parameter may | ||||
|          * be automatically provided using the credentials originally used by | ||||
|          * the user to authenticate. | ||||
|          */ | ||||
|         PASSWORD, | ||||
|  | ||||
|         /** | ||||
|          * A numeric parameter, whose value must contain only digits. | ||||
|          */ | ||||
|         NUMERIC, | ||||
|  | ||||
|         /** | ||||
|          * A boolean parameter, whose value is either blank or "true". | ||||
|          */ | ||||
|         BOOLEAN, | ||||
|  | ||||
|         /** | ||||
|          * An enumerated parameter, whose legal values are fully enumerated | ||||
|          * by a provided, finite list. | ||||
|          */ | ||||
|         ENUM, | ||||
|  | ||||
|         /** | ||||
|          * A text parameter that can span more than one line. | ||||
|          */ | ||||
|         MULTILINE | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * The unique name that identifies this parameter to the protocol plugin. | ||||
|      */ | ||||
|     private String name; | ||||
|  | ||||
|     /** | ||||
|      * A human-readable name to be presented to the user. | ||||
|      */ | ||||
|     private String title; | ||||
|  | ||||
|     /** | ||||
|      * The type of this field. | ||||
|      */ | ||||
|     private Type type; | ||||
|  | ||||
|     /** | ||||
|      * The value of this parameter, for boolean parameters. | ||||
|      */ | ||||
|     private String value; | ||||
|  | ||||
|     /** | ||||
|      * A collection of all associated parameter options. | ||||
|      */ | ||||
|     private Collection<ProtocolParameterOption> options = | ||||
|             new ArrayList<ProtocolParameterOption>(); | ||||
|  | ||||
|     /** | ||||
|      * Returns the name associated with this protocol parameter. | ||||
|      * @return The name associated with this protocol parameter. | ||||
|      */ | ||||
|     public String getName() { | ||||
|         return name; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Sets the name associated with this protocol parameter. This name must | ||||
|      * uniquely identify this parameter among the others accepted by the | ||||
|      * corresponding protocol. | ||||
|      * | ||||
|      * @param name The name to assign to this protocol parameter. | ||||
|      */ | ||||
|     public void setName(String name) { | ||||
|         this.name = name; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns the title associated with this protocol parameter. | ||||
|      * @return The title associated with this protocol parameter. | ||||
|      */ | ||||
|     public String getTitle() { | ||||
|         return title; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Sets the title associated with this protocol parameter. The title must | ||||
|      * be a human-readable string which describes accurately this parameter. | ||||
|      * | ||||
|      * @param title A human-readable string describing this parameter. | ||||
|      */ | ||||
|     public void setTitle(String title) { | ||||
|         this.title = title; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns the value associated with this protocol parameter. | ||||
|      * @return The value associated with this protocol parameter. | ||||
|      */ | ||||
|     public String getValue() { | ||||
|         return value; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Sets the value associated with this protocol parameter. The value must | ||||
|      * be a human-readable string which describes accurately this parameter. | ||||
|      * | ||||
|      * @param value A human-readable string describing this parameter. | ||||
|      */ | ||||
|     public void setValue(String value) { | ||||
|         this.value = value; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns the type of this parameter. | ||||
|      * @return The type of this parameter. | ||||
|      */ | ||||
|     public Type getType() { | ||||
|         return type; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Sets the type of this parameter. | ||||
|      * @param type The type of this parameter. | ||||
|      */ | ||||
|     public void setType(Type type) { | ||||
|         this.type = type; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns a mutable collection of protocol parameter options. Changes to | ||||
|      * this collection directly affect the available options. | ||||
|      * | ||||
|      * @return A mutable collection of parameter options. | ||||
|      */ | ||||
|     public Collection<ProtocolParameterOption> getOptions() { | ||||
|         return options; | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,79 @@ | ||||
| /* | ||||
|  * 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.protocols; | ||||
|  | ||||
| /** | ||||
|  * Describes an available legal value for an enumerated protocol parameter. | ||||
|  * | ||||
|  * @author Michael Jumper | ||||
|  */ | ||||
| public class ProtocolParameterOption { | ||||
|  | ||||
|     /** | ||||
|      * The value that will be sent to the client plugin if this option is | ||||
|      * chosen. | ||||
|      */ | ||||
|     private String value; | ||||
|  | ||||
|     /** | ||||
|      * A human-readable title describing the effect of the value. | ||||
|      */ | ||||
|     private String title; | ||||
|  | ||||
|     /** | ||||
|      * Returns the value that will be sent to the client plugin if this option | ||||
|      * is chosen. | ||||
|      * | ||||
|      * @return The value that will be sent if this option is chosen. | ||||
|      */ | ||||
|     public String getValue() { | ||||
|         return value; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Sets the value that will be sent to the client plugin if this option is | ||||
|      * chosen. | ||||
|      * | ||||
|      * @param value The value to send if this option is chosen. | ||||
|      */ | ||||
|     public void setValue(String value) { | ||||
|         this.value = value; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns the human-readable title describing the effect of this option. | ||||
|      * @return The human-readable title describing the effect of this option. | ||||
|      */ | ||||
|     public String getTitle() { | ||||
|         return title; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Sets the human-readable title describing the effect of this option. | ||||
|      * @param title A human-readable title describing the effect of this option. | ||||
|      */ | ||||
|     public void setTitle(String title) { | ||||
|         this.title = title; | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user