Interface ThreadSecurityContextOverride

All Known Implementing Classes:
JmixSecurityContextHolderStrategy

@NullMarked public interface ThreadSecurityContextOverride
Optional capability of a SecurityContextHolderStrategy: lets the current thread temporarily override the SecurityContext returned by SecurityContextHolder.getContext(), regardless of where the strategy would otherwise take the context from (for example, from the current Vaadin session).

Used by SystemAuthenticator to make begin()/end() affect the current thread only. If the installed strategy does not implement this interface, SystemAuthenticator falls back to SecurityContextHolder.setContext(SecurityContext), which is sufficient for a plain thread-local strategy.

Implementations must keep a per-thread stack so that nested overrides work. SecurityContextHolderStrategy.setContext(SecurityContext) must replace the current override without discarding the enclosing scopes. SecurityContextHolderStrategy.clearContext() must clear the stack when a request or task releases its thread.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Removes the most recently pushed override from the current thread.
    void
    pushContext(org.springframework.security.core.context.SecurityContext context)
    Makes the given context the one returned by getContext() on the current thread until a matching popContext() call.
  • Method Details

    • pushContext

      void pushContext(org.springframework.security.core.context.SecurityContext context)
      Makes the given context the one returned by getContext() on the current thread until a matching popContext() call.
    • popContext

      void popContext()
      Removes the most recently pushed override from the current thread. Does nothing if there is no override.