org.springframework.security.concurrent
Class DelegatingSecurityContextCallable<V>

java.lang.Object
  extended by org.springframework.security.concurrent.DelegatingSecurityContextCallable<V>
All Implemented Interfaces:
Callable<V>

public final class DelegatingSecurityContextCallable<V>
extends Object
implements 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.

Since:
3.2

Constructor Summary
DelegatingSecurityContextCallable(Callable<V> delegate)
          Creates a new DelegatingSecurityContextCallable with the SecurityContext from the SecurityContextHolder.
DelegatingSecurityContextCallable(Callable<V> delegate, SecurityContext securityContext)
          Creates a new DelegatingSecurityContextCallable with a specific SecurityContext.
 
Method Summary
 V call()
           
static
<V> Callable<V>
create(Callable<V> delegate, SecurityContext securityContext)
          Creates a DelegatingSecurityContextCallable and with the given Callable and SecurityContext, but if the securityContext is null will defaults to the current SecurityContext on the SecurityContextHolder
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DelegatingSecurityContextCallable

public DelegatingSecurityContextCallable(Callable<V> delegate,
                                         SecurityContext securityContext)
Creates a new DelegatingSecurityContextCallable with a specific SecurityContext.

Parameters:
delegate - the delegate DelegatingSecurityContextCallable to run with the specified SecurityContext. Cannot be null.
securityContext - the SecurityContext to establish for the delegate Callable. Cannot be null.

DelegatingSecurityContextCallable

public DelegatingSecurityContextCallable(Callable<V> delegate)
Creates a new DelegatingSecurityContextCallable with the SecurityContext from the SecurityContextHolder.

Parameters:
delegate - the delegate Callable to run under the current SecurityContext. Cannot be null.
Method Detail

call

public V call()
       throws Exception
Specified by:
call in interface Callable<V>
Throws:
Exception

create

public static <V> Callable<V> create(Callable<V> delegate,
                                     SecurityContext securityContext)
Creates a DelegatingSecurityContextCallable and with the given Callable and SecurityContext, but if the securityContext is null will defaults to the current SecurityContext on the SecurityContextHolder

Parameters:
delegate - the delegate DelegatingSecurityContextCallable to run with the specified SecurityContext. Cannot be null.
securityContext - the SecurityContext to establish for the delegate Callable. If null, defaults to SecurityContextHolder.getContext()
Returns: