X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Finternal%2Fauth%2FCmsSessionImpl.java;h=9b667717beaf80a60463d7f5068b87c99979798a;hb=35507e18257f2e9f59842ba5120fcd3f19c4cf4d;hp=af29d25945c9eb6b34a084b31f0b6a48b892b83f;hpb=b45e59192a4bb34a6b38a9bfa416b3dc3f6b7892;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/internal/auth/CmsSessionImpl.java b/org.argeo.cms/src/org/argeo/cms/internal/auth/CmsSessionImpl.java index af29d2594..9b667717b 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/auth/CmsSessionImpl.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/auth/CmsSessionImpl.java @@ -10,6 +10,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.LinkedHashSet; +import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -50,6 +51,7 @@ public class CmsSessionImpl implements CmsSession { private final ZonedDateTime creationTime; private ZonedDateTime end; + private final Locale locale; private ServiceRegistration serviceRegistration; @@ -57,8 +59,9 @@ public class CmsSessionImpl implements CmsSession { private Set dataSessionsInUse = new HashSet<>(); private LinkedHashSet additionalDataSessions = new LinkedHashSet<>(); - public CmsSessionImpl(Subject initialSubject, Authorization authorization, String localSessionId) { + public CmsSessionImpl(Subject initialSubject, Authorization authorization, Locale locale, String localSessionId) { this.creationTime = ZonedDateTime.now(); + this.locale = locale; this.initialContext = Subject.doAs(initialSubject, new PrivilegedAction() { @Override @@ -90,15 +93,17 @@ public class CmsSessionImpl implements CmsSession { serviceRegistration = bc.registerService(CmsSession.class, this, props); } - public synchronized void close() { + public void close() { end = ZonedDateTime.now(); serviceRegistration.unregister(); - // TODO check data session in use ? - for (String path : dataSessions.keySet()) - JcrUtils.logoutQuietly(dataSessions.get(path)); - for (Session session : additionalDataSessions) - JcrUtils.logoutQuietly(session); + synchronized (this) { + // TODO check data session in use ? + for (String path : dataSessions.keySet()) + JcrUtils.logoutQuietly(dataSessions.get(path)); + for (Session session : additionalDataSessions) + JcrUtils.logoutQuietly(session); + } try { LoginContext lc; @@ -111,7 +116,7 @@ public class CmsSessionImpl implements CmsSession { } catch (LoginException e) { log.warn("Could not logout " + getSubject() + ": " + e); } - notifyAll(); + log.debug("Closed " + this); } private Subject getSubject() { @@ -199,14 +204,6 @@ public class CmsSessionImpl implements CmsSession { return uuid; } - public String getLocalSessionId() { - return localSessionId; - } - - public ServiceRegistration getServiceRegistration() { - return serviceRegistration; - } - @Override public LdapName getUserDn() { return userDn; @@ -217,10 +214,16 @@ public class CmsSessionImpl implements CmsSession { return localSessionId; } + @Override public boolean isAnonymous() { return anonymous; } + @Override + public Locale getLocale() { + return locale; + } + @Override public ZonedDateTime getCreationTime() { return creationTime; @@ -235,7 +238,7 @@ public class CmsSessionImpl implements CmsSession { return "CMS Session " + userDn + " local=" + localSessionId + ", uuid=" + uuid; } - public static CmsSession getByLocalId(String localId) { + public static CmsSessionImpl getByLocalId(String localId) { Collection> sr; try { sr = bc.getServiceReferences(CmsSession.class, "(" + CmsSession.SESSION_LOCAL_ID + "=" + localId + ")"); @@ -245,7 +248,7 @@ public class CmsSessionImpl implements CmsSession { ServiceReference cmsSessionRef; if (sr.size() == 1) { cmsSessionRef = sr.iterator().next(); - return bc.getService(cmsSessionRef); + return (CmsSessionImpl) bc.getService(cmsSessionRef); } else if (sr.size() == 0) { return null; } else @@ -253,7 +256,7 @@ public class CmsSessionImpl implements CmsSession { } - public static CmsSession getByUuid(String uuid) { + public static CmsSessionImpl getByUuid(Object uuid) { Collection> sr; try { sr = bc.getServiceReferences(CmsSession.class, "(" + CmsSession.SESSION_UUID + "=" + uuid + ")"); @@ -263,7 +266,7 @@ public class CmsSessionImpl implements CmsSession { ServiceReference cmsSessionRef; if (sr.size() == 1) { cmsSessionRef = sr.iterator().next(); - return bc.getService(cmsSessionRef); + return (CmsSessionImpl) bc.getService(cmsSessionRef); } else if (sr.size() == 0) { return null; } else