public interface Permission
Resource
instance.
Every permission has a "factor" value that represents the type and weight of the permission. A negative value (< 0) means denial of access to the resource (or negative permission), a non-negative value (>= 0) means permission of access to the resource (or positive permission). The higher the absolute value of a factor, the higher is its "weight" or priority compared to conflicting permissions defined in other roles. The default factor is 0, so in the simple case of just granting a permission, the user does not have to care about factors at all.
Modifier and Type | Interface and Description |
---|---|
static class |
Permission.Implementation
Simple default implementation of a
Permission . |
Modifier and Type | Method and Description |
---|---|
default boolean |
evaluate(Subject subject)
Evaluates if the passed
Subject instance is granted access to the
Resource instance associated with this Permission
instance. |
int |
factor()
The factor of this
Permission instance. |
static Permission |
New(Resource resource)
Creates a new
Permission instance for the passed Resource
instance and a default factor of 0. |
static Permission |
New(Resource resource,
int factor)
Creates a new
Permission instance for the passed Resource
instance and the passed factor. |
Resource |
resource()
The resource whose access this
Permission instance describes. |
Resource resource()
Permission
instance describes.Resource
instance.int factor()
Permission
instance. See Permission
for details.Permission
instance.default boolean evaluate(Subject subject)
Subject
instance is granted access to the
Resource
instance associated with this Permission
instance. Custom implementations of this method can use arbitrary complex
logic to perform the evaluation.static Permission New(Resource resource, int factor)
Permission
instance for the passed Resource
instance and the passed factor. Note that factor can be any value, no
restriction or validation is wanted in the default implementation.resource
- the resource to be associated with the Permission
instance.factor
- the value used as the Permission
instance's factor.Permission
instance for the passed values.static Permission New(Resource resource)
Permission
instance for the passed Resource
instance and a default factor of 0.resource
- resource the resource to be associated with the
Permission
instance.Permission
instance for the passed values.