Bees v0.5.0 API

bees.core.security
Class PermissionSet

java.lang.Object
  |
  +--bees.core.security.PermissionSet
All Implemented Interfaces:
java.lang.Cloneable

public final class PermissionSet
extends java.lang.Object
implements java.lang.Cloneable

A PermissionSet holds a list of permissions and provides a number of methods for manipulating them.


Constructor Summary
PermissionSet()
          Construct an empty PermissionSet.
PermissionSet(Permission[] permissions)
          Construct a PermissionSet with the given value.
PermissionSet(PermissionSet[] ps)
          Construct a PermissionSet from the given value.
PermissionSet(java.util.Vector permissions)
          Construct a PermissionSet from the given value.
 
Method Summary
 void boundPermissions(PermissionSet ps)
          Bound the Permissions in this set to the ones in the given set.
 void checkPermission(Permission what)
          Check if this set has the given Permission and throw a PermissionException if it doesn't.
 java.lang.Object clone()
           
 boolean equals(java.lang.Object obj)
           
 void grantPermission(Permission what)
          Grant the given Permission to this set.
 void grantPermissions(PermissionSet ps)
          Grant all of the Permissions in the given set to this set.
 Permission hasPermission(Permission what)
          Check if this set has the given Permission.
static PermissionSet instantiate(byte[] flattened)
          Instantiate a Permission object from the given byte array.
static PermissionSet instantiate(XdrByteArray xdr)
          Instantiate a Permission object from the given byte array.
 void marshal(XdrByteArray xdr)
          Marshal this object into the given byte array.
 int marshalledLength()
           
 void revokePermission(Permission what)
          Revoke the given Permission from this set.
 void revokePermissions(PermissionSet ps)
          Revoke all of the Permissions in the given set from this set.
 PermissionSet subset(Permission what)
           
 Permission[] toArray()
           
 byte[] toBytes()
           
 java.lang.String toString()
           
 void updateHash(bees.util.MD5 digest)
          Update an MD5 hash value with the contents of this set.
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PermissionSet

public PermissionSet(Permission[] permissions)
Construct a PermissionSet with the given value.
Parameters:
permissions - The permissions that should be included in this set.

PermissionSet

public PermissionSet(java.util.Vector permissions)
Construct a PermissionSet from the given value.
Parameters:
permissions - A Vector containing Permission objects that should be wrapped by this set.

PermissionSet

public PermissionSet(PermissionSet[] ps)
Construct a PermissionSet from the given value.
Parameters:
ps - An array of PermissionSet's whose elements should make up this set.

PermissionSet

public PermissionSet()
Construct an empty PermissionSet.
Method Detail

toArray

public Permission[] toArray()
Returns:
A copy of the set of Permissions as an array.

grantPermission

public void grantPermission(Permission what)
Grant the given Permission to this set. The set must contain a Permission object with the same name, otherwise this will do nothing. For example, granting the permission "foo=read" to the set { "bar=read,write" } will not result in the set having new permission. However, if the set was { "foo=write", "bar=read,write" } it would change to { "foo=read,write", "bar=read,write" }.
Parameters:
what - The Permission to grant.

grantPermissions

public void grantPermissions(PermissionSet ps)
Grant all of the Permissions in the given set to this set.
Parameters:
ps - The set of permissions to grant to this one.

revokePermission

public void revokePermission(Permission what)
Revoke the given Permission from this set.
Parameters:
what - The Permission to revoke from this set.

revokePermissions

public void revokePermissions(PermissionSet ps)
Revoke all of the Permissions in the given set from this set.
Parameters:
ps - The set of permissions to revoke from this one.

boundPermissions

public void boundPermissions(PermissionSet ps)
Bound the Permissions in this set to the ones in the given set. For example, if the given set is { "foo=read,write" } and this set is { "foo=read", "bar=read,write" }, the result will be { "foo=read" }.
Parameters:
ps - The set of permissions to bound this set to.

subset

public PermissionSet subset(Permission what)

hasPermission

public Permission hasPermission(Permission what)
Check if this set has the given Permission.
Parameters:
what - The permission to check for.
Returns:
The matching permission or null if not found.

checkPermission

public void checkPermission(Permission what)
Check if this set has the given Permission and throw a PermissionException if it doesn't.
Parameters:
what - The permission to check for.

updateHash

public void updateHash(bees.util.MD5 digest)
Update an MD5 hash value with the contents of this set.
Parameters:
digest - The MD5 object to update.

marshalledLength

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

marshal

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

instantiate

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

instantiate

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

toBytes

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

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Object.equals(Object)

clone

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

toString

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

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/