Class Permissionable
Classes that extend this class can be assigned permissions. The User
and Group
classes extend
Permissionable
.
A permission either allows or denies an action
on a product
and namespace
. Each permission specifies:
- The set of
products
that the permission applies to. - The
namespace
of the permission. - The
action
that is being allowed or denied.
Each product
in a product set
can be represented by a regular expression. For example, the regular expression "/FX/.*
" would match all FX products.
The regular expression representing the product
can also contain the substitution tokens "%u
" and "%U
". When the Permissioning Auth Module checks
a permission to see if it applies to a requested product
, it replaces the "%u
" token with the username of the logged in user, and the "%U
" token
with the session name allocated by Liberator for that user session.
Substitution tokens can be placed in a product
permission to prevent one user from accessing another user's data. For example, if the username of the logged in user is
"Bob
" and the requested product is "/Private/John/FX
", the permissioned product "/Private/%u/FX
" will not match the requested product
"/Private/John/FX
", and the permission will not apply to this request.
Product
requests are always denied unless a matching permission allows the action
, and no other permission denies the action
.
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
applyPermission
(Set<String> productSet, String nameSpace, String action, Authorization auth) Adds a permission that either allows or denies a singleaction
on aproduct
set andnamespace
.void
Adds a permission that denies one or moreactions
on aproduct
set andnamespace
.boolean
Indicates whether or not another object is "equal to" thisPermissionable
.getName()
Gets the name of thisPermissionable
.int
hashCode()
Returns a hash code value for thisPermissionable
.void
Adds a permission that allows one or moreactions
on aproduct
set andnamespace
.void
Removes every permission for thisPermissionable
.void
removePermission
(Set<String> products, String namespace, String... actions) Removes a permission for a singleaction
on aproduct
set andnamespace
.
-
Field Details
-
name
-
productPermissionSets
-
parents
-
-
Method Details
-
getName
Gets the name of this
Permissionable
.A
Permissionable
is named when it is created (see thecreateUser()
andcreateGroup()
methods of thePermissioningDataSource
).- Returns:
- the name of this
Permissionable
. - Throws:
IllegalStateException
- if thisPermissionable
was removed from thePermissioningDatasource
.
-
applyPermission
public void applyPermission(Set<String> productSet, String nameSpace, String action, Authorization auth) throws NoTransactionInProgressException, IllegalStateException Adds a permission that either allows or denies a single
action
on aproduct
set andnamespace
.This permission is added to the permissions already assigned to the
Permissionable
, and replaces any other permission thatPermissionable
has for thisaction
,product
set, andnamespace
.- Parameters:
productSet
- the set ofproduct
s that the permission applies to.nameSpace
- thenamespace
of the permission. To add the permission to thedefault namespace
, set thenamespace
toConstants.DEFAULT_PERMISSION_NAMESPACE
.action
- theaction
that is being permitted.auth
- theAuthorization
that allows or denies theaction
.- Throws:
NoTransactionInProgressException
- if this method is called outside the scope of aPermissioningDataSource
transactionIllegalStateException
- if thisPermissionable
was removed from thePermissioningDatasource
.
-
permit
public void permit(Set<String> productSet, String nameSpace, String... actions) throws NoTransactionInProgressException, IllegalStateException Adds a permission that allows one or more
actions
on aproduct
set andnamespace
.This permission is added to the permissions already assigned to this
Permissionable
, and replaces any other permission it has for theseactions
,product
set, andnamespace
.- Parameters:
productSet
- the set ofproducts
this this permissions applies tonameSpace
- thenamespace
of the permission. To add the permission to thedefault namespace
, set thenamespace
toConstants.DEFAULT_PERMISSION_NAMESPACE
.actions
- theaction
s that are being permitted. Any number ofaction
s can be specified as a comma separated sequence ofvarargs
- Throws:
NoTransactionInProgressException
- if this method is called outside the scope of aPermissioningDataSource
transactionIllegalStateException
- if thisPermissionable
was removed from thePermissioningDatasource
.
-
deny
public void deny(Set<String> productSet, String nameSpace, String... actions) throws NoTransactionInProgressException, IllegalStateException Adds a permission that denies one or more
actions
on aproduct
set andnamespace
.This permission is added to the permissions already assigned to this
Permissionable
, and replaces any other permission it has for theseactions
,product
set, andnamespace
.- Parameters:
productSet
- the set ofproducts
this this permissions applies tonameSpace
- thenamespace
of the permission. To add the permission to thedefault namespace
, set thenamespace
toConstants.DEFAULT_PERMISSION_NAMESPACE
.actions
- theaction
s that are being permitted. Any number ofaction
s can be specified as a comma separated sequence ofvarargs
- Throws:
NoTransactionInProgressException
- if this method is called outside the scope of aPermissioningDataSource
transactionIllegalStateException
- if thisPermissionable
was removed from thePermissioningDatasource
.
-
removePermission
public void removePermission(Set<String> products, String namespace, String... actions) throws NoTransactionInProgressException, IllegalStateException Removes a permission for a single
action
on aproduct
set andnamespace
. No permissions are removed if the permission does not exist.- Parameters:
products
- the set ofproduct
s the permission applies tonamespace
- thenamespace
of the permission. If the permission resides in thedefault namespace
, use thenamespace
Constants.DEFAULT_PERMISSION_NAMESPACE
.actions
- theaction
s that permission to be removed allows or denies. Do not specify any code>action if you want to remove all permissions for a givenproduct
set andnamespace
.- Throws:
NoTransactionInProgressException
- if this method is called outside the scope of aPermissioningDataSource
transactionIllegalStateException
- if thisPermissionable
was removed from thePermissioningDatasource
.
-
removeAllPermissions
public void removeAllPermissions()Removes every permission for this
Permissionable
.- Throws:
NoTransactionInProgressException
- if this method is called outside the scope of aPermissioningDataSource
transactionIllegalStateException
- if thisPermissionable
was removed from thePermissioningDatasource
.
-
equals
Indicates whether or not another object is "equal to" this
Permissionable
. The equality is based on the type and name of the objects. -
hashCode
public int hashCode()Returns a hash code value for this
Permissionable
. The hash code is calculated using the type and name of thePermissionable
. -
copyPermissions
-