Class DelegatingSecurityContextCallable<V>
java.lang.Object
org.springframework.security.concurrent.DelegatingSecurityContextCallable<V>
- All Implemented Interfaces:
- Callable<V>
 Wraps a delegate Callable with logic for setting up a SecurityContext
 before invoking the delegate Callable and then removing the
 SecurityContext after the delegate has completed.
 
 If there is a SecurityContext that already exists, it will be restored after
 the call() method is invoked.
 
- Since:
- 3.2
- 
Constructor SummaryConstructorsConstructorDescriptionDelegatingSecurityContextCallable(Callable<V> delegate) Creates a newDelegatingSecurityContextCallablewith theSecurityContextfrom theSecurityContextHolder.DelegatingSecurityContextCallable(Callable<V> delegate, SecurityContext securityContext) Creates a newDelegatingSecurityContextCallablewith a specificSecurityContext.
- 
Method SummaryModifier and TypeMethodDescriptioncall()static <V> Callable<V>create(Callable<V> delegate, SecurityContext securityContext) Creates aDelegatingSecurityContextCallableand with the givenCallableandSecurityContext, but if the securityContext is null will defaults to the currentSecurityContexton theSecurityContextHoldervoidsetSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategyto use.toString()
- 
Constructor Details- 
DelegatingSecurityContextCallableCreates a newDelegatingSecurityContextCallablewith a specificSecurityContext.- Parameters:
- delegate- the delegate- DelegatingSecurityContextCallableto run with the specified- SecurityContext. Cannot be null.
- securityContext- the- SecurityContextto establish for the delegate- Callable. Cannot be null.
 
- 
DelegatingSecurityContextCallableCreates a newDelegatingSecurityContextCallablewith theSecurityContextfrom theSecurityContextHolder.- Parameters:
- delegate- the delegate- Callableto run under the current- SecurityContext. Cannot be null.
 
 
- 
- 
Method Details- 
call
- 
setSecurityContextHolderStrategypublic void setSecurityContextHolderStrategy(SecurityContextHolderStrategy securityContextHolderStrategy) Sets theSecurityContextHolderStrategyto use. The default action is to use theSecurityContextHolderStrategystored inSecurityContextHolder.- Since:
- 5.8
 
- 
toString
- 
createCreates aDelegatingSecurityContextCallableand with the givenCallableandSecurityContext, but if the securityContext is null will defaults to the currentSecurityContexton theSecurityContextHolder- Parameters:
- delegate- the delegate- DelegatingSecurityContextCallableto run with the specified- SecurityContext. Cannot be null.
- securityContext- the- SecurityContextto establish for the delegate- Callable. If null, defaults to- SecurityContextHolder.getContext()
- Returns:
 
 
-