Class AbstractAccessControlManager
- java.lang.Object
-
- org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlManager
-
- All Implemented Interfaces:
AccessControlManager,JackrabbitAccessControlManager,AccessControlConstants
@ProviderType public abstract class AbstractAccessControlManager extends java.lang.Object implements JackrabbitAccessControlManager, AccessControlConstants
Default implementation of theJackrabbitAccessControlManagerinterface. This implementation covers both editing access control content by path and byPrincipalresulting both in the same content structure.
-
-
Field Summary
-
Fields inherited from interface org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AccessControlConstants
AC_NODETYPE_NAMES, ACE_PROPERTY_NAMES, MIX_REP_ACCESS_CONTROLLABLE, MIX_REP_REPO_ACCESS_CONTROLLABLE, NT_REP_ACE, NT_REP_ACL, NT_REP_DENY_ACE, NT_REP_GRANT_ACE, NT_REP_POLICY, NT_REP_RESTRICTIONS, PARAM_RESTRICTION_PROVIDER, POLICY_NODE_NAMES, REP_CURRENT, REP_GLOB, REP_GLOBS, REP_ITEM_NAMES, REP_NODE_PATH, REP_NT_NAMES, REP_POLICY, REP_PREFIXES, REP_PRINCIPAL_NAME, REP_PRIVILEGES, REP_REPO_POLICY, REP_RESTRICTIONS, REP_SUBTREES
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NotNull PrivilegeCollectiongetPrivilegeCollection(@Nullable java.lang.String absPath)Returns thePrivilegeCollectionfor editing session at the given absolute path, which must be an existing node.@NotNull PrivilegeCollectiongetPrivilegeCollection(@Nullable java.lang.String absPath, @NotNull java.util.Set<java.security.Principal> principals)Returns thePrivilegeCollectionfor the given set of principals at the given absolute path, which must be an existing node.@NotNull Privilege[]getPrivileges(@Nullable java.lang.String absPath)Returns the privileges the session has for absolute path absPath, which must be an existing node.@NotNull Privilege[]getPrivileges(@Nullable java.lang.String absPath, @NotNull java.util.Set<java.security.Principal> principals)Returns the privileges the given set ofPrincipals has for absolute pathabsPath, which must be an existing node.@NotNull Privilege[]getSupportedPrivileges(@Nullable java.lang.String absPath)Returns the privileges supported for absolute pathabsPath, which must be an existing node.booleanhasPrivileges(@Nullable java.lang.String absPath, @NotNull java.util.Set<java.security.Principal> principals, @Nullable Privilege[] privileges)Returns whether the given set ofPrincipals has the specified privileges for absolute pathabsPath, which must be an existing node.booleanhasPrivileges(@Nullable java.lang.String absPath, @Nullable Privilege[] privileges)Returns whether the session has the specified privileges for absolute pathabsPath, which must be an existing node.@NotNull PrivilegeCollectionprivilegeCollectionFromNames(@NotNull java.lang.String... privilegeNames)Returns thePrivilegeCollectionfor the specifiedprivilegeNames.@NotNull PrivilegeprivilegeFromName(@NotNull java.lang.String privilegeName)Returns the privilege with the specifiedprivilegeName.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.jcr.security.AccessControlManager
getApplicablePolicies, getEffectivePolicies, getPolicies, removePolicy, setPolicy
-
Methods inherited from interface org.apache.jackrabbit.api.security.JackrabbitAccessControlManager
getApplicablePolicies, getEffectivePolicies, getPolicies
-
-
-
-
Method Detail
-
getSupportedPrivileges
@NotNull public @NotNull Privilege[] getSupportedPrivileges(@Nullable @Nullable java.lang.String absPath) throws RepositoryException
Description copied from interface:AccessControlManagerReturns the privileges supported for absolute pathabsPath, which must be an existing node.This method does not return the privileges held by the session. Instead, it returns the privileges that the repository supports.
- Specified by:
getSupportedPrivilegesin interfaceAccessControlManager- Parameters:
absPath- an absolute path.- Returns:
- an array of
Privileges. - Throws:
PathNotFoundException- if no node atabsPathexists or the session does not have sufficient access to retrieve a node at that location.RepositoryException- if another error occurs.
-
privilegeFromName
@NotNull public @NotNull Privilege privilegeFromName(@NotNull @NotNull java.lang.String privilegeName) throws RepositoryException
Description copied from interface:AccessControlManagerReturns the privilege with the specifiedprivilegeName. Since the privilege name is a JCR name, it may be passed in either qualified or expanded form (see specification for details on JCR names).- Specified by:
privilegeFromNamein interfaceAccessControlManager- Parameters:
privilegeName- the name of an existing privilege.- Returns:
- the
Privilegewith the specifiedprivilegeName. - Throws:
AccessControlException- if no privilege with the specified name exists.RepositoryException- if another error occurs.
-
hasPrivileges
public boolean hasPrivileges(@Nullable @Nullable java.lang.String absPath, @Nullable @Nullable Privilege[] privileges) throws RepositoryExceptionDescription copied from interface:AccessControlManagerReturns whether the session has the specified privileges for absolute pathabsPath, 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.- Specified by:
hasPrivilegesin interfaceAccessControlManager- Parameters:
absPath- an absolute path.privileges- an array ofPrivileges.- Returns:
trueif the session has the specified privileges;falseotherwise.- Throws:
PathNotFoundException- if no node atabsPathexists or the session does not have sufficent access to retrieve a node at that location.RepositoryException- if another error occurs.
-
getPrivileges
@NotNull public @NotNull Privilege[] getPrivileges(@Nullable @Nullable java.lang.String absPath) throws RepositoryException
Description copied from interface:AccessControlManagerReturns the privileges the session has for absolute path absPath, which must be an existing node.The returned privileges are those for which
AccessControlManager.hasPrivileges(java.lang.String, javax.jcr.security.Privilege[])would returntrue.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.- Specified by:
getPrivilegesin interfaceAccessControlManager- Parameters:
absPath- an absolute path.- Returns:
- an array of
Privileges. - Throws:
PathNotFoundException- if no node atabsPathexists or the session does not have sufficient access to retrieve a node at that location.RepositoryException- if another error occurs.
-
hasPrivileges
public boolean hasPrivileges(@Nullable @Nullable java.lang.String absPath, @NotNull @NotNull java.util.Set<java.security.Principal> principals, @Nullable @Nullable Privilege[] privileges) throws RepositoryExceptionDescription copied from interface:JackrabbitAccessControlManagerReturns whether the given set ofPrincipals has the specified privileges for absolute pathabsPath, 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
AccessDeniedExceptionif the session lacksREAD_ACCESS_CONTROLprivilege for theabsPathnode.- Specified by:
hasPrivilegesin interfaceJackrabbitAccessControlManager- Parameters:
absPath- an absolute path.principals- a set ofPrincipals for which is the given privileges are tested.privileges- an array ofPrivileges.- Returns:
trueif the session has the specified privileges;falseotherwise.- Throws:
PathNotFoundException- if no node atabsPathexists or the session does not have sufficient access to retrieve a node at that location.AccessDeniedException- if the session lacksREAD_ACCESS_CONTROLprivilege for theabsPathnode.RepositoryException- if another error occurs.
-
getPrivileges
@NotNull public @NotNull Privilege[] getPrivileges(@Nullable @Nullable java.lang.String absPath, @NotNull @NotNull java.util.Set<java.security.Principal> principals) throws RepositoryException
Description copied from interface:JackrabbitAccessControlManagerReturns the privileges the given set ofPrincipals has for absolute pathabsPath, 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 returntrue.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
AccessDeniedExceptionif the session lacksREAD_ACCESS_CONTROLprivilege for theabsPathnode.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.
- Specified by:
getPrivilegesin interfaceJackrabbitAccessControlManager- Parameters:
absPath- an absolute path.principals- a set ofPrincipals for which is the privileges are retrieved.- Returns:
- an array of
Privileges. - Throws:
PathNotFoundException- if no node atabsPathexists or the session does not have sufficient access to retrieve a node at that location.AccessDeniedException- if the session lacksREAD_ACCESS_CONTROLprivilege for theabsPathnode.RepositoryException- if another error occurs.
-
getPrivilegeCollection
@NotNull public @NotNull PrivilegeCollection getPrivilegeCollection(@Nullable @Nullable java.lang.String absPath) throws RepositoryException
Description copied from interface:JackrabbitAccessControlManagerReturns the
Note: For backwards compatibility this method comes with a default implementation that computes thePrivilegeCollectionfor editing session at the given absolute path, which must be an existing node. This is equivalent toAccessControlManager.getPrivileges(String)andAccessControlManager.hasPrivileges(String, Privilege[])but allows for easy resolution of aggregated privileges (like e.g. jcr:all) and repeated evaluation if the editing session has privileges granted at the given target node.PrivilegeCollectionusing regular JCR/Jackrabbit API, which might not be efficient. Implementations ofJackrabbitAccessControlManagerare therefore expected to overwrite the default.- Specified by:
getPrivilegeCollectionin interfaceJackrabbitAccessControlManager- Parameters:
absPath- An absolute path to an existing JCR node.- Returns:
- A
PrivilegeCollectionwrapping around the privileges granted for the editing session at absPath. - Throws:
PathNotFoundException- if no node atabsPathexists or the session does not have sufficient access to retrieve a node at that location.RepositoryException- If another error occurs.
-
getPrivilegeCollection
@NotNull public @NotNull PrivilegeCollection getPrivilegeCollection(@Nullable @Nullable java.lang.String absPath, @NotNull @NotNull java.util.Set<java.security.Principal> principals) throws RepositoryException
Description copied from interface:JackrabbitAccessControlManagerReturns the
Note: For backwards compatibility this method comes with a default implementation that computes thePrivilegeCollectionfor the given set of principals at the given absolute path, which must be an existing node. This is equivalent toJackrabbitAccessControlManager.getPrivileges(String,Set)andJackrabbitAccessControlManager.hasPrivileges(String, Set, Privilege[])but allows for easy resolution of aggregated privileges (like e.g. jcr:all) and repeated evaluation if the editing session has privileges granted at the given target node.PrivilegeCollectionusing regular JCR/Jackrabbit API, which might not be efficient. Implementations ofJackrabbitAccessControlManagerare therefore expected to overwrite the default.- Specified by:
getPrivilegeCollectionin interfaceJackrabbitAccessControlManager- Parameters:
absPath- An absolute path to an existing JCR node.principals- A set of principals for which thePrivilegeCollectionshould be created.- Returns:
- A
PrivilegeCollectionwrapping around the privileges granted for the editing session at absPath. - Throws:
PathNotFoundException- if no node atabsPathexists or the session does not have sufficient access to retrieve a node at that location.AccessDeniedException- if the session lacksREAD_ACCESS_CONTROLprivilege for theabsPathnode.RepositoryException- If another error occurs.
-
privilegeCollectionFromNames
@NotNull public @NotNull PrivilegeCollection privilegeCollectionFromNames(@NotNull @NotNull java.lang.String... privilegeNames) throws RepositoryException
Description copied from interface:JackrabbitAccessControlManagerReturns the
Note: For backwards compatibility this method comes with a default implementation that computes thePrivilegeCollectionfor the specifiedprivilegeNames. Since the privilege names are JCR names, they may be passed in either qualified or expanded form (see specification for details on JCR names).PrivilegeCollectionusing regular JCR/Jackrabbit API, which might not be efficient. Implementations ofJackrabbitAccessControlManagerare therefore expected to overwrite the default.- Specified by:
privilegeCollectionFromNamesin interfaceJackrabbitAccessControlManager- Parameters:
privilegeNames- the names of existing privilege.- Returns:
- the
PrivilegeCollectionrepresenting the specifiedprivilegeNames. - Throws:
AccessControlException- if no privilege with any of the specified names exists.RepositoryException- If another error occurs.
-
-