JCR system session
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 17 Apr 2011 07:58:36 +0000 (07:58 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 17 Apr 2011 07:58:36 +0000 (07:58 +0000)
NEW - bug 17: Generalize agent management and registration beyond JMS
https://bugzilla.argeo.org/show_bug.cgi?id=17

git-svn-id: https://svn.argeo.org/commons/trunk@4443 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/jcr/SystemSession.java [new file with mode: 0644]

diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/jcr/SystemSession.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/jcr/SystemSession.java
new file mode 100644 (file)
index 0000000..62b0f91
--- /dev/null
@@ -0,0 +1,34 @@
+package org.argeo.security.jcr;
+
+import java.util.concurrent.Callable;
+
+import javax.jcr.Session;
+
+import org.argeo.ArgeoException;
+import org.argeo.jcr.spring.ThreadBoundSession;
+import org.argeo.security.SystemExecutionService;
+
+/** Thread bounded JCR session which logins as system authentication. */
+public class SystemSession extends ThreadBoundSession {
+       private SystemExecutionService systemExecutionService;
+
+       @Override
+       protected Session login() {
+               try {
+                       return systemExecutionService.submit(new Callable<Session>() {
+                               public Session call() throws Exception {
+                                       return SystemSession.super.login();
+                               }
+                       }).get();
+               } catch (Exception e) {
+                       throw new ArgeoException(
+                                       "Cannot login to JCR with system authentication", e);
+               }
+       }
+
+       public void setSystemExecutionService(
+                       SystemExecutionService systemExecutionService) {
+               this.systemExecutionService = systemExecutionService;
+       }
+
+}