Class SpringSecurityContextManager
- java.lang.Object
-
- nl.talsmasoftware.context.springsecurity.SpringSecurityContextManager
-
- All Implemented Interfaces:
Clearable,ClearableContextManager<Authentication>,ContextManager<Authentication>
public class SpringSecurityContextManager extends Object implements ClearableContextManager<Authentication>
A context manager that propagates spring-securityAuthenticationobjects into background threads using theContextAwareExecutorService.Management of the authentication is fully delegated to the Spring
SecurityContextHolder, so no additionalThreadLocalvariables are used.- Author:
- Sjoerd Talsma
-
-
Constructor Summary
Constructors Constructor Description SpringSecurityContextManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Clears the Spring SecurityContext by calling SecurityContextHolder.clearContext().Context<Authentication>getActiveContext()The currently active context, ornullif no context is active.Context<Authentication>initializeNewContext(Authentication value)Creates a new Spring SecurityContext and sets the value in it.
-
-
-
Method Detail
-
initializeNewContext
public Context<Authentication> initializeNewContext(Authentication value)
Creates a new Spring SecurityContext and sets the value in it.This new value is set in the SecurityContextHolder and the current Authentication is remembered, to be restored when the returned
Contextis closed.- Specified by:
initializeNewContextin interfaceContextManager<Authentication>- Parameters:
value- The value to initialize a new context for.- Returns:
- A context with the new Authentication, restoring the previous authentication when closed.
-
getActiveContext
public Context<Authentication> getActiveContext()
Description copied from interface:ContextManagerThe currently active context, ornullif no context is active.- Specified by:
getActiveContextin interfaceContextManager<Authentication>- Returns:
- A context object referring to the current
Authenticationin the spring security context holder. Closing the returned context does nothing.
-
clear
public void clear()
Clears the Spring SecurityContext by calling SecurityContextHolder.clearContext().
-
-