Groovy Documentation

utils.gate.cow
Class CowPermission

java.lang.Object
  utils.gate.cow.CowPermission

class CowPermission

A CowPermission represents the ability of a CoW user to perform actions on wiki pages. Permission is given for specificied actions on a specified controller. Some controllers and actions are system-wide: general auth and auth controllers, or maybe plugin controllers. Where the controller is serving actual wiki pages, then the wiki is also specified, as are regular expressions for directories to be included and excluded by the permission. Permission can therefore be described at a granularity of directories within a specified wiki.

Borrows ideas and code from org.jsecurity.grails.JsecBasicPermission

author:
Angus Roberts


Property Summary
static String WILDCARD

wildcard

private Set actions

The actions described by this Permission

private String controller

The controller described by this Permission

private String excludeDir

Directories excluded by this Permission, as a regular expression relative to the wiki.

private String includeDir

Directories included by this Permission, as a regular expression relative to the wiki.

static Logger log

Logger

private String requiredDir

Directory required by this Permission, as a path relative to the wiki.

private String wiki

The id of the wiki described by this Permission

 
Constructor Summary
CowPermission(Map pageMap, String controller, String actions)

Construct a permission from a page description, controller, and an action.

CowPermission(String wiki, String incDir, String exDir, String controller, String actions)

Creates a new permission with the given controller and actions to be permitted on a controller, in the scope of inicluded and excluded directory regex relative to a wiki.

CowPermission(String wiki, String requiredDir, String controller, String actions)

Creates a new permission with the given controller and actions to be permitted on a controller, in the scope of a directory.

 
Method Summary
boolean equals(Object obj)

Is this CowPermission equal to another object?

int hashCode()

Hash code for this permission

boolean implies(Permission p)

Returns true if this permission (the configured one) implies the parameter permission (the required one), otherwise false.

String toString()

String representaiton of this CowPermission

 
Methods inherited from class Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll
 

Property Detail

WILDCARD

public static final String WILDCARD
wildcard


actions

private Set actions
The actions described by this Permission


controller

private String controller
The controller described by this Permission


excludeDir

private String excludeDir
Directories excluded by this Permission, as a regular expression relative to the wiki. Used by configured permissions.


includeDir

private String includeDir
Directories included by this Permission, as a regular expression relative to the wiki. Used by configured permissions.


log

static Logger log
Logger


requiredDir

private String requiredDir
Directory required by this Permission, as a path relative to the wiki. Used by required permissions.


wiki

private String wiki
The id of the wiki described by this Permission


 
Constructor Detail

CowPermission

public CowPermission(Map pageMap, String controller, String actions)
Construct a permission from a page description, controller, and an action. This constructor is intended to be used at authorisation time, to construct a permission that represents a requirement to carry out an action on a controller, perhaps in the scope of a given wiki page page. The requirement may or may not be granted.
param:
pageMap A Map representing the page, as returned by PageService.analyse(Map)
param:
actions A string of actions separated by ',', ';', or whitespace. For example, 'view,edit', 'create, delete', 'create; modify', 'view edit' are all valid two-action strings. The actions string may also be the wildcard, *.
param:
controller The name of a controller


CowPermission

public CowPermission(String wiki, String incDir, String exDir, String controller, String actions)
Creates a new permission with the given controller and actions to be permitted on a controller, in the scope of inicluded and excluded directory regex relative to a wiki. Intended to be used when constructing a Permission as an assigned right, i.e. when configuring a user or role. Note that included directory regular expressions are applied before excluded directory regular expressions, and so the latter overrides the former.
param:
wiki The id of the wiki to which this permission applies.
param:
incDir A regular expression for directories, relative to the wiki, which this permission includes
param:
exDir A regular expression for directories, relative to the wiki, which this permission excludes
param:
actions A string of actions separated by ',', ';', or whitespace. For example, 'view,edit', 'create, delete', 'create; modify', 'view edit' are all valid two-action strings. The actions string may also be the wildcard, *.
param:
controller The name of a controller


CowPermission

public CowPermission(String wiki, String requiredDir, String controller, String actions)
Creates a new permission with the given controller and actions to be permitted on a controller, in the scope of a directory. This constructor is intended to be used at authorisation time, to construct a permission that represents a requirement to carry out an action on a controller, perhaps in the scope of a given wiki page page and directory. The requirement may or may not be granted.
param:
wiki The id of the wiki to which this permission applies.
param:
requiredDir The directory relative to the wiki, to which this permission applies.
param:
actions A string of actions separated by ',', ';', or whitespace. For example, 'view,edit', 'create, delete', 'create; modify', 'view edit' are all valid two-action strings. The actions string may also be the wildcard, *.
param:
controller The name of a controller


 
Method Detail

equals

public boolean equals(Object obj)
Is this CowPermission equal to another object?


hashCode

public int hashCode()
Hash code for this permission


implies

public boolean implies(Permission p)
Returns true if this permission (the configured one) implies the parameter permission (the required one), otherwise false. This method checks that the required permission has the same controller as this one, the same wiki as this one, that the required permission has a directory path that matches the included directory pattern, does not match the excluded directory pattern, and this permission has a super-set of the actions of the required permission. The wildcard matches all actions. Note that included directiry patterns are applied before excluded directory patterns, and so the latter overrides the former.


toString

public String toString()
String representaiton of this CowPermission


 

Groovy Documentation