| Modifier and Type | Method and Description |
|---|---|
static <T> T |
executeWithFallbackPrincipal(Supplier<Principal> fallbackPrincipal,
Callable<T> callable)
Execute the given
Callable, using the given principal as fallback if there is no other principal
available. |
static void |
executeWithFallbackPrincipal(Supplier<Principal> fallbackPrincipal,
Executable executable)
Execute the given
Executable, using the given principal as fallback if there is no other principal
available. |
static <T> T |
executeWithPrincipal(Principal principal,
Callable<T> callable)
Execute the given
Callable on behalf of a given principal. |
static void |
executeWithPrincipal(Principal principal,
Executable executable)
Execute the given
Executable on behalf of a given principal. |
static Principal |
getCurrentPrincipal()
Returns the current
Principal. |
static Supplier<Principal> |
getFallbackPrincipal()
Global fallback
Principal. |
static PrincipalFacade |
getPrincipalFacade()
Returns the
PrincipalFacade instance. |
static void |
setFallbackPrincipal(Supplier<Principal> fallbackPrincipal)
Global fallback
Principal. |
static void |
setPrincipalFacade(PrincipalFacade principalFacade)
Replaces the default
PrincipalFacade instance. |
static io.vavr.control.Try<Principal> |
tryGetCurrentPrincipal()
|
static io.vavr.control.Try<PrincipalFacade> |
tryGetPrincipalFacade()
Returns a
Try of the PrincipalFacade instance. |
@Nullable public static PrincipalFacade getPrincipalFacade()
PrincipalFacade instance.PrincipalFacade instance, or null.@Nonnull public static io.vavr.control.Try<PrincipalFacade> tryGetPrincipalFacade()
Try of the PrincipalFacade instance.Try of the PrincipalFacade instance.public static void setPrincipalFacade(@Nullable PrincipalFacade principalFacade)
PrincipalFacade instance.principalFacade - An instance of PrincipalFacade. Use null to reset the facade.@Nonnull public static Principal getCurrentPrincipal() throws PrincipalAccessException
Principal.Principal.PrincipalAccessException - If there is an issue while accessing the Principal.@Nonnull public static io.vavr.control.Try<Principal> tryGetCurrentPrincipal()
Try of the current Principal.@Nullable public static <T> T executeWithPrincipal(@Nonnull Principal principal, @Nonnull Callable<T> callable) throws ThreadContextExecutionException
Callable on behalf of a given principal.T - The type of the callable.principal - The principal to execute on behalf of.callable - The callable to execute.ThreadContextExecutionException - If there is an issue while running the code on behalf of the principal.public static void executeWithPrincipal(@Nonnull Principal principal, @Nonnull Executable executable) throws ThreadContextExecutionException
Executable on behalf of a given principal.principal - The principal to execute on behalf of.executable - The executable to execute.ThreadContextExecutionException - If there is an issue while running the code on behalf of the principal.@Nullable public static <T> T executeWithFallbackPrincipal(@Nonnull Supplier<Principal> fallbackPrincipal, @Nonnull Callable<T> callable) throws ThreadContextExecutionException
Callable, using the given principal as fallback if there is no other principal
available.T - The type of the callable.fallbackPrincipal - The principal to fall back to.callable - The callable to execute.ThreadContextExecutionException - If there is an issue while running the code on behalf of the principal.public static void executeWithFallbackPrincipal(@Nonnull Supplier<Principal> fallbackPrincipal, @Nonnull Executable executable) throws ThreadContextExecutionException
Executable, using the given principal as fallback if there is no other principal
available.fallbackPrincipal - The principal to fall back to.executable - The executable to execute.ThreadContextExecutionException - If there is an issue while running the code on behalf of the principal.@Nullable public static Supplier<Principal> getFallbackPrincipal()
Principal. By default, no fallback is used, i.e., the fallback is null. A global
fallback can be useful to ensure a safe fallback or to ease testing with a mocked principal.Copyright © 2021 SAP SE. All rights reserved.