mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 05:31:22 +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.
|
* Add the given permissions to the given user.
|
||||||
* Delete any permissions not in the list, and create any in the list that do not exist
|
|
||||||
* in the database.
|
|
||||||
*
|
*
|
||||||
* @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
|
* @throws GuacamoleException If an error occurs while updating the
|
||||||
* permissions of the given user.
|
* permissions of the given user.
|
||||||
*/
|
*/
|
||||||
@@ -255,14 +254,24 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the new permissions
|
// Create the new permissions
|
||||||
createUserPermissions(newUserPermissions, user_id);
|
createUserPermissions(user_id, newUserPermissions);
|
||||||
createConnectionPermissions(newConnectionPermissions, user_id);
|
createConnectionPermissions(user_id, newConnectionPermissions);
|
||||||
createSystemPermissions(newSystemPermissions, user_id);
|
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
|
// Partition given permissions by permission type
|
||||||
List<UserPermission> removedUserPermissions = new ArrayList<UserPermission>();
|
List<UserPermission> removedUserPermissions = new ArrayList<UserPermission>();
|
||||||
@@ -282,23 +291,23 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete the removed permissions.
|
// Delete the removed permissions.
|
||||||
deleteUserPermissions(removedUserPermissions, user_id);
|
deleteUserPermissions(user_id, removedUserPermissions);
|
||||||
deleteConnectionPermissions(removedConnectionPermissions, user_id);
|
deleteConnectionPermissions(user_id, removedConnectionPermissions);
|
||||||
deleteSystemPermissions(removedSystemPermissions, user_id);
|
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
|
* @param permissions The new permissions the given user should have when
|
||||||
* this operation completes.
|
* 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
|
* @throws GuacamoleException If permission to alter the access permissions
|
||||||
* of affected objects is denied.
|
* of affected objects is denied.
|
||||||
*/
|
*/
|
||||||
private void createUserPermissions(Collection<UserPermission> permissions,
|
private void createUserPermissions(int user_id,
|
||||||
int user_id)
|
Collection<UserPermission> permissions)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
if(permissions.isEmpty())
|
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.
|
* 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
|
* @param permissions The permissions the given user should no longer have
|
||||||
* when this operation completes.
|
* 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
|
* @throws GuacamoleException If permission to alter the access permissions
|
||||||
* of affected objects is denied.
|
* of affected objects is denied.
|
||||||
*/
|
*/
|
||||||
private void deleteUserPermissions(Collection<UserPermission> permissions,
|
private void deleteUserPermissions(int user_id,
|
||||||
int user_id)
|
Collection<UserPermission> permissions)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
if(permissions.isEmpty())
|
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
|
* Create any new permissions having to do with connections for a given
|
||||||
* user.
|
* 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
|
* @param permissions The new permissions the user should have after this
|
||||||
* operation completes.
|
* 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
|
* @throws GuacamoleException If permission to alter the access permissions
|
||||||
* of affected objects is deniedD
|
* of affected objects is deniedD
|
||||||
*/
|
*/
|
||||||
private void createConnectionPermissions(
|
private void createConnectionPermissions(int user_id,
|
||||||
Collection<ConnectionPermission> permissions, int user_id)
|
Collection<ConnectionPermission> permissions)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
if(permissions.isEmpty())
|
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.
|
* 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
|
* @param permissions The permissions the given user should no longer have
|
||||||
* when this operation completes.
|
* 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
|
* @throws GuacamoleException If permission to alter the access permissions
|
||||||
* of affected objects is denied.
|
* of affected objects is denied.
|
||||||
*/
|
*/
|
||||||
private void deleteConnectionPermissions(Collection<ConnectionPermission> permissions,
|
private void deleteConnectionPermissions(int user_id,
|
||||||
int user_id)
|
Collection<ConnectionPermission> permissions)
|
||||||
throws GuacamoleException {
|
throws GuacamoleException {
|
||||||
|
|
||||||
if(permissions.isEmpty())
|
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
|
* Create any new system permissions for a given user. All permissions in
|
||||||
* the given list will be inserted.
|
* 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
|
* @param permissions The new system permissions that the given user should
|
||||||
* have when this operation completes.
|
* have when this operation completes.
|
||||||
* @param user_id The ID of the user whose permissions should be updated.
|
|
||||||
*/
|
*/
|
||||||
private void createSystemPermissions(Collection<SystemPermission> permissions,
|
private void createSystemPermissions(int user_id,
|
||||||
int user_id) {
|
Collection<SystemPermission> permissions) {
|
||||||
|
|
||||||
if(permissions.isEmpty())
|
if(permissions.isEmpty())
|
||||||
return;
|
return;
|
||||||
@@ -614,12 +623,12 @@ public class UserDirectory implements Directory<String, net.sourceforge.guacamol
|
|||||||
* Delete system permissions for a given user. All permissions in
|
* Delete system permissions for a given user. All permissions in
|
||||||
* the given list will be removed from the user.
|
* 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
|
* @param permissions The permissions the given user should no longer have
|
||||||
* when this operation completes.
|
* when this operation completes.
|
||||||
* @param user_id The ID of the user whose permissions should be updated.
|
|
||||||
*/
|
*/
|
||||||
private void deleteSystemPermissions(Collection<SystemPermission> permissions,
|
private void deleteSystemPermissions(int user_id,
|
||||||
int user_id) {
|
Collection<SystemPermission> permissions) {
|
||||||
|
|
||||||
if(permissions.isEmpty())
|
if(permissions.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user