Class SimpleObjectPermissionSet
- java.lang.Object
-
- org.apache.guacamole.net.auth.simple.SimpleObjectPermissionSet
-
- All Implemented Interfaces:
ObjectPermissionSet,PermissionSet<ObjectPermission>
public class SimpleObjectPermissionSet extends Object implements ObjectPermissionSet
A read-only implementation of ObjectPermissionSet which uses a backing Set of Permissions to determine which permissions are present.
-
-
Field Summary
-
Fields inherited from interface org.apache.guacamole.net.auth.permission.ObjectPermissionSet
EMPTY_SET
-
-
Constructor Summary
Constructors Constructor Description SimpleObjectPermissionSet()Creates a new empty SimpleObjectPermissionSet.SimpleObjectPermissionSet(Collection<String> identifiers)Creates a new SimpleObjectPermissionSet which contains only READ permissions for each of the given identifiers.SimpleObjectPermissionSet(Collection<String> identifiers, Collection<ObjectPermission.Type> types)Creates a new SimpleObjectPermissionSet which contains permissions for all possible unique combinations of the given identifiers and permission types.SimpleObjectPermissionSet(Set<ObjectPermission> permissions)Creates a new SimpleObjectPermissionSet which contains the permissions within the given Set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPermission(ObjectPermission.Type permission, String identifier)Adds the specified permission for the object having the given identifier.voidaddPermissions(Set<ObjectPermission> permissions)Adds the specified permissions, if not already granted.Collection<String>getAccessibleObjects(Collection<ObjectPermission.Type> permissionTypes, Collection<String> identifiers)Tests whether this user has the specified permissions for the objects having the given identifiers.Set<ObjectPermission>getPermissions()Returns a Set which contains all permissions granted within this permission set.booleanhasPermission(ObjectPermission.Type permission, String identifier)Tests whether the permission of the given type is granted for the object having the given identifier.voidremovePermission(ObjectPermission.Type permission, String identifier)Removes the specified permission for the object having the given identifier.voidremovePermissions(Set<ObjectPermission> permissions)Removes each of the specified permissions, if granted.protected voidsetPermissions(Set<ObjectPermission> permissions)Sets the Set which backs this SimpleObjectPermissionSet.
-
-
-
Constructor Detail
-
SimpleObjectPermissionSet
public SimpleObjectPermissionSet()
Creates a new empty SimpleObjectPermissionSet. If you are not extending SimpleObjectPermissionSet and only need an immutable, empty ObjectPermissionSet, consider usingObjectPermissionSet.EMPTY_SETinstead.
-
SimpleObjectPermissionSet
public SimpleObjectPermissionSet(Collection<String> identifiers, Collection<ObjectPermission.Type> types)
Creates a new SimpleObjectPermissionSet which contains permissions for all possible unique combinations of the given identifiers and permission types.- Parameters:
identifiers- The identifiers which should be associated permissions having each of the given permission types.types- The types of permissions which should be granted for each of the given identifiers.
-
SimpleObjectPermissionSet
public SimpleObjectPermissionSet(Collection<String> identifiers)
Creates a new SimpleObjectPermissionSet which contains only READ permissions for each of the given identifiers.- Parameters:
identifiers- The identifiers which should each be associated with READ permission.
-
SimpleObjectPermissionSet
public SimpleObjectPermissionSet(Set<ObjectPermission> permissions)
Creates a new SimpleObjectPermissionSet which contains the permissions within the given Set.- Parameters:
permissions- The Set of permissions this SimpleObjectPermissionSet should contain.
-
-
Method Detail
-
setPermissions
protected void setPermissions(Set<ObjectPermission> permissions)
Sets the Set which backs this SimpleObjectPermissionSet. Future function calls on this SimpleObjectPermissionSet will use the provided Set.- Parameters:
permissions- The Set of permissions this SimpleObjectPermissionSet should contain.
-
getPermissions
public Set<ObjectPermission> getPermissions()
Description copied from interface:PermissionSetReturns a Set which contains all permissions granted within this permission set.- Specified by:
getPermissionsin interfaceObjectPermissionSet- Specified by:
getPermissionsin interfacePermissionSet<ObjectPermission>- Returns:
- A Set containing all permissions granted within this permission set.
-
hasPermission
public boolean hasPermission(ObjectPermission.Type permission, String identifier) throws org.apache.guacamole.GuacamoleException
Description copied from interface:ObjectPermissionSetTests whether the permission of the given type is granted for the object having the given identifier.- Specified by:
hasPermissionin interfaceObjectPermissionSet- Parameters:
permission- The permission to check.identifier- The identifier of the object affected by the permission being checked.- Returns:
- true if the permission is granted, false otherwise.
- Throws:
org.apache.guacamole.GuacamoleException- If an error occurs while checking permissions, or if permissions cannot be checked due to lack of permissions to do so.
-
addPermission
public void addPermission(ObjectPermission.Type permission, String identifier) throws org.apache.guacamole.GuacamoleException
Description copied from interface:ObjectPermissionSetAdds the specified permission for the object having the given identifier.- Specified by:
addPermissionin interfaceObjectPermissionSet- Parameters:
permission- The permission to add.identifier- The identifier of the object affected by the permission being added.- Throws:
org.apache.guacamole.GuacamoleException- If an error occurs while adding the permission, or if permission to add permissions is denied.
-
removePermission
public void removePermission(ObjectPermission.Type permission, String identifier) throws org.apache.guacamole.GuacamoleException
Description copied from interface:ObjectPermissionSetRemoves the specified permission for the object having the given identifier.- Specified by:
removePermissionin interfaceObjectPermissionSet- Parameters:
permission- The permission to remove.identifier- The identifier of the object affected by the permission being added.- Throws:
org.apache.guacamole.GuacamoleException- If an error occurs while removing the permission, or if permission to remove permissions is denied.
-
getAccessibleObjects
public Collection<String> getAccessibleObjects(Collection<ObjectPermission.Type> permissionTypes, Collection<String> identifiers) throws org.apache.guacamole.GuacamoleException
Description copied from interface:ObjectPermissionSetTests whether this user has the specified permissions for the objects having the given identifiers. The identifier of an object is returned in a new collection if at least one of the specified permissions is granted for that object.- Specified by:
getAccessibleObjectsin interfaceObjectPermissionSet- Parameters:
permissionTypes- The permissions to check. An identifier will be included in the resulting collection if at least one of these permissions is granted for the associated objectidentifiers- The identifiers of the objects affected by the permissions being checked.- Returns:
- A collection containing the subset of identifiers for which at least one of the specified permissions is granted.
- Throws:
org.apache.guacamole.GuacamoleException- If an error occurs while checking permissions, or if permissions cannot be checked due to lack of permissions to do so.
-
addPermissions
public void addPermissions(Set<ObjectPermission> permissions) throws org.apache.guacamole.GuacamoleException
Description copied from interface:PermissionSetAdds the specified permissions, if not already granted. If a specified permission is already granted, no operation is performed regarding that permission.- Specified by:
addPermissionsin interfaceObjectPermissionSet- Specified by:
addPermissionsin interfacePermissionSet<ObjectPermission>- Parameters:
permissions- The permissions to add.- Throws:
org.apache.guacamole.GuacamoleException- If an error occurs while adding the permissions, or if permission to add permissions is denied.
-
removePermissions
public void removePermissions(Set<ObjectPermission> permissions) throws org.apache.guacamole.GuacamoleException
Description copied from interface:PermissionSetRemoves each of the specified permissions, if granted. If a specified permission is not granted, no operation is performed regarding that permission.- Specified by:
removePermissionsin interfaceObjectPermissionSet- Specified by:
removePermissionsin interfacePermissionSet<ObjectPermission>- Parameters:
permissions- The permissions to remove.- Throws:
org.apache.guacamole.GuacamoleException- If an error occurs while removing the permissions, or if permission to remove permissions is denied.
-
-