Package org.springframework.security.web.util.matcher

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


     * @param pattern the Regular Expression to match on (i.e. "/admin/.+")
     * @return the {@link HttpSecurity} for further customizations
     * @see RegexRequestMatcher
     */
    public HttpSecurity regexMatcher(String pattern) {
        return requestMatcher(new RegexRequestMatcher(pattern, null));
    }
View Full Code Here


         */
        public static List<RequestMatcher> regexMatchers(HttpMethod httpMethod, String...regexPatterns) {
            String method = httpMethod == null ? null : httpMethod.toString();
            List<RequestMatcher> matchers = new ArrayList<RequestMatcher>();
            for(String pattern : regexPatterns) {
                matchers.add(new RegexRequestMatcher(pattern, method));
            }
            return matchers;
        }
View Full Code Here

        assertTrue(matcher.matches(request));
    }

    @Test
    public void requestHasNullMethodAndNullMatcherNoMatch() {
        RegexRequestMatcher matcher = new RegexRequestMatcher("/something/.*", null);
        HttpServletRequest request = createRequestWithNullMethod("/nomatch");
        assertFalse(matcher.matches(request));
    }
View Full Code Here

    @Mock
    private HttpServletRequest request;

    @Test
    public void doesntMatchIfHttpMethodIsDifferent() throws Exception {
        RegexRequestMatcher matcher = new RegexRequestMatcher(".*", "GET");

        MockHttpServletRequest request = new MockHttpServletRequest("POST", "/anything");

        assertFalse(matcher.matches(request));
    }
View Full Code Here

        assertFalse(matcher.matches(request));
    }

    @Test
    public void matchesIfHttpMethodAndPathMatch() throws Exception {
        RegexRequestMatcher matcher = new RegexRequestMatcher(".*", "GET");

        MockHttpServletRequest request = new MockHttpServletRequest("GET", "/anything");
        request.setServletPath("/anything");

        assertTrue(matcher.matches(request));
    }
View Full Code Here

        assertTrue(matcher.matches(request));
    }

    @Test
    public void queryStringIsMatcherCorrectly() throws Exception {
        RegexRequestMatcher matcher = new RegexRequestMatcher(".*\\?x=y", "GET");

        MockHttpServletRequest request = new MockHttpServletRequest("GET", "/any/path?x=y");
        request.setServletPath("/any");
        request.setPathInfo("/path");
        request.setQueryString("x=y");

        assertTrue(matcher.matches(request));
    }
View Full Code Here

        assertTrue(matcher.matches(request));
    }

    @Test
    public void requestHasNullMethodMatches() {
        RegexRequestMatcher matcher = new RegexRequestMatcher("/something/.*", "GET");
        HttpServletRequest request = createRequestWithNullMethod("/something/here");
        assertTrue(matcher.matches(request));
    }
View Full Code Here

    }

    // SEC-2084
    @Test
    public void requestHasNullMethodNoMatch() {
        RegexRequestMatcher matcher = new RegexRequestMatcher("/something/.*", "GET");
        HttpServletRequest request = createRequestWithNullMethod("/nomatch");
        assertFalse(matcher.matches(request));
    }
View Full Code Here

        assertFalse(matcher.matches(request));
    }

    @Test
    public void requestHasNullMethodAndNullMatcherMatches() {
        RegexRequestMatcher matcher = new RegexRequestMatcher("/something/.*", null);
        HttpServletRequest request = createRequestWithNullMethod("/something/here");
        assertTrue(matcher.matches(request));
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.web.util.matcher.RegexRequestMatcher

Copyright © 2018 www.massapicom. 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.