From: <dcr...@hy...> - 2010-01-23 00:36:02
|
Author: dcrutchf Date: 2010-01-22 16:34:15 -0800 (Fri, 22 Jan 2010) New Revision: 14226 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14226 Added: trunk/src/org/hyperic/hq/ui/security/RegistrationRedirectStrategy.java Log: forgot the new class... Added: trunk/src/org/hyperic/hq/ui/security/RegistrationRedirectStrategy.java =================================================================== --- trunk/src/org/hyperic/hq/ui/security/RegistrationRedirectStrategy.java (rev 0) +++ trunk/src/org/hyperic/hq/ui/security/RegistrationRedirectStrategy.java 2010-01-23 00:34:15 UTC (rev 14226) @@ -0,0 +1,33 @@ +package org.hyperic.hq.ui.security; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.hyperic.hq.ui.Constants; +import org.springframework.security.web.RedirectStrategy; + +public class RegistrationRedirectStrategy implements RedirectStrategy { + private String registrationUrl; + + public RegistrationRedirectStrategy(String registrationUrl) { + this.registrationUrl = registrationUrl; + } + + public void sendRedirect(HttpServletRequest request, HttpServletResponse response, String url) throws IOException { + // We determine if the user needs to register with HQ + HttpSession session = request.getSession(); + Boolean needRegistration = (Boolean) session.getAttribute(Constants.NEEDS_REGISTRATION); + + if (Boolean.TRUE.equals(needRegistration)) { + // We need to go to the user registration page + session.removeAttribute(Constants.NEEDS_REGISTRATION); + + response.sendRedirect(this.registrationUrl); + } else { + response.sendRedirect(url); + } + } +} |