com.ecyrd.jspwiki.auth.permissions
Class WikiPermission

java.lang.Object
  extended by java.security.Permission
      extended by com.ecyrd.jspwiki.auth.permissions.WikiPermission
All Implemented Interfaces:
Serializable, Guard

public final class WikiPermission
extends Permission

Permission to perform an global wiki operation, such as self-registering or creating new pages. Permission actions include: createGroups, createPages, editPreferences, editProfile and login.

The target is a given wiki. The syntax for the target is the wiki name. "All wikis" can be specified using a wildcard (*). Page collections may also be specified using a wildcard. For pages, the wildcard may be a prefix, suffix, or all by itself.

Certain permissions imply others. Currently, createGroups implies createPages.

Since:
2.3
Version:
$Revision: 1.14 $ $Date: 2006/05/20 05:20:34 $
Author:
Andrew Jaquith
See Also:
Serialized Form

Field Summary
static WikiPermission CREATE_GROUPS
           
protected static int CREATE_GROUPS_MASK
           
static WikiPermission CREATE_PAGES
           
protected static int CREATE_PAGES_MASK
           
static WikiPermission EDIT_PREFERENCES
           
protected static int EDIT_PREFERENCES_MASK
           
static WikiPermission EDIT_PROFILE
           
protected static int EDIT_PROFILE_MASK
           
static WikiPermission LOGIN
           
protected static int LOGIN_MASK
           
 
Constructor Summary
WikiPermission(String wiki, String actions)
          Creates a new WikiPermission for a specified set of actions.
 
Method Summary
protected static int createMask(String actions)
          Private method that creates a binary mask based on the actions specified.
 boolean equals(Object obj)
          Two WikiPermission objects are considered equal if their wikis and actions (after normalization) are equal.
 String getActions()
          Returns the actions for this permission: "createGroups", "createPages", "editPreferences", "editProfile", or "login".
 String getWiki()
          Returns the name of the wiki containing the page represented by this permission; may return the wildcard string.
 int hashCode()
          Returns the hash code for this WikiPermission.
protected static int impliedMask(int mask)
          Creates an "implied mask" based on the actions originally assigned: for example, createGroups implies createPages.
 boolean implies(Permission permission)
          WikiPermission can only imply other WikiPermissions; no other permission types are implied.
 PermissionCollection newPermissionCollection()
          Returns a new AllPermissionCollection.
 String toString()
          Prints a human-readable representation of this permission.
 
Methods inherited from class java.security.Permission
checkGuard, getName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CREATE_GROUPS_MASK

protected static final int CREATE_GROUPS_MASK
See Also:
Constant Field Values

CREATE_PAGES_MASK

protected static final int CREATE_PAGES_MASK
See Also:
Constant Field Values

EDIT_PREFERENCES_MASK

protected static final int EDIT_PREFERENCES_MASK
See Also:
Constant Field Values

EDIT_PROFILE_MASK

protected static final int EDIT_PROFILE_MASK
See Also:
Constant Field Values

LOGIN_MASK

protected static final int LOGIN_MASK
See Also:
Constant Field Values

CREATE_GROUPS

public static final WikiPermission CREATE_GROUPS

CREATE_PAGES

public static final WikiPermission CREATE_PAGES

LOGIN

public static final WikiPermission LOGIN

EDIT_PREFERENCES

public static final WikiPermission EDIT_PREFERENCES

EDIT_PROFILE

public static final WikiPermission EDIT_PROFILE
Constructor Detail

WikiPermission

public WikiPermission(String wiki,
                      String actions)
Creates a new WikiPermission for a specified set of actions.

Parameters:
actions - the actions for this permission
Method Detail

equals

public final boolean equals(Object obj)
Two WikiPermission objects are considered equal if their wikis and actions (after normalization) are equal.

Specified by:
equals in class Permission
See Also:
Object.equals(java.lang.Object)

getActions

public final String getActions()
Returns the actions for this permission: "createGroups", "createPages", "editPreferences", "editProfile", or "login". The actions will always be sorted in alphabetic order, and will always appear in lower case.

Specified by:
getActions in class Permission
See Also:
Permission.getActions()

getWiki

public final String getWiki()
Returns the name of the wiki containing the page represented by this permission; may return the wildcard string.

Returns:
the wiki

hashCode

public final int hashCode()
Returns the hash code for this WikiPermission.

Specified by:
hashCode in class Permission
See Also:
Object.hashCode()

implies

public final boolean implies(Permission permission)
WikiPermission can only imply other WikiPermissions; no other permission types are implied. One WikiPermission implies another if all of the other WikiPermission's actions are equal to, or a subset of, those for this permission.

Specified by:
implies in class Permission
Parameters:
permission - the permission which may (or may not) be implied by this instance
Returns:
true if the permission is implied, false otherwise
See Also:
Permission.implies(java.security.Permission)

newPermissionCollection

public PermissionCollection newPermissionCollection()
Returns a new AllPermissionCollection.

Overrides:
newPermissionCollection in class Permission
See Also:
Permission.newPermissionCollection(), AllPermissionCollection.getInstance(String)

toString

public final String toString()
Prints a human-readable representation of this permission.

Overrides:
toString in class Permission
See Also:
Object.toString()

impliedMask

protected static final int impliedMask(int mask)
Creates an "implied mask" based on the actions originally assigned: for example, createGroups implies createPages.

Parameters:
mask - the initial mask
Returns:
the implied mask

createMask

protected static final int createMask(String actions)
Private method that creates a binary mask based on the actions specified. This is used by implies(Permission).

Parameters:
actions - the permission actions, separated by commas
Returns:
binary mask representing the permissions