Class GridGainSecurity

java.lang.Object
org.gridgain.internal.security.context.GridGainSecurity

public final class GridGainSecurity extends Object
DSL for running code with security context.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <T> T
    bypass(Supplier<T> supplier)
    Gets 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>
    Wrap callable with current security context set to the executor's thread local state.
    static org.gridgain.internal.security.context.SecurityContext
    context(String username, Set<String> roles)
    Create security context with given roles.
    static <T> T
    getWith(@Nullable org.gridgain.internal.security.context.SecurityContext ctx, Supplier<T> supplier)
    Gets a result of supplier wrapped with given security context.
    static org.gridgain.internal.security.context.SecurityContext
     
    static Runnable
    with(@Nullable org.gridgain.internal.security.context.SecurityContext ctx, Runnable runnable)
    Wrap runnable with given security context set to the executor's thread local state.
    static <T> Consumer<T>
    with(@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.
    static <T, R> Function<T,R>
    with(@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.
    static <T> Supplier<T>
    with(@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.
    static 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static <T> Callable<T> callWithContext(Callable<T> callable)
      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

      public static <T> Supplier<T> withContext(Supplier<T> supplier)
      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

      public static Runnable withContext(Runnable runnable)
      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

      public 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. 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

      public static <T> T bypass(Supplier<T> supplier)
      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()