Detailed Description

AbstractPermissionManager is the base class for concrete PermissionManager implementations.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 30 of file AbstractPermissionManager.php.

+ Inheritance diagram for AbstractPermissionManager:

Public Member Functions

 __construct (PersistenceFacade $persistenceFacade, Session $session)
 
 authorize ($resource, $context, $action, User $user=null)
 
 addTempPermission ($resource, $context, $action)
 
 removeTempPermission ($resource, $context, $action)
 
 hasTempPermission ($resource, $context, $action)
 
 clearTempPermissions ()
 

Public Attributes

const RESOURCE_TYPE_ENTITY_TYPE = 'entity.type'
 
const RESOURCE_TYPE_ENTITY_TYPE_PROPERTY = 'entity.type.property'
 
const RESOURCE_TYPE_ENTITY_INSTANCE = 'entity.instance'
 
const RESOURCE_TYPE_ENTITY_INSTANCE_PROPERTY = 'entity.instance.property'
 
const RESOURCE_TYPE_OTHER = 'other'
 

Protected Member Functions

 authorizeAction ($resource, $context, $action, User $user, $returnNullIfNoPermissionExists=true)
 
 getDefaultPolicy (User $user)
 
 deserializePermissions ($val)
 
 serializePermissions ($permissions)
 
 matchRoles ($permissions, User $user)
 

Protected Attributes

 $_persistenceFacade = null
 
 $_session = null
 

Constructor & Destructor Documentation

__construct ( PersistenceFacade  $persistenceFacade,
Session  $session 
)

Constructor.

Parameters
$persistenceFacade
$session

Definition at line 50 of file AbstractPermissionManager.php.

Member Function Documentation

authorize (   $resource,
  $context,
  $action,
User  $user = null 
)
authorizeAction (   $resource,
  $context,
  $action,
User  $user,
  $returnNullIfNoPermissionExists = true 
)
protected

Authorize the given resource, context, action triple using the temporary permissions or the current user.

Parameters
$resourceThe resource to authorize (e.g. class name of the Controller or ObjectId instance).
$contextThe context in which the action takes place.
$actionThe action to process.
$userUser instance to use for authorization
$returnNullIfNoPermissionExistsOptional, default: true
Returns
Boolean

Definition at line 207 of file AbstractPermissionManager.php.

getDefaultPolicy ( User  $user)
protected

Get the default policy that is used if no permission is set up for a requested action.

Returns
Boolean

Definition at line 246 of file AbstractPermissionManager.php.

deserializePermissions (   $val)
protected

Parse a permissions string and return an associative array with the keys 'default', 'allow', 'deny', where 'allow', 'deny' are arrays itselves holding roles and 'default' is a boolean value derived from the wildcard policy (+* or -*).

Parameters
$valA role string (+*, +administrators, -guest, entries without '+' or '-' prefix default to allow rules).
Returns
Associative array containing the permissions as an associative array with the keys 'default', 'allow', 'deny' or null, if val is empty

Definition at line 259 of file AbstractPermissionManager.php.

serializePermissions (   $permissions)
protected

Convert an associative permissions array with keys 'default', 'allow', 'deny' into a string.

Parameters
$permissionsAssociative array with keys 'default', 'allow', 'deny', where 'allow', 'deny' are arrays itselves holding roles and 'default' is a boolean value derived from the wildcard policy (+* or -*).
Returns
A role string (+*, +administrators, -guest, entries without '+' or '-' prefix default to allow rules).

Definition at line 307 of file AbstractPermissionManager.php.

matchRoles (   $permissions,
User  $user 
)
protected

Matches the roles of the user and the roles in the given permissions.

Parameters
$permissionsAn array containing permissions as an associative array with the keys 'default', 'allow', 'deny', where 'allow', 'deny' are arrays itselves holding roles and 'default' is a boolean value derived from the wildcard policy (+* or -*). 'allow' overwrites 'deny' overwrites 'default'
$userAuthUser instance
Returns
Boolean whether the user has access right according to the permissions.

Definition at line 332 of file AbstractPermissionManager.php.

addTempPermission (   $resource,
  $context,
  $action 
)
removeTempPermission (   $resource,
  $context,
  $action 
)
hasTempPermission (   $resource,
  $context,
  $action 
)
clearTempPermissions ( )

Member Data Documentation

const RESOURCE_TYPE_ENTITY_TYPE = 'entity.type'

Definition at line 32 of file AbstractPermissionManager.php.

const RESOURCE_TYPE_ENTITY_TYPE_PROPERTY = 'entity.type.property'

Definition at line 33 of file AbstractPermissionManager.php.

const RESOURCE_TYPE_ENTITY_INSTANCE = 'entity.instance'

Definition at line 34 of file AbstractPermissionManager.php.

const RESOURCE_TYPE_ENTITY_INSTANCE_PROPERTY = 'entity.instance.property'

Definition at line 35 of file AbstractPermissionManager.php.

const RESOURCE_TYPE_OTHER = 'other'

Definition at line 36 of file AbstractPermissionManager.php.

$_persistenceFacade = null
protected

Definition at line 42 of file AbstractPermissionManager.php.

$_session = null
protected

Definition at line 43 of file AbstractPermissionManager.php.