Package org.opencms.security
Class CmsPermissionSet
- java.lang.Object
-
- org.opencms.security.CmsPermissionSet
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
CmsPermissionSetCustom
public class CmsPermissionSet extends java.lang.Object implements java.io.Serializable
An immutable permission set that contains both allowed and denied permissions as bitsets.Currently supported permissions are:
(r) the right to read the contents of a resourcePERMISSION_READ
(w) the right to write the contents of a resourcePERMISSION_WRITE
(v) the right to see a resource in listings (workplace)PERMISSION_VIEW
(c) the right to set permissions of a resourcePERMISSION_CONTROL
(d) the right direct publish a resource even without publish project permissionsPERMISSION_DIRECT_PUBLISH
- Since:
- 6.0.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static CmsPermissionSet
ACCESS_CONTROL
Permission set to check control access.static CmsPermissionSet
ACCESS_DIRECT_PUBLISH
Permission set to check direct publish permissions.static CmsPermissionSet
ACCESS_READ
Permission set to check read access.static CmsPermissionSet
ACCESS_VIEW
Permission set to check view access.static CmsPermissionSet
ACCESS_WRITE
Permission set to check write access.protected int
m_allowed
The set of allowed permissions.protected int
m_denied
The set of denied permissions.static int
PERMISSION_CONTROL
The permission to control a resource.static int
PERMISSION_DIRECT_PUBLISH
The permission to direct publish a resource.static int
PERMISSION_EMPTY
No permissions for a resource (used especially for denied permissions).static int
PERMISSION_FULL
All allowed permissions for a resource.static int
PERMISSION_READ
The permission to read a resource.static int
PERMISSION_VIEW
The permission to view a resource.static int
PERMISSION_WRITE
The permission to write a resource.
-
Constructor Summary
Constructors Modifier Constructor Description protected
CmsPermissionSet()
Constructor to create an empty permission set.protected
CmsPermissionSet(int allowedPermissions)
Constructor to create a permission set with preset allowed permissions.CmsPermissionSet(int allowedPermissions, int deniedPermissions)
Constructor to create a permission set with preset allowed and denied permissions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
int
getAllowedPermissions()
Returns the currently allowed permissions of ths permission set.int
getDeniedPermissions()
Returns the currently denied permissions of this permission set.static java.util.Set<java.lang.String>
getPermissionKeys()
Returns the message keys of each permission known in the system.int
getPermissions()
Returns the permissions calculated from this permission set.java.lang.String
getPermissionString()
Returns the string representation of the current permissions in this permission set.static int
getPermissionValue(java.lang.String key)
Returns the value of a single permission.int
hashCode()
boolean
requiresControlPermission()
Returns true if control permissions (+c) are required by this permission set.boolean
requiresDirectPublishPermission()
Returns true if direct publish permissions (+d) are required by this permission set.boolean
requiresReadPermission()
Returns true if read permissions (+r) are required by this permission set.boolean
requiresViewPermission()
Returns true if view permissions (+v) are required by this permission set.boolean
requiresWritePermission()
Returns true if write permissions (+w) are required by this permission set.java.lang.String
toString()
Returns the String representation of this permission set object.
-
-
-
Field Detail
-
ACCESS_CONTROL
public static final CmsPermissionSet ACCESS_CONTROL
Permission set to check control access.
-
ACCESS_DIRECT_PUBLISH
public static final CmsPermissionSet ACCESS_DIRECT_PUBLISH
Permission set to check direct publish permissions.
-
ACCESS_READ
public static final CmsPermissionSet ACCESS_READ
Permission set to check read access.
-
ACCESS_VIEW
public static final CmsPermissionSet ACCESS_VIEW
Permission set to check view access.
-
ACCESS_WRITE
public static final CmsPermissionSet ACCESS_WRITE
Permission set to check write access.
-
PERMISSION_CONTROL
public static final int PERMISSION_CONTROL
The permission to control a resource.- See Also:
- Constant Field Values
-
PERMISSION_DIRECT_PUBLISH
public static final int PERMISSION_DIRECT_PUBLISH
The permission to direct publish a resource.- See Also:
- Constant Field Values
-
PERMISSION_EMPTY
public static final int PERMISSION_EMPTY
No permissions for a resource (used especially for denied permissions).- See Also:
- Constant Field Values
-
PERMISSION_FULL
public static final int PERMISSION_FULL
All allowed permissions for a resource.- See Also:
- Constant Field Values
-
PERMISSION_READ
public static final int PERMISSION_READ
The permission to read a resource.- See Also:
- Constant Field Values
-
PERMISSION_VIEW
public static final int PERMISSION_VIEW
The permission to view a resource.- See Also:
- Constant Field Values
-
PERMISSION_WRITE
public static final int PERMISSION_WRITE
The permission to write a resource.- See Also:
- Constant Field Values
-
m_allowed
protected int m_allowed
The set of allowed permissions.
-
m_denied
protected int m_denied
The set of denied permissions.
-
-
Constructor Detail
-
CmsPermissionSet
public CmsPermissionSet(int allowedPermissions, int deniedPermissions)
Constructor to create a permission set with preset allowed and denied permissions.- Parameters:
allowedPermissions
- the set of permissions to allowdeniedPermissions
- the set of permissions to deny
-
CmsPermissionSet
protected CmsPermissionSet()
Constructor to create an empty permission set.
-
CmsPermissionSet
protected CmsPermissionSet(int allowedPermissions)
Constructor to create a permission set with preset allowed permissions.- Parameters:
allowedPermissions
- bitset of allowed permissions
-
-
Method Detail
-
getPermissionKeys
public static java.util.Set<java.lang.String> getPermissionKeys()
Returns the message keys of each permission known in the system.- Returns:
- Enumeration of message keys
-
getPermissionValue
public static int getPermissionValue(java.lang.String key)
Returns the value of a single permission.- Parameters:
key
- the key of the permission- Returns:
- the value of the given permission
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
- See Also:
Object.equals(java.lang.Object)
-
getAllowedPermissions
public int getAllowedPermissions()
Returns the currently allowed permissions of ths permission set.- Returns:
- the allowed permissions as bitset
-
getDeniedPermissions
public int getDeniedPermissions()
Returns the currently denied permissions of this permission set.- Returns:
- the denied permissions as bitset.
-
getPermissions
public int getPermissions()
Returns the permissions calculated from this permission set.These are all permissions allowed but not denied.
- Returns:
- the resulting permission set
-
getPermissionString
public java.lang.String getPermissionString()
Returns the string representation of the current permissions in this permission set.- Returns:
- string of the format {{+|-}{r|w|v|c|d}}*
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- See Also:
Object.hashCode()
-
requiresControlPermission
public boolean requiresControlPermission()
Returns true if control permissions (+c) are required by this permission set.- Returns:
- true if control permissions (+c) are required by this permission set
-
requiresDirectPublishPermission
public boolean requiresDirectPublishPermission()
Returns true if direct publish permissions (+d) are required by this permission set.- Returns:
- true if direct publish permissions (+d) are required by this permission set
-
requiresReadPermission
public boolean requiresReadPermission()
Returns true if read permissions (+r) are required by this permission set.- Returns:
- true if read permissions (+r) are required by this permission set
-
requiresViewPermission
public boolean requiresViewPermission()
Returns true if view permissions (+v) are required by this permission set.- Returns:
- true if view permissions (+v) are required by this permission set
-
requiresWritePermission
public boolean requiresWritePermission()
Returns true if write permissions (+w) are required by this permission set.- Returns:
- true if write permissions (+w) are required by this permission set
-
toString
public java.lang.String toString()
Returns the String representation of this permission set object.- Overrides:
toString
in classjava.lang.Object
- See Also:
Object.toString()
-
-