org.janux.bus.security
Interface PermissionContext

All Superinterfaces:
Sorteable

public interface PermissionContext
extends Sorteable

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.

Since:
0.1
Author:
Philippe Paravicini

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

getName

String getName()
A unique name for this PermissionContext, in the context of the Application


setName

void setName(String name)

getPermissionBits

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.


getPermissionBit

PermissionBit getPermissionBit(String name)
Returns a PermissionBit by its unique name within the PermissionContext


addPermissionBit

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


getValue

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


getMaxValue

long getMaxValue()
returns the maximum value that the permission bitmask can take, should be equal to (2 to the power of getPermissionBits().size()) - 1


getDescription

String getDescription()
Human readable description of this PermissionBit Set


setDescription

void setDescription(String description)

getSortOrder

Integer getSortOrder()
The order in which this PermissionContext should be displayed

Specified by:
getSortOrder in interface Sorteable

setSortOrder

void setSortOrder(Integer sortOrder)
Specified by:
setSortOrder in interface Sorteable

isEnabled

boolean isEnabled()
Determines whether or not this PermissionContext is being used


setEnabled

void setEnabled(boolean visible)


Copyright © 2005-2013 Janux. All Rights Reserved.