Package net.sf.basedb.core
Enum Class Permission
- All Implemented Interfaces:
Serializable
,Comparable<Permission>
,Constable
This enumeration defined constants for permissions.
- Version:
- 2.0
- Author:
- Nicklas
- Developer info
- Permissions are stored in the database as integers, which means that
a given set of permissions must be combined before they are saved.
We use the
grantValue
for this. This value is constructed in such a way that some permissions implicitly activates other permissions as follows:- READ ->
- USE -> READ
- RESTRICTED_WRITE -> USE and READ
- WRITE -> RESTRICTED_WRITE, USE and READ
- DELETE -> WRITE, RESTRICTED_WRITE, USE and READ
- SET_OWNER -> WRITE, RESTRICTED_WRITE, USE and READ
- SET_PERMISSION -> WRITE, RESTRICTED_WRITE, USE and READ
denyValue
is only used by theBasicItem.initPermissions(int, int)
method when a subclass needs to deny a permission. This value is constructed in a similiar way:- READ -> USE, RESTRICTED_WRITE, WRITE, DELETE, SET_OWNER and SET_PERMISSION
- USE -> RESTRICTED_WRITE, WRITE, DELETE, SET_OWNER and SET_PERMISSION
- RESTRICTED_WRITE -> WRITE, DELETE, SET_OWNER and SET_PERMISSION
- WRITE -> DELETE, SET_OWNER and SET_PERMISSION
- DELETE ->
- SET_OWNER ->
- SET_PERMISSION ->
- Last modified
- $Date: 2016-10-19 14:08:22 +0200 (on, 19 okt 2016) $
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantDescriptionThis permission allows a user act as another user using theSessionControl.impersonateLogin(int, String)
method.This permission allows a user create new items.This permission allows a user delete an item.This permission denies a user access to an item.This permission allows a user read information about an item.This permission allows a user to update some information about an item.This permission allows a user to specify which job agent a job should be executed on usingJob.setJobAgent(JobAgent)
.This permission allows a user change the owner of an item.This permission allows a user change the access permission to an item.This permission allows a user to share an item to theGroup.EVERYONE
group.This permission allows a user to use/link to an item.This permission allows a user update the information about an item. -
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprivate
Permission
(int grantValue, int denyValue, String displayValue) Constructor for Permission enums. -
Method Summary
Modifier and TypeMethodDescription(package private) static int
deny
(Set<Permission> permissions) Combine the given permission and convert to the integer deny value.(package private) static int
deny
(Permission permission) Convert the given permission to the integer deny value.(package private) static int
deny
(Permission... permissions) Combine the given permissions and convert to the integer deny value.(package private) int
static Set<Permission>
expand
(Set<Permission> permissions) Expand the given set of permissions to make sure it includes all implicitely granted permissions.(package private) static Set<Permission>
fromDeniedInt
(int permissions) Convert an integer value to a set of denied permissions.(package private) static Set<Permission>
fromInt
(int permissions) Convert an integer value to a set of granted permissions.(package private) static int
grant
(Set<Permission> permissions) Combine the given permission and convert to the integer grant value.(package private) static int
grant
(Permission permission) Convert the given permission to the integer grant value.(package private) static int
grant
(Permission... permissions) Combine the given permissions and convert to the integer grant value.(package private) int
(package private) static boolean
hasPermission
(int permissions, Permission permission) Checks if the givenPermission
is granted by thepermissions
code.(package private) static boolean
isDeniedPermission
(int permissions, Permission permission) Checks if the givenPermission
is denied by thepermissions
code.(package private) static int
Merges a list of integer permission values.toString()
static Permission
Returns the enum constant of this class with the specified name.static Permission[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
READ
This permission allows a user read information about an item. -
USE
This permission allows a user to use/link to an item. -
RESTRICTED_WRITE
This permission allows a user to update some information about an item. -
WRITE
This permission allows a user update the information about an item. -
DELETE
This permission allows a user delete an item. -
SET_OWNER
This permission allows a user change the owner of an item. -
SET_PERMISSION
This permission allows a user change the access permission to an item. -
CREATE
This permission allows a user create new items. -
DENIED
This permission denies a user access to an item. This permission can only be given toRoleKey
:s. -
SHARE_TO_EVERYONE
This permission allows a user to share an item to theGroup.EVERYONE
group. This is a system permission and is only meaningful for the role key for theItem.SYSTEM
item. -
ACT_AS_ANOTHER_USER
This permission allows a user act as another user using theSessionControl.impersonateLogin(int, String)
method. This is a system permission and is only meaningful for the role key for theItem.SYSTEM
item. -
SELECT_JOBAGENT
This permission allows a user to specify which job agent a job should be executed on usingJob.setJobAgent(JobAgent)
. This is a system permission and is only meaningful for the role key for theItem.SYSTEM
item.- Since:
- 2.8
-
-
Field Details
-
grantValue
private final int grantValue -
denyValue
private final int denyValue -
displayValue
-
-
Constructor Details
-
Permission
Constructor for Permission enums.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
grantValue
int grantValue() -
denyValue
int denyValue() -
toString
- Overrides:
toString
in classEnum<Permission>
-
expand
Expand the given set of permissions to make sure it includes all implicitely granted permissions. For example if the set contains WRITE it is exapnded to READ, USE, RESTRICTED_WRITE and WRITE.- Parameters:
permissions
- The permissions to expand- Returns:
- A new set containing the expanded permissions or null if the parameter is null
-
hasPermission
Checks if the givenPermission
is granted by thepermissions
code.- Parameters:
permissions
- The permission combinationpermission
- The permission to check
-
isDeniedPermission
Checks if the givenPermission
is denied by thepermissions
code.- Parameters:
permissions
- The permission combinationpermission
- The permission to check
-
grant
Convert the given permission to the integer grant value. -
grant
Combine the given permissions and convert to the integer grant value. -
grant
Combine the given permission and convert to the integer grant value. -
deny
Convert the given permission to the integer deny value. -
deny
Combine the given permissions and convert to the integer deny value. -
deny
Combine the given permission and convert to the integer deny value. -
fromInt
Convert an integer value to a set of granted permissions. -
fromDeniedInt
Convert an integer value to a set of denied permissions. -
merge
Merges a list of integer permission values.- Parameters:
permissions
- The permission values, null values are ignored- Returns:
- The combined permissions
- Since:
- 2.8
-