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 Summary
ConstructorDescriptionDelegatingSecurityContextCallable
(Callable<V> delegate) Creates a newDelegatingSecurityContextCallable
with theSecurityContext
from theSecurityContextHolder
.DelegatingSecurityContextCallable
(Callable<V> delegate, SecurityContext securityContext) Creates a newDelegatingSecurityContextCallable
with a specificSecurityContext
. -
Method Summary
Modifier and TypeMethodDescriptioncall()
static <V> Callable<V>
create
(Callable<V> delegate, SecurityContext securityContext) Creates aDelegatingSecurityContextCallable
and with the givenCallable
andSecurityContext
, but if the securityContext is null will defaults to the currentSecurityContext
on theSecurityContextHolder
toString()
-
Constructor Details
-
DelegatingSecurityContextCallable
Creates a newDelegatingSecurityContextCallable
with a specificSecurityContext
.- Parameters:
delegate
- the delegateDelegatingSecurityContextCallable
to run with the specifiedSecurityContext
. Cannot be null.securityContext
- theSecurityContext
to establish for the delegateCallable
. Cannot be null.
-
DelegatingSecurityContextCallable
Creates a newDelegatingSecurityContextCallable
with theSecurityContext
from theSecurityContextHolder
.- Parameters:
delegate
- the delegateCallable
to run under the currentSecurityContext
. Cannot be null.
-
-
Method Details
-
call
-
toString
-
create
Creates aDelegatingSecurityContextCallable
and with the givenCallable
andSecurityContext
, but if the securityContext is null will defaults to the currentSecurityContext
on theSecurityContextHolder
- Parameters:
delegate
- the delegateDelegatingSecurityContextCallable
to run with the specifiedSecurityContext
. Cannot be null.securityContext
- theSecurityContext
to establish for the delegateCallable
. If null, defaults toSecurityContextHolder.getContext()
- Returns:
-