arlut.csd.ganymede
Class PermMatrix

java.lang.Object
  |
  +--arlut.csd.ganymede.PermMatrix
All Implemented Interfaces:
java.io.Serializable

public class PermMatrix
extends java.lang.Object
implements java.io.Serializable

Serializable permissions matrix object, used to handle permissions for a given user, admin, or role.

This class stores a read-only Hashtable of PermEntry objects, organized by object type and field id's.

The keys to the Hashtable are Strings that are encoded by the static matrixEntry() methods defined in this class. I probably could have used some sort of class object for the key, but then I would have had to define a key() of similar complexity to the matrixEntry() and decode methods anyway, as well as some sort of on-disk representation for the Ganymede.db file.

Here's some examples of the key encoding algorithm:

PermMatrix is used on the client in the Permissions Editor dialog, and on the server in both PermissionMatrixDBField and GanymedeSession.

See Also:
Serialized Form

Field Summary
(package private) static boolean debug
           
 java.util.Hashtable matrix
           
(package private) static long serialVersionUID
           
 
Constructor Summary
PermMatrix()
           
PermMatrix(java.util.Hashtable orig)
           
PermMatrix(arlut.csd.ganymede.PermMatrix orig)
           
 
Method Summary
private  java.lang.String baseEntry(java.lang.String matrixEntry)
          Private helper method used to generate a matrixEntry() encoded String for a single DBObjectBase from a matrixEntry() encoded String that also includes a field specification.
private  short entryBase(java.lang.String matrixEntry)
          Private helper method used to decode a hash key generated by the matrixEntry() methods.
private  short entryField(java.lang.String matrixEntry)
          Private helper method used to decode a hash key generated by the matrixEntry() methods.
 arlut.csd.ganymede.PermEntry getPerm(arlut.csd.ganymede.Base base)
          Returns a PermEntry object representing this PermMatrix's permissions on the base <base>
 arlut.csd.ganymede.PermEntry getPerm(arlut.csd.ganymede.Base base, arlut.csd.ganymede.BaseField field)
          Returns a PermEntry object representing this PermMatrix's permissions on the field <field> in base <base>
 arlut.csd.ganymede.PermEntry getPerm(short baseID)
          Returns a PermEntry object representing this PermMatrix's permissions on the base <baseID>
 arlut.csd.ganymede.PermEntry getPerm(short baseID, short fieldID)
          Returns a PermEntry object representing this PermMatrix's permissions on the field <fieldID> in base <baseID>
private  boolean isBasePerm(java.lang.String matrixEntry)
          Returns true if the given String encodes the identity of a DBObjectBase and not a field within a DBObjectBase.
static void main(java.lang.String[] argv)
           
private  java.lang.String matrixEntry(short baseID)
          Private method to generate a key for use in our internal Hashtable, used to encode the permission for a given DBObjectBase.
private  java.lang.String matrixEntry(short baseID, short fieldID)
          Private method to generate a key for use in our internal Hashtable, used to encode the permission for a given DBObjectBase and DBObjectBaseField.
 java.lang.String toString()
          Debugging output
 java.lang.String toString(boolean t)
           
 arlut.csd.ganymede.PermMatrix union(java.util.Hashtable orig)
          This method combines this PermMatrix with that of orig.
 arlut.csd.ganymede.PermMatrix union(arlut.csd.ganymede.PermMatrix orig)
          This method combines this PermMatrix with that of orig.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

static final boolean debug
See Also:
Constant Field Values

serialVersionUID

static final long serialVersionUID
See Also:
Constant Field Values

matrix

public java.util.Hashtable matrix
Constructor Detail

PermMatrix

public PermMatrix()

PermMatrix

public PermMatrix(java.util.Hashtable orig)

PermMatrix

public PermMatrix(arlut.csd.ganymede.PermMatrix orig)
Method Detail

union

public arlut.csd.ganymede.PermMatrix union(java.util.Hashtable orig)

This method combines this PermMatrix with that of orig. The returned PermMatrix will allow any access either of the source PermMatrices would.


union

public arlut.csd.ganymede.PermMatrix union(arlut.csd.ganymede.PermMatrix orig)

This method combines this PermMatrix with that of orig. The returned PermMatrix will allow any access either of the source PermMatrices would.

Note that unlike all the other methods in PermMatrix, we are handling inheritance of default permissions for an object base into fields which do not have permissions specified. We have to take this into account here in order to do a proper union.

As a consequence, this union() method is more complex than you might expect. That complexity really is needed.. don't mess with this unless you really, really know what you're doing.


getPerm

public arlut.csd.ganymede.PermEntry getPerm(short baseID,
                                            short fieldID)

Returns a PermEntry object representing this PermMatrix's permissions on the field <fieldID> in base <baseID>

If there is no entry in this PermMatrix for the given field, getPerm() will return null.

See Also:
PermMatrix

getPerm

public arlut.csd.ganymede.PermEntry getPerm(short baseID)

Returns a PermEntry object representing this PermMatrix's permissions on the base <baseID>

See Also:
PermMatrix

getPerm

public arlut.csd.ganymede.PermEntry getPerm(arlut.csd.ganymede.Base base,
                                            arlut.csd.ganymede.BaseField field)

Returns a PermEntry object representing this PermMatrix's permissions on the field <field> in base <base>

See Also:
PermMatrix

getPerm

public arlut.csd.ganymede.PermEntry getPerm(arlut.csd.ganymede.Base base)

Returns a PermEntry object representing this PermMatrix's permissions on the base <base>

See Also:
PermMatrix

matrixEntry

private java.lang.String matrixEntry(short baseID,
                                     short fieldID)

Private method to generate a key for use in our internal Hashtable, used to encode the permission for a given DBObjectBase and DBObjectBaseField.


matrixEntry

private java.lang.String matrixEntry(short baseID)

Private method to generate a key for use in our internal Hashtable, used to encode the permission for a given DBObjectBase.


isBasePerm

private boolean isBasePerm(java.lang.String matrixEntry)

Returns true if the given String encodes the identity of a DBObjectBase and not a field within a DBObjectBase.


entryBase

private short entryBase(java.lang.String matrixEntry)

Private helper method used to decode a hash key generated by the matrixEntry() methods.

Returns:
Returns the DBObjectBase object id encoded by the given String.

entryField

private short entryField(java.lang.String matrixEntry)

Private helper method used to decode a hash key generated by the matrixEntry() methods.

Returns:
Returns the DBObjectBaseField object id encoded by the given String.

baseEntry

private java.lang.String baseEntry(java.lang.String matrixEntry)

Private helper method used to generate a matrixEntry() encoded String for a single DBObjectBase from a matrixEntry() encoded String that also includes a field specification.


toString

public java.lang.String toString()

Debugging output

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(boolean t)

main

public static void main(java.lang.String[] argv)