phpcr/src/PHPCR/Security/AccessControlManagerInterface.php
Copyright 2008-2011 Karsten Dambekalns karsten@typo3.org
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
\PHPCR\Security\AccessControlManagerInterface
It provides methods for:
- Access control discovery
- Assigning access control policies
- Api
Methods
getApplicablePolicies(string | null $absPath) : \Iterator
Returns the access control policies that are capable of being applied to the object specified by $absPath.
If $absPath is the absolute path of an accessible node then the specified object is that node. If $absPath is null then the specified object is the repository as a whole.
Name | Type | Description |
---|---|---|
$absPath | string | null | The absolute path to the node of which privileges are requested or null for the repository as a whole. |
Type | Description |
---|---|
\Iterator | over the applicable access control policies implementing <b>SeekableIterator</b> and <b>Countable</b>. Values are the AccessControlPolicyInterface instances. Keys have no meaning. Returns an empty iterator if no policies are applicable. |
Exception | Description |
---|---|
\PHPCR\PathNotFoundException | if $absPath is non-null and no node at $absPath exists or the session does not have sufficient access to retrieve a node at that location. |
\PHPCR\AccessDeniedException | if the session lacks READ_ACCESS_CONTROL privilege for the absPath node. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
getEffectivePolicies(string | null $absPath) : array
Gets the access control policies currently in effect.
Returns the AccessControlPolicy objects that currently are in effect for the object specified by $absPath. If $absPath is the absolute path of an accessible node then the specified object is that node. If $absPath is null then the specified object is the repository as a whole.
The policies returned by this method may include both those set through this API and implementation specific policies.
Name | Type | Description |
---|---|---|
$absPath | string | null | The absolute path to the node of which privileges are requested or null for non-node privileges. |
Type | Description |
---|---|
array | an array of AccessControlPolicy objects. |
Exception | Description |
---|---|
\PHPCR\PathNotFoundException | if $absPath is non-null and no node at $absPath exists or the session does not have sufficient access to retrieve a node at that location. |
\PHPCR\AccessDeniedException | if the session lacks READ_ACCESS_CONTROL privilege for the absPath node. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
getPolicies(string | null $absPath) : array
Gets the access control policies previously set.
Returns the AccessControlPolicy objects that have been set to the object specified by $absPath. If $absPath is the absolute path of an accessible node then the specified object is that node. If $absPath is null then the specified object is the repository as a whole. If no policy has been set for the specified object, an empty array is returned. This method reflects the binding state, including transient policy modifications.
Use getEffectivePolicies() in order to determine the policy that effectively applies to $absPath.
Name | Type | Description |
---|---|---|
$absPath | string | null | The absolute path to a node the privileges shall be fetched of or null to fetch non-node privileges. |
Type | Description |
---|---|
array | an array of AccessControlPolicy objects or an empty array if no policy has been set. |
Exception | Description |
---|---|
\PHPCR\PathNotFoundException | if $absPath is non-null and no node at $absPath exists or the session does not have sufficient access to retrieve a node at that location. |
\PHPCR\AccessDeniedException | if the session lacks READ_ACCESS_CONTROL privilege for the absPath node. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
getPrivileges(string | null $absPath = null) : array
Reads the privileges of the current session.
Returns the privileges for the object specified by $absPath. If $absPath is the absolute path of an accessible node then the specified object is that node. If $absPath is null then the specified object is the repository as a whole and the privileges in question are those that are not associated with any particular node. This includes such privileges as being able administer the node type registry, for example.
The returned privileges are those for which AccessControlManagerInterface::hasPrivileges() would return true.
The results reported by the this method reflect the net effect of the currently applied control mechanisms. It does not reflect unsaved access control policies or unsaved access control entries. Changes to access control status caused by these mechanisms only take effect on SessionInterface::save() and are only then reflected in the results of the privilege test methods.
Name | Type | Description |
---|---|---|
$absPath | string | null | The absolute path to a node the privileges shall be fetched of or null to fetch non-node privileges. |
Type | Description |
---|---|
array | an array of Privileges. |
Exception | Description |
---|---|
\PHPCR\PathNotFoundException | if $absPath is non-null and no node at $absPath exists or the session does not have sufficient access to retrieve a node at that location. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
getSupportedPrivileges(string | null $absPath = null) : array
Gets privileges of an existing node identified by its path.
Returns the privileges supported for absolute path $absPath, or, if $absPath is null, the privileges supported by the repository that are not associated with any particular node (for example, the privilege of being able to administer the node type registry).
If $absPath is neither the absolute path of an accessible node nor null, then this method throws a PathNotFoundException.
Note that this method does not return the privileges held by the current session, but rather the privileges supported by the repository. supports.
Name | Type | Description |
---|---|---|
$absPath | string | null | The absolute path to a node the privileges shall be fetched of. |
Type | Description |
---|---|
array | An array of Privileges. |
Exception | Description |
---|---|
\PHPCR\PathNotFoundException | if $absPath is non-null and either no node exists at that path or the session does not have sufficient access to retrieve a node at that path. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
hasPrivileges(string | null $absPath, array $privileges) : boolean
Determines whether the session has a given set of privileges.
Returns whether the session has the specified privileges for absolute path $absPath, which must be an existing node or, if $absPath is null, then whether the session has all the specified non-node-related privileges (such as being able administer the node type registry, for example).
Testing an aggregate privilege is equivalent to testing each non aggregate privilege among the set returned by calling PrivilegeInterface::getAggregatePrivileges() for that privilege.
The results reported by this method reflect the net effect of the currently applied control mechanisms. It does not reflect unsaved access control policies or unsaved access control entries. Changes to access control status caused by these mechanisms only take effect on SessionInterface::save() and are only then reflected in the results of the privilege test methods.
Name | Type | Description |
---|---|---|
$absPath | string | null | The absolute path to a node the privileges shall be fetched of. |
$privileges | array | an array of Privileges. |
Type | Description |
---|---|
boolean | true if the session has the specified privileges; false otherwise. |
Exception | Description |
---|---|
\PHPCR\PathNotFoundException | if $absPath is non-null and no node at $absPath exists or the session does not have sufficient access to retrieve a node at that location |
\PHPCR\RepositoryException | if another error occurs. |
- Api
privilegeFromName(string $privilegeName) : \PHPCR\Security\PrivilegeInterface
Returns the privilege with the specified privilegeName.
Name | Type | Description |
---|---|---|
$privilegeName | string | The name of an existing privilege. |
Type | Description |
---|---|
\PHPCR\Security\PrivilegeInterface | the Privilege with the specified name. |
Exception | Description |
---|---|
\PHPCR\Security\AccessControlException | if no privilege with the specified name exists. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
removePolicy(string | null $absPath, \PHPCR\Security\AccessControlPolicyInterface $policy) : void
Removes the specified AccessControlPolicy from the object specified by $absPath.
If $absPath is the absolute path of an accessible node then the specified object is that node. If $absPath is null then the specified object is the repository as a whole.
An AccessControlPolicyInterface can only be removed if it was earlier bound to the specified object through this API. The effect of the removal only takes place upon SessionInterface::save(). Note, that an implementation default or any other effective AccessControlPolicyInterface that has not been applied through this API may never be removed using this method.
Name | Type | Description |
---|---|---|
$absPath | string | null | The absolute path to the node from which privileges are removed or null for the repository as a whole. |
$policy | \PHPCR\Security\AccessControlPolicyInterface | the policy to be removed. |
Exception | Description |
---|---|
\PHPCR\PathNotFoundException | if $absPath is non-null and no node at $absPath exists or the session does not have sufficient access to retrieve a node at that location. |
\PHPCR\Security\AccessControlException | if the policy to remove does not exist at the node at absPath. |
\PHPCR\AccessDeniedException | if the session lacks MODIFY_ACCESS_CONTROL privilege for the absPath node. |
\PHPCR\Lock\LockException | if $absPath specifies a locked node and this implementation performs this validation immediately instead of waiting until save. |
\PHPCR\Version\VersionException | if $absPath specifies a node that is read-only due to a checked-in node and this implementation performs this validation immediately instead of waiting until save. |
\PHPCR\RepositoryException | if another error occurs. |
- Api
setPolicy(string | null $absPath, \PHPCR\Security\AccessControlPolicyInterface $policy) : void
Binds the policy to the object specified by $absPath.
If $absPath is the absolute path of an accessible node then the specified object is that node. If $absPath is null then the specified object is the repository as a whole.
The behavior of AccessControlManagerInterface::setPolicy() differs depending on how the policy object was originally acquired.
If the policy was acquired through AccessControlManagerInterface::getApplicablePolicies() then that policy object is added to the object specified by $absPath.
On the other hand, if the policy was acquired through AccessControlManagerInterface::getPolicies() then that policy object (usually after being altered) replaces its former version on the node at $absPath.
This is a session-write method and therefore the access control policy assignment is only dispatched on Session::save() and will only take effect upon persist.
Name | Type | Description |
---|---|---|
$absPath | string | null | The absolute path to the node to which privileges are to be set or null for the repository as a whole. |
$policy | \PHPCR\Security\AccessControlPolicyInterface | The AccessControlPolicy to be applied. |
Exception | Description |
---|---|
\PHPCR\PathNotFoundException | if $absPath is non-null and no node at $absPath exists or the session does not have sufficient access to retrieve a node at that location. |
\PHPCR\Security\AccessControlException | if the policy is not applicable. |
\PHPCR\AccessDeniedException | if the session lacks MODIFY_ACCESS_CONTROL privilege for $absPath. |
\PHPCR\Lock\LockException | if a lock prevents the assignment and this implementation performs this validation immediately instead of waiting until save. |
\PHPCR\Version\VersionException | if the object specified by $absPath is a node in the read-only state (due to a checked-in) node and this implementation performs this validation immediately. |
\PHPCR\RepositoryException | if another error occurs. |
- Api