public final class DelegatingSecurityContextRunnable
extends java.lang.Object
implements java.lang.Runnable
Wraps a delegate Runnable with logic for setting up a SecurityContext
before invoking the delegate Runnable and then removing the
SecurityContext after the delegate has completed.
If there is a SecurityContext that already exists, it will be
restored after the run() method is invoked.
| Constructor and Description |
|---|
DelegatingSecurityContextRunnable(java.lang.Runnable delegate)
Creates a new
DelegatingSecurityContextRunnable with the
SecurityContext from the SecurityContextHolder. |
DelegatingSecurityContextRunnable(java.lang.Runnable delegate,
SecurityContext securityContext)
Creates a new
DelegatingSecurityContextRunnable with a specific
SecurityContext. |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.Runnable |
create(java.lang.Runnable delegate,
SecurityContext securityContext)
Factory method for creating a
DelegatingSecurityContextRunnable. |
void |
run() |
java.lang.String |
toString() |
public DelegatingSecurityContextRunnable(java.lang.Runnable delegate,
SecurityContext securityContext)
DelegatingSecurityContextRunnable with a specific
SecurityContext.delegate - the delegate Runnable to run with the specified
SecurityContext. Cannot be null.securityContext - the SecurityContext to establish for the delegate
Runnable. Cannot be null.public DelegatingSecurityContextRunnable(java.lang.Runnable delegate)
DelegatingSecurityContextRunnable with the
SecurityContext from the SecurityContextHolder.delegate - the delegate Runnable to run under the current
SecurityContext. Cannot be null.public void run()
run in interface java.lang.Runnablepublic java.lang.String toString()
toString in class java.lang.Objectpublic static java.lang.Runnable create(java.lang.Runnable delegate,
SecurityContext securityContext)
DelegatingSecurityContextRunnable.delegate - the original Runnable that will be delegated to after
establishing a SecurityContext on the SecurityContextHolder. Cannot
have null.securityContext - the SecurityContext to establish before invoking the
delegate Runnable. If null, the current SecurityContext from the
SecurityContextHolder will be used.