reintroduce Spring Security Authenticaiton in SLC
authorMathieu Baudier <mbaudier@argeo.org>
Mon, 9 Jul 2012 14:31:27 +0000 (14:31 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Mon, 9 Jul 2012 14:31:27 +0000 (14:31 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@5423 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

demo/slc_demo_rap.properties
eclipse/plugins/org.argeo.slc.client.ui.dist/plugin.xml
eclipse/plugins/org.argeo.slc.client.ui/plugin.xml
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/ExecutionThread.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/ProcessThread.java
runtime/org.argeo.slc.core/src/main/java/org/argeo/slc/core/execution/ProcessThreadGroup.java

index a64015cde9f0b6c5d260dc6d95bb0a4b5293e864..52a1cd217546e0600d018a2542aa56ad00e96231 100644 (file)
@@ -21,7 +21,8 @@ org.argeo.slc.demo.basic,\
 org.argeo.slc.demo.minimal,\
 
 #org.argeo.security.ui.initialPerspective=org.argeo.slc.client.ui.slcExecutionPerspective
-org.argeo.security.ui.initialPerspective=org.argeo.slc.client.ui.dist.distributionPerspective
+#org.argeo.security.ui.initialPerspective=org.argeo.slc.client.ui.dist.distributionPerspective
+org.argeo.security.ui.initialPerspective=org.argeo.security.ui.userHomePerspective
 
 #spring.security.strategy=MODE_INHERITABLETHREADLOCAL
 
index 97174910966d6ce72c61dffae18afa3bd1d3c195..8479ed3781d2f1fed5bc8babec23d24d9ba9ca26 100644 (file)
              </menu>
           </menuContribution> -->
        </extension>
+  <extension
+           point="org.eclipse.ui.activities">
+        <!-- TODO: find a way to exclude evrything -->
+        <activityPatternBinding
+              activityId="org.argeo.slc.client.ui.slcActivity"
+              isEqualityPattern="true"
+              pattern="org.argeo.slc.client.ui.dist/org.argeo.slc.client.ui.dist.distributionPerspective">
+        </activityPatternBinding>
+        <activityPatternBinding
+              activityId="org.argeo.security.ui.adminActivity"
+              isEqualityPattern="true"
+              pattern="org.argeo.slc.client.ui/org.argeo.slc.client.ui.slcExecutionPerspective">
+        </activityPatternBinding>
+     </extension>
 </plugin>
index 202e6193f34e88503351016139a3630424a11028..bd423323bfc2a54b48396e2d132d9ceb32490489 100644 (file)
             id="org.argeo.slc.client.ui.processEditorInputFactory">
       </factory>
    </extension>
+   <extension
+           point="org.eclipse.ui.activities">
+     </extension>
+  <extension
+           point="org.eclipse.ui.activities">
+        <activity
+              description="SLC users"
+              id="org.argeo.slc.client.ui.slcActivity"
+              name="SLC">
+                 <enabledWhen>
+                   <with variable="roles">
+                     <iterate ifEmpty="false" operator="or">
+                       <equals value="ROLE_SLC" />
+                     </iterate>
+                   </with>
+                 </enabledWhen>
+        </activity>
+        <!-- TODO: find a way to exclude evrything -->
+        <activityPatternBinding
+              activityId="org.argeo.slc.client.ui.slcActivity"
+              isEqualityPattern="true"
+              pattern="org.argeo.slc.client.ui/org.argeo.slc.client.ui.slcExecutionPerspective">
+        </activityPatternBinding>
+        <activityPatternBinding
+              activityId="org.argeo.security.ui.adminActivity"
+              isEqualityPattern="true"
+              pattern="org.argeo.slc.client.ui/org.argeo.slc.client.ui.slcExecutionPerspective">
+        </activityPatternBinding>
+     </extension>
 </plugin>
index e946fe133e5a351dd53274649efa0706de50dec6..48e4ce56df9eca099fe542b9213f295451bd9f53 100644 (file)
@@ -17,9 +17,12 @@ package org.argeo.slc.core.execution;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
 import org.argeo.slc.execution.ExecutionFlowDescriptor;
 import org.argeo.slc.execution.ExecutionStep;
 import org.argeo.slc.process.RealizedFlow;
+import org.springframework.security.Authentication;
+import org.springframework.security.context.SecurityContextHolder;
 
 /** Thread of a single execution */
 public class ExecutionThread extends Thread {
@@ -40,11 +43,11 @@ public class ExecutionThread extends Thread {
 
        public void run() {
                // authenticate thread
-//             Authentication authentication = getProcessThreadGroup()
-//                             .getAuthentication();
-//             if (authentication == null)
-//                     throw new SlcException("Can only execute authenticated threads");
-//             SecurityContextHolder.getContext().setAuthentication(authentication);
+               Authentication authentication = getProcessThreadGroup()
+                               .getAuthentication();
+               if (authentication == null)
+                       throw new SlcException("Can only execute authenticated threads");
+               SecurityContextHolder.getContext().setAuthentication(authentication);
 
                if (getContextClassLoader() != null) {
                        if (log.isTraceEnabled())
index 177df4241908d58f239fbac9e93580e48cfe8207..428cfd178330ed6eff39bea78e6859ddf5682306 100644 (file)
@@ -29,6 +29,8 @@ import org.argeo.slc.execution.ExecutionProcess;
 import org.argeo.slc.execution.ExecutionStep;
 import org.argeo.slc.process.RealizedFlow;
 import org.argeo.slc.process.SlcExecution;
+import org.springframework.security.Authentication;
+import org.springframework.security.context.SecurityContextHolder;
 
 /** Thread of the SLC Process, starting the sub executions. */
 @SuppressWarnings("deprecation")
@@ -57,11 +59,11 @@ public class ProcessThread extends Thread {
 
        public final void run() {
                // authenticate thread
-               // Authentication authentication = getProcessThreadGroup()
-               // .getAuthentication();
-               // if (authentication == null)
-               // throw new SlcException("Can only execute authenticated threads");
-               // SecurityContextHolder.getContext().setAuthentication(authentication);
+                Authentication authentication = getProcessThreadGroup()
+                .getAuthentication();
+                if (authentication == null)
+                throw new SlcException("Can only execute authenticated threads");
+                SecurityContextHolder.getContext().setAuthentication(authentication);
 
                // log.info("\n##\n## SLC Process #" + process.getUuid() +
                // " STARTED by "
index ccff842a4438738066fe6c30f3400c7811afef27..98bbf5272e992f5546df3f84175749f3ec671c7d 100644 (file)
@@ -25,13 +25,15 @@ import org.argeo.slc.execution.ExecutionProcess;
 import org.argeo.slc.execution.ExecutionStep;
 import org.argeo.slc.process.SlcExecution;
 import org.argeo.slc.process.SlcExecutionStep;
+import org.springframework.security.Authentication;
+import org.springframework.security.context.SecurityContextHolder;
 
 /** The thread group attached to a given {@link SlcExecution}. */
 @SuppressWarnings("deprecation")
 public class ProcessThreadGroup extends ThreadGroup {
        private final ExecutionModulesManager executionModulesManager;
        private final ProcessThread processThread;
-//     private final Authentication authentication;
+       private final Authentication authentication;
        private final static Integer STEPS_BUFFER_CAPACITY = 5000;
 
        private BlockingQueue<ExecutionStep> steps = new ArrayBlockingQueue<ExecutionStep>(
@@ -43,13 +45,13 @@ public class ProcessThreadGroup extends ThreadGroup {
                                + " thread group");
                this.executionModulesManager = executionModulesManager;
                this.processThread = processThread;
-//             this.authentication = SecurityContextHolder.getContext()
-//                             .getAuthentication();
+               this.authentication = SecurityContextHolder.getContext()
+                               .getAuthentication();
        }
 
-//     public Authentication getAuthentication() {
-//             return authentication;
-//     }
+       public Authentication getAuthentication() {
+               return authentication;
+       }
 
        public void dispatchAddStep(ExecutionStep step) {
                // legacy