X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Finternal%2Fhttp%2FCmsSessionProvider.java;h=85390e62eeb414d9c0918ca6de106826da09c8bc;hb=b45e59192a4bb34a6b38a9bfa416b3dc3f6b7892;hp=37ba5cdb15332a440e1dac222ecaf7ed16d1db28;hpb=44728c14306ddf25bb5225496de5f44345fab85d;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/internal/http/CmsSessionProvider.java b/org.argeo.cms/src/org/argeo/cms/internal/http/CmsSessionProvider.java index 37ba5cdb1..85390e62e 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/http/CmsSessionProvider.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/http/CmsSessionProvider.java @@ -12,7 +12,7 @@ import javax.servlet.http.HttpServletRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.jackrabbit.server.SessionProvider; -import org.argeo.cms.auth.CmsSession; +import org.argeo.cms.internal.auth.CmsSessionImpl; import org.argeo.jcr.JcrUtils; /** @@ -26,7 +26,7 @@ class CmsSessionProvider implements SessionProvider, Serializable { private final String alias; - private LinkedHashMap cmsSessions = new LinkedHashMap<>(); + private LinkedHashMap cmsSessions = new LinkedHashMap<>(); public CmsSessionProvider(String alias) { this.alias = alias; @@ -35,9 +35,9 @@ class CmsSessionProvider implements SessionProvider, Serializable { public Session getSession(HttpServletRequest request, Repository rep, String workspace) throws javax.jcr.LoginException, ServletException, RepositoryException { - CmsSession cmsSession = WebCmsSessionImpl.getCmsSession(request); -// if (cmsSession == null) -// return anonymousSession(request, rep, workspace); + CmsSessionImpl cmsSession = (CmsSessionImpl) WebCmsSessionImpl.getCmsSession(request); + // if (cmsSession == null) + // return anonymousSession(request, rep, workspace); if (log.isTraceEnabled()) { log.debug("Get JCR session from " + cmsSession); } @@ -46,32 +46,35 @@ class CmsSessionProvider implements SessionProvider, Serializable { return session; } -// private synchronized Session anonymousSession(HttpServletRequest request, Repository repository, String workspace) { -// // TODO rather log in here as anonymous? -// LoginContext lc = (LoginContext) request.getAttribute(NodeConstants.LOGIN_CONTEXT_ANONYMOUS); -// if (lc == null) -// throw new CmsException("No login context available"); -// // optimize -// Session session; -// try { -// session = Subject.doAs(lc.getSubject(), new PrivilegedExceptionAction() { -// @Override -// public Session run() throws Exception { -// return repository.login(workspace); -// } -// }); -// } catch (Exception e) { -// throw new CmsException("Cannot log in to JCR", e); -// } -// return session; -// } + // private synchronized Session anonymousSession(HttpServletRequest request, + // Repository repository, String workspace) { + // // TODO rather log in here as anonymous? + // LoginContext lc = (LoginContext) + // request.getAttribute(NodeConstants.LOGIN_CONTEXT_ANONYMOUS); + // if (lc == null) + // throw new CmsException("No login context available"); + // // optimize + // Session session; + // try { + // session = Subject.doAs(lc.getSubject(), new + // PrivilegedExceptionAction() { + // @Override + // public Session run() throws Exception { + // return repository.login(workspace); + // } + // }); + // } catch (Exception e) { + // throw new CmsException("Cannot log in to JCR", e); + // } + // return session; + // } public synchronized void releaseSession(Session session) { if (cmsSessions.containsKey(session)) { - CmsSession cmsSession = cmsSessions.get(session); + CmsSessionImpl cmsSession = cmsSessions.get(session); cmsSession.releaseDataSession(alias, session); } else { - log.warn("JCR session "+session+" not found in CMS session list. Logging it out..."); + log.warn("JCR session " + session + " not found in CMS session list. Logging it out..."); JcrUtils.logoutQuietly(session); } }