Search in sources :

Example 1 with OrRequestMatcher

use of org.springframework.security.web.util.matcher.OrRequestMatcher in project spring-security by spring-projects.

the class OrRequestMatcherTests method matchesMultiSingleFalse.

@Test
public void matchesMultiSingleFalse() {
    when(delegate.matches(request)).thenReturn(true);
    when(delegate2.matches(request)).thenReturn(false);
    matcher = new OrRequestMatcher(delegate, delegate2);
    assertThat(matcher.matches(request)).isTrue();
}
Also used : OrRequestMatcher(org.springframework.security.web.util.matcher.OrRequestMatcher) Test(org.junit.Test)

Example 2 with OrRequestMatcher

use of org.springframework.security.web.util.matcher.OrRequestMatcher in project spring-security by spring-projects.

the class HttpBasicConfigurer method registerDefaults.

private void registerDefaults(B http) {
    ContentNegotiationStrategy contentNegotiationStrategy = http.getSharedObject(ContentNegotiationStrategy.class);
    if (contentNegotiationStrategy == null) {
        contentNegotiationStrategy = new HeaderContentNegotiationStrategy();
    }
    MediaTypeRequestMatcher restMatcher = new MediaTypeRequestMatcher(contentNegotiationStrategy, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_FORM_URLENCODED, MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_XML, MediaType.MULTIPART_FORM_DATA, MediaType.TEXT_XML);
    restMatcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));
    RequestMatcher notHtmlMatcher = new NegatedRequestMatcher(new MediaTypeRequestMatcher(contentNegotiationStrategy, MediaType.TEXT_HTML));
    RequestMatcher restNotHtmlMatcher = new AndRequestMatcher(Arrays.<RequestMatcher>asList(notHtmlMatcher, restMatcher));
    RequestMatcher preferredMatcher = new OrRequestMatcher(Arrays.asList(X_REQUESTED_WITH, restNotHtmlMatcher));
    registerDefaultEntryPoint(http, preferredMatcher);
    registerDefaultLogoutSuccessHandler(http, preferredMatcher);
}
Also used : NegatedRequestMatcher(org.springframework.security.web.util.matcher.NegatedRequestMatcher) AndRequestMatcher(org.springframework.security.web.util.matcher.AndRequestMatcher) NegatedRequestMatcher(org.springframework.security.web.util.matcher.NegatedRequestMatcher) RequestHeaderRequestMatcher(org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher) RequestMatcher(org.springframework.security.web.util.matcher.RequestMatcher) OrRequestMatcher(org.springframework.security.web.util.matcher.OrRequestMatcher) MediaTypeRequestMatcher(org.springframework.security.web.util.matcher.MediaTypeRequestMatcher) HeaderContentNegotiationStrategy(org.springframework.web.accept.HeaderContentNegotiationStrategy) MediaTypeRequestMatcher(org.springframework.security.web.util.matcher.MediaTypeRequestMatcher) HeaderContentNegotiationStrategy(org.springframework.web.accept.HeaderContentNegotiationStrategy) ContentNegotiationStrategy(org.springframework.web.accept.ContentNegotiationStrategy) AndRequestMatcher(org.springframework.security.web.util.matcher.AndRequestMatcher) OrRequestMatcher(org.springframework.security.web.util.matcher.OrRequestMatcher)

Example 3 with OrRequestMatcher

use of org.springframework.security.web.util.matcher.OrRequestMatcher in project spring-security by spring-projects.

the class OrRequestMatcherTests method matchesMultiTrue.

@Test
public void matchesMultiTrue() {
    when(delegate.matches(request)).thenReturn(true);
    when(delegate2.matches(request)).thenReturn(true);
    matcher = new OrRequestMatcher(delegate, delegate2);
    assertThat(matcher.matches(request)).isTrue();
}
Also used : OrRequestMatcher(org.springframework.security.web.util.matcher.OrRequestMatcher) Test(org.junit.Test)

Example 4 with OrRequestMatcher

use of org.springframework.security.web.util.matcher.OrRequestMatcher in project spring-security by spring-projects.

the class OrRequestMatcherTests method matchesSingleFalse.

@Test
public void matchesSingleFalse() {
    when(delegate.matches(request)).thenReturn(false);
    matcher = new OrRequestMatcher(delegate);
    assertThat(matcher.matches(request)).isFalse();
}
Also used : OrRequestMatcher(org.springframework.security.web.util.matcher.OrRequestMatcher) Test(org.junit.Test)

Example 5 with OrRequestMatcher

use of org.springframework.security.web.util.matcher.OrRequestMatcher in project spring-security by spring-projects.

the class OrRequestMatcherTests method matchesSingleTrue.

@Test
public void matchesSingleTrue() {
    when(delegate.matches(request)).thenReturn(true);
    matcher = new OrRequestMatcher(delegate);
    assertThat(matcher.matches(request)).isTrue();
}
Also used : OrRequestMatcher(org.springframework.security.web.util.matcher.OrRequestMatcher) Test(org.junit.Test)

Aggregations

OrRequestMatcher (org.springframework.security.web.util.matcher.OrRequestMatcher)6 Test (org.junit.Test)5 AndRequestMatcher (org.springframework.security.web.util.matcher.AndRequestMatcher)1 MediaTypeRequestMatcher (org.springframework.security.web.util.matcher.MediaTypeRequestMatcher)1 NegatedRequestMatcher (org.springframework.security.web.util.matcher.NegatedRequestMatcher)1 RequestHeaderRequestMatcher (org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher)1 RequestMatcher (org.springframework.security.web.util.matcher.RequestMatcher)1 ContentNegotiationStrategy (org.springframework.web.accept.ContentNegotiationStrategy)1 HeaderContentNegotiationStrategy (org.springframework.web.accept.HeaderContentNegotiationStrategy)1