]> git.argeo.org Git - lgpl/argeo-commons.git/blob - WebCmsSessionImpl.java
20f4c032e6ab5cab6ac55ea978df809546aaf2e1
[lgpl/argeo-commons.git] / WebCmsSessionImpl.java
1 package org.argeo.cms.internal.http;
2
3 import java.util.Locale;
4
5 import javax.security.auth.Subject;
6 import javax.servlet.http.HttpServletRequest;
7 import javax.servlet.http.HttpSession;
8
9 import org.argeo.cms.internal.auth.CmsSessionImpl;
10 import org.osgi.service.useradmin.Authorization;
11
12 /** CMS session implementation in a web context. */
13 public class WebCmsSessionImpl extends CmsSessionImpl {
14 // private final static Log log =
15 // LogFactory.getLog(WebCmsSessionImpl.class);
16
17 private HttpSession httpSession;
18
19 public WebCmsSessionImpl(Subject initialSubject, Authorization authorization, Locale locale,
20 HttpServletRequest request) {
21 super(initialSubject, authorization, locale, request.getSession(false).getId());
22 httpSession = request.getSession(false);
23 }
24
25 @Override
26 public boolean isValid() {
27 if (isClosed())
28 return false;
29 try {// test http session
30 httpSession.getCreationTime();
31 return true;
32 } catch (IllegalStateException ise) {
33 return false;
34 }
35 }
36
37 public static CmsSessionImpl getCmsSession(HttpServletRequest request) {
38 return CmsSessionImpl.getByLocalId(request.getSession(false).getId());
39 }
40 }