/** * */ package at.gv.egiz.pdfas.web.helper; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import at.gv.egiz.pdfas.exceptions.web.SessionExpiredException; import at.knowcenter.wag.egov.egiz.web.SessionAttributes; /** * @author wprinz * */ public class SessionHelper { /** * The log. */ private static Log log = LogFactory.getLog(SessionHelper.class); public static Object getSession(HttpServletRequest request) throws SessionExpiredException { HttpSession session = request.getSession(false); if (session == null) { String msg = "There is no session associated with this request."; //$NON-NLS-1$ log.error(msg); throw new SessionExpiredException(msg); } Object sessionObject = session.getAttribute(SessionAttributes.ATTRIBUTE_SESSION_INFORMATION); if (sessionObject == null) { String msg = "Unable to find session data in session " + session.getId(); log.error(msg); throw new SessionExpiredException(msg); } return sessionObject; } }