Examples of MediaTypeRequestMatcher


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

        }
        ContentNegotiationStrategy contentNegotiationStrategy = http.getSharedObject(ContentNegotiationStrategy.class);
        if(contentNegotiationStrategy == null) {
            contentNegotiationStrategy = new HeaderContentNegotiationStrategy();
        }
        MediaTypeRequestMatcher preferredMatcher = 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);
        preferredMatcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));
        exceptionHandling.defaultAuthenticationEntryPointFor(postProcess(authenticationEntryPoint), preferredMatcher);


    }
View Full Code Here

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

            contentNegotiationStrategy = new HeaderContentNegotiationStrategy();
        }

        RequestMatcher notFavIcon = new NegatedRequestMatcher(new AntPathRequestMatcher("/**/favicon.ico"));

        MediaTypeRequestMatcher jsonRequest = new MediaTypeRequestMatcher(contentNegotiationStrategy, MediaType.APPLICATION_JSON);
        jsonRequest.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));
        RequestMatcher notJson = new NegatedRequestMatcher(jsonRequest);

        RequestMatcher notXRequestedWith = new NegatedRequestMatcher(new RequestHeaderRequestMatcher("X-Requested-With","XMLHttpRequest"));

        boolean isCsrfEnabled = http.getConfigurer(CsrfConfigurer.class) != null;
View Full Code Here

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

        }
        ContentNegotiationStrategy contentNegotiationStrategy = http.getSharedObject(ContentNegotiationStrategy.class);
        if(contentNegotiationStrategy == null) {
            contentNegotiationStrategy = new HeaderContentNegotiationStrategy();
        }
        MediaTypeRequestMatcher preferredMatcher = new MediaTypeRequestMatcher(contentNegotiationStrategy, MediaType.APPLICATION_XHTML_XML, new MediaType("image","*"), MediaType.TEXT_HTML, MediaType.TEXT_PLAIN);
        preferredMatcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));
        exceptionHandling.defaultAuthenticationEntryPointFor(postProcess(authenticationEntryPoint), preferredMatcher);
    }
View Full Code Here

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

    }

    @Test
    public void mediaAllMatches() {
        request.addHeader("Accept", MediaType.ALL_VALUE);
        matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.TEXT_HTML);

        assertThat(matcher.matches(request)).isTrue();

        matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.APPLICATION_XHTML_XML);
        assertThat(matcher.matches(request)).isTrue();
    }
View Full Code Here

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

    // ignoreMediaTypeAll

    @Test
    public void mediaAllIgnoreMediaTypeAll() {
        request.addHeader("Accept", MediaType.ALL_VALUE);
        matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.TEXT_HTML);
        matcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));

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

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

    }

    @Test
    public void mediaAllAndTextHtmlIgnoreMediaTypeAll() {
        request.addHeader("Accept", MediaType.ALL_VALUE + "," + MediaType.TEXT_HTML_VALUE);
        matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.TEXT_HTML);
        matcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));

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

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

    // JavaDoc

    @Test
    public void javadocJsonJson() {
        request.addHeader("Accept", MediaType.APPLICATION_JSON_VALUE);
        MediaTypeRequestMatcher matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.APPLICATION_JSON);

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

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


    @Test
    public void javadocAllJson() {
        request.addHeader("Accept", MediaType.ALL_VALUE);
        MediaTypeRequestMatcher matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.APPLICATION_JSON);

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

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


    @Test
    public void javadocAllJsonIgnoreAll() {
        request.addHeader("Accept", MediaType.ALL_VALUE);
        MediaTypeRequestMatcher matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.APPLICATION_JSON);
        matcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));
        assertThat(matcher.matches(request)).isFalse();
    }
View Full Code Here

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


    @Test
    public void javadocJsonJsonIgnoreAll() {
        request.addHeader("Accept", MediaType.APPLICATION_JSON_VALUE);
        MediaTypeRequestMatcher matcher = new MediaTypeRequestMatcher(negotiationStrategy, MediaType.APPLICATION_JSON);
        matcher.setIgnoredMediaTypes(Collections.singleton(MediaType.ALL));
        assertThat(matcher.matches(request)).isTrue();
    }
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.