Bees v0.5.0 API

bees.core.security
Class Permission

java.lang.Object
  |
  +--bees.core.security.Permission
All Implemented Interfaces:
java.lang.Cloneable, edu.utah.janosvm.sys.CrossTeamCloneable, PermissionTypes
Direct Known Subclasses:
CountPermission, EnumerationPermission, FilePermission, FloatPermission, IntegerPermission, IPAddressPermission, RangePermission

public class Permission
extends java.lang.Object
implements java.lang.Cloneable, edu.utah.janosvm.sys.CrossTeamCloneable, PermissionTypes

Describes an abstract permission, consisting of a string name and an optional set of actions from the set {read,write,execute}.

Author:
Andrew Whitaker

Field Summary
static int APPEND
          Action determining whether or not the property specified by the permission name is appendable.
static int EXECUTE
          Action determining whether or not the property specified by the permission name is executable.
static int READ
          Action determining whether or not the property specified by the permission name is readable.
static int WRITE
          Action determining whether or not the property specified by the permission name is writable.
 
Fields inherited from interface bees.core.security.PermissionTypes
PERMISSION_BASIC, PERMISSION_CLASSES, PERMISSION_COUNT, PERMISSION_ENUMERATION, PERMISSION_FILE, PERMISSION_FLOAT, PERMISSION_INTEGER, PERMISSION_IP_ADDRESS, PERMISSION_MAX, PERMISSION_MAX_FLOAT, PERMISSION_MAX_INTEGER, PERMISSION_MIN, PERMISSION_MIN_FLOAT, PERMISSION_MIN_INTEGER, PERMISSION_NULL, PERMISSION_RANGE
 
Constructor Summary
Permission()
          Construct an empty Permission.
Permission(java.lang.String name)
          Creates a new permission with the given human-readable name and no actions.
Permission(java.lang.String name, java.lang.String actions)
          Creates a permission with a set of actions.
 
Method Summary
 void bound(Permission what)
          Bound this permission's actions to the ones available in what.
 java.lang.Object clone()
           
 boolean equals(java.lang.Object obj)
          Tests for exact equality: the name and actions must precisely match.
 java.lang.String getAction()
           
 int getActionMask()
           
 java.lang.String getName()
           
protected  int getTypeID()
           
 void grant(Permission what)
          Grant the actions in "what" to this permission.
 boolean implies(Permission p)
          Test whether this permission implies the given permission.
static Permission instantiate(byte[] flattened)
          Instantiate a Permission object from the given byte array.
static Permission instantiate(XdrByteArray xba)
          Instantiate a Permission object from the given byte array.
 void marshal(XdrByteArray xba)
          Marshal this object into the given byte array.
 int marshalledLength()
           
 boolean nameImplies(Permission p)
          Test whether this permission's name implies the given permission.
protected  void orActionMask(int bits)
           
 void revoke(Permission what)
          Revoke the actions in "what" from this permission.
 byte[] toBytes()
           
 java.lang.String toString()
           
 void unmarshal(XdrByteArray xba)
          Unmarshal this object from the given byte array.
 void updateHash(bees.util.MD5 digest)
          Update a an MD5 object with the value of this permission.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

READ

public static final int READ
Action determining whether or not the property specified by the permission name is readable.

WRITE

public static final int WRITE
Action determining whether or not the property specified by the permission name is writable.

EXECUTE

public static final int EXECUTE
Action determining whether or not the property specified by the permission name is executable.

APPEND

public static final int APPEND
Action determining whether or not the property specified by the permission name is appendable.
Constructor Detail

Permission

public Permission(java.lang.String name,
                  java.lang.String actions)
Creates a permission with a set of actions. Actions are specified by passing an argument string consisting of a subset of {"read","write","execute"}. The actions must be lower-case. For example: new Permission ("Routing table","read write")
Parameters:
name - The name of the permission.
actions - The actions granted by this permission.

Permission

public Permission(java.lang.String name)
Creates a new permission with the given human-readable name and no actions. Names serve as unique keys.
Parameters:
name - The name of the permission.

Permission

public Permission()
Construct an empty Permission.
Method Detail

getTypeID

protected int getTypeID()
Returns:
An integer from the PermissionTypes enumeration specifying the type of permission.

getActionMask

public final int getActionMask()
Returns:
The bits that make up the action mask.

orActionMask

protected void orActionMask(int bits)
Parameters:
bits - The bits to or into the action mask.

getAction

public java.lang.String getAction()
Returns:
The actions as a human-readable string.

getName

public final java.lang.String getName()
Returns:
The name of the permission.

nameImplies

public final boolean nameImplies(Permission p)
Test whether this permission's name implies the given permission.
Parameters:
p - The permission to match.
Returns:
True if this permission name matches p.

implies

public boolean implies(Permission p)
Test whether this permission implies the given permission. For example, read/write implies the read permission. Names are case-insensitive.
Parameters:
p - The permission to match.
Returns:
True if this permission matches p.

grant

public void grant(Permission what)
Grant the actions in "what" to this permission.
Parameters:
what - The permissions that should be granted to this permission.

revoke

public void revoke(Permission what)
Revoke the actions in "what" from this permission.
Parameters:
what - The permissions that should be revoked from this permission.

bound

public void bound(Permission what)
Bound this permission's actions to the ones available in what. In other words, the actions available in this permission will be less than or equal to those in "what".
Parameters:
what - The permission that this permission should be bounded by.

updateHash

public void updateHash(bees.util.MD5 digest)
Update a an MD5 object with the value of this permission.

XXX A bit hacky.

Parameters:
digest - The digest to update.

marshalledLength

public int marshalledLength()
Returns:
The number of bytes needed to marshal this permission.

marshal

public void marshal(XdrByteArray xba)
Marshal this object into the given byte array.
Parameters:
xba - The destination for the flattened version of this Permission.

unmarshal

public void unmarshal(XdrByteArray xba)
Unmarshal this object from the given byte array.
Parameters:
xba - The source of the flattened version of this Permission.

toBytes

public byte[] toBytes()
Returns:
A byte array containing the flattened version of this permission.

instantiate

public static Permission instantiate(XdrByteArray xba)
Instantiate a Permission object from the given byte array.
Parameters:
xba - The source of the flattened version of a Permission.
Returns:
A new Permission object.

instantiate

public static Permission instantiate(byte[] flattened)
Instantiate a Permission object from the given byte array.
Parameters:
flattened - The source of the flattened version of a Permission.
Returns:
A new Permission object.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

equals

public boolean equals(java.lang.Object obj)
Tests for exact equality: the name and actions must precisely match. Names are case-insensitive.
Overrides:
equals in class java.lang.Object
Parameters:
obj - The object to compare this one against.
Returns:
True if this object equals the given one.

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object
See Also:
Object.clone()

Bees v0.5.0 API

This documentation is Copyright (C) 2002 The University of Utah. All Rights Reserved. See the individual source files for distribution terms.
Documentation, software, and mailing lists for Bees v0.5.0 can be found at the Janos Project: http://www.cs.utah.edu/flux/janos/