mirror of
				https://github.com/gyurix1968/guacamole-client.git
				synced 2025-10-31 17:13:21 +00:00 
			
		
		
		
	GUAC-1100: Add batch add/remove to permission sets.
This commit is contained in:
		| @@ -23,6 +23,7 @@ | ||||
| package org.glyptodon.guacamole.net.auth.permission; | ||||
|  | ||||
| import java.util.Collection; | ||||
| import java.util.Set; | ||||
| import org.glyptodon.guacamole.GuacamoleException; | ||||
|  | ||||
|  | ||||
| @@ -121,4 +122,48 @@ public interface ObjectPermissionSet<IdentifierType> { | ||||
|             Collection<ObjectPermission.Type> permissions, | ||||
|             Collection<IdentifierType> identifiers) throws GuacamoleException; | ||||
|  | ||||
|     /** | ||||
|      * Returns a Set which contains all permissions granted within this | ||||
|      * permission set. | ||||
|      * | ||||
|      * @return | ||||
|      *     A Set containing all permissions granted within this permission set. | ||||
|      * | ||||
|      * @throws GuacamoleException  | ||||
|      *     If an error occurs while retrieving permissions, or if permissions | ||||
|      *     cannot be retrieved due to lack of permissions to do so. | ||||
|      */ | ||||
|     Set<ObjectPermission<IdentifierType>> getPermissions() | ||||
|             throws GuacamoleException; | ||||
|  | ||||
|     /** | ||||
|      * Adds the specified permissions, if not already granted. If a specified | ||||
|      * permission is already granted, no operation is performed regarding that | ||||
|      * permission. | ||||
|      * | ||||
|      * @param permissions | ||||
|      *     The permissions to add. | ||||
|      * | ||||
|      * @throws GuacamoleException | ||||
|      *     If an error occurs while adding the permissions, or if permission to | ||||
|      *     add permissions is denied. | ||||
|      */ | ||||
|     void addPermissions(Set<ObjectPermission<IdentifierType>> permissions) | ||||
|             throws GuacamoleException; | ||||
|  | ||||
|     /** | ||||
|      * Removes each of the specified permissions, if granted. If a specified | ||||
|      * permission is not granted, no operation is performed regarding that | ||||
|      * permission. | ||||
|      * | ||||
|      * @param permissions | ||||
|      *     The permissions to remove. | ||||
|      * | ||||
|      * @throws GuacamoleException | ||||
|      *     If an error occurs while removing the permissions, or if permission | ||||
|      *     to remove permissions is denied. | ||||
|      */ | ||||
|     void removePermissions(Set<ObjectPermission<IdentifierType>> permissions) | ||||
|             throws GuacamoleException; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -22,6 +22,7 @@ | ||||
|  | ||||
| package org.glyptodon.guacamole.net.auth.permission; | ||||
|  | ||||
| import java.util.Set; | ||||
| import org.glyptodon.guacamole.GuacamoleException; | ||||
|  | ||||
|  | ||||
| @@ -74,4 +75,49 @@ public interface SystemPermissionSet { | ||||
|     void removePermission(SystemPermission.Type permission) | ||||
|             throws GuacamoleException; | ||||
|  | ||||
|     /** | ||||
|      * Returns a Set which contains all system-level permissions granted within | ||||
|      * this permission set. | ||||
|      * | ||||
|      * @return | ||||
|      *     A Set containing all system-level permissions granted within this | ||||
|      *     permission set. | ||||
|      * | ||||
|      * @throws GuacamoleException  | ||||
|      *     If an error occurs while retrieving permissions, or if permissions | ||||
|      *     cannot be retrieved due to lack of permissions to do so. | ||||
|      */ | ||||
|     Set<SystemPermission> getPermissions() throws GuacamoleException; | ||||
|  | ||||
|     /** | ||||
|      * Adds the specified permissions, if not already granted. If a specified | ||||
|      * permission is already granted, no operation is performed regarding that | ||||
|      * permission. | ||||
|      * | ||||
|      * @param permissions | ||||
|      *     The permissions to add. | ||||
|      * | ||||
|      * @throws GuacamoleException | ||||
|      *     If an error occurs while adding the permissions, or if permission to | ||||
|      *     add permissions is denied. | ||||
|      */ | ||||
|     void addPermissions(Set<SystemPermission> permissions) | ||||
|             throws GuacamoleException; | ||||
|  | ||||
|     /** | ||||
|      * Removes each of the specified permissions, if granted. If a specified | ||||
|      * permission is not granted, no operation is performed regarding that | ||||
|      * permission. | ||||
|      * | ||||
|      * @param permissions | ||||
|      *     The permissions to remove. | ||||
|      * | ||||
|      * @throws GuacamoleException | ||||
|      *     If an error occurs while removing the permissions, or if permission | ||||
|      *     to remove permissions is denied. | ||||
|      */ | ||||
|     void removePermissions(Set<SystemPermission> permissions) | ||||
|             throws GuacamoleException; | ||||
|  | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -78,20 +78,11 @@ public class SimpleObjectPermissionSet<IdentifierType> | ||||
|         this.permissions = permissions; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns the Set which currently backs this SimpleObjectPermissionSet. | ||||
|      * Changes to this Set will affect future function calls on this | ||||
|      * SimpleObjectPermissionSet. | ||||
|      * | ||||
|      * @return | ||||
|      *     The Set of permissions this SimpleObjectPermissionSet currently  | ||||
|      *     contains. | ||||
|      */ | ||||
|     protected Set<ObjectPermission<IdentifierType>> getPermissions() { | ||||
|     @Override | ||||
|     public Set<ObjectPermission<IdentifierType>> getPermissions() { | ||||
|         return permissions; | ||||
|     } | ||||
|  | ||||
|     | ||||
|     @Override | ||||
|     public boolean hasPermission(ObjectPermission.Type permission, | ||||
|             IdentifierType identifier) throws GuacamoleException { | ||||
| @@ -140,4 +131,16 @@ public class SimpleObjectPermissionSet<IdentifierType> | ||||
|          | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void addPermissions(Set<ObjectPermission<IdentifierType>> permissions) | ||||
|             throws GuacamoleException { | ||||
|         throw new GuacamoleSecurityException("Permission denied."); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void removePermissions(Set<ObjectPermission<IdentifierType>> permissions) | ||||
|             throws GuacamoleException { | ||||
|         throw new GuacamoleSecurityException("Permission denied."); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -72,16 +72,8 @@ public class SimpleSystemPermissionSet implements SystemPermissionSet { | ||||
|         this.permissions = permissions; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns the Set which currently backs this SimpleSystemPermissionSet. | ||||
|      * Changes to this Set will affect future function calls on this | ||||
|      * SimpleSystemPermissionSet. | ||||
|      * | ||||
|      * @return | ||||
|      *     The Set of permissions this SimpleSystemPermissionSet currently  | ||||
|      *     contains. | ||||
|      */ | ||||
|     protected Set<SystemPermission> getPermissions() { | ||||
|     @Override | ||||
|     public Set<SystemPermission> getPermissions() { | ||||
|         return permissions; | ||||
|     } | ||||
|  | ||||
| @@ -106,4 +98,16 @@ public class SimpleSystemPermissionSet implements SystemPermissionSet { | ||||
|         throw new GuacamoleSecurityException("Permission denied."); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void addPermissions(Set<SystemPermission> permissions) | ||||
|             throws GuacamoleException { | ||||
|         throw new GuacamoleSecurityException("Permission denied."); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void removePermissions(Set<SystemPermission> permissions) | ||||
|             throws GuacamoleException { | ||||
|         throw new GuacamoleSecurityException("Permission denied."); | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user