6.9.2 Checking Permissions

Permission checking is done through the method Session.checkPermission:

javax.jcr.
Session

void

checkPermission(String absPath,
String actions)

Determines whether this Session has permission to perform the specified actions at the specified absPath. This method quietly returns if the access request is permitted, or throws a suitable java.security.AccessControlException otherwise.

The actions parameter is a comma separated list of action strings. The following action strings are defined:

add_node
If checkPermission(path, "add_node") returns quietly, then this Session has permission to add a node at path, otherwise permission is denied.

set_property
If checkPermission(path, "set_property") returns quietly, then this Session has permission to set (add or change) a property at path, otherwise permission is denied.

remove
If checkPermission(path, "remove") returns quietly, then this Session has permission to remove an item at path, otherwise permission is denied.

read
If checkPermission(path, "read") returns quietly, then this Session has permission to retrieve (and read the value of, in the case of a property) an item at path, otherwise permission is denied.

When more than one action is specified in the actions parameter, this method will only return quietly if this Session has permission to perform all of the listed actions at the specified path.

The information returned through this method will only reflect access control policies and not other restrictions that may exist. For example, even though checkPermission may indicate that a particular Session may add a property at /A/B/C, the node type of the node at /A/B may prevent the addition of a property called C.

A RepositoryException is thrown if an error occurs.