Class SecurityContextHolder

java.lang.Object
com.codename1.backend.security.SecurityContextHolder

public final class SecurityContextHolder extends Object

Who the calling thread's request is from.

Authentication who = SecurityContextHolder.getContext().getAuthentication();

The context belongs to the thread serving a request, for the length of that request: the chain that guards the request fills it in, and the server clears it when the request ends. It does not follow work handed to another thread -- an @Async method or a scheduled job starts with none.

  • Method Details

    • getContext

      public static SecurityContext getContext()
      The thread's context; an empty one is made when there is none.
    • setContext

      public static void setContext(SecurityContext context)
      Replaces the thread's context.
    • clearContext

      public static void clearContext()
      Forgets the thread's context.
    • createEmptyContext

      public static SecurityContext createEmptyContext()
      A context with no authentication in it.