diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connection/ModeledConnection.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connection/ModeledConnection.java index 477b58175..dad6c69dd 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connection/ModeledConnection.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connection/ModeledConnection.java @@ -24,7 +24,9 @@ package org.glyptodon.guacamole.auth.jdbc.connection; import com.google.inject.Inject; import com.google.inject.Provider; +import java.util.Collections; import java.util.List; +import java.util.Map; import org.glyptodon.guacamole.auth.jdbc.tunnel.GuacamoleTunnelService; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.auth.jdbc.base.ModeledGroupedDirectoryObject; @@ -123,4 +125,14 @@ public class ModeledConnection extends ModeledGroupedDirectoryObject getAttributes() { + return Collections.emptyMap(); + } + + @Override + public void setAttributes(Map attributes) { + // Drop all attributes - none currently supported + } + } diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connectiongroup/ModeledConnectionGroup.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connectiongroup/ModeledConnectionGroup.java index 01f09006f..5d46147f5 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connectiongroup/ModeledConnectionGroup.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connectiongroup/ModeledConnectionGroup.java @@ -23,6 +23,8 @@ package org.glyptodon.guacamole.auth.jdbc.connectiongroup; import com.google.inject.Inject; +import java.util.Collections; +import java.util.Map; import java.util.Set; import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionService; import org.glyptodon.guacamole.auth.jdbc.tunnel.GuacamoleTunnelService; @@ -108,4 +110,14 @@ public class ModeledConnectionGroup extends ModeledGroupedDirectoryObject getAttributes() { + return Collections.emptyMap(); + } + + @Override + public void setAttributes(Map attributes) { + // Drop all attributes - none currently supported + } + } diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connectiongroup/RootConnectionGroup.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connectiongroup/RootConnectionGroup.java index cca42af27..74fb4295d 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connectiongroup/RootConnectionGroup.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/glyptodon/guacamole/auth/jdbc/connectiongroup/RootConnectionGroup.java @@ -23,6 +23,8 @@ package org.glyptodon.guacamole.auth.jdbc.connectiongroup; import com.google.inject.Inject; +import java.util.Collections; +import java.util.Map; import java.util.Set; import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionService; import org.glyptodon.guacamole.GuacamoleException; @@ -135,4 +137,14 @@ public class RootConnectionGroup extends RestrictedObject return 0; } + @Override + public Map getAttributes() { + return Collections.emptyMap(); + } + + @Override + public void setAttributes(Map attributes) { + throw new UnsupportedOperationException("The root connection group cannot be modified."); + } + } 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 1f1b4f508..36479f96c 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 @@ -23,6 +23,8 @@ package org.glyptodon.guacamole.auth.jdbc.user; import com.google.inject.Inject; +import java.util.Collections; +import java.util.Map; import org.glyptodon.guacamole.auth.jdbc.base.ModeledDirectoryObject; import org.glyptodon.guacamole.auth.jdbc.security.PasswordEncryptionService; import org.glyptodon.guacamole.auth.jdbc.security.SaltService; @@ -179,4 +181,14 @@ public class ModeledUser extends ModeledDirectoryObject implements Us return userPermissionService.getPermissionSet(getCurrentUser(), this); } + @Override + public Map getAttributes() { + return Collections.emptyMap(); + } + + @Override + public void setAttributes(Map attributes) { + // Drop all attributes - none currently supported + } + } 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 0b496240b..171642e7b 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 @@ -28,9 +28,12 @@ import org.glyptodon.guacamole.auth.jdbc.connectiongroup.ConnectionGroupDirector import org.glyptodon.guacamole.auth.jdbc.connection.ConnectionDirectory; import com.google.inject.Inject; import com.google.inject.Provider; +import java.util.Collection; +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.net.auth.ActiveConnection; import org.glyptodon.guacamole.net.auth.Connection; import org.glyptodon.guacamole.net.auth.ConnectionGroup; @@ -130,4 +133,19 @@ public class UserContext extends RestrictedObject } + @Override + public Collection getUserAttributes() { + return Collections.emptyList(); + } + + @Override + public Collection getConnectionAttributes() { + return Collections.emptyList(); + } + + @Override + public Collection getConnectionGroupAttributes() { + return Collections.emptyList(); + } + } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/Connection.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/Connection.java index 6fac0809f..6ab34dab4 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/Connection.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/Connection.java @@ -23,6 +23,7 @@ package org.glyptodon.guacamole.net.auth; import java.util.List; +import java.util.Map; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; @@ -84,6 +85,25 @@ public interface Connection extends Identifiable, Connectable { */ public void setConfiguration(GuacamoleConfiguration config); + /** + * Returns all attributes associated with this connection. + * + * @return + * A map of all attribute identifiers to their corresponding values, + * for all attributes associated with this connection. + */ + Map getAttributes(); + + /** + * Replaces all attributes associated with this connection with the + * attributes in the given map. + * + * @param attributes + * A map of all attribute identifiers to their corresponding values, + * for all attributes associated with this connection. + */ + void setAttributes(Map attributes); + /** * Returns a list of ConnectionRecords representing the usage history * of this Connection, including any active users. ConnectionRecords diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/ConnectionGroup.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/ConnectionGroup.java index 97c66ad02..25eb11797 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/ConnectionGroup.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/ConnectionGroup.java @@ -22,6 +22,7 @@ package org.glyptodon.guacamole.net.auth; +import java.util.Map; import java.util.Set; import org.glyptodon.guacamole.GuacamoleException; @@ -127,5 +128,24 @@ public interface ConnectionGroup extends Identifiable, Connectable { public Set getConnectionGroupIdentifiers() throws GuacamoleException; - + + /** + * Returns all attributes associated with this connection group. + * + * @return + * A map of all attribute identifiers to their corresponding values, + * for all attributes associated with this connection group. + */ + Map getAttributes(); + + /** + * Replaces all attributes associated with this connection group with the + * attributes in the given map. + * + * @param attributes + * A map of all attribute identifiers to their corresponding values, + * for all attributes associated with this connection group. + */ + void setAttributes(Map attributes); + } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/User.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/User.java index 267ad1f0f..b2f13ea23 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/User.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/User.java @@ -22,6 +22,7 @@ package org.glyptodon.guacamole.net.auth; +import java.util.Map; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet; import org.glyptodon.guacamole.net.auth.permission.SystemPermissionSet; @@ -51,6 +52,25 @@ public interface User extends Identifiable { */ public void setPassword(String password); + /** + * Returns all attributes associated with this user. + * + * @return + * A map of all attribute identifiers to their corresponding values, + * for all attributes associated with this user. + */ + Map getAttributes(); + + /** + * Replaces all attributes associated with this user with the attributes in + * the given map. + * + * @param attributes + * A map of all attribute identifiers to their corresponding values, + * for all attributes associated with this user. + */ + void setAttributes(Map attributes); + /** * Returns all system-level permissions given to this user. * 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 38538bce1..e5d1f2547 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 @@ -22,7 +22,9 @@ package org.glyptodon.guacamole.net.auth; +import java.util.Collection; import org.glyptodon.guacamole.GuacamoleException; +import org.glyptodon.guacamole.form.Parameter; /** * The context of an active user. The functions of this class enforce all @@ -110,4 +112,37 @@ public interface UserContext { */ ConnectionGroup getRootConnectionGroup() throws GuacamoleException; + /** + * Retrieves a collection of all attributes applicable to users. This + * collection will contain only those attributes which the current user has + * general permission to view or modify. If there are no such attributes, + * this collection will be empty. + * + * @return + * A collection of all attributes applicable to users. + */ + Collection getUserAttributes(); + + /** + * Retrieves a collection of all attributes applicable to connections. This + * collection will contain only those attributes which the current user has + * general permission to view or modify. If there are no such attributes, + * this collection will be empty. + * + * @return + * A collection of all attributes applicable to connections. + */ + Collection getConnectionAttributes(); + + /** + * Retrieves a collection of all attributes applicable to connection + * groups. This collection will contain only those attributes which the + * current user has general permission to view or modify. If there are no + * such attributes, this collection will be empty. + * + * @return + * A collection of all attributes applicable to connection groups. + */ + Collection getConnectionGroupAttributes(); + } diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnection.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnection.java index e5f2f0d1e..f59d205b0 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnection.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnection.java @@ -24,6 +24,7 @@ package org.glyptodon.guacamole.net.auth.simple; import java.util.Collections; import java.util.List; +import java.util.Map; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.environment.Environment; import org.glyptodon.guacamole.environment.LocalEnvironment; @@ -97,6 +98,16 @@ public class SimpleConnection extends AbstractConnection { return 0; } + @Override + public Map getAttributes() { + return Collections.emptyMap(); + } + + @Override + public void setAttributes(Map attributes) { + // Do nothing - there are no attributes + } + @Override public GuacamoleTunnel connect(GuacamoleClientInformation info) throws GuacamoleException { diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnectionGroup.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnectionGroup.java index a302f4676..179a86b64 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnectionGroup.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleConnectionGroup.java @@ -23,7 +23,9 @@ package org.glyptodon.guacamole.net.auth.simple; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; +import java.util.Map; import java.util.Set; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleSecurityException; @@ -101,6 +103,16 @@ public class SimpleConnectionGroup extends AbstractConnectionGroup { return connectionGroupIdentifiers; } + @Override + public Map getAttributes() { + return Collections.emptyMap(); + } + + @Override + public void setAttributes(Map attributes) { + // Do nothing - there are no attributes + } + @Override public GuacamoleTunnel connect(GuacamoleClientInformation info) throws GuacamoleException { diff --git a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUser.java b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUser.java index a9da2e939..96171c381 100644 --- a/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUser.java +++ b/guacamole-ext/src/main/java/org/glyptodon/guacamole/net/auth/simple/SimpleUser.java @@ -23,9 +23,12 @@ package org.glyptodon.guacamole.net.auth.simple; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; +import java.util.Map; import java.util.Set; import org.glyptodon.guacamole.GuacamoleException; +import org.glyptodon.guacamole.GuacamoleSecurityException; import org.glyptodon.guacamole.net.auth.AbstractUser; import org.glyptodon.guacamole.net.auth.permission.ObjectPermission; import org.glyptodon.guacamole.net.auth.permission.ObjectPermissionSet; @@ -106,6 +109,16 @@ public class SimpleUser extends AbstractUser { } + @Override + public Map getAttributes() { + return Collections.emptyMap(); + } + + @Override + public void setAttributes(Map attributes) { + // Do nothing - there are no attributes + } + @Override public SystemPermissionSet getSystemPermissions() throws GuacamoleException { 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 fd558a668..1f722428f 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,6 +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.net.auth.ActiveConnection; import org.glyptodon.guacamole.net.auth.Connection; import org.glyptodon.guacamole.net.auth.ConnectionGroup; @@ -174,4 +175,19 @@ public class SimpleUserContext implements UserContext { return new SimpleDirectory(); } + @Override + public Collection getUserAttributes() { + return Collections.emptyList(); + } + + @Override + public Collection getConnectionAttributes() { + return Collections.emptyList(); + } + + @Override + public Collection getConnectionGroupAttributes() { + return Collections.emptyList(); + } + } diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/RESTServletModule.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/RESTServletModule.java index a6e54c7a6..568630d7a 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/RESTServletModule.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/RESTServletModule.java @@ -31,9 +31,9 @@ import org.glyptodon.guacamole.net.basic.rest.auth.TokenRESTService; import org.glyptodon.guacamole.net.basic.rest.clipboard.ClipboardRESTService; import org.glyptodon.guacamole.net.basic.rest.connection.ConnectionRESTService; import org.glyptodon.guacamole.net.basic.rest.connectiongroup.ConnectionGroupRESTService; -import org.glyptodon.guacamole.net.basic.rest.protocol.ProtocolRESTService; import org.glyptodon.guacamole.net.basic.rest.activeconnection.ActiveConnectionRESTService; import org.glyptodon.guacamole.net.basic.rest.language.LanguageRESTService; +import org.glyptodon.guacamole.net.basic.rest.schema.SchemaRESTService; import org.glyptodon.guacamole.net.basic.rest.user.UserRESTService; /** @@ -62,7 +62,7 @@ public class RESTServletModule extends ServletModule { bind(ConnectionGroupRESTService.class); bind(ConnectionRESTService.class); bind(LanguageRESTService.class); - bind(ProtocolRESTService.class); + bind(SchemaRESTService.class); bind(TokenRESTService.class); bind(UserRESTService.class); diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnection.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnection.java index 5b8da3f75..628ee1c30 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnection.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnection.java @@ -24,6 +24,7 @@ package org.glyptodon.guacamole.net.basic.rest.connection; import java.util.Map; import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.map.annotate.JsonSerialize; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.net.auth.Connection; import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; @@ -34,6 +35,7 @@ import org.glyptodon.guacamole.protocol.GuacamoleConfiguration; * @author James Muehlner */ @JsonIgnoreProperties(ignoreUnknown = true) +@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL) public class APIConnection { /** @@ -61,6 +63,11 @@ public class APIConnection { */ private Map parameters; + /** + * Map of all associated attributes by attribute identifier. + */ + private Map attributes; + /** * The count of currently active connections using this connection. */ @@ -92,6 +99,9 @@ public class APIConnection { GuacamoleConfiguration configuration = connection.getConfiguration(); this.protocol = configuration.getProtocol(); + // Associate any attributes + this.attributes = connection.getAttributes(); + } /** @@ -195,5 +205,29 @@ public class APIConnection { public void setActiveUsers(int activeConnections) { this.activeConnections = activeConnections; } - + + /** + * Returns a map of all attributes associated with this connection. Each + * entry key is the attribute identifier, while each value is the attribute + * value itself. + * + * @return + * The attribute map for this connection. + */ + public Map getAttributes() { + return attributes; + } + + /** + * Sets the map of all attributes associated with this connection. Each + * entry key is the attribute identifier, while each value is the attribute + * value itself. + * + * @param attributes + * The attribute map for this connection. + */ + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + } diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnectionWrapper.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnectionWrapper.java index 41d64ceb3..ec0b3c7fb 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnectionWrapper.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/APIConnectionWrapper.java @@ -115,6 +115,16 @@ public class APIConnectionWrapper implements Connection { } + @Override + public Map getAttributes() { + return apiConnection.getAttributes(); + } + + @Override + public void setAttributes(Map attributes) { + apiConnection.setAttributes(attributes); + } + @Override public GuacamoleTunnel connect(GuacamoleClientInformation info) throws GuacamoleException { throw new UnsupportedOperationException("Operation not supported."); diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/ConnectionRESTService.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/ConnectionRESTService.java index 30cd75f94..5b67465c5 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/ConnectionRESTService.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connection/ConnectionRESTService.java @@ -305,6 +305,7 @@ public class ConnectionRESTService { existingConnection.setConfiguration(config); existingConnection.setParentIdentifier(connection.getParentIdentifier()); existingConnection.setName(connection.getName()); + existingConnection.setAttributes(connection.getAttributes()); connectionDirectory.update(existingConnection); } diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/APIConnectionGroup.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/APIConnectionGroup.java index b980983b5..82418b906 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/APIConnectionGroup.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/APIConnectionGroup.java @@ -23,7 +23,9 @@ package org.glyptodon.guacamole.net.basic.rest.connectiongroup; import java.util.Collection; +import java.util.Map; import org.codehaus.jackson.annotate.JsonIgnoreProperties; +import org.codehaus.jackson.map.annotate.JsonSerialize; import org.glyptodon.guacamole.net.auth.ConnectionGroup; import org.glyptodon.guacamole.net.auth.ConnectionGroup.Type; import org.glyptodon.guacamole.net.basic.rest.connection.APIConnection; @@ -34,6 +36,7 @@ import org.glyptodon.guacamole.net.basic.rest.connection.APIConnection; * @author James Muehlner */ @JsonIgnoreProperties(ignoreUnknown = true) +@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL) public class APIConnectionGroup { /** @@ -78,6 +81,11 @@ public class APIConnectionGroup { */ private Collection childConnections; + /** + * Map of all associated attributes by attribute identifier. + */ + private Map attributes; + /** * Create an empty APIConnectionGroup. */ @@ -91,13 +99,16 @@ public class APIConnectionGroup { */ public APIConnectionGroup(ConnectionGroup connectionGroup) { + // Set connection group information this.identifier = connectionGroup.getIdentifier(); this.parentIdentifier = connectionGroup.getParentIdentifier(); - this.name = connectionGroup.getName(); this.type = connectionGroup.getType(); this.activeConnections = connectionGroup.getActiveConnections(); + // Associate any attributes + this.attributes = connectionGroup.getAttributes(); + } /** @@ -233,5 +244,29 @@ public class APIConnectionGroup { public void setActiveUsers(int activeConnections) { this.activeConnections = activeConnections; } - + + /** + * Returns a map of all attributes associated with this connection group. + * Each entry key is the attribute identifier, while each value is the + * attribute value itself. + * + * @return + * The attribute map for this connection group. + */ + public Map getAttributes() { + return attributes; + } + + /** + * Sets the map of all attributes associated with this connection group. + * Each entry key is the attribute identifier, while each value is the + * attribute value itself. + * + * @param attributes + * The attribute map for this connection group. + */ + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + } diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/APIConnectionGroupWrapper.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/APIConnectionGroupWrapper.java index c37aee94a..8d3dd2679 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/APIConnectionGroupWrapper.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/APIConnectionGroupWrapper.java @@ -22,6 +22,7 @@ package org.glyptodon.guacamole.net.basic.rest.connectiongroup; +import java.util.Map; import java.util.Set; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.net.GuacamoleTunnel; @@ -105,6 +106,16 @@ public class APIConnectionGroupWrapper implements ConnectionGroup { throw new UnsupportedOperationException("Operation not supported."); } + @Override + public Map getAttributes() { + return apiConnectionGroup.getAttributes(); + } + + @Override + public void setAttributes(Map attributes) { + apiConnectionGroup.setAttributes(attributes); + } + @Override public GuacamoleTunnel connect(GuacamoleClientInformation info) throws GuacamoleException { throw new UnsupportedOperationException("Operation not supported."); diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/ConnectionGroupRESTService.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/ConnectionGroupRESTService.java index 8153421cf..2dbf94d1e 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/ConnectionGroupRESTService.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/connectiongroup/ConnectionGroupRESTService.java @@ -253,6 +253,7 @@ public class ConnectionGroupRESTService { existingConnectionGroup.setName(connectionGroup.getName()); existingConnectionGroup.setParentIdentifier(connectionGroup.getParentIdentifier()); existingConnectionGroup.setType(connectionGroup.getType()); + existingConnectionGroup.setAttributes(connectionGroup.getAttributes()); connectionGroupDirectory.update(existingConnectionGroup); } diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/protocol/ProtocolRESTService.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/protocol/ProtocolRESTService.java deleted file mode 100644 index 4d99465ee..000000000 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/protocol/ProtocolRESTService.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (C) 2014 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.net.basic.rest.protocol; - -import com.google.inject.Inject; -import java.util.Map; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -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.net.basic.rest.AuthProviderRESTExposure; -import org.glyptodon.guacamole.net.basic.rest.auth.AuthenticationService; -import org.glyptodon.guacamole.protocols.ProtocolInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * A REST Service for handling the listing of protocols. - * - * @author James Muehlner - */ -@Path("/protocols") -@Produces(MediaType.APPLICATION_JSON) -public class ProtocolRESTService { - - /** - * Logger for this class. - */ - private static final Logger logger = LoggerFactory.getLogger(ProtocolRESTService.class); - - /** - * A service for authenticating users from auth tokens. - */ - @Inject - private AuthenticationService authenticationService; - - /** - * Gets a map of protocols defined in the system - protocol name to protocol. - * - * @param authToken - * The authentication token that is used to authenticate the user - * performing the operation. - * - * @return - * A map of protocol information, where each key is the unique name - * associated with that protocol. - * - * @throws GuacamoleException - * If an error occurs while retrieving the available protocols. - */ - @GET - @AuthProviderRESTExposure - public Map getProtocols(@QueryParam("token") String authToken) throws GuacamoleException { - - // Verify the given auth token is valid - authenticationService.getUserContext(authToken); - - // Get and return a map of all protocols. - Environment env = new LocalEnvironment(); - return env.getProtocols(); - - } - -} 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 new file mode 100644 index 000000000..029700ec0 --- /dev/null +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/schema/SchemaRESTService.java @@ -0,0 +1,163 @@ +/* + * 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.net.basic.rest.schema; + +import com.google.inject.Inject; +import java.util.Collection; +import java.util.Map; +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +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.net.auth.UserContext; +import org.glyptodon.guacamole.net.basic.rest.AuthProviderRESTExposure; +import org.glyptodon.guacamole.net.basic.rest.auth.AuthenticationService; +import org.glyptodon.guacamole.protocols.ProtocolInfo; + +/** + * A REST service which provides access to descriptions of the properties, + * attributes, etc. of objects used within the Guacamole REST API. + * + * @author Michael Jumper + */ +@Path("/schema") +@Produces(MediaType.APPLICATION_JSON) +@Consumes(MediaType.APPLICATION_JSON) +public class SchemaRESTService { + + /** + * A service for authenticating users from auth tokens. + */ + @Inject + private AuthenticationService authenticationService; + + /** + * Retrieves the possible attributes of a user object. + * + * @param authToken + * The authentication token that is used to authenticate the user + * performing the operation. + * + * @return + * A collection of form parameters which describe the possible + * attributes of a user object. + * + * @throws GuacamoleException + * If an error occurs while retrieving the possible attributes. + */ + @GET + @Path("/users/attributes") + @AuthProviderRESTExposure + public Collection getUserAttributes(@QueryParam("token") String authToken) throws GuacamoleException { + + // Retrieve all possible user attributes + UserContext userContext = authenticationService.getUserContext(authToken); + return userContext.getUserAttributes(); + + } + + /** + * Retrieves the possible attributes of a connection object. + * + * @param authToken + * The authentication token that is used to authenticate the user + * performing the operation. + * + * @return + * A collection of form parameters which describe the possible + * attributes of a connection object. + * + * @throws GuacamoleException + * If an error occurs while retrieving the possible attributes. + */ + @GET + @Path("/connections/attributes") + @AuthProviderRESTExposure + public Collection getConnectionAttributes(@QueryParam("token") String authToken) throws GuacamoleException { + + // Retrieve all possible connection attributes + UserContext userContext = authenticationService.getUserContext(authToken); + return userContext.getConnectionAttributes(); + + } + + /** + * Retrieves the possible attributes of a connection group object. + * + * @param authToken + * The authentication token that is used to authenticate the user + * performing the operation. + * + * @return + * A collection of form parameters which describe the possible + * attributes of a connection group object. + * + * @throws GuacamoleException + * If an error occurs while retrieving the possible attributes. + */ + @GET + @Path("/connectionGroups/attributes") + @AuthProviderRESTExposure + public Collection getConnectionGroupAttributes(@QueryParam("token") String authToken) throws GuacamoleException { + + // Retrieve all possible connection group attributes + UserContext userContext = authenticationService.getUserContext(authToken); + return userContext.getConnectionGroupAttributes(); + + } + + /** + * Gets a map of protocols defined in the system - protocol name to protocol. + * + * @param authToken + * The authentication token that is used to authenticate the user + * performing the operation. + * + * @return + * A map of protocol information, where each key is the unique name + * associated with that protocol. + * + * @throws GuacamoleException + * If an error occurs while retrieving the available protocols. + */ + @GET + @Path("/protocols") + @AuthProviderRESTExposure + public Map getProtocols(@QueryParam("token") String authToken) throws GuacamoleException { + + // Verify the given auth token is valid + authenticationService.getUserContext(authToken); + + // Get and return a map of all protocols. + Environment env = new LocalEnvironment(); + return env.getProtocols(); + + } + +} diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/protocol/package-info.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/schema/package-info.java similarity index 82% rename from guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/protocol/package-info.java rename to guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/schema/package-info.java index 445dc5cef..e9aaaa552 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/protocol/package-info.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/schema/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 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,7 +21,7 @@ */ /** - * Classes related to the protocol retrieval aspect of the Guacamole REST API. + * Classes related to the self-description of the Guacamole REST API, such as + * the attributes or parameters applicable to specific objects. */ -package org.glyptodon.guacamole.net.basic.rest.protocol; - +package org.glyptodon.guacamole.net.basic.rest.schema; diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/APIUser.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/APIUser.java index 6351f2942..a278e0797 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/APIUser.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/APIUser.java @@ -22,6 +22,7 @@ package org.glyptodon.guacamole.net.basic.rest.user; +import java.util.Map; import org.codehaus.jackson.annotate.JsonIgnoreProperties; import org.codehaus.jackson.map.annotate.JsonSerialize; import org.glyptodon.guacamole.net.auth.User; @@ -45,6 +46,11 @@ public class APIUser { */ private String password; + /** + * Map of all associated attributes by attribute identifier. + */ + private Map attributes; + /** * Construct a new empty APIUser. */ @@ -55,8 +61,14 @@ public class APIUser { * @param user The User to construct the APIUser from. */ public APIUser(User user) { + + // Set user information this.username = user.getIdentifier(); this.password = user.getPassword(); + + // Associate any attributes + this.attributes = user.getAttributes(); + } /** @@ -91,4 +103,28 @@ public class APIUser { this.password = password; } + /** + * Returns a map of all attributes associated with this user. Each entry + * key is the attribute identifier, while each value is the attribute + * value itself. + * + * @return + * The attribute map for this user. + */ + public Map getAttributes() { + return attributes; + } + + /** + * Sets the map of all attributes associated with this user. Each entry key + * is the attribute identifier, while each value is the attribute value + * itself. + * + * @param attributes + * The attribute map for this user. + */ + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + } diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/APIUserWrapper.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/APIUserWrapper.java index c1bc8b58a..f918dbf05 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/APIUserWrapper.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/APIUserWrapper.java @@ -22,6 +22,7 @@ package org.glyptodon.guacamole.net.basic.rest.user; +import java.util.Map; import org.glyptodon.guacamole.GuacamoleException; import org.glyptodon.guacamole.GuacamoleUnsupportedException; import org.glyptodon.guacamole.net.auth.User; @@ -71,6 +72,16 @@ public class APIUserWrapper implements User { apiUser.setPassword(password); } + @Override + public Map getAttributes() { + return apiUser.getAttributes(); + } + + @Override + public void setAttributes(Map attributes) { + apiUser.setAttributes(attributes); + } + @Override public SystemPermissionSet getSystemPermissions() throws GuacamoleException { diff --git a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/UserRESTService.java b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/UserRESTService.java index af785fc65..6e57520d1 100644 --- a/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/UserRESTService.java +++ b/guacamole/src/main/java/org/glyptodon/guacamole/net/basic/rest/user/UserRESTService.java @@ -291,6 +291,9 @@ public class UserRESTService { if (user.getPassword() != null) existingUser.setPassword(user.getPassword()); + // Update user attributes + existingUser.setAttributes(user.getAttributes()); + // Update the user userDirectory.update(existingUser); diff --git a/guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js b/guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js index 989875a69..731950db3 100644 --- a/guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js +++ b/guacamole/src/main/webapp/app/manage/controllers/manageConnectionController.js @@ -41,7 +41,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i var connectionService = $injector.get('connectionService'); var connectionGroupService = $injector.get('connectionGroupService'); var permissionService = $injector.get('permissionService'); - var protocolService = $injector.get('protocolService'); + var schemaService = $injector.get('schemaService'); var translationStringService = $injector.get('translationStringService'); /** @@ -205,7 +205,7 @@ angular.module('manage').controller('manageConnectionController', ['$scope', '$i }); // Get protocol metadata - protocolService.getProtocols().success(function protocolsReceived(protocols) { + schemaService.getProtocols().success(function protocolsReceived(protocols) { $scope.protocols = protocols; }); diff --git a/guacamole/src/main/webapp/app/rest/services/cacheService.js b/guacamole/src/main/webapp/app/rest/services/cacheService.js index 12ee0f275..ef523dcb8 100644 --- a/guacamole/src/main/webapp/app/rest/services/cacheService.js +++ b/guacamole/src/main/webapp/app/rest/services/cacheService.js @@ -49,11 +49,11 @@ angular.module('rest').factory('cacheService', ['$injector', service.languages = $cacheFactory('API-LANGUAGES'); /** - * Cache used by protocolService. + * Cache used by schemaService. * * @type $cacheFactory.Cache */ - service.protocols = $cacheFactory('API-PROTOCOLS'); + service.schema = $cacheFactory('API-SCHEMA'); /** * Shared cache used by both userService and permissionService. @@ -68,7 +68,7 @@ angular.module('rest').factory('cacheService', ['$injector', service.clearCaches = function clearCaches() { service.connections.removeAll(); service.languages.removeAll(); - service.protocols.removeAll(); + service.schema.removeAll(); service.users.removeAll(); }; diff --git a/guacamole/src/main/webapp/app/rest/services/protocolService.js b/guacamole/src/main/webapp/app/rest/services/protocolService.js deleted file mode 100644 index 3306f8b1a..000000000 --- a/guacamole/src/main/webapp/app/rest/services/protocolService.js +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2014 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. - */ - -/** - * Service for operating on protocol metadata via the REST API. - */ -angular.module('rest').factory('protocolService', ['$injector', - function protocolService($injector) { - - // Required services - var $http = $injector.get('$http'); - var authenticationService = $injector.get('authenticationService'); - var cacheService = $injector.get('cacheService'); - - var service = {}; - - /** - * Makes a request to the REST API to get the list of protocols, returning - * a promise that provides a map of @link{Protocol} objects by protocol - * name if successful. - * - * @returns {Promise.>} - * A promise which will resolve with a map of @link{Protocol} - * objects by protocol name upon success. - */ - service.getProtocols = function getProtocols() { - - // Build HTTP parameters set - var httpParameters = { - token : authenticationService.getCurrentToken() - }; - - // Retrieve available protocols - return $http({ - cache : cacheService.protocols, - method : 'GET', - url : 'api/protocols', - params : httpParameters - }); - - }; - - return service; - -}]); diff --git a/guacamole/src/main/webapp/app/rest/services/schemaService.js b/guacamole/src/main/webapp/app/rest/services/schemaService.js new file mode 100644 index 000000000..bb8986fa2 --- /dev/null +++ b/guacamole/src/main/webapp/app/rest/services/schemaService.js @@ -0,0 +1,145 @@ +/* + * 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. + */ + +/** + * Service for operating on metadata via the REST API. + */ +angular.module('rest').factory('schemaService', ['$injector', + function schemaService($injector) { + + // Required services + var $http = $injector.get('$http'); + var authenticationService = $injector.get('authenticationService'); + var cacheService = $injector.get('cacheService'); + + var service = {}; + + /** + * 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. + * + * @returns {Promise.} + * A promise which will resolve with an array of @link{Field} + * objects, where each @link{Field} describes a possible attribute. + */ + service.getUserAttributes = function getUserAttributes() { + + // Build HTTP parameters set + var httpParameters = { + token : authenticationService.getCurrentToken() + }; + + // Retrieve available user attributes + return $http({ + cache : cacheService.schema, + method : 'GET', + url : 'api/schema/users/attributes', + params : httpParameters + }); + + }; + + /** + * 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. + * + * @returns {Promise.} + * A promise which will resolve with an array of @link{Field} + * objects, where each @link{Field} describes a possible attribute. + */ + service.getConnectionAttributes = function getConnectionAttributes() { + + // Build HTTP parameters set + var httpParameters = { + token : authenticationService.getCurrentToken() + }; + + // Retrieve available connection attributes + return $http({ + cache : cacheService.schema, + method : 'GET', + url : 'api/schema/connections/attributes', + params : httpParameters + }); + + }; + + /** + * 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. + * + * @returns {Promise.} + * A promise which will resolve with an array of @link{Field} + * objects, where each @link{Field} describes a possible attribute. + */ + service.getConnectionGroupAttributes = function getConnectionGroupAttributes() { + + // Build HTTP parameters set + var httpParameters = { + token : authenticationService.getCurrentToken() + }; + + // Retrieve available connection group attributes + return $http({ + cache : cacheService.schema, + method : 'GET', + url : 'api/schema/connectionGroups/attributes', + params : httpParameters + }); + + }; + + /** + * Makes a request to the REST API to get the list of protocols, returning + * a promise that provides a map of @link{Protocol} objects by protocol + * name if successful. + * + * @returns {Promise.>} + * A promise which will resolve with a map of @link{Protocol} + * objects by protocol name upon success. + */ + service.getProtocols = function getProtocols() { + + // Build HTTP parameters set + var httpParameters = { + token : authenticationService.getCurrentToken() + }; + + // Retrieve available protocols + return $http({ + cache : cacheService.schema, + method : 'GET', + url : 'api/schema/protocols', + params : httpParameters + }); + + }; + + return service; + +}]); diff --git a/guacamole/src/main/webapp/app/rest/types/Connection.js b/guacamole/src/main/webapp/app/rest/types/Connection.js index 3c3efb87a..488cfdcff 100644 --- a/guacamole/src/main/webapp/app/rest/types/Connection.js +++ b/guacamole/src/main/webapp/app/rest/types/Connection.js @@ -79,7 +79,16 @@ angular.module('rest').factory('Connection', [function defineConnection() { * @type Object. */ this.parameters = template.parameters; - + + /** + * Arbitrary name/value pairs which further describe this connection. + * The semantics and validity of these attributes are dictated by the + * extension which defines them. + * + * @type Object. + */ + this.attributes = {}; + /** * The count of currently active connections using this connection. * This field will be returned from the REST API during a get diff --git a/guacamole/src/main/webapp/app/rest/types/ConnectionGroup.js b/guacamole/src/main/webapp/app/rest/types/ConnectionGroup.js index cdb3fe232..7c3dc2b85 100644 --- a/guacamole/src/main/webapp/app/rest/types/ConnectionGroup.js +++ b/guacamole/src/main/webapp/app/rest/types/ConnectionGroup.js @@ -91,6 +91,15 @@ angular.module('rest').factory('ConnectionGroup', [function defineConnectionGrou */ this.childConnectionGroups = template.childConnectionGroups; + /** + * Arbitrary name/value pairs which further describe this connection + * group. The semantics and validity of these attributes are dictated + * by the extension which defines them. + * + * @type Object. + */ + this.attributes = {}; + /** * The count of currently active connections using this connection * group. This field will be returned from the REST API during a get diff --git a/guacamole/src/main/webapp/app/rest/types/User.js b/guacamole/src/main/webapp/app/rest/types/User.js index 499e4d2ab..8c18d0157 100644 --- a/guacamole/src/main/webapp/app/rest/types/User.js +++ b/guacamole/src/main/webapp/app/rest/types/User.js @@ -56,6 +56,15 @@ angular.module('rest').factory('User', [function defineUser() { */ this.password = template.password; + /** + * Arbitrary name/value pairs which further describe this user. The + * semantics and validity of these attributes are dictated by the + * extension which defines them. + * + * @type Object. + */ + this.attributes = {}; + }; return User;