Class PrincipalThreadContextListener

java.lang.Object
com.sap.cloud.sdk.cloudplatform.security.principal.PrincipalThreadContextListener
All Implemented Interfaces:
ThreadContextListener, Comparable<ThreadContextListener>

public class PrincipalThreadContextListener extends Object implements ThreadContextListener
Implementation of ThreadContextListener that ensures the correct initialization of Principals when working with non-container managed threads on all supported Cloud platforms.
  • Field Details

    • PROPERTY_PRINCIPAL

      public static final String PROPERTY_PRINCIPAL
      The ThreadContext key.
  • Constructor Details

    • PrincipalThreadContextListener

      public PrincipalThreadContextListener()
      Default constructor.
    • PrincipalThreadContextListener

      public PrincipalThreadContextListener(@Nonnull Principal principal)
      Constructor for providing a Principal to be returned by this listener.
      Parameters:
      principal - The Principal to be used by this listener.
  • Method Details

    • getPriority

      public int getPriority()
      Description copied from interface: ThreadContextListener
      Returns the priority that defines the order in which listeners are invoked. Smaller priorities are invoked earlier during context initialization and invoked later (reversed initialization order) during context destruction. Negative number must not be used as they are reserved for internal use.
      Specified by:
      getPriority in interface ThreadContextListener
      Returns:
      The priority of this listener implementation.
    • afterInitialize

      public void afterInitialize(@Nonnull ThreadContext threadContext)
      Description copied from interface: ThreadContextListener
      Invoked after the current ThreadContext is initialized and set.
      Specified by:
      afterInitialize in interface ThreadContextListener
      Parameters:
      threadContext - The ThreadContext that was initialized is now set.