Class PermissionHelper


  • public class PermissionHelper
    extends Object
    Contains helper methods for permission checks
    • Constructor Detail

      • PermissionHelper

        public PermissionHelper()
    • Method Detail

      • allRoles

        public static Set<Role> allRoles​(RoleContainer container)
        Returns all roles the given role container has
      • checkContains

        public static <T> void checkContains​(Collection<? super T> allowed,
                                             T element)
        Throws a PermissionDeniedException if allowed is empty or not contains the given element
      • checkContainsId

        public static void checkContainsId​(Collection<? extends IEntity> entities,
                                           Long id)
        Checks whether the given entity collection contains the given id
      • checkSelection

        public static <T> Collection<T> checkSelection​(Collection<T> allowed,
                                                       Collection<T> selection,
                                                       boolean isEmptyAllowedSupported)
        Used for query filter semantics with collections.
        Given a collection with the selected elements and another one with the allowed elements:
        If the allowed elements are empty (and empty for the allowed is not supported) it throws a PermissionDeniedException. Else, if elements is empty, then allowed is returned. Otherwise, the selected elements must be contained in the allowed collection.