X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Finternal%2Fhttp%2FWebCmsSessionImpl.java;h=ce819051870b11dd59caf3c37bab451db4855625;hb=a1e5c8447beec2b896b0a03e38a4c17608a4b85d;hp=06ff57355d0b92ac3b42bb14acc514d163b45492;hpb=34ba1b915e1d406f6574c0be93e1e9da3eab1978;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 06ff57355..ce8190518 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; +/** CMS session implementation in a web context. */ public class WebCmsSessionImpl extends CmsSessionImpl { + private static final long serialVersionUID = -5178883380637048025L; + 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()); } }