Authenticate SLC execution threads
authorMathieu Baudier <mbaudier@argeo.org>
Fri, 2 Mar 2012 12:08:21 +0000 (12:08 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Fri, 2 Mar 2012 12:08:21 +0000 (12:08 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@5131 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

15 files changed:
demo/log4j.properties
demo/site/org.argeo.slc.demo.basic/META-INF/MANIFEST.MF
demo/site/org.argeo.slc.demo.basic/conf/systemCall.xml
demo/slc_demo_rap.properties
demo/slc_demo_rcp.properties
eclipse/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/SlcExecutionPerspective.java
modules/agent/org.argeo.slc.agent/pom.xml
modules/agent/org.argeo.slc.ext.activemq/pom.xml
modules/server/org.argeo.slc.server.repo/META-INF/spring/jcr.xml
modules/server/org.argeo.slc.server.repo/META-INF/spring/services.xml
pom.xml
runtime/org.argeo.slc.core/pom.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 f1f38c20d7ec92d8e40eddbfeb24f2fc0cc418bf..2989237be0007e09a0fa251c5e9208e6e92d0767 100644 (file)
@@ -8,7 +8,7 @@ log4j.logger.org.argeo.jackrabbit.remote.ExtendedDispatcherServlet=ERROR
 log4j.logger.org.springframework.web.servlet.PageNotFound=ERROR
 log4j.logger.org.argeo.server.webextender.TomcatDeployer=WARN
 log4j.logger.org.argeo.slc.client.ui.dist=TRACE
-
+log4j.logger.org.argeo.security.core=TRACE
 #log4j.logger.org.argeo.jcr.proxy=TRACE
 
 #log4j.logger.org.apache.jackrabbit.webdav=DEBUG
index 3df94413243366cbcdf79ae1a6ce348dd3904965..00edc84d0846061de032c49c57fdc7697716bd97 100644 (file)
@@ -17,6 +17,7 @@ Import-Package: net.sf.cglib.core,
  org.argeo.slc.core.test.tree,
  org.argeo.slc.execution,
  org.argeo.slc.jsch,
+ org.argeo.slc.jsch.swing,
  org.argeo.slc.osgi,
  org.argeo.slc.structure,
  org.argeo.slc.test,
index 93fcd4a7fa736b42b52a8ec90df38c2d19985853..bb5f79fb6844bbacbcc8ae33f4913827451c8467 100644 (file)
@@ -35,7 +35,7 @@
                        <bean p:host="localhost" p:port="22" p:user="${user.name}"\r
                                p:localPrivateKey="${user.home}/.ssh/id_rsa" class="org.argeo.slc.jsch.SshTarget">\r
                                <property name="userInfo">\r
-                                       <bean class="org.argeo.slc.jsch.UiUserInfo" />\r
+                                       <bean class="org.argeo.slc.jsch.swing.SwingUserInfo" />\r
                                </property>\r
                        </bean>\r
                </property>\r
index 7a8d96eb6975c316cf666d486468a188a690a92f..ddb0f29ef83f43773e8e44747c56d844ac4fbb29 100644 (file)
@@ -24,8 +24,10 @@ org.argeo.slc.infra.ui.rap,\
 org.argeo.slc.agent,\
 org.argeo.slc.agent.jcr,\
 org.springframework.osgi.web.extender,\
-org.argeo.slc.demo.ant,\
+
+slc.executionModules=org.argeo.slc.demo.ant,\
 org.argeo.slc.demo.basic,\
+org.argeo.slc.demo.minimal,\
 
 #slc.executionModules=org.argeo.infra.slc.rpmfactory,\
 #org.argeo.elgis.rpmfactory,\
index 5d7e4dc9e68f88040f76b634690c082c84ddf810..08e65ac71d401e9689f0e556398f2c746def98de 100644 (file)
@@ -6,10 +6,10 @@ org.argeo.security.dao.os,\
 org.argeo.slc.node.jackrabbit,\
 org.argeo.slc.agent,\
 org.argeo.slc.agent.jcr,\
-org.argeo.slc.demo.ant,\
+
+slc.executionModules=org.argeo.slc.demo.ant,\
 org.argeo.slc.demo.basic,\
 org.argeo.slc.demo.minimal,\
-org.argeo.elgis.rpmfactory,\
 
 eclipse.application=org.argeo.slc.client.rcp.application
 org.argeo.security.ui.initialPerspective=org.argeo.slc.client.ui.slcExecutionPerspective
index d5ba0b0d81c4d67437659f5361c84f9b8b63846b..f53ac7ce2cbb9a64900f7ac4982981b790d974aa 100644 (file)
@@ -17,28 +17,28 @@ public class SlcExecutionPerspective implements IPerspectiveFactory {
                // current space and the part on bottom gets the rest. Likewise, for a
                // horizontal split, the part at left gets the specified ratio of the
                // current space.
-//             IFolderLayout main = layout.createFolder("main", IPageLayout.RIGHT,
-//                             0.3f, editorArea);
+               // IFolderLayout main = layout.createFolder("main", IPageLayout.RIGHT,
+               // 0.3f, editorArea);
                IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT,
                                0.3f, editorArea);
 
                IFolderLayout bottom = layout.createFolder("bottom",
                                IPageLayout.BOTTOM, 0.65f, editorArea);
+               bottom.addView("org.argeo.security.ui.logView");
                bottom.addView("org.argeo.slc.client.ui.jcrProcessListView");
 
-//             IFolderLayout topRight = layout.createFolder("topRight",
-//                             IPageLayout.RIGHT, 0.6f, "main");
+               // IFolderLayout topRight = layout.createFolder("topRight",
+               // IPageLayout.RIGHT, 0.6f, "main");
 
                // add the views to the corresponding place holder
                left.addView("org.argeo.slc.client.ui.jcrExecutionModulesView");
                left.addView("org.argeo.slc.client.ui.jcrResultListView");
 
-//             main.addView("org.argeo.slc.client.ui.processBuilderView");
-//             main.addPlaceholder("org.argeo.slc.client.ui.resultDetailView:UUID-*");
-//             main.addPlaceholder("org.argeo.slc.client.ui.processDetailView:UUID-*");
+               // main.addView("org.argeo.slc.client.ui.processBuilderView");
+               // main.addPlaceholder("org.argeo.slc.client.ui.resultDetailView:UUID-*");
+               // main.addPlaceholder("org.argeo.slc.client.ui.processDetailView:UUID-*");
 
-
-//             topRight.addView("org.argeo.slc.client.ui.processParametersView");
+               // topRight.addView("org.argeo.slc.client.ui.processParametersView");
        }
 
 }
