Example usage for org.springframework.security.web.savedrequest HttpSessionRequestCache HttpSessionRequestCache

List of usage examples for org.springframework.security.web.savedrequest HttpSessionRequestCache HttpSessionRequestCache

Introduction

In this page you can find the example usage for org.springframework.security.web.savedrequest HttpSessionRequestCache HttpSessionRequestCache.

Prototype

HttpSessionRequestCache

Source Link

Usage

From source file:org.orcid.frontend.web.controllers.RegistrationController.java

private String calculateRedirectUrl(HttpServletRequest request, HttpServletResponse response) {
    SavedRequest savedRequest = new HttpSessionRequestCache().getRequest(request, response);
    if (savedRequest != null) {
        String savedUrl = savedRequest.getRedirectUrl();
        if (savedUrl != null) {
            try {
                String path = new URL(savedUrl).getPath();
                if (path != null && path.contains("/oauth/")) {
                    // This redirect url is OK
                    return savedUrl;
                }//w w  w . j a  v  a2s .c om
            } catch (MalformedURLException e) {
                LOGGER.debug("Malformed saved redirect url: {}", savedUrl);
            }
        }
    }
    return getBaseUri() + "/my-orcid";
}

From source file:org.orcid.frontend.web.controllers.RegistrationController.java

@RequestMapping(value = "/register", method = RequestMethod.GET)
public ModelAndView register(HttpServletRequest request, HttpServletResponse response) {
    ModelAndView mav = new ModelAndView("register");
    SavedRequest savedRequest = new HttpSessionRequestCache().getRequest(request, response);
    LOGGER.debug("Saved url before registration is: "
            + (savedRequest != null ? savedRequest.getRedirectUrl() : " no saved request"));
    return mav;/*from w ww .  j  a v  a2 s .  c  o  m*/
}