Examples of RequestMatcher


Examples of org.springframework.security.web.util.matcher.RequestMatcher

    }

    @Test
    public void requestMatcherDefinesCorrectSubsetOfCachedRequests() throws Exception {
        HttpSessionRequestCache cache = new HttpSessionRequestCache();
        cache.setRequestMatcher(new RequestMatcher() {
            public boolean matches(HttpServletRequest request) {
                return request.getMethod().equals("GET");
            }
        });
View Full Code Here

Examples of org.springframework.security.web.util.matcher.RequestMatcher

  /**
   * Default constructor.
   * @param defaultFilterProcessesUrl the url of the filter
   */
  public OpenIDAuthFilter(final String defaultFilterProcessesUrl) {
    setRequiresAuthenticationRequestMatcher(new RequestMatcher() {
      public boolean matches(HttpServletRequest request) {
        String uri = request.getRequestURI();
        boolean matches;
        if ("".equals(request.getContextPath())) {
          matches = uri.endsWith(defaultFilterProcessesUrl);
View Full Code Here

Examples of org.springframework.security.web.util.matcher.RequestMatcher

    }

    CachedCsrfTokenRepository str = new CachedCsrfTokenRepository();
    Para.injectInto(str);

    http.csrf().requireCsrfProtectionMatcher(new RequestMatcher() {
      private Pattern allowedMethods = Pattern.compile("^(GET|HEAD|TRACE|OPTIONS)$");

      public boolean matches(HttpServletRequest request) {
        return !RestRequestMatcher.INSTANCE.matches(request)
            && !allowedMethods.matcher(request.getMethod()).matches();
View Full Code Here

Examples of org.springframework.security.web.util.matcher.RequestMatcher

  }

  @Profile("test")
  @Bean(name = "csrfMatcher")
  public RequestMatcher testCsrfMatcher() {
    return new RequestMatcher() {

      @Override
      public boolean matches(HttpServletRequest request) {
        return false;
      }
View Full Code Here

Examples of org.springframework.security.web.util.matcher.RequestMatcher

  public RequestMatcher csrfMatcher() {
    /**
     * Copy of default request matcher from
     * CsrfFilter$DefaultRequiresCsrfMatcher
     */
    return new RequestMatcher() {
      private Pattern allowedMethods = Pattern
        .compile("^(GET|HEAD|TRACE|OPTIONS)$");

      /*
       * (non-Javadoc)
 
View Full Code Here

Examples of org.springframework.security.web.util.matcher.RequestMatcher

    }

    CachedCsrfTokenRepository str = new CachedCsrfTokenRepository();
    Para.injectInto(str);

    http.csrf().requireCsrfProtectionMatcher(new RequestMatcher() {
      private Pattern allowedMethods = Pattern.compile("^(GET|HEAD|TRACE|OPTIONS)$");

      public boolean matches(HttpServletRequest request) {
        return !RestRequestMatcher.INSTANCE.matches(request)
            && !allowedMethods.matcher(request.getMethod()).matches();
View Full Code Here

Examples of org.springframework.security.web.util.matcher.RequestMatcher

  private String realm;

  @Override
  protected void configure(HttpSecurity http) throws Exception {

    final RequestMatcher textHtmlMatcher = new MediaTypeRequestMatcher(contentNegotiationStrategy,
        MediaType.TEXT_HTML);

    final String loginPage = "/admin-ui/login";

    BasicAuthenticationEntryPoint basicAuthenticationEntryPoint = new BasicAuthenticationEntryPoint();
View Full Code Here

Examples of org.springframework.test.web.client.RequestMatcher

  /**
   * Assert the request content type as a {@link MediaType}.
   */
  public RequestMatcher mimeType(final MediaType expectedContentType) {
    return new RequestMatcher() {
      public void match(ClientHttpRequest request) throws IOException, AssertionError {
        MediaType actualContentType = request.getHeaders().getContentType();
        assertTrue("Content type not set", actualContentType != null);
        assertEquals("Content type", expectedContentType, actualContentType);
      }
View Full Code Here

Examples of org.springframework.test.web.client.RequestMatcher

  /**
   * Get the body of the request as a UTF-8 string and appply the given {@link Matcher}.
   */
  public RequestMatcher string(final Matcher<? super String> matcher) {
    return new RequestMatcher() {
      public void match(ClientHttpRequest request) throws IOException, AssertionError {
        MockClientHttpRequest mockRequest = (MockClientHttpRequest) request;
        MatcherAssert.assertThat("Request content", mockRequest.getBodyAsString(), matcher);
      }
    };
View Full Code Here

Examples of org.springframework.test.web.client.RequestMatcher

  /**
   * Compare the body of the request to the given byte array.
   */
  public RequestMatcher bytes(final byte[] expectedContent) {
    return new RequestMatcher() {
      public void match(ClientHttpRequest request) throws IOException, AssertionError {
        MockClientHttpRequest mockRequest = (MockClientHttpRequest) request;
        byte[] content = mockRequest.getBodyAsBytes();
        MatcherAssert.assertThat("Request content", content, Matchers.equalTo(expectedContent));
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.