|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface PermissionContext
A PermissionContext represents a set of individual Permissions defined for a specific business context; for example, a PermissionContext named 'PERSON' may define five Permissions with names 'READ', 'UPDATE', 'CREATE', 'DISABLE', 'PURGE', that define the kind of operations on Persons that may be restricted by the security system.
The PermissionBit interface, in turn, foresees an implementation that relies on bitmasks as a way to assign Permissions to a Role. In the example above, the five Permissions above would be assigned values 1, 2, 4, 8, 16 respectively, which would correspond to bit positions 0,1,2,3 and 4. In base-2 the five permissions would read 00001, 00010, 00100, 01000, 10000, respectively.
In order to grant READ/UPDATE permissions to a Role, a Role would be assigned the value 3=1+2 (in base-2: 00011) in the context of PermissionContext PERSON; a Role with a value of PERSON value of 31 = 1 + 2 + 4 + 8 + 16 would have all Permissions, or 11111 in base-2.
Method Summary | |
---|---|
void |
addPermissionBit(PermissionBit permissionBit)
Adds a PermissionBit to this PermissionContext - the implementation should make sure that there are no two PermissionBits with the same name, and that the value of PermissionBit.getPosition() is sequential and without gaps |
String |
getDescription()
Human readable description of this PermissionBit Set |
long |
getMaxValue()
returns the maximum value that the permission bitmask can take, should be equal to (2 to the power of getPermissionBits().size()) - 1 |
String |
getName()
A unique name for this PermissionContext, in the context of the Application |
PermissionBit |
getPermissionBit(String name)
Returns a PermissionBit by its unique name within the PermissionContext |
List<PermissionBit> |
getPermissionBits()
The set of permissions that this PermissionBit Set defines; note that this represents meta information of what sort of Permissions are available to be assigned within the context of a Busines Context and a Role, but that a PermissionBit Set does not confer any of these Permissions per-se to any entity. |
Integer |
getSortOrder()
The order in which this PermissionContext should be displayed |
long |
getValue(String[] permNames)
convenience method that returns the sum of values of a set of PermissionBits specified by name; for example, in the example above getValue({READ, UPDATE}) would return 3 |
boolean |
isEnabled()
Determines whether or not this PermissionContext is being used |
void |
setDescription(String description)
|
void |
setEnabled(boolean visible)
|
void |
setName(String name)
|
void |
setSortOrder(Integer sortOrder)
|
Method Detail |
---|
String getName()
void setName(String name)
List<PermissionBit> getPermissionBits()
PermissionBit getPermissionBit(String name)
void addPermissionBit(PermissionBit permissionBit)
long getValue(String[] permNames)
long getMaxValue()
String getDescription()
void setDescription(String description)
Integer getSortOrder()
getSortOrder
in interface Sorteable
void setSortOrder(Integer sortOrder)
setSortOrder
in interface Sorteable
boolean isEnabled()
void setEnabled(boolean visible)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |