From e7574c0276bcfd5e069a98d32aaf0a563c8a3fce Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 26 May 2015 14:42:39 -0700 Subject: [PATCH] GUAC-800: Use Forms for attributes, not just Fields. --- .../guacamole/auth/jdbc/user/ModeledUser.java | 15 ++++++--- .../guacamole/auth/jdbc/user/UserContext.java | 12 +++---- .../main/resources/translations/en_US.json | 6 +++- .../guacamole/net/auth/UserContext.java | 8 ++--- .../net/auth/simple/SimpleUserContext.java | 14 ++++---- .../basic/rest/schema/SchemaRESTService.java | 20 +++++------ .../controllers/manageUserController.js | 5 +-- .../webapp/app/rest/services/schemaService.js | 33 ++++++++++--------- 8 files changed, 63 insertions(+), 50 deletions(-) diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/ModeledUser.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/ModeledUser.java index aeceff64b..0f234c494 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/ModeledUser.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/ModeledUser.java @@ -38,6 +38,7 @@ import org.glyptodon.guacamole.auth.jdbc.permission.ConnectionGroupPermissionSer import org.glyptodon.guacamole.auth.jdbc.permission.ConnectionPermissionService; import org.glyptodon.guacamole.auth.jdbc.permission.UserPermissionService; import org.glyptodon.guacamole.form.Field; +import org.glyptodon.guacamole.form.Form; import org.glyptodon.guacamole.net.auth.User; import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet; import org.glyptodon.guacamole.net.auth.permission.SystemPermission; @@ -58,15 +59,19 @@ public class ModeledUser extends ModeledDirectoryObject implements Us public static final String DISABLED_ATTRIBUTE_NAME = "disabled"; /** - * A typed field corresponding to the disabled attribute of a user. + * All attributes related to restricting user accounts, within a logical + * form. */ - public static final Field DISABLED_ATTRIBUTE = new Field(DISABLED_ATTRIBUTE_NAME, "Disabled", "true"); + public static final Form ACCOUNT_RESTRICTIONS = new Form("restrictions", "Account Restrictions", Arrays.asList( + new Field(DISABLED_ATTRIBUTE_NAME, "Disabled", "true") + )); /** - * All possible attributes of user objects. + * All possible attributes of user objects organized as individual, + * logical forms. */ - public static final Collection ATTRIBUTES = Collections.unmodifiableCollection(Arrays.asList( - DISABLED_ATTRIBUTE + public static final Collection
ATTRIBUTES = Collections.unmodifiableCollection(Arrays.asList( + ACCOUNT_RESTRICTIONS )); /** diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/UserContext.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/UserContext.java index 3ff9280fa..41c61e340 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/UserContext.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/user/UserContext.java @@ -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.Field; +import org.glyptodon.guacamole.form.Form; 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 getUserAttributes() { + public Collection getUserAttributes() { return ModeledUser.ATTRIBUTES; } @Override - public Collection getConnectionAttributes() { - return Collections.emptyList(); + public Collection getConnectionAttributes() { + return Collections.emptyList(); } @Override - public Collection getConnectionGroupAttributes() { - return Collections.emptyList(); + public Collection getConnectionGroupAttributes() { + return Collections.emptyList(); } } diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en_US.json b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en_US.json index 2937a9713..920ded08f 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en_US.json +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/resources/translations/en_US.json @@ -1,5 +1,9 @@ { "USER_ATTRIBUTES" : { - "FIELD_HEADER_DISABLED" : "Disabled:" + + "FIELD_HEADER_DISABLED" : "Login disabled:", + + "SECTION_HEADER_RESTRICTIONS" : "Account Restrictions" + } } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/UserContext.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/UserContext.java index 44ca67f20..e1dddb23c 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/UserContext.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/UserContext.java @@ -24,7 +24,7 @@ package org.glyptodon.guacamole.net.auth; import java.util.Collection; import org.glyptodon.guacamole.GuacamoleException; -import org.glyptodon.guacamole.form.Field; +import org.glyptodon.guacamole.form.Form; /** * 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 getUserAttributes(); + Collection 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 getConnectionAttributes(); + Collection 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 getConnectionGroupAttributes(); + Collection getConnectionGroupAttributes(); } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUserContext.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUserContext.java index ee5f24ab3..5a41e44d2 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUserContext.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUserContext.java @@ -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.Field; +import org.glyptodon.guacamole.form.Form; 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 getUserAttributes() { - return Collections.emptyList(); + public Collection getUserAttributes() { + return Collections.emptyList(); } @Override - public Collection getConnectionAttributes() { - return Collections.emptyList(); + public Collection getConnectionAttributes() { + return Collections.emptyList(); } @Override - public Collection getConnectionGroupAttributes() { - return Collections.emptyList(); + public Collection getConnectionGroupAttributes() { + return Collections.emptyList(); } } diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/schema/SchemaRESTService.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/schema/SchemaRESTService.java index fa1dda932..05d0c6d77 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/schema/SchemaRESTService.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/schema/SchemaRESTService.java @@ -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.Field; +import org.glyptodon.guacamole.form.Form; 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 fields which describe the possible attributes - * of a user object. + * A collection of forms 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 getUserAttributes(@QueryParam("token") String authToken) throws GuacamoleException { + public Collection 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 fields which describe the possible attributes - * of a connection object. + * A collection of forms 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 getConnectionAttributes(@QueryParam("token") String authToken) throws GuacamoleException { + public Collection 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 fields which describe the possible attributes - * of a connection group object. + * A collection of forms 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 getConnectionGroupAttributes(@QueryParam("token") String authToken) throws GuacamoleException { + public Collection getConnectionGroupAttributes(@QueryParam("token") String authToken) throws GuacamoleException { // Retrieve all possible connection group attributes UserContext userContext = authenticationService.getUserContext(authToken); diff --git a/guacamole/src/main/webapp/app/manage/controllers/manageUserController.js b/guacamole/src/main/webapp/app/manage/controllers/manageUserController.js index 8dd282d6b..c8a641d79 100644 --- a/guacamole/src/main/webapp/app/manage/controllers/manageUserController.js +++ b/guacamole/src/main/webapp/app/manage/controllers/manageUserController.js @@ -105,9 +105,10 @@ angular.module('manage').controller('manageUserController', ['$scope', '$injecto /** * All available user attributes. This is only the set of attribute - * definitions, not attribute values. + * definitions, organized as logical groupings of attributes, not attribute + * values. * - * @type Field[] + * @type Form[] */ $scope.attributes = null; diff --git a/guacamole/src/main/webapp/app/rest/services/schemaService.js b/guacamole/src/main/webapp/app/rest/services/schemaService.js index bb8986fa2..0ca3596c5 100644 --- a/guacamole/src/main/webapp/app/rest/services/schemaService.js +++ b/guacamole/src/main/webapp/app/rest/services/schemaService.js @@ -36,12 +36,13 @@ angular.module('rest').factory('schemaService', ['$injector', /** * Makes a request to the REST API to get the list of available attributes * for user objects, returning a promise that provides an array of - * @link{Field} objects if successful. Each element of the array describes - * a possible attribute. + * @link{Form} objects if successful. Each element of the array describes + * a logical grouping of possible attributes. * - * @returns {Promise.} - * A promise which will resolve with an array of @link{Field} - * objects, where each @link{Field} describes a possible attribute. + * @returns {Promise.} + * A promise which will resolve with an array of @link{Form} + * objects, where each @link{Form} describes a logical grouping of + * possible attributes. */ service.getUserAttributes = function getUserAttributes() { @@ -63,12 +64,13 @@ angular.module('rest').factory('schemaService', ['$injector', /** * Makes a request to the REST API to get the list of available attributes * for connection objects, returning a promise that provides an array of - * @link{Field} objects if successful. Each element of the array describes - * a possible attribute. + * @link{Form} objects if successful. Each element of the array describes + * a logical grouping of possible attributes. * - * @returns {Promise.} - * A promise which will resolve with an array of @link{Field} - * objects, where each @link{Field} describes a possible attribute. + * @returns {Promise.} + * A promise which will resolve with an array of @link{Form} + * objects, where each @link{Form} describes a logical grouping of + * possible attributes. */ service.getConnectionAttributes = function getConnectionAttributes() { @@ -90,12 +92,13 @@ angular.module('rest').factory('schemaService', ['$injector', /** * Makes a request to the REST API to get the list of available attributes * for connection group objects, returning a promise that provides an array - * of @link{Field} objects if successful. Each element of the array - * describes a possible attribute. + * of @link{Form} objects if successful. Each element of the array + * a logical grouping of possible attributes. * - * @returns {Promise.} - * A promise which will resolve with an array of @link{Field} - * objects, where each @link{Field} describes a possible attribute. + * @returns {Promise.} + * A promise which will resolve with an array of @link{Form} + * objects, where each @link{Form} describes a logical grouping of + * possible attributes. */ service.getConnectionGroupAttributes = function getConnectionGroupAttributes() {