\acdhOeaw\fedora\aclWebAcl

Provides ACL management.

A WebAcl object stores access control rules for a given FedoraResource object and provides methods to manipulate them.

Static methods provide a way to adjust class-oriented access control rules.

Keeping ACL rules in order is very troublesome in general.

The first problem is that every ACL resource can contain rules for any combination of users, groups, classes, resources and access modes. While the repo-php-util can follow some guidelines on write (e.g. "only one resource/class described in a single acl resource"), it must be able to cope with any mess on read.

Another big problem is tracking the current set of all rules connected with a given resource. It requires either inspecting the whole acl collection (which is terribly slow but reliable) or quering a triplestore (which is fast but unreliable as the triplestore is synchronized only at the transaction commit). This problem is not fully addressed by this class. During a transaction it provides proper tracking for the rules describing user/group access rights to particular resources. Tracking is not provided for rules describing access rights to classes and for rules specyfying access rights to more then one resource and/or class. This means you must commit a transaction and call reload() method on all WebAcl objects after every change made to class ACL rules to keep your WebAcl objects up to date.

When a compound (describing more then one class and/or resource) rule is encountered, it is automatically splitted into "simple" rules (each descrining exactly one resource/class). Similarly to class rules, a transaction commit and reload() calls on WebAcl objects is required to make WebAcl objects aware of this transformation.

Summary

Methods
Properties
Constants
setAutosave()
__construct()
save()
revokeAll()
getMode()
grant()
revoke()
getRules()
reload()
createAcl()
deleteAcl()
__toString()
$debug
ACL_LINK_PROP
ACL_CHILDREN_PROP
ACL_CLASS
QUERY
No protected methods found
No protected properties found
N/A
initRules()
checkParam()
$autosave
$res
$extRules
$resRules
N/A

Constants

ACL_CHILDREN_PROP

ACL_CHILDREN_PROP

ACL_CLASS

ACL_CLASS

QUERY

QUERY

Properties

$debug

$debug : boolean

Should debug information be displayed

Type

boolean

$autosave

$autosave : boolean

Should `WebAclRule` resources be synced with the Fedora immediately

Type

boolean

$extRules

$extRules : array

Collection of rules inherited from parent (in Fedora terms) resources.

Type

array

$resRules

$resRules : array

Collection of rules applied dirtectly to the resource or its classes.

Type

array

Methods

setAutosave()

setAutosave(boolean  $autosave) 

When autosave is turned on, all changes to `WebAclRule` objects are immediately synced with the Fedora.

It is convenient but may be slower if you apply many rules to a single resource (e.g. when you grant the same access rights to many users).

When autosave is off, you must call a save() method for the changes to be populated to the Fedora (of course you must also commit a transaction separately to make them persistent).

Parameters

boolean $autosave

__construct()

__construct(\acdhOeaw\fedora\FedoraResource  $res) 

Creates a WebAcl object

Parameters

\acdhOeaw\fedora\FedoraResource $res

corresponding Fedora resource

save()

save() 

Manually triggers synchronization of all stored `WebAclRule` objects with the Fedora.

revokeAll()

revokeAll(integer  $mode = \acdhOeaw\fedora\acl\WebAclRule::READ) : \acdhOeaw\fedora\acl\WebAcl

Revokes privileges from all users, groups and classes for a given Fedora resource.

Only rules directly targeting the given resource are removed. Rules inherited from Fedora parents sharing the same ACL are not affected.

If $mode equals to WebAclRule::WRITE all privileges are limited to WebAclRule::READ.

If $mode equals to WebAclRule::READ all privileges are revoked.

Parameters

integer $mode

WebAclRule::READ or WebAclRule::WRITE

Returns

\acdhOeaw\fedora\acl\WebAcl

getMode()

getMode(string  $type, string  $name = null, boolean  $inherited = true) : integer

Returns effective access rights for a given user/group.

Parameters

string $type

WebAclRule::USER or WebAclRule::Group

string $name

user/group name

boolean $inherited

should rules inherited from parents (in Fedora terms) resources be taken into account?

Returns

integer —

(WebAclRule::READ or WebAclRule::WRITE)

grant()

grant(string  $type, string  $name, integer  $mode = \acdhOeaw\fedora\acl\WebAclRule::READ) 

Grants give rights to a given user/group.

Parameters

string $type

WebAclRule::USER or WebAclRule::GROUP

string $name

user/group name

integer $mode

WebAclRule::READ or WebAclRule::WRITE

revoke()

revoke(string  $type, string  $name, integer  $mode = \acdhOeaw\fedora\acl\WebAclRule::READ) 

Revokes access rights from a given user/group.

Parameters

string $type

WebAclRule::USER or WebAclRule::GROUP

string $name

user/group name

integer $mode

WebAclRule::READ or WebAclRule::WRITE

getRules()

getRules(boolean  $inherited = true) : array

Fetches an array of `WebAclRule` objects containing access rules for a corresponding Fedora resource.

Parameters

boolean $inherited

should rules inherited from parent (in Fedora terms) resources be taken into account?

Returns

array

reload()

reload() 

Reloads access rules by quering a triplestore.

See class description for use cases.

createAcl()

createAcl() 

Creates an ACL attached directly to a given resource.

All rules describing resource from ACL currently in effect are automatically moved to the newly created ACL.

Resource has to permanently exist in the repository for operation to succeed (you can not create a resource's ACL within the same transaction a resource was created). If it is not a case, a NotFound exception is rised.

If an ACL attached directly to the resource already exists, nothing happens.

Throws

\RuntimeException

deleteAcl()

deleteAcl() : \acdhOeaw\fedora\acl\WebAcl

Removes ACL directly attached to this resource.

If there is no such ACL, error is thrown.

Throws

\acdhOeaw\fedora\exceptions\NotFound

Returns

\acdhOeaw\fedora\acl\WebAcl

__toString()

__toString() : string

Provides a nice printable representation.

Returns

string

initRules()

initRules(\EasyRdf\Sparql\Result  $results, \acdhOeaw\fedora\Fedora  $fedora, string  $aclUrl) : array

Preprocesses rules fetched from the SPARQL query: - skips rules which no longer exist in the Fedora - splits compound rules into simple ones

Parameters

\EasyRdf\Sparql\Result $results

SPARQL result set containg a rule variable with a Fedora URIs of ACL Fedora resources

\acdhOeaw\fedora\Fedora $fedora

Fedora connection object

string $aclUrl

URL of the ACL where splitted rules (if there will be such) should be saved

Returns

array —

collection of WebAclRule objects

checkParam()

checkParam(string  $type, integer  $mode) 

Checks the `grant()` and `revoke()` method parameters.

Parameters

string $type
integer $mode

Throws

\acdhOeaw\fedora\exceptions\NotFound