public interface Role
Modifier and Type | Interface and Description |
---|---|
static interface |
Role.Creator
Interface equivalent of a constructor for the interface type
Role
. |
static class |
Role.Implementation
A simple
Role.Mutable default implementation. |
static interface |
Role.Mutable
Extension of the type
Role with mutability methods. |
Modifier and Type | Method and Description |
---|---|
static Map<Resource,Permission> |
collectEffectivePermissions(Collection<Role> roles)
Utility method that collects the effective permissions from a collection
of passed roles.
|
static <M extends Map<Resource,Permission>> |
collectEffectivePermissions(Collection<Role> roles,
Set<Role> handledRoles,
Set<Permission> handledPermissions,
Set<Resource> handledResources,
M collectedPermissions) |
static void |
collectEffectivePermissions(Iterable<Permission> permissions,
Set<Permission> handledPermissions,
Set<Resource> handledResources,
Map<Resource,Permission> effectivePermissions) |
static void |
collectEffectivePermissions(Resource resource,
Permission permission,
Set<Resource> handledResources,
Map<Resource,Permission> effectivePermissions) |
static <R,C extends Set<? super Role>> |
collectEffectiveRoles(Collection<Role> roles,
C effectiveRoles) |
default Map<Resource,Permission> |
effectivePermissions()
Returns the effective permissions of this
Role instance, meaning
a collection containing all the permissions that this instance has been
defined by and the effective permissions of all its roles. |
default Set<Role> |
effectiveRoles()
Returns the effective roles of this
Role instance, meaning a
collection containing all the roles that this instance has been defined
by and all their effective roles. |
String |
name() |
static Role |
New(String name)
Returns a new
Role instance with the passed name that is
otherwise empty. |
static Role |
New(String name,
Permission... permissions)
Returns a new
Role instance defined by the passed values with no
explicit parent roles. |
static Role |
New(String name,
Role... roles)
Returns a new
Role instance defined by the passed values with no
explicit permissions. |
static Role |
New(String name,
Set<? extends Role> roles,
Set<? extends Permission> permissions)
Returns a new
Role instance defined by the passed values. |
static Role |
NewFromPermissions(String name,
Set<? extends Permission> permissions)
Returns a new
Role instance defined by the passed values with no
explicit parent roles. |
static Role |
NewFromRoles(String name,
Set<? extends Role> roles)
Returns a new
Role instance defined by the passed values with no
explicit permissions. |
Collection<Permission> |
permissions() |
static Role |
provide(Role role,
String name,
Set<String> parentRoles,
Set<String> permissions)
Validates and returns a passed non-null
Role instance or creates
a new one in case of a null refrence. |
Collection<Role> |
roles() |
static void |
update(Role role,
String name,
Set<Role> parentRoles,
Set<Permission> permissions)
Updates the passed
Role instance for the given values. |
String name()
Collection<Role> roles()
Collection<Permission> permissions()
default Set<Role> effectiveRoles()
Role
instance, meaning a
collection containing all the roles that this instance has been defined
by and all their effective roles. Every Role
instance is only
returned once (identity uniqueness).default Map<Resource,Permission> effectivePermissions()
Role
instance, meaning
a collection containing all the permissions that this instance has been
defined by and the effective permissions of all its roles. For every
unique Resource
instance the permission with the highest absolute
value is returned.static Map<Resource,Permission> collectEffectivePermissions(Collection<Role> roles)
roles
- the Role
instances whose effective permissions shall
be determined.effectivePermissions()
static <M extends Map<Resource,Permission>> M collectEffectivePermissions(Collection<Role> roles, Set<Role> handledRoles, Set<Permission> handledPermissions, Set<Resource> handledResources, M collectedPermissions)
static <R,C extends Set<? super Role>> C collectEffectiveRoles(Collection<Role> roles, C effectiveRoles)
static void collectEffectivePermissions(Iterable<Permission> permissions, Set<Permission> handledPermissions, Set<Resource> handledResources, Map<Resource,Permission> effectivePermissions)
static void collectEffectivePermissions(Resource resource, Permission permission, Set<Resource> handledResources, Map<Resource,Permission> effectivePermissions)
static Role New(String name, Set<? extends Role> roles, Set<? extends Permission> permissions)
Role
instance defined by the passed values.name
- the unchangeable identifying name of the role.roles
- the parent roles of the new role, potentially none.permissions
- the explicitely granted permissions for the new role,
potentially none.Role
instance.static Role NewFromRoles(String name, Set<? extends Role> roles)
Role
instance defined by the passed values with no
explicit permissions.name
- the unchangeable identifying name of the role.roles
- the parent roles of the new role, potentially none.Role
instance.static Role NewFromPermissions(String name, Set<? extends Permission> permissions)
Role
instance defined by the passed values with no
explicit parent roles.name
- the unchangeable identifying name of the role.permissions
- the explicitely granted permissions for the new role,
potentially none.Role
instance.static Role New(String name)
Role
instance with the passed name that is
otherwise empty.name
- the unchangeable identifying name of the role.Role
instance.static Role New(String name, Role... roles)
Role
instance defined by the passed values with no
explicit permissions.name
- the unchangeable identifying name of the role.roles
- the parent roles of the new role, potentially none.Role
instance.static Role New(String name, Permission... permissions)
Role
instance defined by the passed values with no
explicit parent roles.name
- the unchangeable identifying name of the role.permissions
- the explicitely granted permissions for the new role,
potentially none.Role
instance.static Role provide(Role role, String name, Set<String> parentRoles, Set<String> permissions)
Role
instance or creates
a new one in case of a null refrence. In this simple defeault
implementation, validating simply means to check if the passed role's
name is equal to the passed name.role
- an already existing Role
instance for that name or
null.name
- the indentifying name of the role. May not be null.parentRoles
- the names of the parent roles as per definition.permissions
- the names of the explicit permissions as per definition.Role
instance, otherwise a new one.static void update(Role role, String name, Set<Role> parentRoles, Set<Permission> permissions)
Role
instance for the given values. If
inconsistencies are detected or the instance is not Role.Mutable
, an
IllegalArgumentException
is thrown.role
- the Role
instance to be updated.name
- the identifiying name of the role.parentRoles
- the parent roles that the passed Role
instance shall
be updated with.permissions
- the explicit permissions that the passed Role
instance
shall be updated with.IllegalArgumentException
- if name is null, names do not match or the role is not
Role.Mutable
.