Package org.uberfire.security.impl.authz
Class DefaultPermissionCollection
- java.lang.Object
-
- org.uberfire.security.impl.authz.DefaultPermissionCollection
-
- All Implemented Interfaces:
PermissionCollection
@Portable public class DefaultPermissionCollection extends Object implements PermissionCollection
A collection where the permissions are ordered by name.
-
-
Constructor Summary
Constructors Constructor Description DefaultPermissionCollection()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PermissionCollectionadd(Permission... permissions)Adds a permission object to the current collection of permission objects.DefaultPermissionCollectionclone()Creates an exact copy of this instance.Collection<Permission>collection()Returns all the Permission objects in the collection.protected booleanequalsName(String s1, String s2)Permissionget(String name)Gets a permission object matching the specified name.booleanimplies(Permission permission)Checks to see if the specified permission is implied by the collection of Permission objects held in this PermissionCollection.booleanimpliesName(Permission permission)It returns true provided this collection already contains a permission which implies by name (SeePermission.impliesName(Permission)) the permission passed as a parameter.PermissionCollectioninvert(Permission target)PermissionCollectionmerge(PermissionCollection other, int priority)Get all the permissions from this collection and the given one and puts them into a brand new collection instance.PermissionCollectionremove(Permission... permissions)Removes a permission object from the current collection of permission objects.StringtoString()
-
-
-
Method Detail
-
collection
public Collection<Permission> collection()
Description copied from interface:PermissionCollectionReturns all the Permission objects in the collection.- Specified by:
collectionin interfacePermissionCollection- Returns:
- A collection of all the Permissions.
-
add
public PermissionCollection add(Permission... permissions)
Description copied from interface:PermissionCollectionAdds a permission object to the current collection of permission objects.- Specified by:
addin interfacePermissionCollection- Parameters:
permissions- the Permission objects to add.
-
remove
public PermissionCollection remove(Permission... permissions)
Description copied from interface:PermissionCollectionRemoves a permission object from the current collection of permission objects.- Specified by:
removein interfacePermissionCollection- Parameters:
permissions- the Permission objects to remove.
-
get
public Permission get(String name)
Description copied from interface:PermissionCollectionGets a permission object matching the specified name.- Specified by:
getin interfacePermissionCollection- Parameters:
name- The fully qualified name of the permission.- Returns:
- A Permission instance or null if not found.
-
implies
public boolean implies(Permission permission)
Description copied from interface:PermissionCollectionChecks to see if the specified permission is implied by the collection of Permission objects held in this PermissionCollection.- Specified by:
impliesin interfacePermissionCollection- Parameters:
permission- the Permission object to compare.- Returns:
- true if "permission" is implied by the permissions in the collection, false if not.
-
impliesName
public boolean impliesName(Permission permission)
Description copied from interface:PermissionCollectionIt returns true provided this collection already contains a permission which implies by name (SeePermission.impliesName(Permission)) the permission passed as a parameter.- Specified by:
impliesNamein interfacePermissionCollection- Parameters:
permission- the permission to check- Returns:
- true if the permission name is implied by this collection, false otherwise.
-
merge
public PermissionCollection merge(PermissionCollection other, int priority)
Description copied from interface:PermissionCollectionGet all the permissions from this collection and the given one and puts them into a brand new collection instance. Any "redundant" permission instance ("implied" by other permissions in the collection) are left out from the outcome. Notice also, thepriorityparameter is taken into account in case the same permission is present in both collections.- Specified by:
mergein interfacePermissionCollection- Parameters:
other- the collection to merge.priority- integer indicating what to do if the same permission is found in both collections:- 0 = same priority (GRANTED permissions win by default)
- negative integer = this collection wins
- positive integer = the other collection wins
- Returns:
- A collection containing the merge result.
-
clone
public DefaultPermissionCollection clone()
Description copied from interface:PermissionCollectionCreates an exact copy of this instance.- Specified by:
clonein interfacePermissionCollection- Overrides:
clonein classObject- Returns:
- A brand new Permission instance
-
invert
public PermissionCollection invert(Permission target)
-
-