Package com.randomnoun.common.security
Class Permission
java.lang.Object
com.randomnoun.common.security.Permission
- All Implemented Interfaces:
Serializable
A class encapsulating permission information. A 'permission' allows a user (or role)
to perform an 'activity' on a 'resource'. Roles, activities and resources are
all specified as Strings, a user is specified by a User object (identified by
username and customerId).
A resource may also have a criteria supplied; e.g. a user may have a view/account permission, but only accounts with a certain monetary value.
Two constructors are provided, one for users and one for roles. Note that there are no 'setter' methods in this class; permissions may only be altered through creating new ones.
- Author:
- knoxg
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPermission
(User user, String activity, String resource, ResourceCriteria resourceCriteria) Create a new role-based permission.Permission
(String permission) Create a permission that is not assigned to either a user or rolePermission
(String permission, ResourceCriteria resourceCriteria) Create a permission that is not assigned to either a user or role, with a resource criteriaPermission
(String activity, String resource) Create a permission that is not assigned to either a user or rolePermission
(String role, String activity, String resource, ResourceCriteria resourceCriteria) Create a new role-based permission. -
Method Summary
Modifier and TypeMethodDescriptionReturns the activity this permission applies to.Returns the resource this permission applies to.Returns the resourceCriteria that applies to this permission.getRole()
Returns the role this permission applies to, or null if it is a user-based role.getUser()
Returns the user this permission applies to, or null if it is a user-based role.
-
Constructor Details
-
Permission
Create a new role-based permission.- Parameters:
role
- the name of this role this permission applies toactivity
- the name of the activity we are permittingresource
- the resource we are permitting access toresourceCriteria
- a criteria which limits the types of resources that this permission applies to
-
Permission
Create a new role-based permission.- Parameters:
user
- the user this permission applies toactivity
- the name of the activity we are permittingresource
- the resource we are permitting access toresourceCriteria
- a criteria which limits the types of resources that this permission applies to
-
Permission
Create a permission that is not assigned to either a user or role- Parameters:
activity
- the name of the activity we are permittingresource
- the resource we are permitting acess to
-
Permission
Create a permission that is not assigned to either a user or role- Parameters:
permission
- a permission in 'activity.resource' format
-
Permission
Create a permission that is not assigned to either a user or role, with a resource criteria- Parameters:
permission
- a permission in 'activity.resource' format
-
-
Method Details
-
getRole
Returns the role this permission applies to, or null if it is a user-based role.- Returns:
- the role this permission applies to, or null if it is a user-based role
-
getUser
Returns the user this permission applies to, or null if it is a user-based role.- Returns:
- the user this permission applies to, or null if it is a user-based role
-
getActivity
Returns the activity this permission applies to.- Returns:
- the activity this permission applies to
-
getResource
Returns the resource this permission applies to.- Returns:
- the resource this permission applies to
-
getResourceCriteria
Returns the resourceCriteria that applies to this permission.- Returns:
- the resourceCriteria that applies to this permission
-