Class GridGainSecurity
java.lang.Object
org.gridgain.internal.security.context.GridGainSecurity
DSL for running code with security context.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TGets a result of supplier wrapped with system bypass security context.static <T> Callable<T>callWith(@Nullable org.gridgain.internal.security.context.SecurityContext ctx, Callable<T> callable) Wrap callable with given security context set to the executor's thread local state.static <T> Callable<T>callWithContext(Callable<T> callable) Wrap callable with current security context set to the executor's thread local state.static org.gridgain.internal.security.context.SecurityContextCreate security context with given roles.static <T> TGets a result of supplier wrapped with given security context.static org.gridgain.internal.security.context.SecurityContextstatic RunnableWrap runnable with given security context set to the executor's thread local state.static <T> Consumer<T>Wrap consumer with given security context set to the executor's thread local state.static <T,R> Function<T, R> Wrap function with given security context set to the executor's thread local state.static <T> Supplier<T>Wrap supplier with given security context set to the executor's thread local state.static RunnablewithContext(Runnable runnable) Wrap runnable with current security context set to the executor's thread local state.static <T,R> Function<T, R> withContext(Function<T, R> function) Wrap function with current security context set to the executor's thread local state.static <T> Supplier<T>withContext(Supplier<T> supplier) Wrap supplier with current security context set to the executor's thread local state.
-
Constructor Details
-
GridGainSecurity
public GridGainSecurity()
-
-
Method Details
-
callWith
public static <T> Callable<T> callWith(@Nullable @Nullable org.gridgain.internal.security.context.SecurityContext ctx, Callable<T> callable) Wrap callable with given security context set to the executor's thread local state.- Type Parameters:
T- type of callable result.- Parameters:
ctx- security context.callable- callable to wrap.- Returns:
- wrapped callable with security context set.
-
with
public static <T> Supplier<T> with(@Nullable @Nullable org.gridgain.internal.security.context.SecurityContext ctx, Supplier<T> supplier) Wrap supplier with given security context set to the executor's thread local state.- Type Parameters:
T- type of supplier result.- Parameters:
ctx- security context.supplier- supplier to wrap.- Returns:
- wrapped supplier with security context.
-
with
public static <T> Consumer<T> with(@Nullable @Nullable org.gridgain.internal.security.context.SecurityContext ctx, Consumer<T> consumer) Wrap consumer with given security context set to the executor's thread local state.- Type Parameters:
T- The input argument type of consumer.- Parameters:
ctx- security context.consumer- consumer to wrap.- Returns:
- wrapped consumer with security context.
-
with
public static Runnable with(@Nullable @Nullable org.gridgain.internal.security.context.SecurityContext ctx, Runnable runnable) Wrap runnable with given security context set to the executor's thread local state.- Parameters:
ctx- security context.runnable- runnable to wrap.- Returns:
- wrapped runnable with security context.
-
with
public static <T,R> Function<T,R> with(@Nullable @Nullable org.gridgain.internal.security.context.SecurityContext ctx, Function<T, R> function) Wrap function with given security context set to the executor's thread local state.- Type Parameters:
T- the type of the input to the function.R- the type of the result of the function.- Parameters:
ctx- security context.function- function to wrap.- Returns:
- wrapped function with security.
- Throws:
SecurityContextIsNotSetException- if security context is not set.
-
callWithContext
Wrap callable with current security context set to the executor's thread local state. The context is propagated from the current thread into the executor's thread.- Type Parameters:
T- type of callable result.- Parameters:
callable- callable to wrap.- Returns:
- wrapped callable with security.
- Throws:
SecurityContextIsNotSetException- if security context is not set.
-
withContext
Wrap supplier with current security context set to the executor's thread local state. The context is propagated from the current thread into the executor's thread.- Type Parameters:
T- type of supplier result.- Parameters:
supplier- supplier to wrap.- Returns:
- wrapped supplier with security.
- Throws:
SecurityContextIsNotSetException- if security context is not set.
-
withContext
Wrap runnable with current security context set to the executor's thread local state. The context is propagated from the current thread into the executor's thread.- Parameters:
runnable- runnable to wrap.- Returns:
- wrapped runnable with security.
- Throws:
SecurityContextIsNotSetException- if security context is not set.
-
withContext
Wrap function with current security context set to the executor's thread local state. The context is propagated from the current thread into the executor's thread.- Type Parameters:
T- the type of the input to the function.R- the type of the result of the function.- Parameters:
function- function to wrap.- Returns:
- wrapped function with security.
- Throws:
SecurityContextIsNotSetException- if security context is not set.
-
context
public static org.gridgain.internal.security.context.SecurityContext context(String username, Set<String> roles) Create security context with given roles.- Parameters:
username- username.roles- roles.- Returns:
- security context.
-
bypass
Gets a result of supplier wrapped with system bypass security context.- Parameters:
supplier- supplier to wrap.- Returns:
- Result of wrapped supplier.
-
getWith
public static <T> T getWith(@Nullable @Nullable org.gridgain.internal.security.context.SecurityContext ctx, Supplier<T> supplier) Gets a result of supplier wrapped with given security context.- Parameters:
ctx- security context.supplier- supplier to wrap.- Returns:
- Result of wrapped supplier.
-
systemContext
public static org.gridgain.internal.security.context.SecurityContext systemContext()
-