mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Ticket #269: Clean up permission create/remove prototypes, add missing JavaDoc, fix whitespace at end of line.
This commit is contained in:
@@ -227,11 +227,10 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all the permissions for a given user to be only those specified in the user object.
|
||||
* Delete any permissions not in the list, and create any in the list that do not exist
|
||||
* in the database.
|
||||
* Add the given permissions to the given user.
|
||||
*
|
||||
* @param user The user whose permissions should be updated.
|
||||
* @param user_id The ID of the user whose permissions should be updated.
|
||||
* @param permissions The permissions to add.
|
||||
* @throws GuacamoleException If an error occurs while updating the
|
||||
* permissions of the given user.
|
||||
*/
|
||||
@@ -255,14 +254,24 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol
|
||||
}
|
||||
|
||||
// Create the new permissions
|
||||
createUserPermissions(newUserPermissions, user_id);
|
||||
createConnectionPermissions(newConnectionPermissions, user_id);
|
||||
createSystemPermissions(newSystemPermissions, user_id);
|
||||
createUserPermissions(user_id, newUserPermissions);
|
||||
createConnectionPermissions(user_id, newConnectionPermissions);
|
||||
createSystemPermissions(user_id, newSystemPermissions);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void removePermissions(int user_id, Set<Permission> permissions) throws GuacamoleException {
|
||||
|
||||
/**
|
||||
* Remove the given permissions from the given user.
|
||||
*
|
||||
* @param user_id The ID of the user whose permissions should be updated.
|
||||
* @param permissions The permissions to remove.
|
||||
* @throws GuacamoleException If an error occurs while updating the
|
||||
* permissions of the given user.
|
||||
*/
|
||||
private void removePermissions(int user_id, Set<Permission> permissions)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Partition given permissions by permission type
|
||||
List<UserPermission> removedUserPermissions = new ArrayList<UserPermission>();
|
||||
@@ -282,23 +291,23 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol
|
||||
}
|
||||
|
||||
// Delete the removed permissions.
|
||||
deleteUserPermissions(removedUserPermissions, user_id);
|
||||
deleteConnectionPermissions(removedConnectionPermissions, user_id);
|
||||
deleteSystemPermissions(removedSystemPermissions, user_id);
|
||||
deleteUserPermissions(user_id, removedUserPermissions);
|
||||
deleteConnectionPermissions(user_id, removedConnectionPermissions);
|
||||
deleteSystemPermissions(user_id, removedSystemPermissions);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create any new permissions having to do with users for a given user.
|
||||
* Create the given user permissions for the given user.
|
||||
*
|
||||
* @param user_id The ID of the user to change the permissions of.
|
||||
* @param permissions The new permissions the given user should have when
|
||||
* this operation completes.
|
||||
* @param user_id The ID of the user to change the permissions of.
|
||||
* @throws GuacamoleException If permission to alter the access permissions
|
||||
* of affected objects is denied.
|
||||
*/
|
||||
private void createUserPermissions(Collection<UserPermission> permissions,
|
||||
int user_id)
|
||||
private void createUserPermissions(int user_id,
|
||||
Collection<UserPermission> permissions)
|
||||
throws GuacamoleException {
|
||||
|
||||
if(permissions.isEmpty())
|
||||
@@ -353,14 +362,14 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol
|
||||
/**
|
||||
* Delete permissions having to do with users for a given user.
|
||||
*
|
||||
* @param user_id The ID of the user to change the permissions of.
|
||||
* @param permissions The permissions the given user should no longer have
|
||||
* when this operation completes.
|
||||
* @param user_id The ID of the user to change the permissions of.
|
||||
* @throws GuacamoleException If permission to alter the access permissions
|
||||
* of affected objects is denied.
|
||||
*/
|
||||
private void deleteUserPermissions(Collection<UserPermission> permissions,
|
||||
int user_id)
|
||||
private void deleteUserPermissions(int user_id,
|
||||
Collection<UserPermission> permissions)
|
||||
throws GuacamoleException {
|
||||
|
||||
if(permissions.isEmpty())
|
||||
@@ -419,14 +428,14 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol
|
||||
* Create any new permissions having to do with connections for a given
|
||||
* user.
|
||||
*
|
||||
* @param user_id The ID of the user to assign or remove permissions from.
|
||||
* @param permissions The new permissions the user should have after this
|
||||
* operation completes.
|
||||
* @param user_id The ID of the user to assign or remove permissions from.
|
||||
* @throws GuacamoleException If permission to alter the access permissions
|
||||
* of affected objects is deniedD
|
||||
*/
|
||||
private void createConnectionPermissions(
|
||||
Collection<ConnectionPermission> permissions, int user_id)
|
||||
private void createConnectionPermissions(int user_id,
|
||||
Collection<ConnectionPermission> permissions)
|
||||
throws GuacamoleException {
|
||||
|
||||
if(permissions.isEmpty())
|
||||
@@ -483,14 +492,14 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol
|
||||
/**
|
||||
* Delete permissions having to do with connections for a given user.
|
||||
*
|
||||
* @param user_id The ID of the user to change the permissions of.
|
||||
* @param permissions The permissions the given user should no longer have
|
||||
* when this operation completes.
|
||||
* @param user_id The ID of the user to change the permissions of.
|
||||
* @throws GuacamoleException If permission to alter the access permissions
|
||||
* of affected objects is denied.
|
||||
*/
|
||||
private void deleteConnectionPermissions(Collection<ConnectionPermission> permissions,
|
||||
int user_id)
|
||||
private void deleteConnectionPermissions(int user_id,
|
||||
Collection<ConnectionPermission> permissions)
|
||||
throws GuacamoleException {
|
||||
|
||||
if(permissions.isEmpty())
|
||||
@@ -549,12 +558,12 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol
|
||||
* Create any new system permissions for a given user. All permissions in
|
||||
* the given list will be inserted.
|
||||
*
|
||||
* @param user_id The ID of the user whose permissions should be updated.
|
||||
* @param permissions The new system permissions that the given user should
|
||||
* have when this operation completes.
|
||||
* @param user_id The ID of the user whose permissions should be updated.
|
||||
*/
|
||||
private void createSystemPermissions(Collection<SystemPermission> permissions,
|
||||
int user_id) {
|
||||
private void createSystemPermissions(int user_id,
|
||||
Collection<SystemPermission> permissions) {
|
||||
|
||||
if(permissions.isEmpty())
|
||||
return;
|
||||
@@ -614,12 +623,12 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol
|
||||
* Delete system permissions for a given user. All permissions in
|
||||
* the given list will be removed from the user.
|
||||
*
|
||||
* @param user_id The ID of the user whose permissions should be updated.
|
||||
* @param permissions The permissions the given user should no longer have
|
||||
* when this operation completes.
|
||||
* @param user_id The ID of the user whose permissions should be updated.
|
||||
*/
|
||||
private void deleteSystemPermissions(Collection<SystemPermission> permissions,
|
||||
int user_id) {
|
||||
private void deleteSystemPermissions(int user_id,
|
||||
Collection<SystemPermission> permissions) {
|
||||
|
||||
if(permissions.isEmpty())
|
||||
return;
|
||||
|
Reference in New Issue
Block a user