Package org.springframework.security.web.csrf

Examples of org.springframework.security.web.csrf.DefaultCsrfToken


    private DefaultCsrfToken token;
    private MockServletContext servletContext;

    @Before
    public void setup() {
        token = new DefaultCsrfToken("header", "param", "token");
        servletContext = new MockServletContext();
    }
View Full Code Here


    private DefaultCsrfToken token;
    private MockServletContext servletContext;

    @Before
    public void setup() throws Exception {
        token = new DefaultCsrfToken("header", "param", "token");
        servletContext = new MockServletContext();
        mockWebTestUtils();
    }
View Full Code Here

    @Before
    public void setup() {
        request = new MockHttpServletRequest();
        processor = new CsrfRequestDataValueProcessor();

        token = new DefaultCsrfToken("1", "a", "b");
        request.setAttribute(CsrfToken.class.getName(), token);

        expected.put(token.getParameterName(),token.getToken());
    }
View Full Code Here

        assertThat(processor.processUrl(request, url)).isEqualTo(url);
    }

    @Test
    public void createGetExtraHiddenFieldsHasCsrfToken() {
        CsrfToken token = new DefaultCsrfToken("1", "a", "b");
        request.setAttribute(CsrfToken.class.getName(), token);
        Map<String,String> expected = new HashMap<String,String>();
        expected.put(token.getParameterName(),token.getToken());

        RequestDataValueProcessor processor = new CsrfRequestDataValueProcessor();
        assertThat(processor.getExtraHiddenFields(request)).isEqualTo(expected);
    }
View Full Code Here

        this.tag = new CsrfMetaTagsTag();
    }

    @Test
    public void handleTokenRendersTags() {
        CsrfToken token = new DefaultCsrfToken("X-Csrf-Token", "_csrf", "abc123def456ghi789");

        String value = this.tag.handleToken(token);

        assertNotNull("The returned value should not be null.", value);
        assertEquals("The output is not correct.",
View Full Code Here

                value);
    }

    @Test
    public void handleTokenRendersTagsDifferentToken() {
        CsrfToken token = new DefaultCsrfToken("csrfHeader", "csrfParameter", "fooBarBazQux");

        String value = this.tag.handleToken(token);

        assertNotNull("The returned value should not be null.", value);
        assertEquals("The output is not correct.",
View Full Code Here

    }

    @Test
    public void hasCsrfRendersReturnedValue() throws JspException, UnsupportedEncodingException {

        CsrfToken token = new DefaultCsrfToken("X-Csrf-Token", "_csrf", "abc123def456ghi789");
        this.request.setAttribute(CsrfToken.class.getName(), token);

        this.tag.handleReturn = "fooBarBazQux";

        int returned = this.tag.doEndTag();
View Full Code Here

    }

    @Test
    public void hasCsrfRendersDifferentValue() throws JspException, UnsupportedEncodingException {

        CsrfToken token = new DefaultCsrfToken("X-Csrf-Token", "_csrf", "abc123def456ghi789");
        this.request.setAttribute(CsrfToken.class.getName(), token);

        this.tag.handleReturn = "<input type=\"hidden\" />";

        int returned = this.tag.doEndTag();
View Full Code Here

        this.tag = new CsrfInputTag();
    }

    @Test
    public void handleTokenReturnsHiddenInput() {
        CsrfToken token = new DefaultCsrfToken("X-Csrf-Token", "_csrf", "abc123def456ghi789");

        String value = this.tag.handleToken(token);

        assertNotNull("The returned value should not be null.", value);
        assertEquals("The output is not correct.",
View Full Code Here

                value);
    }

    @Test
    public void handleTokenReturnsHiddenInputDifferentTokenValue() {
        CsrfToken token = new DefaultCsrfToken("X-Csrf-Token", "csrfParameter", "fooBarBazQux");

        String value = this.tag.handleToken(token);

        assertNotNull("The returned value should not be null.", value);
        assertEquals("The output is not correct.",
View Full Code Here

TOP

Related Classes of org.springframework.security.web.csrf.DefaultCsrfToken

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.