diff --git a/extensions/guacamole-auth-json/src/main/java/org/apache/guacamole/auth/json/user/UserData.java b/extensions/guacamole-auth-json/src/main/java/org/apache/guacamole/auth/json/user/UserData.java index 2e3048f0fa..4050ec26c5 100644 --- a/extensions/guacamole-auth-json/src/main/java/org/apache/guacamole/auth/json/user/UserData.java +++ b/extensions/guacamole-auth-json/src/main/java/org/apache/guacamole/auth/json/user/UserData.java @@ -53,7 +53,7 @@ public class UserData { /** * All connections accessible by this user. The key of each entry is both - * the connection identifier and the connection name. + * the connection identifier. */ private ConcurrentMap connections; @@ -63,6 +63,12 @@ public class UserData { */ public static class Connection { + /** + * The human-readable name of this connection. If unset, the connection + * key is used as the display name. + */ + private String name; + /** * An arbitrary, opaque, unique ID for this connection. If specified * via the "join" (primaryConnection) property of another connection, @@ -98,6 +104,26 @@ public static class Connection { */ private boolean singleUse = false; + /** + * Returns the human-readable name of this connection, if any. + * + * @return + * The human-readable name of this connection, or null if unset. + */ + public String getName() { + return name; + } + + /** + * Sets the human-readable name of this connection. + * + * @param name + * The human-readable name of this connection. + */ + public void setName(String name) { + this.name = name; + } + /** * Returns an arbitrary, opaque, unique ID for this connection. If * defined, this ID may be used via the "join" (primaryConnection) @@ -319,7 +345,7 @@ public void setSingleUse(boolean singleUse) { * Returns all connections stored within this UserData object as an * unmodifiable map. Each of these connections is accessible by the user * specified by getUsername(). The key of each entry within the map is the - * identifier and human-readable name of the corresponding connection. + * identifier of the corresponding connection. * * @return * An unmodifiable map of all connections stored within this @@ -334,7 +360,7 @@ public Map getConnections() { * Replaces all connections stored within this UserData object with the * given connections. Each of these connections will be accessible by the * user specified by getUsername(). The key of each entry within the map is - * the identifier and human-readable name of the corresponding connection. + * the identifier of the corresponding connection. * * @param connections * A map of all connections to be stored within this UserData object, diff --git a/extensions/guacamole-auth-json/src/main/java/org/apache/guacamole/auth/json/user/UserDataConnection.java b/extensions/guacamole-auth-json/src/main/java/org/apache/guacamole/auth/json/user/UserDataConnection.java index 48a9de18d3..ba0fd3c80a 100644 --- a/extensions/guacamole-auth-json/src/main/java/org/apache/guacamole/auth/json/user/UserDataConnection.java +++ b/extensions/guacamole-auth-json/src/main/java/org/apache/guacamole/auth/json/user/UserDataConnection.java @@ -47,11 +47,15 @@ public class UserDataConnection implements Connection { private ConnectionService connectionService; /** - * A human-readable value which both uniquely identifies this connection - * and serves as the connection display name. + * The unique identifier of this connection. */ private String identifier; + /** + * The human-readable name of this connection. + */ + private String name; + /** * The UserData associated with this connection. This UserData will be * automatically updated as this connection is used. @@ -65,8 +69,8 @@ public class UserDataConnection implements Connection { /** * Initializes this UserDataConnection with the given data, unique - * identifier, and connection information. This function MUST be invoked - * before any particular UserDataConnection is actually used. + * identifier, display name, and connection information. This function MUST + * be invoked before any particular UserDataConnection is actually used. * * @param data * The UserData that this connection should manage. @@ -75,6 +79,9 @@ public class UserDataConnection implements Connection { * The identifier associated with this connection within the given * UserData. * + * @param name + * The human-readable name of this connection. + * * @param connection * The connection data associated with this connection within the given * UserData. @@ -83,9 +90,10 @@ public class UserDataConnection implements Connection { * A reference to this UserDataConnection. */ public UserDataConnection init(UserData data, String identifier, - UserData.Connection connection) { + String name, UserData.Connection connection) { this.identifier = identifier; + this.name = name; this.data = data; this.connection = connection; @@ -105,7 +113,7 @@ public void setIdentifier(String identifier) { @Override public String getName() { - return identifier; + return name; } @Override diff --git a/extensions/guacamole-auth-json/src/main/java/org/apache/guacamole/auth/json/user/UserDataService.java b/extensions/guacamole-auth-json/src/main/java/org/apache/guacamole/auth/json/user/UserDataService.java index 33b5beb7d0..b5e9d72525 100644 --- a/extensions/guacamole-auth-json/src/main/java/org/apache/guacamole/auth/json/user/UserDataService.java +++ b/extensions/guacamole-auth-json/src/main/java/org/apache/guacamole/auth/json/user/UserDataService.java @@ -325,12 +325,16 @@ public Directory getConnectionDirectory(UserData userData) { // Pull connection and associated identifier String identifier = entry.getKey(); UserData.Connection connection = entry.getValue(); + String name = connection.getName(); + if (name == null || name.isEmpty()) + name = identifier; // Create Guacamole connection containing the defined identifier // and parameters Connection guacConnection = userDataConnectionProvider.get().init( userData, identifier, + name, connection );