Example usage for org.springframework.security.web DefaultRedirectStrategy setContextRelative

List of usage examples for org.springframework.security.web DefaultRedirectStrategy setContextRelative

Introduction

In this page you can find the example usage for org.springframework.security.web DefaultRedirectStrategy setContextRelative.

Prototype

public void setContextRelative(boolean useRelativeContext) 

Source Link

Document

If true, causes any redirection URLs to be calculated minus the protocol and context path (defaults to false).

Usage

From source file:org.terasoluna.gfw.security.web.redirect.RedirectAuthenticationHandlerTest.java

@Test
public void testOnAuthenticationSuccess_SetNullRedirectToRedirectStrategyAndSetContextRelative()
        throws Exception {
    RedirectAuthenticationHandler redireHandler = new RedirectAuthenticationHandler();
    DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
    redirectStrategy.setContextRelative(true);
    redireHandler.setRedirectStrategy(redirectStrategy);

    // set Blank URI
    String redirectURI = "http://localhost/foo/bar";
    request.setParameter("redirectTo", redirectURI);

    // expected data
    String expectedRedirectURL = "bar";

    // run//w ww .  ja  va  2 s .c  om
    redireHandler.onAuthenticationSuccess(request, response, auth);

    // assert
    assertThat(response.getRedirectedUrl(), is(expectedRedirectURL));
}