index ccd133cdce8bbf99dc5a516ddb4dce7aa4159983..e82c797fb5e64f68f16e5f720522974fb61b196e 100644 (file)
@@ -9,4 +9,20 @@
        </parent>
        <artifactId>org.argeo.slc.agent</artifactId>
        <name>SLC Agent</name>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <configuration>
+                                       <instructions>
+                                               <Import-Package>
+                                                       *,
+                                                       org.argeo.slc.core.test.tree
+                                               </Import-Package>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
 </project>
\ No newline at end of file
index eaa33bc584ed3d577881f566671b0620fba84f9e..8e5cfc769b0ade9189a05083aa2bed0aba9dcf14 100644 (file)
@@ -25,7 +25,6 @@
                                                        org.argeo.slc.build,
                                                        org.argeo.slc.core.execution,
                                                        org.argeo.slc.core.attachment,
-                                                       org.argeo.slc.core.execution,
                                                        org.argeo.slc.core.structure,
                                                        org.argeo.slc.core.structure.tree,
                                                        org.argeo.slc.core.test,
index 428dab3f020353c1849eefe74d2013e5ad49e6f6..2ac9d15e670f619535cb5b5004d02c7a79c7e3a9 100644 (file)
@@ -34,4 +34,8 @@
                <property name="repository" ref="jcrRepository" />\r
        </bean>\r
 \r
+       <bean\r
+               class="org.argeo.security.core.AuthenticatedApplicationContextInitialization">\r
+               <property name="authenticationManager" ref="authenticationManager" />\r
+       </bean>\r
 </beans>
\ No newline at end of file
index 206b6d41ec7d3a9f7a5c0dc2c2c6ec4235ee3a23..57e0cf6077ee5419a6e4fa43ff7a93b9d8194964 100644 (file)
                <property name="defaultRepositories" ref="defaultMavenRepositories" />
        </bean>
 
-       <bean
-               class="org.argeo.security.core.AuthenticatedApplicationContextInitialization">
-               <property name="authenticationManager" ref="authenticationManager" />
-       </bean>
-
-
 </beans>
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 7a8c369b738f8a3cd6950d040fb7f4720a808b1c..ea34cd896c199cb3f5d8d7c76f9442bb88e22f14 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -151,100 +151,100 @@ limitations under the License.
                        <url>file://${site.repoBase}/${developmentCycle.slc}/</url>
                </site>
        </distributionManagement>
