Package net.sf.basedb.core
Enum Permission
- java.lang.Object
-
- java.lang.Enum<Permission>
-
- net.sf.basedb.core.Permission
-
- All Implemented Interfaces:
Serializable
,Comparable<Permission>
public enum Permission extends Enum<Permission>
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) $
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ACT_AS_ANOTHER_USER
This permission allows a user act as another user using theSessionControl.impersonateLogin(int, String)
method.CREATE
This permission allows a user create new items.DELETE
This permission allows a user delete an item.DENIED
This permission denies a user access to an item.READ
This permission allows a user read information about an item.RESTRICTED_WRITE
This permission allows a user to update some information about an item.SELECT_JOBAGENT
This permission allows a user to specify which job agent a job should be executed on usingJob.setJobAgent(JobAgent)
.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.SHARE_TO_EVERYONE
This permission allows a user to share an item to theGroup.EVERYONE
group.USE
This permission allows a user to use/link to an item.WRITE
This permission allows a user update the information about an item.
-
Field Summary
Fields Modifier and Type Field Description private int
denyValue
private String
displayValue
private int
grantValue
-
Constructor Summary
Constructors Modifier Constructor Description private
Permission(int grantValue, int denyValue, String displayValue)
Constructor for Permission enums.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (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
denyValue()
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
grantValue()
(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
merge(Integer... permissions)
Merges a list of integer permission values.String
toString()
static Permission
valueOf(String name)
Returns the enum constant of this type with the specified name.static Permission[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
READ
public static final Permission READ
This permission allows a user read information about an item.
-
USE
public static final Permission USE
This permission allows a user to use/link to an item.
-
RESTRICTED_WRITE
public static final Permission RESTRICTED_WRITE
This permission allows a user to update some information about an item.
-
WRITE
public static final Permission WRITE
This permission allows a user update the information about an item.
-
DELETE
public static final Permission DELETE
This permission allows a user delete an item.
-
SET_OWNER
public static final Permission SET_OWNER
This permission allows a user change the owner of an item.
-
SET_PERMISSION
public static final Permission SET_PERMISSION
This permission allows a user change the access permission to an item.
-
CREATE
public static final Permission CREATE
This permission allows a user create new items.
-
DENIED
public static final Permission DENIED
This permission denies a user access to an item. This permission can only be given toRoleKey
:s.
-
SHARE_TO_EVERYONE
public static final Permission 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
public static final Permission 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
public static final Permission 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 Detail
-
grantValue
private final int grantValue
-
denyValue
private final int denyValue
-
displayValue
private final String displayValue
-
-
Constructor Detail
-
Permission
private Permission(int grantValue, int denyValue, String displayValue)
Constructor for Permission enums.
-
-
Method Detail
-
values
public static Permission[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Permission c : Permission.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Permission valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified nameNullPointerException
- if the argument is null
-
grantValue
int grantValue()
-
denyValue
int denyValue()
-
toString
public String toString()
- Overrides:
toString
in classEnum<Permission>
-
expand
public static Set<Permission> expand(Set<Permission> permissions)
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
static boolean hasPermission(int permissions, Permission permission)
Checks if the givenPermission
is granted by thepermissions
code.- Parameters:
permissions
- The permission combinationpermission
- The permission to check
-
isDeniedPermission
static boolean isDeniedPermission(int permissions, Permission permission)
Checks if the givenPermission
is denied by thepermissions
code.- Parameters:
permissions
- The permission combinationpermission
- The permission to check
-
grant
static int grant(Permission permission)
Convert the given permission to the integer grant value.
-
grant
static int grant(Permission... permissions)
Combine the given permissions and convert to the integer grant value.
-
grant
static int grant(Set<Permission> permissions)
Combine the given permission and convert to the integer grant value.
-
deny
static int deny(Permission permission)
Convert the given permission to the integer deny value.
-
deny
static int deny(Permission... permissions)
Combine the given permissions and convert to the integer deny value.
-
deny
static int deny(Set<Permission> permissions)
Combine the given permission and convert to the integer deny value.
-
fromInt
static Set<Permission> fromInt(int permissions)
Convert an integer value to a set of granted permissions.
-
fromDeniedInt
static Set<Permission> fromDeniedInt(int permissions)
Convert an integer value to a set of denied permissions.
-
merge
static int merge(Integer... permissions)
Merges a list of integer permission values.- Parameters:
permissions
- The permission values, null values are ignored- Returns:
- The combined permissions
- Since:
- 2.8
-
-