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;
private final ZonedDateTime creationTime;
private ZonedDateTime end;
+ private final Locale locale;
private ServiceRegistration<CmsSession> serviceRegistration;
private Set<String> dataSessionsInUse = new HashSet<>();
private LinkedHashSet<Session> 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<AccessControlContext>() {
@Override
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;
} catch (LoginException e) {
log.warn("Could not logout " + getSubject() + ": " + e);
}
- notifyAll();
+ log.debug("Closed " + this);
}
private Subject getSubject() {
return uuid;
}
- public String getLocalSessionId() {
- return localSessionId;
- }
-
- public ServiceRegistration<CmsSession> getServiceRegistration() {
- return serviceRegistration;
- }
-
@Override
public LdapName getUserDn() {
return userDn;
return localSessionId;
}
+ @Override
public boolean isAnonymous() {
return anonymous;
}
+ @Override
+ public Locale getLocale() {
+ return locale;
+ }
+
@Override
public ZonedDateTime getCreationTime() {
return creationTime;
return "CMS Session " + userDn + " local=" + localSessionId + ", uuid=" + uuid;
}
- public static CmsSession getByLocalId(String localId) {
+ public static CmsSessionImpl getByLocalId(String localId) {
Collection<ServiceReference<CmsSession>> sr;
try {
sr = bc.getServiceReferences(CmsSession.class, "(" + CmsSession.SESSION_LOCAL_ID + "=" + localId + ")");
ServiceReference<CmsSession> 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
}
- public static CmsSession getByUuid(String uuid) {
+ public static CmsSessionImpl getByUuid(Object uuid) {
Collection<ServiceReference<CmsSession>> sr;
try {
sr = bc.getServiceReferences(CmsSession.class, "(" + CmsSession.SESSION_UUID + "=" + uuid + ")");
ServiceReference<CmsSession> 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