public class DefaultAccessManager extends AbstractAccessControlManager implements AccessManager
DefaultAccessManager controls access by evaluating access
control policies for the Subject attached to the
Session this manager has been built for.
Please note the following exceptional situations:
This manager allows all privileges for a particular item if
It allows to access all available workspaces if
WorkspaceAccessManager is defined.
How access control policies are matched to a particular item is defined by
the AccessControlProvider set to this AccessManager.
AccessManager,
AccessControlManagerREAD, REMOVE, WRITE| Constructor and Description |
|---|
DefaultAccessManager() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canAccess(String workspaceName)
Determines whether the subject of the current context is granted access
to the given workspace.
|
boolean |
canRead(Path itemPath,
ItemId itemId)
Determines whether the item with the specified
itemPath
or itemId can be read. |
protected void |
checkInitialized()
Check if this manager has been properly initialized.
|
void |
checkPermission(ItemId id,
int permissions)
Determines whether the specified
permissions are granted
on the item with the specified id (i.e. |
void |
checkPermission(Path absPath,
int permissions)
Determines whether the specified
permissions are granted
on the item with the specified id (i.e. |
protected void |
checkPermission(String absPath,
int permission)
Check if the specified privileges are granted at
absPath. |
void |
checkRepositoryPermission(int permissions)
Determines whether the specified
permissions are granted
on the repository level. |
protected void |
checkValidNodePath(String absPath)
Tests if the given
absPath is absolute and points to an existing node. |
void |
close()
Close this access manager.
|
JackrabbitAccessControlPolicy[] |
getApplicablePolicies(Principal principal)
Returns the applicable policies for the specified
principal
or an empty array if no additional policies can be applied. |
javax.jcr.security.AccessControlPolicyIterator |
getApplicablePolicies(String absPath)
Returns an empty iterator.
|
javax.jcr.security.AccessControlPolicy[] |
getEffectivePolicies(Set<Principal> principals)
Returns the
AccessControlPolicy objects that are in effect
for the given Principals. |
javax.jcr.security.AccessControlPolicy[] |
getEffectivePolicies(String absPath) |
JackrabbitAccessControlPolicy[] |
getPolicies(Principal principal)
Returns the
AccessControlPolicy objects that have been set
for the given principal or an empty array if no policy has
been set. |
javax.jcr.security.AccessControlPolicy[] |
getPolicies(String absPath)
Returns
null. |
protected PrivilegeManager |
getPrivilegeManager() |
javax.jcr.security.Privilege[] |
getPrivileges(String absPath) |
javax.jcr.security.Privilege[] |
getPrivileges(String absPath,
Set<Principal> principals)
Returns the privileges the given set of
Principals has for
absolute path absPath, which must be an existing node. |
boolean |
hasPrivileges(String absPath,
javax.jcr.security.Privilege[] privileges) |
boolean |
hasPrivileges(String absPath,
Set<Principal> principals,
javax.jcr.security.Privilege[] privileges)
Returns whether the given set of
Principals has the specified
privileges for absolute path absPath, which must be an
existing node. |
void |
init(AMContext amContext)
Initialize this access manager.
|
void |
init(AMContext amContext,
AccessControlProvider acProvider,
WorkspaceAccessManager wspAccessManager)
Initialize this access manager.
|
boolean |
isGranted(ItemId id,
int actions)
Determines whether the specified
permissions are granted
on the item with the specified id (i.e. |
boolean |
isGranted(Path absPath,
int permissions)
Determines whether the specified
permissions are granted
on the item with the specified absPath (i.e. |
boolean |
isGranted(Path parentPath,
Name childName,
int permissions)
Determines whether the specified
permissions are granted
on an item represented by the combination of the given
parentPath and childName (i.e. |
void |
removePolicy(String absPath,
javax.jcr.security.AccessControlPolicy policy)
Always throws
AccessControlException |
void |
setPolicy(String absPath,
javax.jcr.security.AccessControlPolicy policy)
Always throws
AccessControlException |
getSupportedPrivileges, privilegeFromNamepublic void init(AMContext amContext) throws javax.jcr.AccessDeniedException, Exception
AccessManagerAccessDeniedException will
be thrown if the subject of the given context is not
granted access to the specified workspace.init in interface AccessManageramContext - access manager contextjavax.jcr.AccessDeniedException - if the subject is not granted access
to the specified workspace.Exception - if another error occursAccessManager.init(AMContext)public void init(AMContext amContext, AccessControlProvider acProvider, WorkspaceAccessManager wspAccessManager) throws javax.jcr.AccessDeniedException, Exception
AccessManagerAccessDeniedException will
be thrown if the subject of the given context is not
granted access to the specified workspace.init in interface AccessManageramContext - access manager context.acProvider - The access control provider.wspAccessManager - The workspace access manager.javax.jcr.AccessDeniedException - if the subject is not granted access
to the specified workspace.Exception - if another error occursAccessManager.init(AMContext, AccessControlProvider, WorkspaceAccessManager)public void close()
throws Exception
AccessManagerclose in interface AccessManagerException - if an error occursAccessManager.close()public void checkPermission(ItemId id, int permissions) throws javax.jcr.AccessDeniedException, javax.jcr.ItemNotFoundException, javax.jcr.RepositoryException
AccessManagerpermissions are granted
on the item with the specified id (i.e. the target item).checkPermission in interface AccessManagerid - the id of the target itempermissions - A combination of one or more of the following constants
encoded as a bitmask value:
READWRITEREMOVEjavax.jcr.AccessDeniedException - if permission is deniedjavax.jcr.ItemNotFoundException - if the target item does not existjavax.jcr.RepositoryException - it an error occursAccessManager.checkPermission(ItemId, int)public void checkPermission(Path absPath, int permissions) throws javax.jcr.AccessDeniedException, javax.jcr.RepositoryException
AccessManagerpermissions are granted
on the item with the specified id (i.e. the target item).checkPermission in interface AccessManagerabsPath - Path to an item.permissions - A combination of one or more of the
Permission
constants encoded as a bitmask value.javax.jcr.AccessDeniedException - if permission is deniedjavax.jcr.RepositoryException - it another error occursAccessManager.checkPermission(Path, int)public void checkRepositoryPermission(int permissions)
throws javax.jcr.AccessDeniedException,
javax.jcr.RepositoryException
AccessManagerpermissions are granted
on the repository level.checkRepositoryPermission in interface AccessManagerpermissions - The permissions to check.javax.jcr.AccessDeniedException - if permissions are denied.javax.jcr.RepositoryException - if another error occurs.AccessManager.checkRepositoryPermission(int)public boolean isGranted(ItemId id, int actions) throws javax.jcr.ItemNotFoundException, javax.jcr.RepositoryException
AccessManagerpermissions are granted
on the item with the specified id (i.e. the target item).isGranted in interface AccessManagerid - the id of the target itemactions - A combination of one or more of the following constants
encoded as a bitmask value:
READWRITEREMOVEtrue if permission is granted; otherwise falsejavax.jcr.ItemNotFoundException - if the target item does not existjavax.jcr.RepositoryException - if another error occursAccessManager.isGranted(ItemId, int)public boolean isGranted(Path absPath, int permissions) throws javax.jcr.RepositoryException
AccessManagerpermissions are granted
on the item with the specified absPath (i.e. the target
item, that may or may not yet exist).isGranted in interface AccessManagerabsPath - the absolute path to testpermissions - A combination of one or more of the
Permission
constants encoded as a bitmask value.true if the specified permissions are granted;
otherwise false.javax.jcr.RepositoryException - if an error occurs.AccessManager.isGranted(Path, int)public boolean isGranted(Path parentPath, Name childName, int permissions) throws javax.jcr.RepositoryException
AccessManagerpermissions are granted
on an item represented by the combination of the given
parentPath and childName (i.e. the target
item, that may or may not yet exist).isGranted in interface AccessManagerparentPath - Path to an existing parent node.childName - Name of the child item that may or may not exist yet.permissions - A combination of one or more of the
Permission
constants encoded as a bitmask value.true if the specified permissions are granted;
otherwise false.javax.jcr.RepositoryException - if an error occurs.AccessManager.isGranted(Path, Name, int)public boolean canRead(Path itemPath, ItemId itemId) throws javax.jcr.RepositoryException
AccessManageritemPath
or itemId can be read. Either of the two parameters
may be null.AccessManager.isGranted(Path, int) should be used instead.
If this method is called with both Path and ItemId it is left to the evaluation, which parameter is used.
canRead in interface AccessManageritemPath - The path to the item or null if itemId
should be used to determine the READ permission.itemId - Id of the item to be tested or null if the
itemPath should be used to determine the permission.true if the item can be read; otherwise false.javax.jcr.RepositoryException - if the item is NEW and only an itemId is
specified or if another error occurs.AccessManager.canRead(org.apache.jackrabbit.spi.Path,org.apache.jackrabbit.core.id.ItemId)public boolean canAccess(String workspaceName) throws javax.jcr.RepositoryException
AccessManagerfalse, if no such workspace
exists.canAccess in interface AccessManagerworkspaceName - name of workspacetrue if the subject of the current context is
granted access to the given workspace; otherwise false.javax.jcr.RepositoryException - if an error occurs.AccessManager.canAccess(String)public boolean hasPrivileges(String absPath, javax.jcr.security.Privilege[] privileges) throws javax.jcr.PathNotFoundException, javax.jcr.RepositoryException
hasPrivileges in interface javax.jcr.security.AccessControlManagerjavax.jcr.PathNotFoundExceptionjavax.jcr.RepositoryExceptionAccessControlManager.hasPrivileges(String, Privilege[])public javax.jcr.security.Privilege[] getPrivileges(String absPath) throws javax.jcr.PathNotFoundException, javax.jcr.RepositoryException
getPrivileges in interface javax.jcr.security.AccessControlManagerjavax.jcr.PathNotFoundExceptionjavax.jcr.RepositoryExceptionAccessControlManager.getPrivileges(String)public javax.jcr.security.AccessControlPolicy[] getPolicies(String absPath) throws javax.jcr.PathNotFoundException, javax.jcr.AccessDeniedException, javax.jcr.RepositoryException
AbstractAccessControlManagernull.getPolicies in interface javax.jcr.security.AccessControlManagergetPolicies in class AbstractAccessControlManagerabsPath - Path to an existing node.null.javax.jcr.PathNotFoundExceptionjavax.jcr.AccessDeniedExceptionjavax.jcr.RepositoryExceptionAccessControlManager.getPolicies(String)public javax.jcr.security.AccessControlPolicy[] getEffectivePolicies(String absPath) throws javax.jcr.PathNotFoundException, javax.jcr.AccessDeniedException, javax.jcr.RepositoryException
getEffectivePolicies in interface javax.jcr.security.AccessControlManagerjavax.jcr.PathNotFoundExceptionjavax.jcr.AccessDeniedExceptionjavax.jcr.RepositoryExceptionAccessControlManager.getEffectivePolicies(String)public javax.jcr.security.AccessControlPolicyIterator getApplicablePolicies(String absPath) throws javax.jcr.PathNotFoundException, javax.jcr.AccessDeniedException, javax.jcr.RepositoryException
AbstractAccessControlManagergetApplicablePolicies in interface javax.jcr.security.AccessControlManagergetApplicablePolicies in class AbstractAccessControlManagerabsPath - Path to an existing node.javax.jcr.PathNotFoundExceptionjavax.jcr.AccessDeniedExceptionjavax.jcr.RepositoryExceptionAccessControlManager.getApplicablePolicies(String)public void setPolicy(String absPath, javax.jcr.security.AccessControlPolicy policy) throws javax.jcr.PathNotFoundException, javax.jcr.security.AccessControlException, javax.jcr.AccessDeniedException, javax.jcr.RepositoryException
AbstractAccessControlManagerAccessControlExceptionsetPolicy in interface javax.jcr.security.AccessControlManagersetPolicy in class AbstractAccessControlManagerjavax.jcr.PathNotFoundExceptionjavax.jcr.security.AccessControlExceptionjavax.jcr.AccessDeniedExceptionjavax.jcr.RepositoryExceptionAccessControlManager.setPolicy(String, AccessControlPolicy)public void removePolicy(String absPath, javax.jcr.security.AccessControlPolicy policy) throws javax.jcr.PathNotFoundException, javax.jcr.security.AccessControlException, javax.jcr.AccessDeniedException, javax.jcr.RepositoryException
AbstractAccessControlManagerAccessControlExceptionremovePolicy in interface javax.jcr.security.AccessControlManagerremovePolicy in class AbstractAccessControlManagerjavax.jcr.PathNotFoundExceptionjavax.jcr.security.AccessControlExceptionjavax.jcr.AccessDeniedExceptionjavax.jcr.RepositoryExceptionAccessControlManager.removePolicy(String, AccessControlPolicy)public JackrabbitAccessControlPolicy[] getApplicablePolicies(Principal principal) throws javax.jcr.AccessDeniedException, javax.jcr.security.AccessControlException, javax.jcr.UnsupportedRepositoryOperationException, javax.jcr.RepositoryException
JackrabbitAccessControlManagerprincipal
or an empty array if no additional policies can be applied.getApplicablePolicies in interface JackrabbitAccessControlManagergetApplicablePolicies in class AbstractAccessControlManagerprincipal - A principal known to the editing session.principal. Note
that the policy object returned must reveal the path of the node where
they can be applied later on using AccessControlManager.setPolicy(String, javax.jcr.security.AccessControlPolicy).javax.jcr.AccessDeniedException - if the session lacks
MODIFY_ACCESS_CONTROL privilege.javax.jcr.security.AccessControlException - if the specified principal does not exist
or if another access control related exception occurs.javax.jcr.UnsupportedRepositoryOperationException - if editing access control
policies by principal is not supported.javax.jcr.RepositoryException - if another error occurs.JackrabbitAccessControlManager.getApplicablePolicies(Principal)public JackrabbitAccessControlPolicy[] getPolicies(Principal principal) throws javax.jcr.AccessDeniedException, javax.jcr.security.AccessControlException, javax.jcr.UnsupportedRepositoryOperationException, javax.jcr.RepositoryException
JackrabbitAccessControlManagerAccessControlPolicy objects that have been set
for the given principal or an empty array if no policy has
been set. This method reflects the binding state, including transient
policy modifications.getPolicies in interface JackrabbitAccessControlManagergetPolicies in class AbstractAccessControlManagerprincipal - A valid principal.javax.jcr.AccessDeniedException - if the session lacks
READ_ACCESS_CONTROL privilege.javax.jcr.security.AccessControlException - if the specified principal does not exist
or if another access control related exception occurs.javax.jcr.UnsupportedRepositoryOperationException - if editing access control
policies by principal is not supported.javax.jcr.RepositoryException - If another error occurs.JackrabbitAccessControlManager.getPolicies(Principal)public javax.jcr.security.AccessControlPolicy[] getEffectivePolicies(Set<Principal> principals) throws javax.jcr.AccessDeniedException, javax.jcr.security.AccessControlException, javax.jcr.UnsupportedRepositoryOperationException, javax.jcr.RepositoryException
JackrabbitAccessControlManagerAccessControlPolicy objects that are in effect
for the given Principals. This may be policies set through
this API or some implementation specific (default) policies.getEffectivePolicies in interface JackrabbitAccessControlManagerprincipals - A set of valid principals.javax.jcr.AccessDeniedException - if the session lacks
READ_ACCESS_CONTROL privilege.javax.jcr.security.AccessControlException - if the specified principal does not exist
or if another access control related exception occurs.javax.jcr.UnsupportedRepositoryOperationException - if editing access control
policies by principal is not supported.javax.jcr.RepositoryException - If another error occurs.JackrabbitAccessControlManager.getEffectivePolicies(Set)public boolean hasPrivileges(String absPath, Set<Principal> principals, javax.jcr.security.Privilege[] privileges) throws javax.jcr.PathNotFoundException, javax.jcr.RepositoryException
JackrabbitAccessControlManagerPrincipals has the specified
privileges for absolute path absPath, which must be an
existing node.
Testing an aggregate privilege is equivalent to testing each non
aggregate privilege among the set returned by calling
Privilege.getAggregatePrivileges() for that privilege.
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
Session.save() and are only then reflected in the results of
the privilege test methods.
Since this method allows to view the privileges of principals other
than included in the editing session, this method must throw
AccessDeniedException if the session lacks
READ_ACCESS_CONTROL privilege for the absPath
node.
hasPrivileges in interface JackrabbitAccessControlManagerabsPath - an absolute path.principals - a set of Principals for which is the
given privileges are tested.privileges - an array of Privileges.true if the session has the specified privileges;
false otherwise.javax.jcr.PathNotFoundException - if no node at absPath exists
or the session does not have sufficient access to retrieve a node at that location.javax.jcr.AccessDeniedException - if the session lacks
READ_ACCESS_CONTROL privilege for the absPath node.javax.jcr.RepositoryException - if another error occurs.JackrabbitAccessControlManager.hasPrivileges(String, Set, Privilege[])public javax.jcr.security.Privilege[] getPrivileges(String absPath, Set<Principal> principals) throws javax.jcr.PathNotFoundException, javax.jcr.RepositoryException
JackrabbitAccessControlManagerPrincipals has for
absolute path absPath, which must be an existing node.
The returned privileges are those for which JackrabbitAccessControlManager.hasPrivileges(java.lang.String, java.util.Set<java.security.Principal>, javax.jcr.security.Privilege[]) 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
Session.save() and are only then reflected in the results of
the privilege test methods.
Since this method allows to view the privileges of principals other
than included in the editing session, this method must throw
AccessDeniedException if the session lacks
READ_ACCESS_CONTROL privilege for the absPath
node.
Note that this method does not resolve any group membership, as this is the job of the user manager. nor does it augment the set with the "everyone" principal.
getPrivileges in interface JackrabbitAccessControlManagerabsPath - an absolute path.principals - a set of Principals for which is the
privileges are retrieved.Privileges.javax.jcr.PathNotFoundException - if no node at absPath exists
or the session does not have sufficient access to retrieve a node at that
location.javax.jcr.AccessDeniedException - if the session lacks READ_ACCESS_CONTROL
privilege for the absPath node.javax.jcr.RepositoryException - if another error occurs.JackrabbitAccessControlManager.getPrivileges(String, Set)protected void checkInitialized()
AbstractAccessControlManagercheckInitialized in class AbstractAccessControlManagerAbstractAccessControlManager.checkInitialized()protected void checkValidNodePath(String absPath) throws javax.jcr.PathNotFoundException, javax.jcr.RepositoryException
AbstractAccessControlManagerabsPath is absolute and points to an existing node.checkValidNodePath in class AbstractAccessControlManagerabsPath - Path to an existing node.javax.jcr.PathNotFoundException - if no node at absPath exists
or the session does not have privilege to retrieve the node.javax.jcr.RepositoryException - If the given absPath is not
absolute or if some other error occurs.AbstractAccessControlManager.checkValidNodePath(String)protected void checkPermission(String absPath, int permission) throws javax.jcr.AccessDeniedException, javax.jcr.RepositoryException
AbstractAccessControlManagerabsPath.checkPermission in class AbstractAccessControlManagerabsPath - Path to an existing node.permission - Permissions to be checked.javax.jcr.AccessDeniedException - if the session does not have the
specified privileges.javax.jcr.PathNotFoundException - if no node exists at absPath
of if the session does not have the permission to READ it.javax.jcr.RepositoryException - If another error occurs.AbstractAccessControlManager.checkPermission(String,int)protected PrivilegeManager getPrivilegeManager() throws javax.jcr.RepositoryException
getPrivilegeManager in class AbstractAccessControlManagerjavax.jcr.RepositoryException - If another error occurs.AbstractAccessControlManager.getPrivilegeManager()Copyright © 2004-2020 The Apache Software Foundation. All Rights Reserved.