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

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

Introduction

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

Prototype

public void sendRedirect(HttpServletRequest request, HttpServletResponse response, String url)
        throws IOException 

Source Link

Document

Redirects the response to the supplied URL.

Usage

From source file:org.apache.rave.portal.web.controller.handler.OpenIDAuthenticationFailureHandler.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    if (exception instanceof UsernameNotFoundException
            && exception.getAuthentication() instanceof OpenIDAuthenticationToken
            && ((OpenIDAuthenticationToken) exception.getAuthentication()).getStatus()
                    .equals(OpenIDAuthenticationStatus.SUCCESS)) {

        OpenIDAuthenticationToken token = (OpenIDAuthenticationToken) exception.getAuthentication();
        String url = token.getIdentityUrl();
        User user = createTemporaryUser(token, url);
        request.getSession(true).setAttribute(ModelKeys.NEW_USER, user);

        DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
        log.info("Redirecting to new user account creation page");
        super.setRedirectStrategy(redirectStrategy);
        redirectStrategy.sendRedirect(request, response, "/" + ViewNames.CREATE_ACCOUNT_PAGE);
        return;//from   w  w w .  j  a v a2  s .  c  o m
    } else {
        super.onAuthenticationFailure(request, response, exception);
    }
}