Class NullSecurityContextRepository

All Implemented Interfaces:

public final class NullSecurityContextRepository extends Object implements SecurityContextRepository
  • Constructor Details

    • NullSecurityContextRepository

      public NullSecurityContextRepository()
  • Method Details

    • containsContext

      public boolean containsContext(jakarta.servlet.http.HttpServletRequest request)
      Description copied from interface: SecurityContextRepository
      Allows the repository to be queried as to whether it contains a security context for the current request.
      Specified by:
      containsContext in interface SecurityContextRepository
      request - the current request
      true if a context is found for the request, false otherwise
    • loadContext

      public SecurityContext loadContext(HttpRequestResponseHolder requestResponseHolder)
      Description copied from interface: SecurityContextRepository
      Obtains the security context for the supplied request. For an unauthenticated user, an empty context implementation should be returned. This method should not return null.

      The use of the HttpRequestResponseHolder parameter allows implementations to return wrapped versions of the request or response (or both), allowing them to access implementation-specific state for the request. The values obtained from the holder will be passed on to the filter chain and also to the saveContext method when it is finally called to allow implicit saves of the SecurityContext. Implementations may wish to return a subclass of SaveContextOnUpdateOrErrorResponseWrapper as the response object, which guarantees that the context is persisted when an error or redirect occurs. Implementations may allow passing in the original request response to allow explicit saves.

      Specified by:
      loadContext in interface SecurityContextRepository
      requestResponseHolder - holder for the current request and response for which the context should be loaded.
      The security context which should be used for the current request, never null.
    • saveContext

      public void saveContext(SecurityContext context, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
      Description copied from interface: SecurityContextRepository
      Stores the security context on completion of a request.
      Specified by:
      saveContext in interface SecurityContextRepository
      context - the non-null context which was obtained from the holder.
    • setSecurityContextHolderStrategy

      public void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy)
      Sets the SecurityContextHolderStrategy to use. The default action is to use the SecurityContextHolderStrategy stored in SecurityContextHolder.