mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
Merge pull request #70 from glyptodon/no-null-identifiers
GUAC-1001: Do not use null identifiers
This commit is contained in:
@@ -52,8 +52,13 @@ public interface Connection {
|
|||||||
public void setName(String name);
|
public void setName(String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the unique identifier assigned to this Connection.
|
* Returns the unique identifier assigned to this Connection. All
|
||||||
* @return The unique identifier assigned to this Connection.
|
* connections must have a deterministic, unique identifier which may not
|
||||||
|
* be null.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* The unique identifier assigned to this Connection, which may not be
|
||||||
|
* null.
|
||||||
*/
|
*/
|
||||||
public String getIdentifier();
|
public String getIdentifier();
|
||||||
|
|
||||||
|
@@ -52,8 +52,13 @@ public interface ConnectionGroup {
|
|||||||
public void setName(String name);
|
public void setName(String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the unique identifier assigned to this ConnectionGroup.
|
* Returns the unique identifier assigned to this ConnectionGroup. All
|
||||||
* @return The unique identifier assigned to this ConnectionGroup.
|
* connection groups must have a deterministic, unique identifier which may
|
||||||
|
* not be null.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* The unique identifier assigned to this ConnectionGroup, which may
|
||||||
|
* not be null.
|
||||||
*/
|
*/
|
||||||
public String getIdentifier();
|
public String getIdentifier();
|
||||||
|
|
||||||
|
@@ -36,8 +36,11 @@ public interface User {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of this user, which must be unique across all users.
|
* Returns the name of this user, which must be unique across all users.
|
||||||
|
* All users must have a deterministic, unique username which may not be
|
||||||
|
* null.
|
||||||
*
|
*
|
||||||
* @return The name of this user.
|
* @return
|
||||||
|
* The unique username of this user, which may not be null.
|
||||||
*/
|
*/
|
||||||
public String getUsername();
|
public String getUsername();
|
||||||
|
|
||||||
|
@@ -66,6 +66,9 @@ public abstract class SimpleAuthenticationProvider
|
|||||||
public UserContext getUserContext(Credentials credentials)
|
public UserContext getUserContext(Credentials credentials)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
|
// Get username, if any
|
||||||
|
String username = credentials.getUsername();
|
||||||
|
|
||||||
// Get configurations
|
// Get configurations
|
||||||
Map<String, GuacamoleConfiguration> configs =
|
Map<String, GuacamoleConfiguration> configs =
|
||||||
getAuthorizedConfigurations(credentials);
|
getAuthorizedConfigurations(credentials);
|
||||||
@@ -83,7 +86,12 @@ public abstract class SimpleAuthenticationProvider
|
|||||||
tokenFilter.filterValues(config.getParameters());
|
tokenFilter.filterValues(config.getParameters());
|
||||||
|
|
||||||
// Return user context restricted to authorized configs
|
// Return user context restricted to authorized configs
|
||||||
return new SimpleUserContext(credentials.getUsername(), configs);
|
if (username != null && !username.isEmpty())
|
||||||
|
return new SimpleUserContext(username, configs);
|
||||||
|
|
||||||
|
// If there is no associated username, let SimpleUserContext generate one
|
||||||
|
else
|
||||||
|
return new SimpleUserContext(configs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -297,10 +297,10 @@ public class ConnectionGroupRESTService {
|
|||||||
* The ID of the connection group to retrieve.
|
* The ID of the connection group to retrieve.
|
||||||
*
|
*
|
||||||
* @param permissions
|
* @param permissions
|
||||||
* If specified, limit the returned list to only those connections for
|
* If specified and non-empty, limit the returned list to only those
|
||||||
* which the current user has any of the given permissions. Otherwise,
|
* connections for which the current user has any of the given
|
||||||
* all visible connections are returned. Connection groups are
|
* permissions. Otherwise, all visible connections are returned.
|
||||||
* unaffected by this parameter.
|
* Connection groups are unaffected by this parameter.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
* The requested connection group, including all descendants.
|
* The requested connection group, including all descendants.
|
||||||
@@ -319,6 +319,10 @@ public class ConnectionGroupRESTService {
|
|||||||
|
|
||||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
UserContext userContext = authenticationService.getUserContext(authToken);
|
||||||
|
|
||||||
|
// Do not filter on permissions if no permissions are specified
|
||||||
|
if (permissions != null && permissions.isEmpty())
|
||||||
|
permissions = null;
|
||||||
|
|
||||||
// Retrieve requested connection group and all descendants
|
// Retrieve requested connection group and all descendants
|
||||||
APIConnectionGroup connectionGroup = retrieveConnectionGroup(userContext, connectionGroupID, true, permissions);
|
APIConnectionGroup connectionGroup = retrieveConnectionGroup(userContext, connectionGroupID, true, permissions);
|
||||||
if (connectionGroup == null)
|
if (connectionGroup == null)
|
||||||
|
@@ -176,6 +176,10 @@ public class UserRESTService {
|
|||||||
UserContext userContext = authenticationService.getUserContext(authToken);
|
UserContext userContext = authenticationService.getUserContext(authToken);
|
||||||
User self = userContext.self();
|
User self = userContext.self();
|
||||||
|
|
||||||
|
// Do not filter on permissions if no permissions are specified
|
||||||
|
if (permissions != null && permissions.isEmpty())
|
||||||
|
permissions = null;
|
||||||
|
|
||||||
// An admin user has access to any user
|
// An admin user has access to any user
|
||||||
boolean isAdmin = self.hasPermission(new SystemPermission(SystemPermission.Type.ADMINISTER));
|
boolean isAdmin = self.hasPermission(new SystemPermission(SystemPermission.Type.ADMINISTER));
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user