Merge pull request #189 from glyptodon/forms

GUAC-800: Migrate to JSON for protocol descriptions.
This commit is contained in:
James Muehlner
2015-05-26 10:41:14 -07:00
31 changed files with 1271 additions and 877 deletions

View File

@@ -33,7 +33,7 @@ import java.util.Collections;
import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.auth.jdbc.base.RestrictedObject;
import org.glyptodon.guacamole.auth.jdbc.activeconnection.ActiveConnectionDirectory;
import org.glyptodon.guacamole.form.Parameter;
import org.glyptodon.guacamole.form.Field;
import org.glyptodon.guacamole.net.auth.ActiveConnection;
import org.glyptodon.guacamole.net.auth.Connection;
import org.glyptodon.guacamole.net.auth.ConnectionGroup;
@@ -134,18 +134,18 @@ public class UserContext extends RestrictedObject
}
@Override
public Collection<Parameter> getUserAttributes() {
return Collections.<Parameter>emptyList();
public Collection<Field> getUserAttributes() {
return Collections.<Field>emptyList();
}
@Override
public Collection<Parameter> getConnectionAttributes() {
return Collections.<Parameter>emptyList();
public Collection<Field> getConnectionAttributes() {
return Collections.<Field>emptyList();
}
@Override
public Collection<Parameter> getConnectionGroupAttributes() {
return Collections.<Parameter>emptyList();
public Collection<Field> getConnectionGroupAttributes() {
return Collections.<Field>emptyList();
}
}

View File

@@ -128,6 +128,13 @@
<scope>test</scope>
</dependency>
<!-- Jackson for JSON support -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.2</version>
</dependency>
</dependencies>
</project>

View File

@@ -22,7 +22,6 @@
package org.glyptodon.guacamole.environment;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilenameFilter;
@@ -31,18 +30,13 @@ import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import org.codehaus.jackson.map.ObjectMapper;
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
@@ -79,6 +73,11 @@ public class LocalEnvironment implements Environment {
*/
private final Map<String, ProtocolInfo> availableProtocols;
/**
* The Jackson parser for parsing JSON files.
*/
private static final ObjectMapper mapper = new ObjectMapper();
/**
* Creates a new Environment, initializing that environment based on the
* location of GUACAMOLE_HOME and the contents of guacamole.properties.
@@ -162,48 +161,25 @@ public class LocalEnvironment implements Environment {
}
/**
* Parses the given XML file, returning the parsed ProtocolInfo.
* Parses the given JSON file, returning the parsed ProtocolInfo. The JSON
* format is conveniently and intentionally identical to a serialized
* ProtocolInfo object, which is identical to the JSON format used by the
* protocol REST service built into the Guacamole web application.
*
* @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.
* @param input
* An input stream containing JSON describing the forms and parameters
* associated with a protocol supported by Guacamole.
*
* @return
* A new ProtocolInfo object which contains the forms and parameters
* described by the JSON file parsed.
*
* @throws IOException
* If an error occurs while parsing the JSON 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);
}
throws IOException {
return mapper.readValue(input, ProtocolInfo.class);
}
/**
@@ -212,9 +188,11 @@ public class LocalEnvironment implements Environment {
* 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.
* @return
* A map of all available protocols.
*
* @throws GuacamoleException
* If an error occurs while reading the various protocol JSON files.
*/
private Map<String, ProtocolInfo> readProtocols() throws GuacamoleException {
@@ -227,13 +205,13 @@ public class LocalEnvironment implements Environment {
// Read protocols from directory if it exists
if (protocol_directory.isDirectory()) {
// Get all XML files
// Get all JSON files
File[] files = protocol_directory.listFiles(
new FilenameFilter() {
@Override
public boolean accept(File file, String string) {
return string.endsWith(".xml");
return string.endsWith(".json");
}
}
@@ -261,7 +239,7 @@ public class LocalEnvironment implements Environment {
}
catch (IOException e) {
logger.error("Unable to read connection parameter information from \"{}\": {}", file.getAbsolutePath(), e.getMessage());
logger.debug("Error reading protocol XML.", e);
logger.debug("Error reading protocol JSON.", e);
}
}
@@ -276,11 +254,18 @@ public class LocalEnvironment implements Environment {
InputStream stream = LocalEnvironment.class.getResourceAsStream(
"/org/glyptodon/guacamole/protocols/"
+ protocol + ".xml");
+ protocol + ".json");
// Parse XML if available
if (stream != null)
protocols.put(protocol, readProtocol(stream));
// Parse JSON if available
if (stream != null) {
try {
protocols.put(protocol, readProtocol(stream));
}
catch (IOException e) {
logger.error("Unable to read pre-defined connection parameter information for protocol \"{}\": {}", protocol, e.getMessage());
logger.debug("Error reading pre-defined protocol JSON.", e);
}
}
}

View File

@@ -0,0 +1,277 @@
/*
* 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.form;
import java.util.ArrayList;
import java.util.Collection;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Represents an arbitrary field, such as an HTTP parameter, the parameter of a
* remote desktop protocol, or an input field within a form.
*
* @author Michael Jumper
*/
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class Field {
/**
* All possible types of field.
*/
public enum Type {
/**
* A text field, accepting arbitrary values.
*/
TEXT,
/**
* A username field. This field type generally behaves identically to
* arbitrary text fields, but has semantic differences.
*/
USERNAME,
/**
* A password field, whose value is sensitive and must be hidden.
*/
PASSWORD,
/**
* A numeric field, whose value must contain only digits.
*/
NUMERIC,
/**
* A boolean field, whose value is either blank or "true".
*/
BOOLEAN,
/**
* An enumerated field, whose legal values are fully enumerated by a
* provided, finite list.
*/
ENUM,
/**
* A text field that can span more than one line.
*/
MULTILINE
}
/**
* The unique name that identifies this field.
*/
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 field, when checked. This is only applicable to
* BOOLEAN fields.
*/
private String value;
/**
* A collection of all associated field options.
*/
private Collection<FieldOption> options;
/**
* Creates a new Parameter with no associated name, title, or type.
*/
public Field() {
}
/**
* Creates a new Parameter with the given name, title, and type.
*
* @param name
* The unique name to associate with this field.
*
* @param title
* The human-readable title to associate with this field.
*
* @param type
* The type of this field.
*/
public Field(String name, String title, Type type) {
this.name = name;
this.title = title;
this.type = type;
}
/**
* Creates a new BOOLEAN Parameter with the given name, title, and value.
*
* @param name
* The unique name to associate with this field.
*
* @param title
* The human-readable title to associate with this field.
*
* @param value
* The value that should be assigned to this field if enabled.
*/
public Field(String name, String title, String value) {
this.name = name;
this.title = title;
this.type = Type.BOOLEAN;
this.value = value;
}
/**
* Creates a new ENUM Parameter with the given name, title, and options.
*
* @param name
* The unique name to associate with this field.
*
* @param title
* The human-readable title to associate with this field.
*
* @param options
* A collection of all possible valid options for this field.
*/
public Field(String name, String title, Collection<FieldOption> options) {
this.name = name;
this.title = title;
this.type = Type.ENUM;
this.options = options;
}
/**
* Returns the unique name associated with this field.
*
* @return
* The unique name associated with this field.
*/
public String getName() {
return name;
}
/**
* Sets the unique name associated with this field.
*
* @param name
* The unique name to assign to this field.
*/
public void setName(String name) {
this.name = name;
}
/**
* Returns the human-readable title associated with this field.
*
* @return
* The human-readable title associated with this field.
*/
public String getTitle() {
return title;
}
/**
* Sets the title associated with this field. The title must be a human-
* readable string which describes accurately this field.
*
* @param title
* A human-readable string describing this field.
*/
public void setTitle(String title) {
this.title = title;
}
/**
* Returns the value that should be assigned to this field if enabled. This
* is only applicable to BOOLEAN fields.
*
* @return
* The value that should be assigned to this field if enabled.
*/
public String getValue() {
return value;
}
/**
* Sets the value that should be assigned to this field if enabled. This is
* only applicable to BOOLEAN fields.
*
* @param value
* The value that should be assigned to this field if enabled.
*/
public void setValue(String value) {
this.value = value;
}
/**
* Returns the type of this field.
*
* @return
* The type of this field.
*/
public Type getType() {
return type;
}
/**
* Sets the type of this field.
*
* @param type
* The type of this field.
*/
public void setType(Type type) {
this.type = type;
}
/**
* Returns a mutable collection of field options. Changes to this
* collection directly affect the available options. This is only
* applicable to ENUM fields.
*
* @return
* A mutable collection of field options, or null if the field has no
* options.
*/
public Collection<FieldOption> getOptions() {
return options;
}
/**
* Sets the options available as possible values of this field. This is
* only applicable to ENUM fields.
*
* @param options
* The options to associate with this field.
*/
public void setOptions(Collection<FieldOption> options) {
this.options = options;
}
}

View File

@@ -22,12 +22,15 @@
package org.glyptodon.guacamole.form;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Describes an available legal value for an enumerated parameter.
* Describes an available legal value for an enumerated field.
*
* @author Michael Jumper
*/
public class ParameterOption {
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class FieldOption {
/**
* The value that will be assigned if this option is chosen.
@@ -40,13 +43,13 @@ public class ParameterOption {
private String title;
/**
* Creates a new ParameterOption with no associated value or title.
* Creates a new FieldOption with no associated value or title.
*/
public ParameterOption() {
public FieldOption() {
}
/**
* Creates a new ParameterOption having the given value and title.
* Creates a new FieldOption having the given value and title.
*
* @param value
* The value to assign if this option is chosen.
@@ -54,11 +57,11 @@ public class ParameterOption {
* @param title
* The human-readable title to associate with this option.
*/
public ParameterOption(String value, String title) {
public FieldOption(String value, String title) {
this.value = value;
this.title = title;
}
/**
* Returns the value that will be assigned if this option is chosen.
*

View File

@@ -0,0 +1,143 @@
/*
* Copyright (C) 2015 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.form;
import java.util.ArrayList;
import java.util.Collection;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Information which describes logical set of fields.
*
* @author Michael Jumper
*/
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
public class Form {
/**
* The name of this form. The form name must identify the form uniquely
* from other forms.
*/
private String name;
/**
* The a human-readable title describing this form.
*/
private String title;
/**
* All fields associated with this form.
*/
private Collection<Field> fields;
/**
* Creates a new Form object with no associated fields. The name and title
* of the form are left unset as null. If no form name is provided, this
* form must not be used in the same context as another unnamed form.
*/
public Form() {
fields = new ArrayList<Field>();
}
/**
* Creates a new Form object having the given name and title, and
* containing the given fields.
*
* @param name
* A name which uniquely identifies this form.
*
* @param title
* A human-readable title describing this form.
*
* @param fields
* The fields to provided within the new Form.
*/
public Form(String name, String title, Collection<Field> fields) {
this.fields = fields;
}
/**
* Returns a mutable collection of the fields associated with this form.
* Changes to this collection affect the fields exposed to the user.
*
* @return
* A mutable collection of fields.
*/
public Collection<Field> getFields() {
return fields;
}
/**
* Sets the collection of fields associated with this form.
*
* @param fields
* The collection of fields to associate with this form.
*/
public void setFields(Collection<Field> fields) {
this.fields = fields;
}
/**
* Returns the name of this form. Form names must uniquely identify each
* form.
*
* @return
* The name of this form, or null if the form has no name.
*/
public String getName() {
return name;
}
/**
* Sets the name of this form. Form names must uniquely identify each form.
*
* @param name
* The name to assign to this form.
*/
public void setName(String name) {
this.name = name;
}
/**
* Returns the human-readable title associated with this form. A form's
* title describes the form, but need not be unique.
*
* @return
* A human-readable title describing this form.
*/
public String getTitle() {
return title;
}
/**
* Sets the human-readable title associated with this form. A form's title
* describes the form, but need not be unique.
*
* @param title
* A human-readable title describing this form.
*/
public void setTitle(String title) {
this.title = title;
}
}

View File

@@ -1,283 +0,0 @@
/*
* 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.form;
import java.util.ArrayList;
import java.util.Collection;
/**
* Represents an arbitrary parameter, such as an HTTP parameter, or the
* parameter of a remote desktop protocol.
*
* @author Michael Jumper
*/
public class Parameter {
/**
* All possible types of 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.
*/
private String name;
/**
* A human-readable name to be presented to the user.
*/
private String title;
/**
* The type of this parameter.
*/
private Type type;
/**
* The value of this parameter, when checked. This is only applicable to
* BOOLEAN parameters.
*/
private String value;
/**
* A collection of all associated parameter options.
*/
private Collection<ParameterOption> options;
/**
* Creates a new Parameter with no associated name, title, or type.
*/
public Parameter() {
this.options = new ArrayList<ParameterOption>();
}
/**
* Creates a new Parameter with the given name, title, and type.
*
* @param name
* The unique name to associate with this parameter.
*
* @param title
* The human-readable title to associate with this parameter.
*
* @param type
* The type of this parameter.
*/
public Parameter(String name, String title, Type type) {
this.name = name;
this.title = title;
this.type = type;
this.options = new ArrayList<ParameterOption>();
}
/**
* Creates a new BOOLEAN Parameter with the given name, title, and value.
*
* @param name
* The unique name to associate with this parameter.
*
* @param title
* The human-readable title to associate with this parameter.
*
* @param value
* The value that should be assigned to this parameter if enabled.
*/
public Parameter(String name, String title, String value) {
this.name = name;
this.title = title;
this.type = Type.BOOLEAN;
this.value = value;
this.options = new ArrayList<ParameterOption>();
}
/**
* Creates a new ENUM Parameter with the given name, title, and options.
*
* @param name
* The unique name to associate with this parameter.
*
* @param title
* The human-readable title to associate with this parameter.
*
* @param options
* A collection of all possible valid options for this parameter.
*/
public Parameter(String name, String title, Collection<ParameterOption> options) {
this.name = name;
this.title = title;
this.type = Type.ENUM;
this.options = options;
}
/**
* Returns the unique name associated with this parameter.
*
* @return
* The unique name associated with this parameter.
*/
public String getName() {
return name;
}
/**
* Sets the unique name associated with this parameter.
*
* @param name
* The unique name to assign to this parameter.
*/
public void setName(String name) {
this.name = name;
}
/**
* Returns the human-readable title associated with this parameter.
*
* @return
* The human-readable title associated with this parameter.
*/
public String getTitle() {
return title;
}
/**
* Sets the title associated with this 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 that should be assigned to this parameter if enabled.
* This is only applicable to BOOLEAN parameters.
*
* @return
* The value that should be assigned to this parameter if enabled.
*/
public String getValue() {
return value;
}
/**
* Sets the value that should be assigned to this parameter if enabled.
* This is only applicable to BOOLEAN parameters.
*
* @param value
* The value that should be assigned to this parameter if enabled.
*/
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 parameter options. Changes to this
* collection directly affect the available options. This is only
* applicable to ENUM parameters.
*
* @return
* A mutable collection of parameter options.
*/
public Collection<ParameterOption> getOptions() {
return options;
}
/**
* Sets the options available as possible values of this parameter. This
* is only applicable to ENUM parameters.
*
* @param options
* The options to associate with this parameter.
*/
public void setOptions(Collection<ParameterOption> options) {
this.options = options;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 Glyptodon LLC
* Copyright (C) 2015 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
@@ -21,8 +21,7 @@
*/
/**
* Classes related to parsing XML files which describe the parameters of a
* protocol.
* Provides classes which describe the contents and semantics of forms which
* may be presented to the user.
*/
package org.glyptodon.guacamole.xml.protocol;
package org.glyptodon.guacamole.form;

View File

@@ -24,7 +24,7 @@ package org.glyptodon.guacamole.net.auth;
import java.util.Collection;
import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.form.Parameter;
import org.glyptodon.guacamole.form.Field;
/**
* The context of an active user. The functions of this class enforce all
@@ -121,7 +121,7 @@ public interface UserContext {
* @return
* A collection of all attributes applicable to users.
*/
Collection<Parameter> getUserAttributes();
Collection<Field> getUserAttributes();
/**
* Retrieves a collection of all attributes applicable to connections. This
@@ -132,7 +132,7 @@ public interface UserContext {
* @return
* A collection of all attributes applicable to connections.
*/
Collection<Parameter> getConnectionAttributes();
Collection<Field> getConnectionAttributes();
/**
* Retrieves a collection of all attributes applicable to connection
@@ -143,6 +143,6 @@ public interface UserContext {
* @return
* A collection of all attributes applicable to connection groups.
*/
Collection<Parameter> getConnectionGroupAttributes();
Collection<Field> getConnectionGroupAttributes();
}

View File

@@ -25,7 +25,7 @@ package org.glyptodon.guacamole.net.auth.credentials;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import org.glyptodon.guacamole.form.Parameter;
import org.glyptodon.guacamole.form.Field;
/**
* Information which describes a set of valid credentials.
@@ -35,45 +35,45 @@ import org.glyptodon.guacamole.form.Parameter;
public class CredentialsInfo {
/**
* All parameters required for valid credentials.
* All fields required for valid credentials.
*/
private final Collection<Parameter> parameters;
private final Collection<Field> fields;
/**
* Creates a new CredentialsInfo object which requires the given parameters
* for any conforming credentials.
* Creates a new CredentialsInfo object which requires the given fields for
* any conforming credentials.
*
* @param parameters
* The parameters to require.
* @param fields
* The fields to require.
*/
public CredentialsInfo(Collection<Parameter> parameters) {
this.parameters = parameters;
public CredentialsInfo(Collection<Field> fields) {
this.fields = fields;
}
/**
* Returns all parameters required for valid credentials as described by
* this object.
* Returns all fields required for valid credentials as described by this
* object.
*
* @return
* All parameters required for valid credentials.
* All fields required for valid credentials.
*/
public Collection<Parameter> getParameters() {
return Collections.unmodifiableCollection(parameters);
public Collection<Field> getFields() {
return Collections.unmodifiableCollection(fields);
}
/**
* CredentialsInfo object which describes empty credentials. No parameters
* are required.
* CredentialsInfo object which describes empty credentials. No fields are
* required.
*/
public static final CredentialsInfo EMPTY = new CredentialsInfo(Collections.<Parameter>emptyList());
public static final CredentialsInfo EMPTY = new CredentialsInfo(Collections.<Field>emptyList());
/**
* CredentialsInfo object which describes standard username/password
* credentials.
*/
public static final CredentialsInfo USERNAME_PASSWORD = new CredentialsInfo(Arrays.asList(
new Parameter("username", "username", Parameter.Type.USERNAME),
new Parameter("password", "password", Parameter.Type.PASSWORD)
new Field("username", "username", Field.Type.USERNAME),
new Field("password", "password", Field.Type.PASSWORD)
));
}

View File

@@ -28,7 +28,7 @@ import java.util.Collections;
import java.util.Map;
import java.util.UUID;
import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.form.Parameter;
import org.glyptodon.guacamole.form.Field;
import org.glyptodon.guacamole.net.auth.ActiveConnection;
import org.glyptodon.guacamole.net.auth.Connection;
import org.glyptodon.guacamole.net.auth.ConnectionGroup;
@@ -176,18 +176,18 @@ public class SimpleUserContext implements UserContext {
}
@Override
public Collection<Parameter> getUserAttributes() {
return Collections.<Parameter>emptyList();
public Collection<Field> getUserAttributes() {
return Collections.<Field>emptyList();
}
@Override
public Collection<Parameter> getConnectionAttributes() {
return Collections.<Parameter>emptyList();
public Collection<Field> getConnectionAttributes() {
return Collections.<Field>emptyList();
}
@Override
public Collection<Parameter> getConnectionGroupAttributes() {
return Collections.<Parameter>emptyList();
public Collection<Field> getConnectionGroupAttributes() {
return Collections.<Field>emptyList();
}
}

View File

@@ -24,11 +24,11 @@ package org.glyptodon.guacamole.protocols;
import java.util.ArrayList;
import java.util.Collection;
import org.glyptodon.guacamole.form.Parameter;
import org.glyptodon.guacamole.form.Form;
/**
* Describes a protocol and all parameters associated with it, as required by
* a protocol plugin for guacd. This class allows known parameters for a
* Describes a protocol and all forms associated with it, as required by
* a protocol plugin for guacd. This class allows known forms for a
* protocol to be exposed to the user as friendly fields.
*
* @author Michael Jumper
@@ -46,21 +46,21 @@ public class ProtocolInfo {
private String name;
/**
* A collection of all associated protocol parameters.
* A collection of all associated protocol forms.
*/
private Collection<Parameter> parameters;
private Collection<Form> forms;
/**
* Creates a new ProtocolInfo with no associated name, title, or
* parameters.
* forms.
*/
public ProtocolInfo() {
this.parameters = new ArrayList<Parameter>();
this.forms = new ArrayList<Form>();
}
/**
* Creates a new ProtocolInfo having the given name and title, but without
* any parameters.
* any forms.
*
* @param name
* The unique name associated with the protocol.
@@ -69,13 +69,13 @@ public class ProtocolInfo {
* The human-readable title to associate with the protocol.
*/
public ProtocolInfo(String name, String title) {
this.name = name;
this.title = title;
this.parameters = new ArrayList<Parameter>();
this.name = name;
this.title = title;
this.forms = new ArrayList<Form>();
}
/**
* Creates a new ProtocolInfo having the given name, title, and parameters.
* Creates a new ProtocolInfo having the given name, title, and forms.
*
* @param name
* The unique name associated with the protocol.
@@ -83,13 +83,13 @@ public class ProtocolInfo {
* @param title
* The human-readable title to associate with the protocol.
*
* @param parameters
* The parameters to associate with the protocol.
* @param forms
* The forms to associate with the protocol.
*/
public ProtocolInfo(String name, String title, Collection<Parameter> parameters) {
this.name = name;
this.title = title;
this.parameters = parameters;
public ProtocolInfo(String name, String title, Collection<Form> forms) {
this.name = name;
this.title = title;
this.forms = forms;
}
/**
@@ -131,25 +131,25 @@ public class ProtocolInfo {
}
/**
* Returns a mutable collection of the protocol parameters associated with
* this protocol. Changes to this collection affect the parameters exposed
* Returns a mutable collection of the protocol forms associated with
* this protocol. Changes to this collection affect the forms exposed
* to the user.
*
* @return A mutable collection of protocol parameters.
* @return A mutable collection of protocol forms.
*/
public Collection<Parameter> getParameters() {
return parameters;
public Collection<Form> getForms() {
return forms;
}
/**
* Sets the collection of protocol parameters associated with this
* Sets the collection of protocol forms associated with this
* protocol.
*
* @param parameters
* The collection of parameters to associate with this protocol.
* @param forms
* The collection of forms to associate with this protocol.
*/
public void setParameters(Collection<Parameter> parameters) {
this.parameters = parameters;
public void setForms(Collection<Form> forms) {
this.forms = forms;
}
}

View File

@@ -1,65 +0,0 @@
/*
* 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.xml.protocol;
import org.glyptodon.guacamole.form.ParameterOption;
import org.glyptodon.guacamole.xml.TagHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/**
* TagHandler for the "option" element.
*
* @author Mike Jumper
*/
public class OptionTagHandler implements TagHandler {
/**
* The option backing this option tag.
*/
private ParameterOption option = new ParameterOption();
@Override
public void init(Attributes attributes) throws SAXException {
option.setValue(attributes.getValue("value"));
}
@Override
public TagHandler childElement(String localName) throws SAXException {
throw new SAXException("The 'param' tag can contain no elements.");
}
@Override
public void complete(String textContent) throws SAXException {
option.setTitle(textContent);
}
/**
* Returns the ParameterOption backing this tag.
* @return The ParameterOption backing this tag.
*/
public ParameterOption asParameterOption() {
return option;
}
}

View File

@@ -1,124 +0,0 @@
/*
* 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.xml.protocol;
import org.glyptodon.guacamole.form.Parameter;
import org.glyptodon.guacamole.xml.TagHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/**
* TagHandler for the "param" element.
*
* @author Mike Jumper
*/
public class ParamTagHandler implements TagHandler {
/**
* The Parameter backing this tag handler.
*/
private Parameter protocolParameter = new Parameter();
@Override
public void init(Attributes attributes) throws SAXException {
protocolParameter.setName(attributes.getValue("name"));
protocolParameter.setTitle(attributes.getValue("title"));
protocolParameter.setValue(attributes.getValue("value"));
// Parse type
String type = attributes.getValue("type");
// Text field
if ("text".equals(type))
protocolParameter.setType(Parameter.Type.TEXT);
// Numeric field
else if ("numeric".equals(type))
protocolParameter.setType(Parameter.Type.NUMERIC);
// Username field
else if ("username".equals(type))
protocolParameter.setType(Parameter.Type.USERNAME);
// Password field
else if ("password".equals(type))
protocolParameter.setType(Parameter.Type.PASSWORD);
// Enumerated field
else if ("enum".equals(type))
protocolParameter.setType(Parameter.Type.ENUM);
// Multiline field
else if ("multiline".equals(type))
protocolParameter.setType(Parameter.Type.MULTILINE);
// Boolean field
else if ("boolean".equals(type)) {
protocolParameter.setType(Parameter.Type.BOOLEAN);
if(protocolParameter.getValue() == null)
throw new SAXException
("A value is required for the boolean parameter type.");
}
// Otherwise, fail with unrecognized type
else
throw new SAXException("Invalid parameter type: " + type);
}
@Override
public TagHandler childElement(String localName) throws SAXException {
// Start parsing of option tags
if (localName.equals("option")) {
// Get tag handler for option tag
OptionTagHandler tagHandler = new OptionTagHandler();
// Store stub in options collection
protocolParameter.getOptions().add(
tagHandler.asParameterOption());
return tagHandler;
}
return null;
}
@Override
public void complete(String textContent) throws SAXException {
// Do nothing
}
/**
* Returns the Parameter backing this tag.
* @return The Parameter backing this tag.
*/
public Parameter asParameter() {
return protocolParameter;
}
}

View File

@@ -1,81 +0,0 @@
/*
* 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.xml.protocol;
import org.glyptodon.guacamole.protocols.ProtocolInfo;
import org.glyptodon.guacamole.xml.TagHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
/**
* TagHandler for the "protocol" element.
*
* @author Mike Jumper
*/
public class ProtocolTagHandler implements TagHandler {
/**
* The ProtocolInfo object which will contain all data parsed by this tag
* handler.
*/
private ProtocolInfo info = new ProtocolInfo();
@Override
public void init(Attributes attributes) throws SAXException {
info.setName(attributes.getValue("name"));
info.setTitle(attributes.getValue("title"));
}
@Override
public TagHandler childElement(String localName) throws SAXException {
// Start parsing of param tags, add to list of all parameters
if (localName.equals("param")) {
// Get tag handler for param tag
ParamTagHandler tagHandler = new ParamTagHandler();
// Store stub in parameters collection
info.getParameters().add(tagHandler.asParameter());
return tagHandler;
}
return null;
}
@Override
public void complete(String textContent) throws SAXException {
// Do nothing
}
/**
* Returns the ProtocolInfo backing this tag.
* @return The ProtocolInfo backing this tag.
*/
public ProtocolInfo asProtocolInfo() {
return info;
}
}

View File

@@ -0,0 +1,253 @@
{
"title" : "RDP",
"name" : "rdp",
"forms" : [
{
"title" : "Network",
"name" : "network",
"fields" : [
{
"name" : "hostname",
"title" : "Hostname",
"type" : "TEXT"
},
{
"name" : "port",
"title" : "Port",
"type" : "NUMERIC"
}
]
},
{
"title" : "Authentication",
"name" : "authentication",
"fields" : [
{
"name" : "username",
"title" : "Username",
"type" : "USERNAME"
},
{
"name" : "password",
"title" : "Password",
"type" : "PASSWORD"
},
{
"name" : "domain",
"title" : "Domain",
"type" : "TEXT"
},
{
"name" : "security",
"title" : "Security mode",
"type" : "ENUM",
"options" : [
{
"value" : "",
"title" : ""
},
{
"value" : "rdp",
"title" : "RDP encryption"
},
{
"value" : "tls",
"title" : "TLS encryption"
},
{
"value" : "nla",
"title" : "NLA (Network Level Authentication)"
},
{
"value" : "any",
"title" : "Any"
}
]
},
{
"name" : "disable-auth",
"title" : "Disable authentication",
"type" : "BOOLEAN"
},
{
"name" : "ignore-cert",
"title" : "Ignore server certificate",
"type" : "BOOLEAN"
}
]
},
{
"title" : "Basic Parameters",
"name" : "basic-parameters",
"fields" : [
{
"name" : "initial-program",
"title" : "Initial program",
"type" : "TEXT"
},
{
"name" : "client-name",
"title" : "Client name",
"type" : "TEXT"
},
{
"name" : "server-layout",
"title" : "Keyboard layout",
"type" : "ENUM",
"options" : [
{
"value" : "",
"title" : ""
},
{
"value" : "en-us-qwerty",
"title" : "US English (Qwerty)"
},
{
"value" : "fr-fr-azerty",
"title" : "French (Azerty)"
},
{
"value" : "de-de-qwertz",
"title" : "German (Qwertz)"
},
{
"value" : "it-it-qwerty",
"title" : "Italian (Qwerty)"
},
{
"value" : "sv-se-qwerty",
"title" : "Swedish (Qwerty)"
},
{
"value" : "failsafe",
"title" : "Unicode"
}
]
},
{
"name" : "console",
"title" : "Administrator console",
"type" : "BOOLEAN",
"value" : "true"
}
]
},
{
"title" : "Display",
"name" : "display",
"fields" : [
{
"name" : "width",
"title" : "Display width",
"type" : "NUMERIC"
},
{
"name" : "height",
"title" : "Display height",
"type" : "NUMERIC"
},
{
"name" : "dpi",
"title" : "Display resolution (DPI)",
"type" : "NUMERIC"
},
{
"name" : "color-depth",
"title" : "Color depth",
"type" : "ENUM",
"options" : [
{
"value" : "",
"title" : ""
},
{
"value" : "8",
"title" : "256 color"
},
{
"value" : "16",
"title" : "Low color (16-bit)"
},
{
"value" : "24",
"title" : "True color (24-bit)"
},
{
"value" : "32",
"title" : "True color (32-bit)"
}
]
}
]
},
{
"title" : "Device Redirection",
"name" : "device-redirection",
"fields" : [
{
"name" : "console-audio",
"title" : "Support audio in console",
"type" : "BOOLEAN",
"value" : "true"
},
{
"name" : "disable-audio",
"title" : "Disable audio",
"type" : "BOOLEAN",
"value" : "true"
},
{
"name" : "enable-printing",
"title" : "Enable printing",
"type" : "BOOLEAN",
"value" : "true"
},
{
"name" : "enable-drive",
"title" : "Enable drive",
"type" : "BOOLEAN",
"value" : "true"
},
{
"name" : "drive-path",
"title" : "Drive path",
"type" : "TEXT"
},
{
"name" : "static-channels",
"title" : "Static channel names",
"type" : "TEXT"
}
]
},
{
"title" : "RemoteApp",
"name" : "remoteapp",
"fields" : [
{
"name" : "remote-app",
"title" : "RemoteApp program",
"type" : "TEXT"
},
{
"name" : "remote-app-dir",
"title" : "RemoteApp working directory",
"type" : "TEXT"
},
{
"name" : "remote-app-args",
"title" : "RemoteApp parameters",
"type" : "TEXT"
}
]
}
]
}

View File

@@ -1,57 +0,0 @@
<protocol name="rdp" title="RDP">
<param name="hostname" type="text" title="Hostname"/>
<param name="port" type="numeric" title="Port"/>
<param name="username" type="username" title="Username"/>
<param name="password" type="password" title="Password"/>
<param name="domain" type="text" title="Domain"/>
<param name="initial-program" type="text" title="Initial program"/>
<param name="client-name" type="text" title="Client name"/>
<param name="width" type="numeric" title="Display width"/>
<param name="height" type="numeric" title="Display height"/>
<param name="dpi" type="numeric" title="Display resolution (DPI)"/>
<param name="color-depth" type="enum" title="Color depth">
<option value=""></option>
<option value="8">256 color</option>
<option value="16">Low color (16-bit)</option>
<option value="24">True color (24-bit)</option>
<option value="32">True color (32-bit)</option>
</param>
<param name="server-layout" type="enum" title="Keyboard layout">
<option value=""></option>
<option value="en-us-qwerty">US English (Qwerty)</option>
<option value="fr-fr-azerty">French (Azerty)</option>
<option value="de-de-qwertz">German (Qwertz)</option>
<option value="it-it-qwerty">Italian (Qwerty)</option>
<option value="sv-se-qwerty">Swedish (Qwerty)</option>
<option value="failsafe">Unicode</option>
</param>
<param name="console" type="boolean" title="Administrator console" value="true"/>
<param name="console-audio" type="boolean" title="Support audio in console" value="true"/>
<param name="disable-audio" type="boolean" title="Disable audio" value="true"/>
<param name="enable-printing" type="boolean" title="Enable printing" value="true"/>
<param name="enable-drive" type="boolean" title="Enable drive" value="true"/>
<param name="drive-path" type="text" title="Drive path"/>
<param name="security" type="enum" title="Security mode">
<option value=""></option>
<option value="rdp">RDP encryption</option>
<option value="tls">TLS encryption</option>
<option value="nla">NLA (Network Level Authentication)</option>
<option value="any">Any</option>
</param>
<param name="disable-auth" type="boolean" title="Disable authentication" value="true"/>
<param name="ignore-cert" type="boolean" title="Ignore server certificate" value="true"/>
<param name="remote-app" type="text" title="RemoteApp program"/>
<param name="remote-app-dir" type="text" title="RemoteApp working directory"/>
<param name="remote-app-args" type="text" title="RemoteApp parameters"/>
<param name="static-channels" type="text" title="Static channel names"/>
</protocol>

View File

@@ -0,0 +1,143 @@
{
"title" : "SSH",
"name" : "ssh",
"forms" : [
{
"title" : "Network",
"name" : "network",
"fields" : [
{
"name" : "hostname",
"title" : "Hostname",
"type" : "TEXT"
},
{
"name" : "port",
"title" : "Port",
"type" : "NUMERIC"
}
]
},
{
"title" : "Authentication",
"name" : "authentication",
"fields" : [
{
"name" : "username",
"title" : "Username",
"type" : "USERNAME"
},
{
"name" : "password",
"title" : "Password",
"type" : "PASSWORD"
},
{
"name" : "private-key",
"title" : "Private key",
"type" : "MULTILINE"
},
{
"name" : "passphrase",
"title" : "Passphrase",
"type" : "PASSWORD"
}
]
},
{
"title" : "Display",
"name" : "display",
"fields" : [
{
"name" : "font-name",
"title" : "Font name",
"type" : "TEXT"
},
{
"name" : "font-size",
"title" : "Font size",
"type" : "ENUM",
"options" : [
{
"value" : "",
"title" : ""
},
{
"value" : "8",
"title" : "8"
},
{
"value" : "9",
"title" : "9"
},
{
"value" : "10",
"title" : "10"
},
{
"value" : "11",
"title" : "11"
},
{
"value" : "12",
"title" : "12"
},
{
"value" : "14",
"title" : "14"
},
{
"value" : "18",
"title" : "18"
},
{
"value" : "24",
"title" : "24"
},
{
"value" : "30",
"title" : "30"
},
{
"value" : "36",
"title" : "36"
},
{
"value" : "48",
"title" : "48"
},
{
"value" : "60",
"title" : "60"
},
{
"value" : "72",
"title" : "72"
},
{
"value" : "96",
"title" : "96"
}
]
}
]
},
{
"title" : "SFTP",
"name" : "sftp",
"fields" : [
{
"name" : "enable-sftp",
"title" : "Enable SFTP",
"type" : "BOOLEAN",
"value" : "true"
}
]
}
]
}

View File

@@ -1,33 +0,0 @@
<protocol name="ssh" title="SSH">
<param name="hostname" title="Hostname" type="text"/>
<param name="port" title="Port" type="numeric"/>
<param name="username" title="Username" type="username"/>
<param name="password" title="Password" type="password"/>
<param name="font-name" title="Font name" type="text"/>
<param name="font-size" title="Font size" type="enum">
<option value=""></option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="14">14</option>
<option value="18">18</option>
<option value="24">24</option>
<option value="30">30</option>
<option value="36">36</option>
<option value="48">48</option>
<option value="60">60</option>
<option value="72">72</option>
<option value="96">96</option>
</param>
<param name="enable-sftp" type="boolean" title="Enable SFTP" value="true"/>
<param name="private-key" type="multiline" title="Private key"/>
<param name="passphrase" type="password" title="Passphrase"/>
</protocol>

View File

@@ -0,0 +1,125 @@
{
"title" : "Telnet",
"name" : "telnet",
"forms" : [
{
"title" : "Network",
"name" : "network",
"fields" : [
{
"name" : "hostname",
"title" : "Hostname",
"type" : "TEXT"
},
{
"name" : "port",
"title" : "Port",
"type" : "NUMERIC"
}
]
},
{
"title" : "Authentication",
"name" : "authentication",
"fields" : [
{
"name" : "username",
"title" : "Username",
"type" : "USERNAME"
},
{
"name" : "password",
"title" : "Password",
"type" : "PASSWORD"
},
{
"name" : "password-regex",
"title" : "Password regular expression",
"type" : "TEXT"
}
]
},
{
"title" : "Display",
"name" : "display",
"fields" : [
{
"name" : "font-name",
"title" : "Font name",
"type" : "TEXT"
},
{
"name" : "font-size",
"title" : "Font size",
"type" : "ENUM",
"options" : [
{
"value" : "",
"title" : ""
},
{
"value" : "8",
"title" : "8"
},
{
"value" : "9",
"title" : "9"
},
{
"value" : "10",
"title" : "10"
},
{
"value" : "11",
"title" : "11"
},
{
"value" : "12",
"title" : "12"
},
{
"value" : "14",
"title" : "14"
},
{
"value" : "18",
"title" : "18"
},
{
"value" : "24",
"title" : "24"
},
{
"value" : "30",
"title" : "30"
},
{
"value" : "36",
"title" : "36"
},
{
"value" : "48",
"title" : "48"
},
{
"value" : "60",
"title" : "60"
},
{
"value" : "72",
"title" : "72"
},
{
"value" : "96",
"title" : "96"
}
]
}
]
}
]
}

View File

@@ -1,31 +0,0 @@
<protocol name="telnet" title="Telnet">
<param name="hostname" title="Hostname" type="text"/>
<param name="port" title="Port" type="numeric"/>
<param name="username" title="Username" type="username"/>
<param name="password" title="Password" type="password"/>
<param name="password-regex"
title="Password regular expression" type="text"/>
<param name="font-name" title="Font name" type="text"/>
<param name="font-size" title="Font size" type="enum">
<option value=""></option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="14">14</option>
<option value="18">18</option>
<option value="24">24</option>
<option value="30">30</option>
<option value="36">36</option>
<option value="48">48</option>
<option value="60">60</option>
<option value="72">72</option>
<option value="96">96</option>
</param>
</protocol>

View File

@@ -0,0 +1,136 @@
{
"title" : "VNC",
"name" : "vnc",
"forms" : [
{
"title" : "Network",
"name" : "network",
"fields" : [
{
"name" : "hostname",
"title" : "Hostname",
"type" : "TEXT"
},
{
"name" : "port",
"title" : "Port",
"type" : "NUMERIC"
}
]
},
{
"title" : "Authentication",
"name" : "authentication",
"fields" : [
{
"name" : "password",
"title" : "Password",
"type" : "PASSWORD"
}
]
},
{
"title" : "Display",
"name" : "display",
"fields" : [
{
"name" : "read-only",
"title" : "Read-only",
"type" : "BOOLEAN",
"value" : "true"
},
{
"name" : "swap-red-blue",
"title" : "Swap red/blue components",
"type" : "BOOLEAN",
"value" : "true"
},
{
"name" : "cursor",
"title" : "Cursor",
"type" : "ENUM",
"options" : [
{
"value" : "",
"title" : ""
},
{
"value" : "local",
"title" : "Local"
},
{
"value" : "remote",
"title" : "Remote"
}
]
},
{
"name" : "color-depth",
"title" : "Color depth",
"type" : "ENUM",
"options" : [
{
"value" : "",
"title" : ""
},
{
"value" : "8",
"title" : "256 color"
},
{
"value" : "16",
"title" : "Low color (16-bit)"
},
{
"value" : "24",
"title" : "True color (24-bit)"
},
{
"value" : "32",
"title" : "True color (32-bit)"
}
]
}
]
},
{
"title" : "Repeater",
"name" : "repeater",
"fields" : [
{
"name" : "dest-host",
"title" : "Repeater destination host",
"type" : "TEXT"
},
{
"name" : "dest-port",
"title" : "Repeater destination port",
"type" : "NUMERIC"
}
]
},
{
"title" : "Audio",
"name" : "audio",
"fields" : [
{
"name" : "enable-audio",
"title" : "Enable audio",
"type" : "BOOLEAN",
"value" : "true"
},
{
"name" : "audio-servername",
"title" : "Audio server name",
"type" : "TEXT"
}
]
}
]
}

View File

@@ -1,30 +0,0 @@
<protocol name="vnc" title="VNC">
<param name="hostname" type="text" title="Hostname"/>
<param name="port" type="numeric" title="Port"/>
<param name="password" type="password" title="Password"/>
<param name="read-only" type="boolean" title="Read-only" value="true"/>
<param name="swap-red-blue" type="boolean" title="Swap red/blue components" value="true"/>
<param name="cursor" type="enum" title="Cursor">
<option value=""></option>
<option value="local">Local</option>
<option value="remote">Remote</option>
</param>
<param name="color-depth" type="enum" title="Color depth">
<option value=""></option>
<option value="8">256 color</option>
<option value="16">Low color (16-bit)</option>
<option value="24">True color (24-bit)</option>
<option value="32">True color (32-bit)</option>
</param>
<param name="dest-host" type="text" title="Repeater destination host"/>
<param name="dest-port" type="numeric" title="Repeater destination port"/>
<param name="enable-audio" type="boolean" title="Enable audio" value="true"/>
<param name="audio-servername" type="text" title="Audio server name"/>
</protocol>

View File

@@ -24,7 +24,7 @@ package org.glyptodon.guacamole.net.basic.rest;
import java.util.Collection;
import javax.ws.rs.core.Response;
import org.glyptodon.guacamole.form.Parameter;
import org.glyptodon.guacamole.form.Field;
/**
* Describes an error that occurred within a REST endpoint.
@@ -40,9 +40,9 @@ public class APIError {
private final String message;
/**
* All expected request parameters, if any.
* All expected request parameters, if any, as a collection of fields.
*/
private final Collection<Parameter> expected;
private final Collection<Field> expected;
/**
* The type of error that occurred.
@@ -140,9 +140,9 @@ public class APIError {
*
* @param expected
* All parameters expected in the original request, or now required as
* a result of the original request.
* a result of the original request, as a collection of fields.
*/
public APIError(Type type, String message, Collection<Parameter> expected) {
public APIError(Type type, String message, Collection<Field> expected) {
this.type = type;
this.message = message;
this.expected = expected;
@@ -159,12 +159,13 @@ public class APIError {
}
/**
* Returns an object which describes the required credentials.
* Returns a collection of all required parameters, where each parameter is
* represented by a field.
*
* @return
* An object which describes the required credentials.
* A collection of all required parameters.
*/
public Collection<Parameter> getExpected() {
public Collection<Field> getExpected() {
return expected;
}

View File

@@ -25,7 +25,7 @@ package org.glyptodon.guacamole.net.basic.rest;
import java.util.Collection;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import org.glyptodon.guacamole.form.Parameter;
import org.glyptodon.guacamole.form.Field;
/**
* An exception that will result in the given error error information being
@@ -76,9 +76,9 @@ public class APIException extends WebApplicationException {
*
* @param expected
* All parameters expected in the original request, or now required as
* a result of the original request.
* a result of the original request, as a collection of fields.
*/
public APIException(APIError.Type type, String message, Collection<Parameter> expected) {
public APIException(APIError.Type type, String message, Collection<Field> expected) {
this(new APIError(type, message, expected));
}

View File

@@ -22,14 +22,12 @@
package org.glyptodon.guacamole.net.basic.rest;
import javax.ws.rs.core.Response;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.glyptodon.guacamole.GuacamoleClientException;
import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.GuacamoleResourceNotFoundException;
import org.glyptodon.guacamole.GuacamoleSecurityException;
import org.glyptodon.guacamole.net.auth.credentials.CredentialsInfo;
import org.glyptodon.guacamole.net.auth.credentials.GuacamoleInsufficientCredentialsException;
import org.glyptodon.guacamole.net.auth.credentials.GuacamoleInvalidCredentialsException;
import org.slf4j.Logger;
@@ -65,7 +63,7 @@ public class AuthProviderRESTExceptionWrapper implements MethodInterceptor {
throw new APIException(
APIError.Type.INSUFFICIENT_CREDENTIALS,
message,
e.getCredentialsInfo().getParameters()
e.getCredentialsInfo().getFields()
);
}
@@ -80,7 +78,7 @@ public class AuthProviderRESTExceptionWrapper implements MethodInterceptor {
throw new APIException(
APIError.Type.INVALID_CREDENTIALS,
message,
e.getCredentialsInfo().getParameters()
e.getCredentialsInfo().getFields()
);
}

View File

@@ -34,7 +34,7 @@ import javax.ws.rs.core.MediaType;
import org.glyptodon.guacamole.GuacamoleException;
import org.glyptodon.guacamole.environment.Environment;
import org.glyptodon.guacamole.environment.LocalEnvironment;
import org.glyptodon.guacamole.form.Parameter;
import org.glyptodon.guacamole.form.Field;
import org.glyptodon.guacamole.net.auth.UserContext;
import org.glyptodon.guacamole.net.basic.rest.AuthProviderRESTExposure;
import org.glyptodon.guacamole.net.basic.rest.auth.AuthenticationService;
@@ -65,8 +65,8 @@ public class SchemaRESTService {
* performing the operation.
*
* @return
* A collection of form parameters which describe the possible
* attributes of a user object.
* A collection of form fields which describe the possible attributes
* of a user object.
*
* @throws GuacamoleException
* If an error occurs while retrieving the possible attributes.
@@ -74,7 +74,7 @@ public class SchemaRESTService {
@GET
@Path("/users/attributes")
@AuthProviderRESTExposure
public Collection<Parameter> getUserAttributes(@QueryParam("token") String authToken) throws GuacamoleException {
public Collection<Field> getUserAttributes(@QueryParam("token") String authToken) throws GuacamoleException {
// Retrieve all possible user attributes
UserContext userContext = authenticationService.getUserContext(authToken);
@@ -90,8 +90,8 @@ public class SchemaRESTService {
* performing the operation.
*
* @return
* A collection of form parameters which describe the possible
* attributes of a connection object.
* A collection of form fields which describe the possible attributes
* of a connection object.
*
* @throws GuacamoleException
* If an error occurs while retrieving the possible attributes.
@@ -99,7 +99,7 @@ public class SchemaRESTService {
@GET
@Path("/connections/attributes")
@AuthProviderRESTExposure
public Collection<Parameter> getConnectionAttributes(@QueryParam("token") String authToken) throws GuacamoleException {
public Collection<Field> getConnectionAttributes(@QueryParam("token") String authToken) throws GuacamoleException {
// Retrieve all possible connection attributes
UserContext userContext = authenticationService.getUserContext(authToken);
@@ -115,8 +115,8 @@ public class SchemaRESTService {
* performing the operation.
*
* @return
* A collection of form parameters which describe the possible
* attributes of a connection group object.
* A collection of form fields which describe the possible attributes
* of a connection group object.
*
* @throws GuacamoleException
* If an error occurs while retrieving the possible attributes.
@@ -124,7 +124,7 @@ public class SchemaRESTService {
@GET
@Path("/connectionGroups/attributes")
@AuthProviderRESTExposure
public Collection<Parameter> getConnectionGroupAttributes(@QueryParam("token") String authToken) throws GuacamoleException {
public Collection<Field> getConnectionGroupAttributes(@QueryParam("token") String authToken) throws GuacamoleException {
// Retrieve all possible connection group attributes
UserContext userContext = authenticationService.getUserContext(authToken);

View File

@@ -29,6 +29,8 @@
.connection-parameters .form .fields {
display: table;
padding-left: .5em;
border-left: 3px solid rgba(0,0,0,0.125);
}
.connection-parameters .form .fields .labeled-field {
@@ -41,3 +43,7 @@
padding: 0.125em;
vertical-align: top;
}
.connection-parameters .form .fields .field-header {
padding-right: 1em;
}

View File

@@ -61,7 +61,7 @@ THE SOFTWARE.
<h2 class="header">{{'MANAGE_CONNECTION.SECTION_HEADER_PARAMETERS' | translate}}</h2>
<div class="section connection-parameters" ng-class="{loading: !parameters}">
<guac-form namespace="getNamespace(connection.protocol)"
content="protocols[connection.protocol].parameters"
content="protocols[connection.protocol].forms"
model="parameters"></guac-form>
</div>

View File

@@ -54,13 +54,13 @@ angular.module('rest').factory('Protocol', [function defineProtocol() {
this.title = template.title;
/**
* An array of all known parameters for this protocol, their types,
* and other information.
* An array of forms containing all known parameters for this protocol,
* their types, and other information.
*
* @type Field[]
* @type Form[]
* @default []
*/
this.parameters = template.parameters || [];
this.forms = template.forms || [];
};

View File

@@ -247,7 +247,7 @@
"FIELD_HEADER_DISABLE_AUDIO" : "Disable audio:",
"FIELD_HEADER_DISABLE_AUTH" : "Disable authentication:",
"FIELD_HEADER_DOMAIN" : "Domain:",
"FIELD_HEADER_DPI" : "Display resolution (DPI):",
"FIELD_HEADER_DPI" : "Resolution (DPI):",
"FIELD_HEADER_DRIVE_PATH" : "Drive path:",
"FIELD_HEADER_ENABLE_DRIVE" : "Enable drive:",
"FIELD_HEADER_ENABLE_PRINTING" : "Enable printing:",
@@ -257,9 +257,9 @@
"FIELD_HEADER_INITIAL_PROGRAM" : "Initial program:",
"FIELD_HEADER_PASSWORD" : "Password:",
"FIELD_HEADER_PORT" : "Port:",
"FIELD_HEADER_REMOTE_APP_ARGS" : "RemoteApp parameters:",
"FIELD_HEADER_REMOTE_APP_DIR" : "RemoteApp working directory:",
"FIELD_HEADER_REMOTE_APP" : "RemoteApp program:",
"FIELD_HEADER_REMOTE_APP_ARGS" : "Parameters:",
"FIELD_HEADER_REMOTE_APP_DIR" : "Working directory:",
"FIELD_HEADER_REMOTE_APP" : "Program:",
"FIELD_HEADER_SECURITY" : "Security mode:",
"FIELD_HEADER_SERVER_LAYOUT" : "Keyboard layout:",
"FIELD_HEADER_USERNAME" : "Username:",
@@ -286,7 +286,14 @@
"FIELD_OPTION_SERVER_LAYOUT_IT_IT_QWERTY" : "Italian (Qwerty)",
"FIELD_OPTION_SERVER_LAYOUT_SV_SE_QWERTY" : "Swedish (Qwerty)",
"NAME" : "RDP"
"NAME" : "RDP",
"SECTION_HEADER_AUTHENTICATION" : "Authentication",
"SECTION_HEADER_BASIC_PARAMETERS" : "Basic Settings",
"SECTION_HEADER_DEVICE_REDIRECTION" : "Device Redirection",
"SECTION_HEADER_DISPLAY" : "Display",
"SECTION_HEADER_NETWORK" : "Network",
"SECTION_HEADER_REMOTEAPP" : "RemoteApp"
},
@@ -318,7 +325,12 @@
"FIELD_OPTION_FONT_SIZE_96" : "96",
"FIELD_OPTION_FONT_SIZE_EMPTY" : "",
"NAME" : "SSH"
"NAME" : "SSH",
"SECTION_HEADER_AUTHENTICATION" : "Authentication",
"SECTION_HEADER_DISPLAY" : "Display",
"SECTION_HEADER_NETWORK" : "Network",
"SECTION_HEADER_SFTP" : "SFTP"
},
@@ -348,7 +360,11 @@
"FIELD_OPTION_FONT_SIZE_96" : "96",
"FIELD_OPTION_FONT_SIZE_EMPTY" : "",
"NAME" : "Telnet"
"NAME" : "Telnet",
"SECTION_HEADER_AUTHENTICATION" : "Authentication",
"SECTION_HEADER_DISPLAY" : "Display",
"SECTION_HEADER_NETWORK" : "Network"
},
@@ -357,8 +373,8 @@
"FIELD_HEADER_AUDIO_SERVERNAME" : "Audio server name:",
"FIELD_HEADER_COLOR_DEPTH" : "Color depth:",
"FIELD_HEADER_CURSOR" : "Cursor:",
"FIELD_HEADER_DEST_HOST" : "Repeater destination host:",
"FIELD_HEADER_DEST_PORT" : "Repeater destination port:",
"FIELD_HEADER_DEST_HOST" : "Destination host:",
"FIELD_HEADER_DEST_PORT" : "Destination port:",
"FIELD_HEADER_ENABLE_AUDIO" : "Enable audio:",
"FIELD_HEADER_HOSTNAME" : "Hostname:",
"FIELD_HEADER_PASSWORD" : "Password:",
@@ -376,7 +392,13 @@
"FIELD_OPTION_CURSOR_LOCAL" : "Local",
"FIELD_OPTION_CURSOR_REMOTE" : "Remote",
"NAME" : "VNC"
"NAME" : "VNC",
"SECTION_HEADER_AUDIO" : "Audio",
"SECTION_HEADER_AUTHENTICATION" : "Authentication",
"SECTION_HEADER_DISPLAY" : "Display",
"SECTION_HEADER_NETWORK" : "Network",
"SECTION_HEADER_REPEATER" : "VNC Repeater"
},