public class PermissionHelper
extends java.lang.Object
| Constructor and Description |
|---|
PermissionHelper() |
| Modifier and Type | Method and Description |
|---|---|
static <E,A extends E> |
applyAllowed(java.util.Collection<E> elements,
java.util.Collection<A> allowed)
Basically 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, throws a
PermissionDeniedException. |
static <T> void |
checkContains(java.util.Collection<? super T> allowed,
T element)
Throws a
PermissionDeniedException if allowed is empty or not contains the given element |
static void |
checkContainsId(java.util.Collection<? extends IEntity> entities,
java.lang.Long id)
Checks whether the given entity collection contains the given id
|
static void |
checkEquals(java.lang.Object expected,
java.lang.Object actual)
Throws a
PermissionDeniedException if expected is not the same as actual |
static void |
checkNotEmpty(java.util.Collection<?> collection)
Throws a
PermissionDeniedException if the given collection is empty |
static void |
checkNotNull(java.lang.Object object)
Throws a
PermissionDeniedException if the given object is null |
static <T> java.util.Collection<T> |
checkSelection(java.util.Collection<T> allowed,
java.util.Collection<T> selection)
Same as
checkSelection(Collection, Collection, boolean) but not supporting an empty collection for the
allowed elements. |
static <T> java.util.Collection<T> |
checkSelection(java.util.Collection<T> allowed,
java.util.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. |
static boolean |
hasRole(RoleContainer container,
Role role)
Returns whether the given
RoleContainer has the given Role |
public static <E,A extends E> java.util.Set<E> applyAllowed(java.util.Collection<E> elements,
java.util.Collection<A> allowed)
PermissionDeniedException.
If elements or elements.retainAll(allowed) are empty, then allowed is returned.
Otherwise, returns elements.retainAll(allowed).public static <T> void checkContains(java.util.Collection<? super T> allowed,
T element)
PermissionDeniedException if allowed is empty or not contains the given elementpublic static void checkContainsId(java.util.Collection<? extends IEntity> entities, java.lang.Long id)
public static void checkEquals(java.lang.Object expected,
java.lang.Object actual)
PermissionDeniedException if expected is not the same as actualpublic static void checkNotEmpty(java.util.Collection<?> collection)
PermissionDeniedException if the given collection is emptypublic static void checkNotNull(java.lang.Object object)
PermissionDeniedException if the given object is nullpublic static <T> java.util.Collection<T> checkSelection(java.util.Collection<T> allowed,
java.util.Collection<T> selection)
checkSelection(Collection, Collection, boolean) but not supporting an empty collection for the
allowed elements.public static <T> java.util.Collection<T> checkSelection(java.util.Collection<T> allowed,
java.util.Collection<T> selection,
boolean isEmptyAllowedSupported)
public static boolean hasRole(RoleContainer container, Role role)
RoleContainer has the given Role