Interface SecurityContextHolderStrategy
-
- All Known Implementing Classes:
ListeningSecurityContextHolderStrategy
,TestSecurityContextHolderStrategyAdapter
public interface SecurityContextHolderStrategy
A strategy for storing security context information against a thread.The preferred strategy is loaded by
SecurityContextHolder
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
clearContext()
Clears the current context.SecurityContext
createEmptyContext()
Creates a new, empty context implementation, for use by SecurityContextRepository implementations, when creating a new context for the first time.SecurityContext
getContext()
Obtains the current context.default java.util.function.Supplier<SecurityContext>
getDeferredContext()
Obtains aSupplier
that returns the current context.void
setContext(SecurityContext context)
Sets the current context.default void
setDeferredContext(java.util.function.Supplier<SecurityContext> deferredContext)
Sets aSupplier
that will return the current context.
-
-
-
Method Detail
-
clearContext
void clearContext()
Clears the current context.
-
getContext
SecurityContext getContext()
Obtains the current context.- Returns:
- a context (never
null
- create a default implementation if necessary)
-
getDeferredContext
default java.util.function.Supplier<SecurityContext> getDeferredContext()
Obtains aSupplier
that returns the current context.- Returns:
- a
Supplier
that returns the current context (nevernull
- create a default implementation if necessary) - Since:
- 5.8
-
setContext
void setContext(SecurityContext context)
Sets the current context.- Parameters:
context
- to the new argument (should never benull
, although implementations must check ifnull
has been passed and throw anIllegalArgumentException
in such cases)
-
setDeferredContext
default void setDeferredContext(java.util.function.Supplier<SecurityContext> deferredContext)
Sets aSupplier
that will return the current context. Implementations can override the default to avoid invokingSupplier.get()
.- Parameters:
deferredContext
- aSupplier
that returns theSecurityContext
- Since:
- 5.8
-
createEmptyContext
SecurityContext createEmptyContext()
Creates a new, empty context implementation, for use by SecurityContextRepository implementations, when creating a new context for the first time.- Returns:
- the empty context.
-
-