-       <reporting>
-               <plugins>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-project-info-reports-plugin</artifactId>
-                               <version>2.3.1</version>
-                               <reportSets>
-                                       <reportSet>
-                                               <reports>
-                                                       <report>index</report>
-                                                       <report>summary</report>
-                                                       <report>license</report>
-                                                       <report>scm</report>
-                                                       <report>issue-tracking</report>
-                                                       <report>dependencies</report>
-                                               </reports>
-                                       </reportSet>
-                                       <reportSet>
-                                               <inherited>false</inherited>
-                                               <reports>
-                                                       <report>project-team</report>
-                                               </reports>
-                                       </reportSet>
-                               </reportSets>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-javadoc-plugin</artifactId>
-                               <version>2.7</version>
-                               <inherited>false</inherited>
-                               <configuration>
-                                       <aggregate>true</aggregate>
-                                       <encoding>UTF-8</encoding>
-                               </configuration>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-jxr-plugin</artifactId>
-                               <version>2.2</version>
-                               <configuration>
-                                       <aggregate>true</aggregate>
-                               </configuration>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-surefire-report-plugin</artifactId>
-                               <version>2.7.1</version>
-                               <inherited>false</inherited>
-                               <configuration>
-                                       <aggregate>true</aggregate>
-                               </configuration>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.codehaus.mojo</groupId>
-                               <artifactId>taglist-maven-plugin</artifactId>
-                               <version>2.4</version>
-                               <configuration>
-                                       <aggregate>true</aggregate>
-                                       <tags>
-                                               <tag>TODO</tag>
-                                               <tag>FIXME</tag>
-                                               <tag>@deprecated</tag>
-                                       </tags>
-                               </configuration>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-changelog-plugin</artifactId>
-                               <version>2.2</version>
-                               <inherited>false</inherited>
-                       </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-pmd-plugin</artifactId>
-                               <version>2.3</version>
-                               <inherited>false</inherited>
-                               <configuration>
-                                       <linkXref>true</linkXref>
-                                       <targetJdk>1.5</targetJdk>
-                                       <aggregate>true</aggregate>
-                                       <excludes>
-                                               <exclude>**/springutil/*.java</exclude>
-                                       </excludes>
-                               </configuration>
-                               <reportSets>
-                                       <reportSet>
-                                               <reports>
-                                                       <report>cpd</report>
-                                               </reports>
-                                       </reportSet>
-                               </reportSets>
-                       </plugin>
-               </plugins>
-       </reporting>
+<!--   <reporting> -->
+<!--           <plugins> -->
+<!--                   <plugin> -->
+<!--                           <groupId>org.apache.maven.plugins</groupId> -->
+<!--                           <artifactId>maven-project-info-reports-plugin</artifactId> -->
+<!--                           <version>2.3.1</version> -->
+<!--                           <reportSets> -->
+<!--                                   <reportSet> -->
+<!--                                           <reports> -->
+<!--                                                   <report>index</report> -->
+<!--                                                   <report>summary</report> -->
+<!--                                                   <report>license</report> -->
+<!--                                                   <report>scm</report> -->
+<!--                                                   <report>issue-tracking</report> -->
+<!--                                                   <report>dependencies</report> -->
+<!--                                           </reports> -->
+<!--                                   </reportSet> -->
+<!--                                   <reportSet> -->
+<!--                                           <inherited>false</inherited> -->
+<!--                                           <reports> -->
+<!--                                                   <report>project-team</report> -->
+<!--                                           </reports> -->
+<!--                                   </reportSet> -->
+<!--                           </reportSets> -->
+<!--                   </plugin> -->
+<!--                   <plugin> -->
+<!--                           <groupId>org.apache.maven.plugins</groupId> -->
+<!--                           <artifactId>maven-javadoc-plugin</artifactId> -->
+<!--                           <version>2.7</version> -->
+<!--                           <inherited>false</inherited> -->
+<!--                           <configuration> -->
+<!--                                   <aggregate>true</aggregate> -->
+<!--                                   <encoding>UTF-8</encoding> -->
+<!--                           </configuration> -->
+<!--                   </plugin> -->
+<!--                   <plugin> -->
+<!--                           <groupId>org.apache.maven.plugins</groupId> -->
+<!--                           <artifactId>maven-jxr-plugin</artifactId> -->
+<!--                           <version>2.2</version> -->
+<!--                           <configuration> -->
+<!--                                   <aggregate>true</aggregate> -->
+<!--                           </configuration> -->
+<!--                   </plugin> -->
+<!--                   <plugin> -->
+<!--                           <groupId>org.apache.maven.plugins</groupId> -->
+<!--                           <artifactId>maven-surefire-report-plugin</artifactId> -->
+<!--                           <version>2.7.1</version> -->
+<!--                           <inherited>false</inherited> -->
+<!--                           <configuration> -->
+<!--                                   <aggregate>true</aggregate> -->
+<!--                           </configuration> -->
+<!--                   </plugin> -->
+<!--                   <plugin> -->
+<!--                           <groupId>org.codehaus.mojo</groupId> -->
+<!--                           <artifactId>taglist-maven-plugin</artifactId> -->
+<!--                           <version>2.4</version> -->
+<!--                           <configuration> -->
+<!--                                   <aggregate>true</aggregate> -->
+<!--                                   <tags> -->
+<!--                                           <tag>TODO</tag> -->
+<!--                                           <tag>FIXME</tag> -->
+<!--                                           <tag>@deprecated</tag> -->
+<!--                                   </tags> -->
+<!--                           </configuration> -->
+<!--                   </plugin> -->
+<!--                   <plugin> -->
+<!--                           <groupId>org.apache.maven.plugins</groupId> -->
+<!--                           <artifactId>maven-changelog-plugin</artifactId> -->
+<!--                           <version>2.2</version> -->
+<!--                           <inherited>false</inherited> -->
+<!--                   </plugin> -->
+<!--                   <plugin> -->
+<!--                           <groupId>org.apache.maven.plugins</groupId> -->
+<!--                           <artifactId>maven-pmd-plugin</artifactId> -->
+<!--                           <version>2.3</version> -->
+<!--                           <inherited>false</inherited> -->
+<!--                           <configuration> -->
+<!--                                   <linkXref>true</linkXref> -->
+<!--                                   <targetJdk>1.5</targetJdk> -->
+<!--                                   <aggregate>true</aggregate> -->
+<!--                                   <excludes> -->
+<!--                                           <exclude>**/springutil/*.java</exclude> -->
+<!--                                   </excludes> -->
+<!--                           </configuration> -->
+<!--                           <reportSets> -->
+<!--                                   <reportSet> -->
+<!--                                           <reports> -->
+<!--                                                   <report>cpd</report> -->
+<!--                                           </reports> -->
+<!--                                   </reportSet> -->
+<!--                           </reportSets> -->
+<!--                   </plugin> -->
+<!--           </plugins> -->
+<!--   </reporting> -->
        <profiles>
                <profile>
                        <id>developer</id>
index d14cb4c0c94171e55d7f35b2c61a4b94d8b31aff..25f149ffdcbd2bc824f1e34d6892b105d190c5c7 100644 (file)
                        <type>pom</type>
                </dependency>
 
+               <!-- Spring -->
                <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>org.springframework.context</artifactId>
                </dependency>
+               <dependency>
+                       <groupId>org.springframework.security</groupId>
+                       <artifactId>org.springframework.security.core</artifactId>
+               </dependency>
 
                <dependency>
                        <groupId>net.sourceforge.cglib</groupId>
index 7493de4e7bd5178474304110ede04cc84c86ac6a..23bb947eee3ca5e240d179c13861b33fd7799ce3 100644 (file)
@@ -18,9 +18,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,6 +43,13 @@ 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);
+
                if (getContextClassLoader() != null) {
                        if (log.isTraceEnabled())
                                log.trace("Context class loader set to "
@@ -82,6 +92,10 @@ public class ExecutionThread extends Thread {
                processThread.getProcessThreadGroup().dispatchAddStep(step);
        }
 
+       protected ProcessThreadGroup getProcessThreadGroup() {
+               return processThread.getProcessThreadGroup();
+       }
+
        public RealizedFlow getRealizedFlow() {
                return realizedFlow;
        }
index b116696f16ee15a2227db219f7e7ca54622a265e..3117a3fd578b8229f7c4de65479916532b5e6464 100644 (file)
@@ -30,6 +30,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,8 +59,15 @@ public class ProcessThread extends Thread {
        }
 
        public final void run() {
-               log.info("\n##\n## SLC Process #" + process.getUuid()
-                               + " STARTED\n##\n");
+               // authenticate thread
+               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 "
+                               + authentication.getName() + "\n##\n");
 
                // Start logging
                new LoggingThread().start();
index 893d878fd99ae6ff8d9a427bc140ecc58abdaeef..d7fa4f959eb45361d444b21e1ee08442a3322a1a 100644 (file)
@@ -26,13 +26,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 static Integer STEPS_BUFFER_CAPACITY = 5000;
 
        private BlockingQueue<ExecutionStep> steps = new ArrayBlockingQueue<ExecutionStep>(
@@ -44,6 +46,12 @@ public class ProcessThreadGroup extends ThreadGroup {
                                + " thread group");
                this.executionModulesManager = executionModulesManager;
                this.processThread = processThread;
+               this.authentication = SecurityContextHolder.getContext()
+                               .getAuthentication();
+       }
+
+       public Authentication getAuthentication() {
+               return authentication;
        }
 
        public void dispatchAddStep(ExecutionStep step) {