Class JmixSecurityContextHolderStrategy

java.lang.Object
io.jmix.flowui.sys.JmixSecurityContextHolderStrategy
All Implemented Interfaces:
ThreadSecurityContextOverride, org.springframework.security.core.context.SecurityContextHolderStrategy

@NullMarked public class JmixSecurityContextHolderStrategy extends Object implements org.springframework.security.core.context.SecurityContextHolderStrategy, ThreadSecurityContextOverride
SecurityContextHolderStrategy for FlowUI applications.

Delegates to Vaadin's VaadinAwareSecurityContextHolderStrategy, which prefers the security context stored in the current Vaadin session over the thread-local one. On top of that, it lets SystemAuthenticator install a context that takes precedence for the current thread only, so that begin()/end() take effect on UI threads and never modify the context shared by all threads of the HTTP session.

setContext(SecurityContext) replaces the context within the current override, preserving the enclosing scopes. clearContext() drops all overrides when a request or task releases its thread.

  • Constructor Details

    • JmixSecurityContextHolderStrategy

      public JmixSecurityContextHolderStrategy()
    • JmixSecurityContextHolderStrategy

      public JmixSecurityContextHolderStrategy(org.springframework.security.core.context.SecurityContextHolderStrategy delegate)
  • Method Details

    • getContext

      public org.springframework.security.core.context.SecurityContext getContext()
      Specified by:
      getContext in interface org.springframework.security.core.context.SecurityContextHolderStrategy
    • getDeferredContext

      public Supplier<org.springframework.security.core.context.SecurityContext> getDeferredContext()
      Specified by:
      getDeferredContext in interface org.springframework.security.core.context.SecurityContextHolderStrategy
    • setContext

      public void setContext(org.springframework.security.core.context.SecurityContext context)
      Specified by:
      setContext in interface org.springframework.security.core.context.SecurityContextHolderStrategy
    • setDeferredContext

      public void setDeferredContext(Supplier<org.springframework.security.core.context.SecurityContext> deferredContext)
      Specified by:
      setDeferredContext in interface org.springframework.security.core.context.SecurityContextHolderStrategy
    • clearContext

      public void clearContext()
      Specified by:
      clearContext in interface org.springframework.security.core.context.SecurityContextHolderStrategy
    • createEmptyContext

      public org.springframework.security.core.context.SecurityContext createEmptyContext()
      Specified by:
      createEmptyContext in interface org.springframework.security.core.context.SecurityContextHolderStrategy
    • pushContext

      public void pushContext(org.springframework.security.core.context.SecurityContext context)
      Description copied from interface: ThreadSecurityContextOverride
      Makes the given context the one returned by getContext() on the current thread until a matching ThreadSecurityContextOverride.popContext() call.
      Specified by:
      pushContext in interface ThreadSecurityContextOverride
    • popContext

      public void popContext()
      Description copied from interface: ThreadSecurityContextOverride
      Removes the most recently pushed override from the current thread. Does nothing if there is no override.
      Specified by:
      popContext in interface ThreadSecurityContextOverride