org.jboss.portal.security.impl.jacc
Class Permissions

java.lang.Object
  extended by org.jboss.portal.security.impl.jacc.Permissions

public final class Permissions
extends java.lang.Object

Author:
Sohil Shah

Constructor Summary
Permissions()
          Creates a new Permissions object containing no PermissionCollections.
 
Method Summary
 void add(java.security.Permission permission)
          Adds a permission object to the PermissionCollection for the class the permission belongs to.
 boolean implies(java.security.Permission permission)
          Checks to see if this object's PermissionCollection for permissions of the specified permission's type implies the permissions expressed in the permission object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Permissions

public Permissions()
Creates a new Permissions object containing no PermissionCollections.

Method Detail

add

public void add(java.security.Permission permission)
Adds a permission object to the PermissionCollection for the class the permission belongs to. For example, if permission is a FilePermission, it is added to the FilePermissionCollection stored in this Permissions object.

This method creates a new PermissionCollection object (and adds the permission to it) if an appropriate collection does not yet exist.

Parameters:
permission - the Permission object to add.
Throws:
java.lang.SecurityException - if this Permissions object is marked as readonly.
See Also:
PermissionCollection.isReadOnly()

implies

public boolean implies(java.security.Permission permission)
Checks to see if this object's PermissionCollection for permissions of the specified permission's type implies the permissions expressed in the permission object. Returns true if the combination of permissions in the appropriate PermissionCollection (e.g., a FilePermissionCollection for a FilePermission) together imply the specified permission.

For example, suppose there is a FilePermissionCollection in this Permissions object, and it contains one FilePermission that specifies "read" access for all files in all subdirectories of the "/tmp" directory, and another FilePermission that specifies "write" access for all files in the "/tmp/scratch/foo" directory. Then if the implies method is called with a permission specifying both "read" and "write" access to files in the "/tmp/scratch/foo" directory, true is returned.

Additionally, if this PermissionCollection contains the AllPermission, this method will always return true.

Parameters:
permission - the Permission object to check.
Returns:
true if "permission" is implied by the permissions in the PermissionCollection it belongs to, false if not.