Rename packages in order to make future stable documentation clearer.
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / internal / auth / CmsSessionImpl.java
index 9b667717beaf80a60463d7f5068b87c99979798a..f8d5863e69321f530ca818fc89c86b23b5f9ed64 100644 (file)
@@ -15,6 +15,7 @@ import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
 
+import javax.crypto.SecretKey;
 import javax.jcr.Repository;
 import javax.jcr.Session;
 import javax.naming.InvalidNameException;
@@ -25,11 +26,11 @@ import javax.security.auth.login.LoginException;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.argeo.api.NodeConstants;
+import org.argeo.api.security.NodeSecurityUtils;
 import org.argeo.cms.CmsException;
 import org.argeo.cms.auth.CmsSession;
 import org.argeo.jcr.JcrUtils;
-import org.argeo.node.NodeConstants;
-import org.argeo.node.security.NodeSecurityUtils;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.FrameworkUtil;
 import org.osgi.framework.InvalidSyntaxException;
@@ -123,6 +124,14 @@ public class CmsSessionImpl implements CmsSession {
                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);
+       }
+
        public synchronized Session getDataSession(String cn, String workspace, Repository repository) {
                // FIXME make it more robust
                if (workspace == null)
@@ -173,6 +182,8 @@ public class CmsSessionImpl implements CmsSession {
                if (additionalDataSessions.contains(session)) {
                        JcrUtils.logoutQuietly(session);
                        additionalDataSessions.remove(session);
+                       if (log.isTraceEnabled())
+                               log.trace("Remove additional data session " + session);
                        return;
                }
                String path = cn + '/' + session.getWorkspace().getName();
@@ -182,6 +193,8 @@ public class CmsSessionImpl implements CmsSession {
                Session registeredSession = dataSessions.get(path);
                if (session != registeredSession)
                        log.warn("Data session " + path + " not consistent for " + userDn);
+               if (log.isTraceEnabled())
+                       log.trace("Released data session " + session + " for " + path);
                notifyAll();
        }