Groovy Documentation

services
Class SecurityService

java.lang.Object
  services.SecurityService

class SecurityService

CoW specific security service.

author:
Angus Roberts


Property Summary
static Map conf

Get configuration

 
Constructor Summary
SecurityService()

 
Method Summary
boolean anonAllowed(CowPermission requiredPerm)

Returns true if a required permission is implied by a configured permission assigned to the "anonymous" role.

void assignToDefaultRole(JsecUser jsecUser)

Assign a user to the default role

boolean checkPermission(def controllerName, def actions, def wikiId, def dir)

Check whether the current (anonymous or logged-in) user has permission for the given controller, actions, wiki and directory.

boolean checkServer()

Checks whether the user is in server mode.

boolean checkWorkstation()

Checks whether the user is in workstation mode.

void createDefaultRoles(String wikiId)

Create a few default roles and role permissions for a wiki, but do not add any specific users to the roles.

void deleteRolesAndPermissions(String wikiId)

Delete all permissions on a given wiki, and all roles that only have permissions on the given wiki.

static JsecActionList getActionList(def name)

Get a JsecActionList, null if none exists

private JsecActionList getActionList(def name, def actions)

Get a JsecActionList

static JsecControllerName getController(def name)

Get a JsecController, creating if it doesn't exist

private JsecRole getRole(def roleName)

Get a role, creating a new one if none exists

private JsecRole getRoleWithPermission(def roleName, def wikiId, def dir, def controller, def actions)

Get a role, creating a new one if none exists, and creating an associated CowPermission.

private JsecRole getRoleWithPermission(def roleName, def wikiId, def incDir, def exDir, def controller, def actions)

Get a role, creating a new one if none exists, and creating an associated CowPermission.

String getUsername()

Get the current username from jsecurity.

boolean isPermitted(CowPermission requiredPerm)

Returns true if a required permission matches any configured permissions.

static def isProtectedControllerName(def controllerOrName)

Check whether the given controller (or controller name) is one of the pre-configured contollers

static def isProtectedRole(def roleOrName)

Check whether the given role (or role name) is one of the three special "protected" roles, admin, default or anon.

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

Property Detail

conf

static Map conf
Get configuration


 
Constructor Detail

SecurityService

SecurityService()


 
Method Detail

anonAllowed

boolean anonAllowed(CowPermission requiredPerm)
Returns true if a required permission is implied by a configured permission assigned to the "anonymous" role.


assignToDefaultRole

void assignToDefaultRole(JsecUser jsecUser)
Assign a user to the default role


checkPermission

boolean checkPermission(def controllerName, def actions, def wikiId, def dir)
Check whether the current (anonymous or logged-in) user has permission for the given controller, actions, wiki and directory.


checkServer

boolean checkServer()
Checks whether the user is in server mode. Returns true if in server mode, otherwise false.


checkWorkstation

boolean checkWorkstation()
Checks whether the user is in workstation mode. Returns true if in workstaiton mode, otherwise false.


createDefaultRoles

void createDefaultRoles(String wikiId)
Create a few default roles and role permissions for a wiki, but do not add any specific users to the roles.


deleteRolesAndPermissions

void deleteRolesAndPermissions(String wikiId)
Delete all permissions on a given wiki, and all roles that only have permissions on the given wiki. We leave any roles that also have permissions on other wikis.


getActionList

public static JsecActionList getActionList(def name)
Get a JsecActionList, null if none exists
param:
name the name of the JsecActionList


getActionList

private JsecActionList getActionList(def name, def actions)
Get a JsecActionList
param:
name the name of the JsecActionList
param:
the actions


getController

public static JsecControllerName getController(def name)
Get a JsecController, creating if it doesn't exist
param:
name the name of the JsecController


getRole

private JsecRole getRole(def roleName)
Get a role, creating a new one if none exists
param:
roleName the name of the role


getRoleWithPermission

private JsecRole getRoleWithPermission(def roleName, def wikiId, def dir, def controller, def actions)
Get a role, creating a new one if none exists, and creating an associated CowPermission. This method creates a permission with no directory excluded. Note that there is no check for an existing JsecRolePermissionRel for the CowPermission and Role, and so duplicates will be created. Querying to find existing objects has proved difficult using any of the various mechanisms available.
param:
roleName the name of the role
param:
wiki the wiki that this role will apply to
param:
includeDir regexp directory included for this role
param:
actions that this role can perform, as a JsecActionList


getRoleWithPermission

private JsecRole getRoleWithPermission(def roleName, def wikiId, def incDir, def exDir, def controller, def actions)
Get a role, creating a new one if none exists, and creating an associated CowPermission. Note that there is no check for an existing JsecRolePermissionRel for the CowPermission and Role, and so duplicates will be created. Querying to find existing objects has proved difficult using any of the various mechanisms available.
param:
roleName the name of the role
param:
wiki the wiki that this role will apply to
param:
includeDir regexp directory included for this role
param:
excludeDir regexp directory excluded for this role
param:
actions that this role can perform, as a JsecActionList


getUsername

String getUsername()
Get the current username from jsecurity.


isPermitted

boolean isPermitted(CowPermission requiredPerm)
Returns true if a required permission matches any configured permissions.


isProtectedControllerName

public static def isProtectedControllerName(def controllerOrName)
Check whether the given controller (or controller name) is one of the pre-configured contollers


isProtectedRole

public static def isProtectedRole(def roleOrName)
Check whether the given role (or role name) is one of the three special "protected" roles, admin, default or anon.


 

Groovy Documentation