org.norther.tammi.core.security
Class ResourcePermission

java.lang.Object
  extended by java.security.Permission
      extended by org.norther.tammi.core.security.DefaultPermission
          extended by org.norther.tammi.core.security.ResourcePermission
All Implemented Interfaces:
Serializable, Guard
Direct Known Subclasses:
RegexPermission

public class ResourcePermission
extends DefaultPermission
implements Serializable

ResourcePermission represents access to server resources. The actions to be granted are passed to the constructor in a string containing a list of one or more comma-separated keywords. The possible keywords are "read", "write", "execute", and "delete". Their meaning is defined as follows:

  read
      read permission
  write
      write permission
  execute
      execute permission
  delete
      delete permission
 

The actions string is converted to lowercase before processing.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.norther.tammi.core.security.DefaultPermission
ALL, ALL_ACTION, ANY_ROLE, DELETE, DELETE_ACTION, EXECUTE, EXECUTE_ACTION, GROUP, GROUP_ACTION, NO_ACTION, NONE, OVERRIDE, OVERRIDE_ACTION, READ, READ_ACTION, READ_WRITE, READ_WRITE_ACTION, WRITE, WRITE_ACTION
 
Constructor Summary
ResourcePermission(String name, int mask)
          Constructs a new permission with a mask.
ResourcePermission(String name, String actions)
          Constructs a new permission with actions.
 
Method Summary
 boolean equals(Object obj)
          Checks two permissions for equality.
 String getActions()
          Gets the actions as a string.
 int hashCode()
          Returns the hash code.
 boolean implies(Permission p)
          Checks if the permission implies the specified permission.
protected  boolean impliesIgnoreMask(ResourcePermission p)
          Checks if this permission object implies the specified permission when actions are ignored.
 PermissionCollection newPermissionCollection()
          Returns a new permission collection for storing resource permissions.
 
Methods inherited from class org.norther.tammi.core.security.DefaultPermission
toActionMask, toActionString
 
Methods inherited from class java.security.Permission
checkGuard, getName, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResourcePermission

public ResourcePermission(String name,
                          String actions)
Constructs a new permission with actions.

Parameters:
name - the name of the resource.
actions - the action string.

ResourcePermission

public ResourcePermission(String name,
                          int mask)
Constructs a new permission with a mask.

Parameters:
name - the name of the resource.
mask - the action mask to use.
Method Detail

getActions

public String getActions()
Gets the actions as a string.

Specified by:
getActions in class Permission
Returns:
the actions.

implies

public boolean implies(Permission p)
Checks if the permission implies the specified permission.

Specified by:
implies in class Permission
Parameters:
p - the permission to check against.
Returns:
true if the specified permission is implied.

newPermissionCollection

public PermissionCollection newPermissionCollection()
Returns a new permission collection for storing resource permissions.

Overrides:
newPermissionCollection in class Permission
Returns:
a new permission collection.

equals

public boolean equals(Object obj)
Checks two permissions for equality.

Specified by:
equals in class Permission
Parameters:
obj - the object we are testing.
Returns:
true if permissions are equal.

hashCode

public int hashCode()
Returns the hash code.

Specified by:
hashCode in class Permission
Returns:
a hash code.

impliesIgnoreMask

protected boolean impliesIgnoreMask(ResourcePermission p)
Checks if this permission object implies the specified permission when actions are ignored.

Parameters:
p - the permission to check against.
Returns:
true if the specified permission is implied by this object.


Copyright © 2004 The Norther Organization. All rights reserved.