GUACAMOLE-708: Implement isSkeleton method for ModeledUser.

This commit is contained in:
Virtually Nick
2020-06-20 21:15:47 -04:00
parent 486ab9aefa
commit 2bf29a0d97
2 changed files with 17 additions and 4 deletions

View File

@@ -427,11 +427,13 @@ public abstract class ModeledDirectoryObjectService<InternalType extends Modeled
protected Collection<ObjectPermissionModel> getImplicitPermissions(ModeledAuthenticatedUser user,
ModelType model) {
// Check to see if the user granting permissions is a skeleton user,
// thus lacking database backing.
if (user.getUser().isSkeleton())
return Collections.emptyList();
// Get the user model and check for an entity ID.
UserModel userModel = user.getUser().getModel();
Integer entityId = userModel.getEntityID();
if (entityId == null)
return Collections.emptyList();
// Build list of implicit permissions
Collection<ObjectPermissionModel> implicitPermissions =
@@ -442,7 +444,7 @@ public abstract class ModeledDirectoryObjectService<InternalType extends Modeled
// Create model which grants this permission to the current user
ObjectPermissionModel permissionModel = new ObjectPermissionModel();
permissionModel.setEntityID(entityId);
permissionModel.setEntityID(userModel.getEntityID());
permissionModel.setType(permission);
permissionModel.setObjectIdentifier(model.getIdentifier());

View File

@@ -764,4 +764,15 @@ public class ModeledUser extends ModeledPermissions<UserModel> implements User {
return super.getEffective();
}
/**
* Returns true if this user is a skeleton user, lacking a database entity
* entry.
*
* @return
* True if this user is a skeleton user, otherwise false.
*/
public boolean isSkeleton() {
return (getModel().getEntityID() == null);
}
}