Codota Logo
SecurityMockMvcRequestPostProcessors.testSecurityContext
Code IndexAdd Codota to your IDE (free)

How to use
testSecurityContext
method
in
org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors

Best Java code snippets using org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.testSecurityContext (Showing top 4 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Connection c =
  • Codota IconDataSource dataSource;dataSource.getConnection()
  • Codota IconString url;DriverManager.getConnection(url)
  • Codota IconIdentityDatabaseUtil.getDBConnection()
  • Smart code suggestions by Codota
}
origin: org.springframework.boot/spring-boot-test-autoconfigure

@Override
public RequestPostProcessor beforeMockMvcCreated(
    ConfigurableMockMvcBuilder<?> builder,
    WebApplicationContext context) {
  return SecurityMockMvcRequestPostProcessors.testSecurityContext();
}
origin: org.springframework.security/spring-security-test

  @Override
  public RequestPostProcessor beforeMockMvcCreated(
      ConfigurableMockMvcBuilder<?> builder, WebApplicationContext context) {
    String securityBeanId = BeanIds.SPRING_SECURITY_FILTER_CHAIN;
    if (this.springSecurityFilterChain == null
        && context.containsBean(securityBeanId)) {
      this.springSecurityFilterChain = context.getBean(securityBeanId,
          Filter.class);
    }

    if (this.springSecurityFilterChain == null) {
      throw new IllegalStateException(
          "springSecurityFilterChain cannot be null. Ensure a Bean with the name "
              + securityBeanId
              + " implementing Filter is present or inject the Filter to be used.");
    }

    builder.addFilters(this.springSecurityFilterChain);
    context.getServletContext().setAttribute(BeanIds.SPRING_SECURITY_FILTER_CHAIN,
        this.springSecurityFilterChain);

    return testSecurityContext();
  }
}
origin: apache/servicemix-bundles

  @Override
  public RequestPostProcessor beforeMockMvcCreated(
      ConfigurableMockMvcBuilder<?> builder, WebApplicationContext context) {
    String securityBeanId = BeanIds.SPRING_SECURITY_FILTER_CHAIN;
    if (this.springSecurityFilterChain == null
        && context.containsBean(securityBeanId)) {
      this.springSecurityFilterChain = context.getBean(securityBeanId,
          Filter.class);
    }

    if (this.springSecurityFilterChain == null) {
      throw new IllegalStateException(
          "springSecurityFilterChain cannot be null. Ensure a Bean with the name "
              + securityBeanId
              + " implementing Filter is present or inject the Filter to be used.");
    }

    builder.addFilters(this.springSecurityFilterChain);
    context.getServletContext().setAttribute(BeanIds.SPRING_SECURITY_FILTER_CHAIN,
        this.springSecurityFilterChain);

    return testSecurityContext();
  }
}
origin: stormpath/stormpath-sdk-java

@Override
public RequestPostProcessor beforeMockMvcCreated(
    ConfigurableMockMvcBuilder<?> builder, WebApplicationContext context) {
  String stormpathFilterBeanId = "stormpathFilter";
  String springSecurityFilterBeanId = BeanIds.SPRING_SECURITY_FILTER_CHAIN;
  if (this.springSecurityFilter == null && context.containsBean(springSecurityFilterBeanId)) {
    this.springSecurityFilter = context.getBean(springSecurityFilterBeanId, Filter.class);
  }
  if (this.stormpathFilter == null && context.containsBean(stormpathFilterBeanId)) {
    this.stormpathFilter = context.getBean(stormpathFilterBeanId, Filter.class);
  }
  if (this.springSecurityFilter == null) {
    throw new IllegalStateException(
        "springSecurityFilter cannot be null. Ensure a Bean with the name "
            + springSecurityFilterBeanId
            + " implementing Filter is present or inject the Filter to be used.");
  }
  if (this.stormpathFilter == null) {
    throw new IllegalStateException(
        "stormpathFilter cannot be null. Ensure a Bean with the name "
            + stormpathFilterBeanId
            + " implementing Filter is present or inject the Filter to be used.");
  }
  builder.addFilters(this.springSecurityFilter);
  builder.addFilters(this.stormpathFilter); //Let's put Stormpath behind Spring Security
  context.getServletContext().setAttribute(StormpathFilter.class.getName(), this.stormpathFilter.getClass().getName());
  context.getServletContext().setAttribute(BeanIds.SPRING_SECURITY_FILTER_CHAIN, this.springSecurityFilter);
  return testSecurityContext();
}
org.springframework.security.test.web.servlet.requestSecurityMockMvcRequestPostProcessorstestSecurityContext

Javadoc

Creates a RequestPostProcessor that can be used to ensure that the resulting request is ran with the user in the TestSecurityContextHolder.

Popular methods of SecurityMockMvcRequestPostProcessors

  • httpBasic
    Convenience mechanism for setting the Authorization header to use HTTP Basic with the given username
  • user
    Establish a SecurityContext that has a UsernamePasswordAuthenticationToken for the Authentication#ge
  • csrf
    Creates a RequestPostProcessor that will automatically populate a valid CsrfToken in the request.
  • x509
    Populates the provided X509Certificate instances on the request.
  • digest
    Creates a DigestRequestPostProcessor that enables easily adding digest based authentication to a req
  • authentication
    Establish a SecurityContext that uses the specified Authenticationfor the Authentication#getPrincipa
  • securityContext
    Establish the specified SecurityContext to be used. This works by associating the user to the HttpSe

Popular in Java

  • Finding current android device location
  • putExtra (Intent)
  • runOnUiThread (Activity)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • FileOutputStream (java.io)
    A file output stream is an output stream for writing data to aFile or to a FileDescriptor. Whether
  • IOException (java.io)
    Signals that an I/O exception of some sort has occurred. This class is the general class of exceptio
  • MessageFormat (java.text)
    MessageFormat provides a means to produce concatenated messages in language-neutral way. Use this to
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • JOptionPane (javax.swing)
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now