congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
DelegatingSecurityContextRunnable
Code IndexAdd Tabnine to your IDE (free)

How to use
DelegatingSecurityContextRunnable
in
org.springframework.security.concurrent

Best Java code snippets using org.springframework.security.concurrent.DelegatingSecurityContextRunnable (Showing top 20 results out of 315)

origin: spring-projects/spring-security

  /**
   * Factory method for creating a {@link DelegatingSecurityContextRunnable}.
   *
   * @param delegate the original {@link Runnable} that will be delegated to after
   * establishing a {@link SecurityContext} on the {@link SecurityContextHolder}. Cannot
   * have null.
   * @param securityContext the {@link SecurityContext} to establish before invoking the
   * delegate {@link Runnable}. If null, the current {@link SecurityContext} from the
   * {@link SecurityContextHolder} will be used.
   * @return
   */
  public static Runnable create(Runnable delegate, SecurityContext securityContext) {
    Assert.notNull(delegate, "delegate cannot be  null");
    return securityContext == null ? new DelegatingSecurityContextRunnable(delegate)
        : new DelegatingSecurityContextRunnable(delegate, securityContext);
  }
}
origin: spring-projects/spring-security

protected final Runnable wrap(Runnable delegate) {
  return DelegatingSecurityContextRunnable.create(delegate, securityContext);
}
origin: org.springframework.security/spring-security-core

  /**
   * Factory method for creating a {@link DelegatingSecurityContextRunnable}.
   *
   * @param delegate the original {@link Runnable} that will be delegated to after
   * establishing a {@link SecurityContext} on the {@link SecurityContextHolder}. Cannot
   * have null.
   * @param securityContext the {@link SecurityContext} to establish before invoking the
   * delegate {@link Runnable}. If null, the current {@link SecurityContext} from the
   * {@link SecurityContextHolder} will be used.
   * @return
   */
  public static Runnable create(Runnable delegate, SecurityContext securityContext) {
    Assert.notNull(delegate, "delegate cannot be  null");
    return securityContext == null ? new DelegatingSecurityContextRunnable(delegate)
        : new DelegatingSecurityContextRunnable(delegate, securityContext);
  }
}
origin: org.springframework.security/spring-security-core

protected final Runnable wrap(Runnable delegate) {
  return DelegatingSecurityContextRunnable.create(delegate, securityContext);
}
origin: spring-projects/spring-security

@Test(expected = IllegalArgumentException.class)
public void constructorNullDelegate() {
  new DelegatingSecurityContextRunnable(null);
}
origin: spring-projects/spring-security

@Test(expected = IllegalArgumentException.class)
public void createNullDelegateAndSecurityContext() {
  DelegatingSecurityContextRunnable.create(null, null);
}
origin: spring-projects/spring-security

@Test
public void toStringDelegates() {
  runnable = new DelegatingSecurityContextRunnable(delegate, securityContext);
  assertThat(runnable.toString()).isEqualTo(delegate.toString());
}
origin: spring-projects/spring-security

@Test(expected = IllegalArgumentException.class)
public void createNullDelegate() {
  DelegatingSecurityContextRunnable.create(null, securityContext);
}
origin: spring-projects/spring-security

@Test(expected = IllegalArgumentException.class)
public void constructorNullDelegateNonNullSecurityContext() {
  new DelegatingSecurityContextRunnable(null, securityContext);
}
origin: spring-projects/spring-security

@Test(expected = IllegalArgumentException.class)
public void createNullDelegateAndSecurityContext() {
  DelegatingSecurityContextRunnable.create(null, null);
}
origin: spring-projects/spring-security

@Test(expected = IllegalArgumentException.class)
public void constructorNullSecurityContext() {
  new DelegatingSecurityContextRunnable(delegate, null);
}
origin: spring-projects/spring-security

@Test
public void create() throws Exception {
  runnable = DelegatingSecurityContextRunnable.create(delegate, securityContext);
  assertWrapped(runnable);
}
origin: spring-projects/spring-security

@Test(expected = IllegalArgumentException.class)
public void constructorNullDelegateAndSecurityContext() {
  new DelegatingSecurityContextRunnable(null, null);
}
origin: spring-projects/spring-security

@Test
public void createNullSecurityContext() throws Exception {
  SecurityContextHolder.setContext(securityContext);
  runnable = DelegatingSecurityContextRunnable.create(delegate, null);
  SecurityContextHolder.clearContext(); // ensure runnable is what sets up the
                      // SecurityContextHolder
  assertWrapped(runnable);
}
origin: spring-projects/spring-security

@Test
public void call() throws Exception {
  runnable = new DelegatingSecurityContextRunnable(delegate, securityContext);
  assertWrapped(runnable);
}
origin: apache/servicemix-bundles

protected final Runnable wrap(Runnable delegate) {
  return DelegatingSecurityContextRunnable.create(delegate, securityContext);
}
origin: spring-projects/spring-security

@Test
public void callDefaultSecurityContext() throws Exception {
  SecurityContextHolder.setContext(securityContext);
  runnable = new DelegatingSecurityContextRunnable(delegate);
  SecurityContextHolder.clearContext(); // ensure runnable is what sets up the
                      // SecurityContextHolder
  assertWrapped(runnable);
}
origin: spring-projects/spring-security

@Test
public void callOnSameThread() throws Exception {
  originalSecurityContext = securityContext;
  SecurityContextHolder.setContext(originalSecurityContext);
  executor = synchronousExecutor();
  runnable = new DelegatingSecurityContextRunnable(delegate,
      securityContext);
  assertWrapped(runnable);
}
origin: apache/servicemix-bundles

  /**
   * Factory method for creating a {@link DelegatingSecurityContextRunnable}.
   *
   * @param delegate the original {@link Runnable} that will be delegated to after
   * establishing a {@link SecurityContext} on the {@link SecurityContextHolder}. Cannot
   * have null.
   * @param securityContext the {@link SecurityContext} to establish before invoking the
   * delegate {@link Runnable}. If null, the current {@link SecurityContext} from the
   * {@link SecurityContextHolder} will be used.
   * @return
   */
  public static Runnable create(Runnable delegate, SecurityContext securityContext) {
    Assert.notNull(delegate, "delegate cannot be  null");
    return securityContext == null ? new DelegatingSecurityContextRunnable(delegate)
        : new DelegatingSecurityContextRunnable(delegate, securityContext);
  }
}
origin: stackoverflow.com

 public void authorizedExecute(Runnable runnable) {
  new Thread(new DelegatingSecurityContextRunnable(runnable)).start();
}
org.springframework.security.concurrentDelegatingSecurityContextRunnable

Javadoc

Wraps a delegate Runnable with logic for setting up a SecurityContextbefore 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.

Most used methods

  • <init>
    Creates a new DelegatingSecurityContextRunnable with a specific SecurityContext.
  • create
    Factory method for creating a DelegatingSecurityContextRunnable.

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getResourceAsStream (ClassLoader)
  • startActivity (Activity)
  • requestLocationUpdates (LocationManager)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • String (java.lang)
  • HashSet (java.util)
    HashSet is an implementation of a Set. All optional operations (adding and removing) are supported.
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • JFrame (javax.swing)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now