mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUAC-800: Update REST services to allow read/write of attributes on users, connections, and groups.
This commit is contained in:
@@ -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<String, String> parameters;
|
||||
|
||||
/**
|
||||
* Map of all associated attributes by attribute identifier.
|
||||
*/
|
||||
private Map<String, String> 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<String, String> 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<String, String> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -115,6 +115,16 @@ public class APIConnectionWrapper implements Connection {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getAttributes() {
|
||||
return apiConnection.getAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttributes(Map<String, String> attributes) {
|
||||
apiConnection.setAttributes(attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleTunnel connect(GuacamoleClientInformation info) throws GuacamoleException {
|
||||
throw new UnsupportedOperationException("Operation not supported.");
|
||||
|
@@ -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);
|
||||
|
||||
}
|
||||
|
@@ -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<APIConnection> childConnections;
|
||||
|
||||
/**
|
||||
* Map of all associated attributes by attribute identifier.
|
||||
*/
|
||||
private Map<String, String> 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<String, String> 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<String, String> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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<String, String> getAttributes() {
|
||||
return apiConnectionGroup.getAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttributes(Map<String, String> attributes) {
|
||||
apiConnectionGroup.setAttributes(attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleTunnel connect(GuacamoleClientInformation info) throws GuacamoleException {
|
||||
throw new UnsupportedOperationException("Operation not supported.");
|
||||
|
@@ -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);
|
||||
|
||||
}
|
||||
|
@@ -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<String, String> 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<String, String> 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<String, String> attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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<String, String> getAttributes() {
|
||||
return apiUser.getAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttributes(Map<String, String> attributes) {
|
||||
apiUser.setAttributes(attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemPermissionSet getSystemPermissions()
|
||||
throws GuacamoleException {
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -79,7 +79,16 @@ angular.module('rest').factory('Connection', [function defineConnection() {
|
||||
* @type Object.<String, String>
|
||||
*/
|
||||
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.<String, String>
|
||||
*/
|
||||
this.attributes = {};
|
||||
|
||||
/**
|
||||
* The count of currently active connections using this connection.
|
||||
* This field will be returned from the REST API during a get
|
||||
|
@@ -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.<String, String>
|
||||
*/
|
||||
this.attributes = {};
|
||||
|
||||
/**
|
||||
* The count of currently active connections using this connection
|
||||
* group. This field will be returned from the REST API during a get
|
||||
|
@@ -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.<String, String>
|
||||
*/
|
||||
this.attributes = {};
|
||||
|
||||
};
|
||||
|
||||
return User;
|
||||
|
Reference in New Issue
Block a user