com.zphinx.spine.security
Class PermissionLevel

java.lang.Object
  extended by com.zphinx.spine.security.PermissionLevel
All Implemented Interfaces:
Serializable

public class PermissionLevel
extends Object
implements Serializable

PermissionLevel represents an object which mimics the default unix octal ACL system defined by the presence of Owner,group and public access rights.

It allows flags for setting the values Read,Write, and Execute flags and also provides a constructor which allows the client programmer to directly specify the octal numerical equivalent of a resources access rights. i.e calling :

PermissionLevel pl = new PermissionLevel({7,5,5});
Will create a new permissionLevel allowing the owner read,write, execute access and group, public access rights of read and execute.

Version:
$1.0

Copyright ©Zphinx Software Solutions

Author:
David Ladapo
See Also:
Serialized Form

Constructor Summary
PermissionLevel()
          Default constructor which initializes the permission level of this object to it's unix equivalent of 755 as defined by: Owner - Read,Write,Execute Group - Read,NoWrite,Execute public - Read,NoWrite,Execute
PermissionLevel(boolean[] ownerPermission, boolean[] groupPermission, boolean[] publicPermission)
          Constructor allowing the client programmer to specify the contents of the permissionLevel using boolean arrays.
PermissionLevel(int[] permit)
          Constructor which uses the numerical(octal) equivalent of the unit access control rights system to assign permission flags to this PermissionLevel.
 
Method Summary
 boolean[] getGroupPermission()
          Gets the group permissions for this object
 boolean getGroupPermission(int i)
          Gets the group read,write and execute flags for this permission object
 boolean[] getOwnerPermission()
          Gets the owner permissions for this object
 boolean getOwnerPermission(int i)
          Gets the owner's read,write and execute flags for this permission object
 int[] getPermissionOctal()
          Gets the octal representation of this permissionLevel
 boolean[] getPublicPermission()
          Gets the public permissions for this object
 boolean getPublicPermission(int i)
          Gets the public read,write and execute flags for this permission object
 void setGroupPermission(boolean[] groupPermission)
          Sets the group permissions for this object
 void setGroupPermission(int index, String value)
          Sets the read,write and execute flags for the groupPermission in the order shown i.e [R,W,X].at the stated index
 void setOwnerPermission(boolean[] ownerPermission)
          Sets the owner permissions for this object
 void setOwnerPermission(int index, String value)
          Sets the read,write and execute flags for the ownerPermission in the order shown i.e [R,W,X].at the stated index
 void setPublicPermission(boolean[] publicPermission)
          Sets the public permissions for this object
 void setPublicPermission(int index, String value)
          Sets the read,write and execute flags for the publicPermission in the order shown i.e [R,W,X].at the stated index
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PermissionLevel

public PermissionLevel()
Default constructor which initializes the permission level of this object to it's unix equivalent of 755 as defined by:


PermissionLevel

public PermissionLevel(int[] permit)
                throws SpineException
Constructor which uses the numerical(octal) equivalent of the unit access control rights system to assign permission flags to this PermissionLevel. These are defined as:

Any of these octal numbers can be set as a member of the int array passed to this constructor. The values are then transposed to a boolean array which is determined respectively and is symbolized using a boolean array to represent
[Read,Write,Execute] i.e
[true,false,true] will yield [Read,NoWrite,Execute] or 5 in octal notation

Parameters:
permit - The array of int flags which define the access rights.
Throws:
SpineException - A spine exception is thrown should there be an error creating a permission level

PermissionLevel

public PermissionLevel(boolean[] ownerPermission,
                       boolean[] groupPermission,
                       boolean[] publicPermission)
                throws SpineException
Constructor allowing the client programmer to specify the contents of the permissionLevel using boolean arrays. The contents of the arrays are of the format:

[ReadFlag,WriteFlag,ExecuteFlag] eg if a boolean array is set as [true,false,false] for a public permission set, then this permissionLevel object will have a unix equivalent of readOnly or [Read,NoWrite,NoExecute].

Parameters:
ownerPermission - The owner's permission boolean array
groupPermission - The group's permission boolean array
publicPermission - The public's permission boolean array
Throws:
SpineException - A spine exception is thrown should there be an error creating a permission level
Method Detail

getGroupPermission

public boolean[] getGroupPermission()
Gets the group permissions for this object

Returns:
Returns the groupPermission.

getOwnerPermission

public boolean[] getOwnerPermission()
Gets the owner permissions for this object

Returns:
Returns the ownerPermission.

getPublicPermission

public boolean[] getPublicPermission()
Gets the public permissions for this object

Returns:
Returns the publicPermission.

getPermissionOctal

public int[] getPermissionOctal()
Gets the octal representation of this permissionLevel

Returns:
An octal indicating the permissionLevel assigned to this role

toString

public String toString()
Overrides:
toString in class Object

getGroupPermission

public boolean getGroupPermission(int i)
Gets the group read,write and execute flags for this permission object

Parameters:
i - An int denoting location of the flag to get from the boolean array representing the groups permission
Returns:
Returns the groupPermission.

getOwnerPermission

public boolean getOwnerPermission(int i)
Gets the owner's read,write and execute flags for this permission object

Parameters:
i - An int denoting location of the flag to get from the boolean array representing the owner's permission
Returns:
Returns the ownerPermission.

getPublicPermission

public boolean getPublicPermission(int i)
Gets the public read,write and execute flags for this permission object

Parameters:
i - An int denoting location of the flag to get from the boolean array representing the public permission
Returns:
Returns the publicPermission.

setGroupPermission

public void setGroupPermission(int index,
                               String value)
Sets the read,write and execute flags for the groupPermission in the order shown i.e [R,W,X].at the stated index

Parameters:
index - The index of the group permission to set
value - The value of the group permission to set either true or false

setOwnerPermission

public void setOwnerPermission(int index,
                               String value)
Sets the read,write and execute flags for the ownerPermission in the order shown i.e [R,W,X].at the stated index

Parameters:
index - The index of the owner permission to set
value - The value of the owner permission to set, either true or false

setPublicPermission

public void setPublicPermission(int index,
                                String value)
Sets the read,write and execute flags for the publicPermission in the order shown i.e [R,W,X].at the stated index

Parameters:
index - The index of the public permission to set
value - The value to set (true or false)

setGroupPermission

public void setGroupPermission(boolean[] groupPermission)
Sets the group permissions for this object

Parameters:
groupPermission - The groupPermission to set.

setOwnerPermission

public void setOwnerPermission(boolean[] ownerPermission)
Sets the owner permissions for this object

Parameters:
ownerPermission - The ownerPermission to set.

setPublicPermission

public void setPublicPermission(boolean[] publicPermission)
Sets the public permissions for this object

Parameters:
publicPermission - The publicPermission to set.