Interface JackrabbitAccessControlManager

  • All Superinterfaces:
    javax.jcr.security.AccessControlManager
    All Known Implementing Classes:
    AbstractAccessControlManager

    @ProviderType
    public interface JackrabbitAccessControlManager
    extends javax.jcr.security.AccessControlManager
    JackrabbitAccessControlManager provides extensions to the AccessControlManager interface.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      @NotNull JackrabbitAccessControlPolicy[] getApplicablePolicies​(@NotNull java.security.Principal principal)
      Returns the applicable policies for the specified principal or an empty array if no additional policies can be applied.
      @NotNull javax.jcr.security.AccessControlPolicy[] getEffectivePolicies​(@NotNull java.util.Set<java.security.Principal> principals)
      Returns the AccessControlPolicy objects that are in effect for the given Principals.
      default @NotNull java.util.Iterator<javax.jcr.security.AccessControlPolicy> getEffectivePolicies​(@NotNull java.util.Set<java.security.Principal> principals, @Nullable java.lang.String... absPaths)
      Returns the AccessControlPolicy objects that are in effect for the given Principals at the specified absolute paths.
      @NotNull JackrabbitAccessControlPolicy[] getPolicies​(@NotNull java.security.Principal principal)
      Returns the AccessControlPolicy objects that have been set for the given principal or an empty array if no policy has been set.
      default @NotNull PrivilegeCollection getPrivilegeCollection​(@Nullable java.lang.String absPath)
      Returns the PrivilegeCollection for editing session at the given absolute path, which must be an existing node.
      default @NotNull PrivilegeCollection getPrivilegeCollection​(@Nullable java.lang.String absPath, @NotNull java.util.Set<java.security.Principal> principals)
      Returns the PrivilegeCollection for the given set of principals at the given absolute path, which must be an existing node.
      @NotNull javax.jcr.security.Privilege[] getPrivileges​(@Nullable java.lang.String absPath, @NotNull java.util.Set<java.security.Principal> principals)
      Returns the privileges the given set of Principals has for absolute path absPath, which must be an existing node.
      boolean hasPrivileges​(@Nullable java.lang.String absPath, @NotNull java.util.Set<java.security.Principal> principals, @NotNull 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.
      default @NotNull PrivilegeCollection privilegeCollectionFromNames​(@NotNull java.lang.String... privilegeNames)
      Returns the PrivilegeCollection for the specified privilegeNames.
      • Methods inherited from interface javax.jcr.security.AccessControlManager

        getApplicablePolicies, getEffectivePolicies, getPolicies, getPrivileges, getSupportedPrivileges, hasPrivileges, privilegeFromName, removePolicy, setPolicy
    • Method Detail

      • getApplicablePolicies

        @NotNull
        @NotNull JackrabbitAccessControlPolicy[] getApplicablePolicies​(@NotNull
                                                                       @NotNull java.security.Principal principal)
                                                                throws javax.jcr.AccessDeniedException,
                                                                       javax.jcr.security.AccessControlException,
                                                                       javax.jcr.UnsupportedRepositoryOperationException,
                                                                       javax.jcr.RepositoryException
        Returns the applicable policies for the specified principal or an empty array if no additional policies can be applied.
        Parameters:
        principal - A principal known to the editing session.
        Returns:
        array of policies for the specified 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).
        Throws:
        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.
        See Also:
        JackrabbitAccessControlPolicy.getPath()
      • getPolicies

        @NotNull
        @NotNull JackrabbitAccessControlPolicy[] getPolicies​(@NotNull
                                                             @NotNull java.security.Principal principal)
                                                      throws javax.jcr.AccessDeniedException,
                                                             javax.jcr.security.AccessControlException,
                                                             javax.jcr.UnsupportedRepositoryOperationException,
                                                             javax.jcr.RepositoryException
        Returns the AccessControlPolicy 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.
        Parameters:
        principal - A valid principal.
        Returns:
        The policies defined for the given principal or an empty array.
        Throws:
        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.
      • getEffectivePolicies

        @NotNull
        @NotNull javax.jcr.security.AccessControlPolicy[] getEffectivePolicies​(@NotNull
                                                                               @NotNull java.util.Set<java.security.Principal> principals)
                                                                        throws javax.jcr.AccessDeniedException,
                                                                               javax.jcr.security.AccessControlException,
                                                                               javax.jcr.UnsupportedRepositoryOperationException,
                                                                               javax.jcr.RepositoryException
        Returns the AccessControlPolicy objects that are in effect for the given Principals. This may be policies set through this API or some implementation specific (default) policies.
        Parameters:
        principals - A set of valid principals.
        Returns:
        The policies defined for the given principal or an empty array.
        Throws:
        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.
      • getEffectivePolicies

        @NotNull
        default @NotNull java.util.Iterator<javax.jcr.security.AccessControlPolicy> getEffectivePolicies​(@NotNull
                                                                                                         @NotNull java.util.Set<java.security.Principal> principals,
                                                                                                         @Nullable
                                                                                                         @Nullable java.lang.String... absPaths)
                                                                                                  throws javax.jcr.AccessDeniedException,
                                                                                                         javax.jcr.security.AccessControlException,
                                                                                                         javax.jcr.UnsupportedRepositoryOperationException,
                                                                                                         javax.jcr.RepositoryException
        Returns the AccessControlPolicy objects that are in effect for the given Principals at the specified absolute paths. This may be policies set through this API or some implementation specific (default) policies. Note, that this method will make a best effort approach to reflect the effects of the existing access control setup. For backwards compatibility this new method comes with a default implementation that calls getEffectivePolicies(Set) followed by a best effort approach to determine effect on any of specified paths, which does not take the effect of restrictions into account.
        Parameters:
        principals - A set of valid principals for which the effective policies should be computed.
        absPaths - The absolute paths for which the effective policies should be computed. In contrast to AccessControlManager.getEffectivePolicies(String) this method does not mandate the paths to point to existing nodes.
        Returns:
        The policies defined for the given principal or an empty iterator.
        Throws:
        javax.jcr.AccessDeniedException - if the session lacks READ_ACCESS_CONTROL privilege to retrieve the information for the given principals or paths.
        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 or path is not supported or if this method is not implemented.
        javax.jcr.RepositoryException - If another error occurs.
        Since:
        Oak 1.52.0
      • hasPrivileges

        boolean hasPrivileges​(@Nullable
                              @Nullable java.lang.String absPath,
                              @NotNull
                              @NotNull java.util.Set<java.security.Principal> principals,
                              @NotNull
                              @NotNull javax.jcr.security.Privilege[] privileges)
                       throws javax.jcr.PathNotFoundException,
                              javax.jcr.AccessDeniedException,
                              javax.jcr.RepositoryException
        Returns whether the given set of Principals 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.

        Parameters:
        absPath - an absolute path.
        principals - a set of Principals for which is the given privileges are tested.
        privileges - an array of Privileges.
        Returns:
        true if the session has the specified privileges; false otherwise.
        Throws:
        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.
      • getPrivileges

        @NotNull
        @NotNull javax.jcr.security.Privilege[] getPrivileges​(@Nullable
                                                              @Nullable java.lang.String absPath,
                                                              @NotNull
                                                              @NotNull java.util.Set<java.security.Principal> principals)
                                                       throws javax.jcr.PathNotFoundException,
                                                              javax.jcr.AccessDeniedException,
                                                              javax.jcr.RepositoryException
        Returns the privileges the given set of Principals has for absolute path absPath, which must be an existing node.

        The returned privileges are those for which 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.

        Parameters:
        absPath - an absolute path.
        principals - a set of Principals for which is the privileges are retrieved.
        Returns:
        an array of Privileges.
        Throws:
        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.
      • getPrivilegeCollection

        @NotNull
        default @NotNull PrivilegeCollection getPrivilegeCollection​(@Nullable
                                                                    @Nullable java.lang.String absPath)
                                                             throws javax.jcr.RepositoryException

        Returns the PrivilegeCollection for editing session at the given absolute path, which must be an existing node. This is equivalent to AccessControlManager.getPrivileges(String) and AccessControlManager.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.

        Note: For backwards compatibility this method comes with a default implementation that computes the PrivilegeCollection using regular JCR/Jackrabbit API, which might not be efficient. Implementations of JackrabbitAccessControlManager are therefore expected to overwrite the default.
        Parameters:
        absPath - An absolute path to an existing JCR node.
        Returns:
        A PrivilegeCollection wrapping around the privileges granted for the editing session at absPath.
        Throws:
        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.RepositoryException - If another error occurs.
        Since:
        Oak 1.42.0
      • getPrivilegeCollection

        @NotNull
        default @NotNull PrivilegeCollection getPrivilegeCollection​(@Nullable
                                                                    @Nullable java.lang.String absPath,
                                                                    @NotNull
                                                                    @NotNull java.util.Set<java.security.Principal> principals)
                                                             throws javax.jcr.RepositoryException

        Returns the PrivilegeCollection for the given set of principals at the given absolute path, which must be an existing node. This is equivalent to getPrivileges(String,Set) and 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.

        Note: For backwards compatibility this method comes with a default implementation that computes the PrivilegeCollection using regular JCR/Jackrabbit API, which might not be efficient. Implementations of JackrabbitAccessControlManager are therefore expected to overwrite the default.
        Parameters:
        absPath - An absolute path to an existing JCR node.
        principals - A set of principals for which the PrivilegeCollection should be created.
        Returns:
        A PrivilegeCollection wrapping around the privileges granted for the editing session at absPath.
        Throws:
        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.
        Since:
        Oak 1.42.0
      • privilegeCollectionFromNames

        @NotNull
        default @NotNull PrivilegeCollection privilegeCollectionFromNames​(@NotNull
                                                                          @NotNull java.lang.String... privilegeNames)
                                                                   throws javax.jcr.RepositoryException

        Returns the PrivilegeCollection for the specified privilegeNames. Since the privilege names are JCR names, they may be passed in either qualified or expanded form (see specification for details on JCR names).

        Note: For backwards compatibility this method comes with a default implementation that computes the PrivilegeCollection using regular JCR/Jackrabbit API, which might not be efficient. Implementations of JackrabbitAccessControlManager are therefore expected to overwrite the default.
        Parameters:
        privilegeNames - the names of existing privilege.
        Returns:
        the PrivilegeCollection representing the specified privilegeNames.
        Throws:
        javax.jcr.security.AccessControlException - if no privilege with any of the specified names exists.
        javax.jcr.RepositoryException - If another error occurs.
        Since:
        Oak 1.42.0