mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUAC-1176: Generalize form fields by removing the value property. Add type-specific convenience classes for each field.
This commit is contained in:
@@ -37,6 +37,7 @@ import org.glyptodon.guacamole.auth.jdbc.activeconnection.ActiveConnectionPermis
|
||||
import org.glyptodon.guacamole.auth.jdbc.permission.ConnectionGroupPermissionService;
|
||||
import org.glyptodon.guacamole.auth.jdbc.permission.ConnectionPermissionService;
|
||||
import org.glyptodon.guacamole.auth.jdbc.permission.UserPermissionService;
|
||||
import org.glyptodon.guacamole.form.BooleanField;
|
||||
import org.glyptodon.guacamole.form.Field;
|
||||
import org.glyptodon.guacamole.form.Form;
|
||||
import org.glyptodon.guacamole.net.auth.User;
|
||||
@@ -68,9 +69,9 @@ public class ModeledUser extends ModeledDirectoryObject<UserModel> implements Us
|
||||
* All attributes related to restricting user accounts, within a logical
|
||||
* form.
|
||||
*/
|
||||
public static final Form ACCOUNT_RESTRICTIONS = new Form("restrictions", "Account Restrictions", Arrays.asList(
|
||||
new Field(DISABLED_ATTRIBUTE_NAME, "Disabled", "true"),
|
||||
new Field(EXPIRED_ATTRIBUTE_NAME, "Password expired", "true")
|
||||
public static final Form ACCOUNT_RESTRICTIONS = new Form("restrictions", "Account Restrictions", Arrays.<Field>asList(
|
||||
new BooleanField(DISABLED_ATTRIBUTE_NAME, "Disabled", "true"),
|
||||
new BooleanField(EXPIRED_ATTRIBUTE_NAME, "Password expired", "true")
|
||||
));
|
||||
|
||||
/**
|
||||
|
@@ -39,6 +39,7 @@ import org.glyptodon.guacamole.auth.jdbc.permission.ObjectPermissionModel;
|
||||
import org.glyptodon.guacamole.auth.jdbc.permission.UserPermissionMapper;
|
||||
import org.glyptodon.guacamole.auth.jdbc.security.PasswordEncryptionService;
|
||||
import org.glyptodon.guacamole.form.Field;
|
||||
import org.glyptodon.guacamole.form.PasswordField;
|
||||
import org.glyptodon.guacamole.net.auth.User;
|
||||
import org.glyptodon.guacamole.net.auth.credentials.CredentialsInfo;
|
||||
import org.glyptodon.guacamole.net.auth.credentials.GuacamoleInsufficientCredentialsException;
|
||||
@@ -81,7 +82,7 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
|
||||
* The password field to provide the user when their password is expired
|
||||
* and must be changed.
|
||||
*/
|
||||
private static final Field NEW_PASSWORD = new Field(NEW_PASSWORD_PARAMETER, "New password", Field.Type.PASSWORD);
|
||||
private static final Field NEW_PASSWORD = new PasswordField(NEW_PASSWORD_PARAMETER, "New password");
|
||||
|
||||
/**
|
||||
* The name of the HTTP password confirmation parameter to expect if the
|
||||
@@ -93,7 +94,7 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
|
||||
* The password confirmation field to provide the user when their password
|
||||
* is expired and must be changed.
|
||||
*/
|
||||
private static final Field CONFIRM_NEW_PASSWORD = new Field(CONFIRM_NEW_PASSWORD_PARAMETER, "Confirm new password", Field.Type.PASSWORD);
|
||||
private static final Field CONFIRM_NEW_PASSWORD = new PasswordField(CONFIRM_NEW_PASSWORD_PARAMETER, "Confirm new password");
|
||||
|
||||
/**
|
||||
* Information describing the expected credentials if a user's password is
|
||||
|
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.Collections;
|
||||
|
||||
/**
|
||||
* Represents a field with strictly one possible value. It is assumed that the
|
||||
* field may be blank, but that its sole non-blank value is the value provided.
|
||||
* The provided value represents "true" while all other values, including
|
||||
* having no associated value, represent "false".
|
||||
*
|
||||
* @author Michael Jumper
|
||||
*/
|
||||
public class BooleanField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new BooleanField with the given name, title, and truth value.
|
||||
* The truth value is the value that, when assigned to this field, means
|
||||
* that this field is "true".
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*
|
||||
* @param title
|
||||
* The human-readable title to associate with this field.
|
||||
*
|
||||
* @param truthValue
|
||||
* The value to consider "true" for this field. All other values will
|
||||
* be considered "false".
|
||||
*/
|
||||
public BooleanField(String name, String title, String truthValue) {
|
||||
super(name, title, Field.Type.BOOLEAN, Collections.singletonList(
|
||||
new FieldOption(truthValue, truthValue)
|
||||
));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.Collection;
|
||||
|
||||
/**
|
||||
* Represents an arbitrary field with a finite, enumerated set of possible
|
||||
* values.
|
||||
*
|
||||
* @author Michael Jumper
|
||||
*/
|
||||
public class EnumField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new EnumField with the given name, title, and possible values.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*
|
||||
* @param title
|
||||
* The human-readable title to associate with this field.
|
||||
*
|
||||
* @param options
|
||||
* All possible legal options for this field.
|
||||
*/
|
||||
public EnumField(String name, String title, Collection<FieldOption> options) {
|
||||
super(name, title, Field.Type.ENUM, options);
|
||||
}
|
||||
|
||||
}
|
@@ -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
|
||||
@@ -27,7 +27,11 @@ 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.
|
||||
* remote desktop protocol, or an input field within a form. Fields are generic
|
||||
* and typed dynamically through a type string, with the semantics of the field
|
||||
* defined by the type string. The behavior of each field type is defined
|
||||
* either through the web application itself (see FormService.js) or through
|
||||
* extensions.
|
||||
*
|
||||
* @author Michael Jumper
|
||||
*/
|
||||
@@ -94,13 +98,7 @@ public class Field {
|
||||
private String 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.
|
||||
* A collection of all legal values of this field.
|
||||
*/
|
||||
private Collection<FieldOption> options;
|
||||
|
||||
@@ -111,7 +109,7 @@ public class Field {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Parameter with the given name, title, and type.
|
||||
* Creates a new Field with the given name, title, and type.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
@@ -123,13 +121,14 @@ public class Field {
|
||||
* The type of this field.
|
||||
*/
|
||||
public Field(String name, String title, String type) {
|
||||
this.name = name;
|
||||
this.title = title;
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.title = title;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ENUM Parameter with the given name, title, and options.
|
||||
* Creates a new Field with the given name, title, type, and possible
|
||||
* values.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
@@ -137,13 +136,17 @@ public class Field {
|
||||
* @param title
|
||||
* The human-readable title to associate with this field.
|
||||
*
|
||||
* @param type
|
||||
* The type of this field.
|
||||
*
|
||||
* @param options
|
||||
* A collection of all possible valid options for this field.
|
||||
*/
|
||||
public Field(String name, String title, Collection<FieldOption> options) {
|
||||
public Field(String name, String title, String type,
|
||||
Collection<FieldOption> options) {
|
||||
this.name = name;
|
||||
this.title = title;
|
||||
this.type = Type.ENUM;
|
||||
this.type = type;
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
@@ -188,28 +191,6 @@ public class Field {
|
||||
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.
|
||||
*
|
||||
@@ -232,8 +213,7 @@ public class Field {
|
||||
|
||||
/**
|
||||
* Returns a mutable collection of field options. Changes to this
|
||||
* collection directly affect the available options. This is only
|
||||
* applicable to ENUM fields.
|
||||
* collection directly affect the available options.
|
||||
*
|
||||
* @return
|
||||
* A mutable collection of field options, or null if the field has no
|
||||
@@ -244,8 +224,7 @@ public class Field {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the options available as possible values of this field. This is
|
||||
* only applicable to ENUM fields.
|
||||
* Sets the options available as possible values of this field.
|
||||
*
|
||||
* @param options
|
||||
* The options to associate with this field.
|
||||
|
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Represents a field which can contain multiple lines of text.
|
||||
*
|
||||
* @author Michael Jumper
|
||||
*/
|
||||
public class MultilineField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new MultilineField with the given name and title.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*
|
||||
* @param title
|
||||
* The human-readable title to associate with this field.
|
||||
*/
|
||||
public MultilineField(String name, String title) {
|
||||
super(name, title, Field.Type.MULTILINE);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Represents a field which may contain only integer values.
|
||||
*
|
||||
* @author Michael Jumper
|
||||
*/
|
||||
public class NumericField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new NumericField with the given name and title.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*
|
||||
* @param title
|
||||
* The human-readable title to associate with this field.
|
||||
*/
|
||||
public NumericField(String name, String title) {
|
||||
super(name, title, Field.Type.NUMERIC);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Represents a field which contains sensitive text information related to
|
||||
* authenticating a user.
|
||||
*
|
||||
* @author Michael Jumper
|
||||
*/
|
||||
public class PasswordField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new PasswordField with the given name and title.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*
|
||||
* @param title
|
||||
* The human-readable title to associate with this field.
|
||||
*/
|
||||
public PasswordField(String name, String title) {
|
||||
super(name, title, Field.Type.PASSWORD);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Represents a basic text field. The field may generally contain any data, but
|
||||
* may not contain multiple lines.
|
||||
*
|
||||
* @author Michael Jumper
|
||||
*/
|
||||
public class TextField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new TextField with the given name and title.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*
|
||||
* @param title
|
||||
* The human-readable title to associate with this field.
|
||||
*/
|
||||
public TextField(String name, String title) {
|
||||
super(name, title, Field.Type.TEXT);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Represents a text field which will contain the uniquely-identifying name of
|
||||
* a user.
|
||||
*
|
||||
* @author Michael Jumper
|
||||
*/
|
||||
public class UsernameField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new UsernameField with the given name and title.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*
|
||||
* @param title
|
||||
* The human-readable title to associate with this field.
|
||||
*/
|
||||
public UsernameField(String name, String title) {
|
||||
super(name, title, Field.Type.USERNAME);
|
||||
}
|
||||
|
||||
}
|
@@ -26,6 +26,8 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import org.glyptodon.guacamole.form.Field;
|
||||
import org.glyptodon.guacamole.form.PasswordField;
|
||||
import org.glyptodon.guacamole.form.UsernameField;
|
||||
|
||||
/**
|
||||
* Information which describes a set of valid credentials.
|
||||
@@ -71,13 +73,13 @@ public class CredentialsInfo {
|
||||
* A field describing the username HTTP parameter expected by Guacamole
|
||||
* during login, if usernames are being used.
|
||||
*/
|
||||
public static final Field USERNAME = new Field("username", "username", Field.Type.USERNAME);
|
||||
public static final Field USERNAME = new UsernameField("username", "username");
|
||||
|
||||
/**
|
||||
* A field describing the password HTTP parameter expected by Guacamole
|
||||
* during login, if passwords are being used.
|
||||
*/
|
||||
public static final Field PASSWORD = new Field("password", "password", Field.Type.PASSWORD);
|
||||
public static final Field PASSWORD = new PasswordField("password", "password");
|
||||
|
||||
/**
|
||||
* CredentialsInfo object which describes standard username/password
|
||||
|
@@ -67,16 +67,22 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "disable-auth",
|
||||
"title" : "Disable authentication",
|
||||
"type" : "BOOLEAN",
|
||||
"value" : "true"
|
||||
"name" : "disable-auth",
|
||||
"title" : "Disable authentication",
|
||||
"type" : "BOOLEAN",
|
||||
"options" : [{
|
||||
"value" : "true",
|
||||
"title" : "true"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name" : "ignore-cert",
|
||||
"title" : "Ignore server certificate",
|
||||
"type" : "BOOLEAN",
|
||||
"value" : "true"
|
||||
"name" : "ignore-cert",
|
||||
"title" : "Ignore server certificate",
|
||||
"type" : "BOOLEAN",
|
||||
"options" : [{
|
||||
"value" : "true",
|
||||
"title" : "true"
|
||||
}]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -131,10 +137,13 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name" : "console",
|
||||
"title" : "Administrator console",
|
||||
"type" : "BOOLEAN",
|
||||
"value" : "true"
|
||||
"name" : "console",
|
||||
"title" : "Administrator console",
|
||||
"type" : "BOOLEAN",
|
||||
"options" : [{
|
||||
"value" : "true",
|
||||
"title" : "true"
|
||||
}]
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -193,28 +202,40 @@
|
||||
"name" : "device-redirection",
|
||||
"fields" : [
|
||||
{
|
||||
"name" : "console-audio",
|
||||
"title" : "Support audio in console",
|
||||
"type" : "BOOLEAN",
|
||||
"value" : "true"
|
||||
"name" : "console-audio",
|
||||
"title" : "Support audio in console",
|
||||
"type" : "BOOLEAN",
|
||||
"options" : [{
|
||||
"value" : "true",
|
||||
"title" : "true"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name" : "disable-audio",
|
||||
"title" : "Disable audio",
|
||||
"type" : "BOOLEAN",
|
||||
"value" : "true"
|
||||
"name" : "disable-audio",
|
||||
"title" : "Disable audio",
|
||||
"type" : "BOOLEAN",
|
||||
"options" : [{
|
||||
"value" : "true",
|
||||
"title" : "true"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name" : "enable-printing",
|
||||
"title" : "Enable printing",
|
||||
"type" : "BOOLEAN",
|
||||
"value" : "true"
|
||||
"name" : "enable-printing",
|
||||
"title" : "Enable printing",
|
||||
"type" : "BOOLEAN",
|
||||
"options" : [{
|
||||
"value" : "true",
|
||||
"title" : "true"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name" : "enable-drive",
|
||||
"title" : "Enable drive",
|
||||
"type" : "BOOLEAN",
|
||||
"value" : "true"
|
||||
"name" : "enable-drive",
|
||||
"title" : "Enable drive",
|
||||
"type" : "BOOLEAN",
|
||||
"options" : [{
|
||||
"value" : "true",
|
||||
"title" : "true"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name" : "drive-path",
|
||||
|
@@ -131,10 +131,13 @@
|
||||
"name" : "sftp",
|
||||
"fields" : [
|
||||
{
|
||||
"name" : "enable-sftp",
|
||||
"title" : "Enable SFTP",
|
||||
"type" : "BOOLEAN",
|
||||
"value" : "true"
|
||||
"name" : "enable-sftp",
|
||||
"title" : "Enable SFTP",
|
||||
"type" : "BOOLEAN",
|
||||
"options" : [{
|
||||
"value" : "true",
|
||||
"title" : "true"
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@@ -37,16 +37,22 @@
|
||||
"name" : "display",
|
||||
"fields" : [
|
||||
{
|
||||
"name" : "read-only",
|
||||
"title" : "Read-only",
|
||||
"type" : "BOOLEAN",
|
||||
"value" : "true"
|
||||
"name" : "read-only",
|
||||
"title" : "Read-only",
|
||||
"type" : "BOOLEAN",
|
||||
"options" : [{
|
||||
"value" : "true",
|
||||
"title" : "true"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name" : "swap-red-blue",
|
||||
"title" : "Swap red/blue components",
|
||||
"type" : "BOOLEAN",
|
||||
"value" : "true"
|
||||
"name" : "swap-red-blue",
|
||||
"title" : "Swap red/blue components",
|
||||
"type" : "BOOLEAN",
|
||||
"options" : [{
|
||||
"value" : "true",
|
||||
"title" : "true"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name" : "cursor",
|
||||
@@ -119,10 +125,13 @@
|
||||
"name" : "audio",
|
||||
"fields" : [
|
||||
{
|
||||
"name" : "enable-audio",
|
||||
"title" : "Enable audio",
|
||||
"type" : "BOOLEAN",
|
||||
"value" : "true"
|
||||
"name" : "enable-audio",
|
||||
"title" : "Enable audio",
|
||||
"type" : "BOOLEAN",
|
||||
"options" : [{
|
||||
"value" : "true",
|
||||
"title" : "true"
|
||||
}]
|
||||
},
|
||||
{
|
||||
"name" : "audio-servername",
|
||||
|
@@ -29,12 +29,12 @@ angular.module('form').controller('checkboxFieldController', ['$scope',
|
||||
|
||||
// Update typed value when model is changed
|
||||
$scope.$watch('model', function modelChanged(model) {
|
||||
$scope.typedValue = (model === $scope.field.value);
|
||||
$scope.typedValue = (model === $scope.field.options[0].value);
|
||||
});
|
||||
|
||||
// Update string value in model when typed value is changed
|
||||
$scope.$watch('typedValue', function typedValueChanged(typedValue) {
|
||||
$scope.model = (typedValue ? $scope.field.value : '');
|
||||
$scope.model = (typedValue ? $scope.field.options[0].value : '');
|
||||
});
|
||||
|
||||
}]);
|
||||
|
@@ -64,16 +64,7 @@ angular.module('rest').factory('Field', [function defineField() {
|
||||
this.type = template.type || Field.Type.TEXT;
|
||||
|
||||
/**
|
||||
* The value to set the parameter to, in the case of a BOOLEAN
|
||||
* parameter, to enable that parameter's effect.
|
||||
*
|
||||
* @type String
|
||||
*/
|
||||
this.value = template.value;
|
||||
|
||||
/**
|
||||
* All possible legal values for this parameter. This property is only
|
||||
* applicable to ENUM type parameters.
|
||||
* All possible legal values for this parameter.
|
||||
*
|
||||
* @type FieldOption[]
|
||||
*/
|
||||
@@ -123,7 +114,9 @@ angular.module('rest').factory('Field', [function defineField() {
|
||||
/**
|
||||
* The type string associated with parameters that may contain only a
|
||||
* single possible value, where that value enables the parameter's
|
||||
* effect.
|
||||
* effect. It is assumed that each BOOLEAN field will provide exactly
|
||||
* one possible value (option), which will be the value if that field
|
||||
* is true.
|
||||
*
|
||||
* @type String
|
||||
*/
|
||||
|
Reference in New Issue
Block a user