Search in sources :

Example 1 with RequestHeaderRequestMatcher

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

the class RequestHeaderRequestMatcherTests method matchesHeaderNameDoesNotMatch.

@Test
public void matchesHeaderNameDoesNotMatch() {
    request.addHeader(headerName + "notMatch", headerValue);
    assertThat(new RequestHeaderRequestMatcher(headerName).matches(request)).isFalse();
}
Also used : RequestHeaderRequestMatcher(org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher) Test(org.junit.Test)

Example 2 with RequestHeaderRequestMatcher

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

the class RequestHeaderRequestMatcherTests method matchesHeaderNameValueHeaderValueNotMatch.

@Test
public void matchesHeaderNameValueHeaderValueNotMatch() {
    request.addHeader(headerName, headerValue + "notMatch");
    assertThat(new RequestHeaderRequestMatcher(headerName, headerValue).matches(request)).isFalse();
}
Also used : RequestHeaderRequestMatcher(org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher) Test(org.junit.Test)

Example 3 with RequestHeaderRequestMatcher

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

the class RequestHeaderRequestMatcherTests method matchesHeaderNameValueHeaderNameNotMatch.

@Test
public void matchesHeaderNameValueHeaderNameNotMatch() {
    request.addHeader(headerName + "notMatch", headerValue);
    assertThat(new RequestHeaderRequestMatcher(headerName, headerValue).matches(request)).isFalse();
}
Also used : RequestHeaderRequestMatcher(org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher) Test(org.junit.Test)

Example 4 with RequestHeaderRequestMatcher

use of org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher in project ma-core-public by infiniteautomation.

the class MangoSecurityConfiguration method createBrowserHtmlRequestMatcher.

/**
 * Internal method to create a static matcher
 * @return
 */
private static RequestMatcher createBrowserHtmlRequestMatcher() {
    ContentNegotiationStrategy contentNegotiationStrategy = contentNegotiationStrategy();
    MediaTypeRequestMatcher mediaMatcher = new MediaTypeRequestMatcher(contentNegotiationStrategy, MediaType.APPLICATION_XHTML_XML, MediaType.TEXT_HTML);
    mediaMatcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));
    RequestMatcher notXRequestedWith = new NegatedRequestMatcher(new RequestHeaderRequestMatcher("X-Requested-With", "XMLHttpRequest"));
    return new AndRequestMatcher(Arrays.asList(notXRequestedWith, mediaMatcher));
}
Also used : NegatedRequestMatcher(org.springframework.security.web.util.matcher.NegatedRequestMatcher) RequestHeaderRequestMatcher(org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher) RequestMatcher(org.springframework.security.web.util.matcher.RequestMatcher) AndRequestMatcher(org.springframework.security.web.util.matcher.AndRequestMatcher) NegatedRequestMatcher(org.springframework.security.web.util.matcher.NegatedRequestMatcher) MediaTypeRequestMatcher(org.springframework.security.web.util.matcher.MediaTypeRequestMatcher) AntPathRequestMatcher(org.springframework.security.web.util.matcher.AntPathRequestMatcher) MediaTypeRequestMatcher(org.springframework.security.web.util.matcher.MediaTypeRequestMatcher) HeaderContentNegotiationStrategy(org.springframework.web.accept.HeaderContentNegotiationStrategy) ContentNegotiationStrategy(org.springframework.web.accept.ContentNegotiationStrategy) RequestHeaderRequestMatcher(org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher) AndRequestMatcher(org.springframework.security.web.util.matcher.AndRequestMatcher)

Example 5 with RequestHeaderRequestMatcher

use of org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher in project atlas by apache.

the class AtlasSecurityConfig method getDelegatingAuthenticationEntryPoint.

public DelegatingAuthenticationEntryPoint getDelegatingAuthenticationEntryPoint() {
    LinkedHashMap<RequestMatcher, AuthenticationEntryPoint> entryPointMap = new LinkedHashMap<>();
    entryPointMap.put(new RequestHeaderRequestMatcher("User-Agent", "Mozilla"), atlasAuthenticationEntryPoint);
    DelegatingAuthenticationEntryPoint entryPoint = new DelegatingAuthenticationEntryPoint(entryPointMap);
    entryPoint.setDefaultEntryPoint(getAuthenticationEntryPoint());
    return entryPoint;
}
Also used : RequestHeaderRequestMatcher(org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher) RequestMatcher(org.springframework.security.web.util.matcher.RequestMatcher) AtlasAuthenticationEntryPoint(org.apache.atlas.web.filters.AtlasAuthenticationEntryPoint) DelegatingAuthenticationEntryPoint(org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint) BasicAuthenticationEntryPoint(org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint) AuthenticationEntryPoint(org.springframework.security.web.AuthenticationEntryPoint) RequestHeaderRequestMatcher(org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher) DelegatingAuthenticationEntryPoint(org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

RequestHeaderRequestMatcher (org.springframework.security.web.util.matcher.RequestHeaderRequestMatcher)17 RequestMatcher (org.springframework.security.web.util.matcher.RequestMatcher)9 NegatedRequestMatcher (org.springframework.security.web.util.matcher.NegatedRequestMatcher)8 AndRequestMatcher (org.springframework.security.web.util.matcher.AndRequestMatcher)7 MediaTypeRequestMatcher (org.springframework.security.web.util.matcher.MediaTypeRequestMatcher)7 Test (org.junit.Test)6 AntPathRequestMatcher (org.springframework.security.web.util.matcher.AntPathRequestMatcher)6 MediaType (org.springframework.http.MediaType)4 AuthenticationEntryPoint (org.springframework.security.web.AuthenticationEntryPoint)4 DelegatingAuthenticationEntryPoint (org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint)4 ContentNegotiationStrategy (org.springframework.web.accept.ContentNegotiationStrategy)4 HeaderContentNegotiationStrategy (org.springframework.web.accept.HeaderContentNegotiationStrategy)4 LinkedHashMap (java.util.LinkedHashMap)3 AtlasAuthenticationEntryPoint (org.apache.atlas.web.filters.AtlasAuthenticationEntryPoint)2 HttpSecurity (org.springframework.security.config.annotation.web.builders.HttpSecurity)2 LoginUrlAuthenticationEntryPoint (org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint)2 BasicAuthenticationEntryPoint (org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint)2 OrRequestMatcher (org.springframework.security.web.util.matcher.OrRequestMatcher)2 Initializer (alfio.config.Initializer)1 AuthenticationConstants (alfio.config.authentication.AuthenticationConstants)1