- // TODO check data session in use ?
- for (String path : dataSessions.keySet())
- JcrUtils.logoutQuietly(dataSessions.get(path));
- for (Session session : additionalDataSessions)
- JcrUtils.logoutQuietly(session);
- notifyAll();
+ 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;
+ if (isAnonymous()) {
+ lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_ANONYMOUS, getSubject());
+ } else {
+ lc = new LoginContext(NodeConstants.LOGIN_CONTEXT_USER, getSubject());
+ }
+ lc.logout();
+ } catch (LoginException e) {
+ log.warn("Could not logout " + getSubject() + ": " + e);
+ }
+ log.debug("Closed " + this);
+ }
+
+ private Subject getSubject() {
+ return Subject.getSubject(initialContext);
+ }
+
+ public Set<SecretKey> getSecretKeys() {
+ return getSubject().getPrivateCredentials(SecretKey.class);
+ }
+
+ public Session newDataSession(String cn, String workspace, Repository repository) {
+ return login(repository, workspace);