X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Finternal%2Fhttp%2FWebCmsSessionImpl.java;h=1df7b1760cfb4471ca013ca3b564ec3b87929379;hb=09d97fb1d28c9bbe4b2ec9fc511adf5127a256c1;hp=139e23ba7b7c01432a96a6378f3dc24262ae9f69;hpb=02a6354c17ddb160513580e9e3c7826d9475b177;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/internal/http/WebCmsSessionImpl.java b/org.argeo.cms/src/org/argeo/cms/internal/http/WebCmsSessionImpl.java index 139e23ba7..1df7b1760 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/http/WebCmsSessionImpl.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/http/WebCmsSessionImpl.java @@ -1,22 +1,38 @@ package org.argeo.cms.internal.http; +import java.util.Locale; + import javax.security.auth.Subject; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; -import org.argeo.cms.auth.CmsSession; import org.argeo.cms.internal.auth.CmsSessionImpl; import org.osgi.service.useradmin.Authorization; public class WebCmsSessionImpl extends CmsSessionImpl { + // private final static Log log = + // LogFactory.getLog(WebCmsSessionImpl.class); + + private HttpSession httpSession; + + public WebCmsSessionImpl(Subject initialSubject, Authorization authorization, Locale locale, HttpServletRequest request) { + super(initialSubject, authorization, locale,request.getSession(false).getId()); + httpSession = request.getSession(false); + } - public WebCmsSessionImpl(Subject initialSubject, Authorization authorization, String httpSessionId) { - super(initialSubject, authorization, httpSessionId); + @Override + public boolean isValid() { + if (isClosed()) + return false; + try {// test http session + httpSession.getCreationTime(); + return true; + } catch (IllegalStateException ise) { + return false; + } } - public static CmsSession getCmsSession(HttpServletRequest request) { - CmsSession cmsSession = (CmsSession) request.getAttribute(CmsSession.class.getName()); - if (cmsSession != null) - return cmsSession; - return CmsSessionImpl.getByLocalId(request.getSession().getId()); + public static CmsSessionImpl getCmsSession(HttpServletRequest request) { + return CmsSessionImpl.getByLocalId(request.getSession(false).getId()); } }