GUACAMOLE-360: Add convenience function for testing user identity.
This commit is contained in:
1 parent
ad937defa6
commit
ea142d15ce
3 files changed
+17
-2
No files matched your search
+1
-1
@@ -97,7 +97,7 @@ public class ActiveConnectionPermissionService
|
||||
permissions.add(new ObjectPermission(ObjectPermission.Type.READ, identifier));
|
||||
|
||||
// If we're an admin, or the connection is ours, then we can DELETE
|
||||
if (isAdmin || (targetEntity.isUser() && targetEntity.getIdentifier().equals(record.getUsername())))
|
||||
if (isAdmin || targetEntity.isUser(record.getUsername()))
|
||||
permissions.add(new ObjectPermission(ObjectPermission.Type.DELETE, identifier));
|
||||
|
||||
}
|
||||
|
||||
+15
@@ -105,6 +105,21 @@ public abstract class ModeledPermissions<ModelType extends EntityModel>
|
||||
return getModel().getEntityType() == EntityType.USER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the underlying entity represents a specific user having
|
||||
* the given username.
|
||||
*
|
||||
* @param username
|
||||
* The username of a user.
|
||||
*
|
||||
* @return
|
||||
* true if the underlying entity is a user that has the given username,
|
||||
* false otherwise.
|
||||
*/
|
||||
public boolean isUser(String username) {
|
||||
return isUser() && getIdentifier().equals(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the underlying entity is a user group. Entities may be
|
||||
* either users or user groups.
|
||||
|
||||
+1
-1
@@ -101,7 +101,7 @@ public abstract class AbstractPermissionService<PermissionSetType extends Permis
|
||||
throws GuacamoleException {
|
||||
|
||||
// A user can always read their own permissions
|
||||
if (targetEntity.isUser() && user.getUser().getIdentifier().equals(targetEntity.getIdentifier()))
|
||||
if (targetEntity.isUser(user.getUser().getIdentifier()))
|
||||
return true;
|
||||
|
||||
// A system adminstrator can do anything
|
||||
|
||||
Reference in new issue
Block a user