flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cd...@apache.org
Subject git commit: [flex-falcon] [refs/heads/feature/maven-migration-test] - - The maven plugin confiuration had some "old-style" config options, I updated it to be 100% state-of-the-art-maven - Added a first version of a component for the maven plugin handling
Date Fri, 15 Apr 2016 10:04:53 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/feature/maven-migration-test de0706362 -> 96ce16348


- The maven plugin confiuration had some "old-style" config options, I updated it to be 100%
state-of-the-art-maven
- Added a first version of a component for the maven plugin handling the FlashPlayer trust
settings
- Added a duplicate of this security handler to allow updating the security settings for the
manually executed tests in the compiler module (hopefully this will make the jenkins build
work)


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/96ce1634
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/96ce1634
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/96ce1634

Branch: refs/heads/feature/maven-migration-test
Commit: 96ce16348d241e273de0661f8e56d04c3dc790a3
Parents: de07063
Author: Christofer Dutz <christofer.dutz@codecentric.de>
Authored: Fri Apr 15 12:04:43 2016 +0200
Committer: Christofer Dutz <christofer.dutz@codecentric.de>
Committed: Fri Apr 15 12:04:43 2016 +0200

----------------------------------------------------------------------
 compiler/pom.xml                                |   7 ++
 .../src/test/java/as/ASFeatureTestsBase.java    |   5 +
 .../java/utils/FlashplayerSecurityHandler.java  | 123 ++++++++++++++++++
 flexjs-maven-plugin/pom.xml                     |  86 +++++++++----
 .../apache/flex/maven/flexjs/CompileMojo.java   |   9 ++
 .../flexjs/FlashplayerSecurityHandler.java      | 125 +++++++++++++++++++
 .../flex/maven/flexjs/SecurityHandler.java      |  12 ++
 7 files changed, 342 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/96ce1634/compiler/pom.xml
----------------------------------------------------------------------
diff --git a/compiler/pom.xml b/compiler/pom.xml
index 35952f3..fc67522 100644
--- a/compiler/pom.xml
+++ b/compiler/pom.xml
@@ -426,6 +426,13 @@
             <version>4.10</version>
             <scope>test</scope>
         </dependency>
+        <!-- TODO: Currently only needed for the duplicate FlashplayerSecurityHandler
-->
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <version>3.4</version>
+            <scope>test</scope>
+        </dependency>
         <!--
 
                 Importing SWCs will add them to the test classpath.

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/96ce1634/compiler/src/test/java/as/ASFeatureTestsBase.java
----------------------------------------------------------------------
diff --git a/compiler/src/test/java/as/ASFeatureTestsBase.java b/compiler/src/test/java/as/ASFeatureTestsBase.java
index f7ac2f9..eede5f5 100644
--- a/compiler/src/test/java/as/ASFeatureTestsBase.java
+++ b/compiler/src/test/java/as/ASFeatureTestsBase.java
@@ -22,6 +22,7 @@ package as;
 import org.apache.flex.compiler.clients.MXMLC;
 import org.apache.flex.compiler.problems.ICompilerProblem;
 import org.apache.flex.utils.*;
+import utils.FlashplayerSecurityHandler;
 
 import java.io.BufferedWriter;
 import java.io.File;
@@ -135,6 +136,10 @@ public class ASFeatureTestsBase
 		try
 		{
 			System.out.println("Executing test:\n" + Arrays.toString(runArgs));
+
+			// TODO: Hack to add the directory containing the temp swf to the flashplayer trust.
+			new FlashplayerSecurityHandler().trustFile(tempASFile.getParentFile());
+
 			exitCode = executeCommandWithTimeout(runArgs, 20);
 		}
 		catch (Exception e)

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/96ce1634/compiler/src/test/java/utils/FlashplayerSecurityHandler.java
----------------------------------------------------------------------
diff --git a/compiler/src/test/java/utils/FlashplayerSecurityHandler.java b/compiler/src/test/java/utils/FlashplayerSecurityHandler.java
new file mode 100644
index 0000000..1637156
--- /dev/null
+++ b/compiler/src/test/java/utils/FlashplayerSecurityHandler.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package utils;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Little helper that adds a directory to the FlashPlayer trust settings.
+ * This prevents the FlashPlayer from complaining about running untrusted
+ * code, which will prevent the tests using the FlashPlayer from succeeding.
+ *
+ * Created by christoferdutz on 14.04.16.
+ *
+ * TODO: Clean up the tests.
+ * @deprecated This class is duplicated here to allow trusting SWFs till the testsuite has
been migrated.
+ */
+public class FlashplayerSecurityHandler {
+
+    public void trustFile(File directory) {
+        File securityTrustFile = new File(getSecuritySettingsDirectory(), "apache-flex-maven-plugin.cfg");
+
+        if(!securityTrustFile.exists()) {
+            System.out.println(" - Creating new FlashPlayer security trust file at: " + securityTrustFile.getPath());
+            try {
+                if(!securityTrustFile.createNewFile()) {
+                    throw new RuntimeException("Could not create FlashPlayer security trust
file at: " +
+                            securityTrustFile.getPath());
+                }
+            } catch (IOException e) {
+                throw new RuntimeException("Could not create FlashPlayer security trust file
at: " +
+                        securityTrustFile.getPath(), e);
+            }
+        } else {
+            System.out.println(" - Creating new FlashPlayer security trust file at: " + securityTrustFile.getPath());
+        }
+
+        // Check if the current directory is already listed in the file, if not, append it
to the file.
+        try {
+            List<String> trustedDirectories = FileUtils.readLines(securityTrustFile,
"UTF-8");
+            if(!trustedDirectories.contains(directory.getAbsolutePath())) {
+                FileUtils.writeStringToFile(securityTrustFile, directory.getAbsolutePath()
+ "\n", "UTF-8", true);
+                System.out.println(" - Added directory '" + directory.getAbsolutePath() +
+                        "' to FlashPlayer security trust file at: " + securityTrustFile.getPath());
+            } else {
+                System.out.println(" - Directory '" + directory.getAbsolutePath() +
+                        "' already listed in FlashPlayer security trust file at: " + securityTrustFile.getPath());
+            }
+        } catch (IOException e) {
+            throw new RuntimeException("Could not add directory '" + directory.getPath()
+
+                    "' to FlashPlayer security trust file", e);
+        }
+    }
+
+    private File getSecuritySettingsDirectory() {
+        File userHome = new File(System.getProperty("user.home"));
+        File securitySettingsDirectory;
+
+        if(SystemUtils.IS_OS_WINDOWS) {
+            // Try to get the location of the APPDATA directory from an environment-variable.
+            File appDataDirectory;
+            if(System.getenv("APPDATA") != null) {
+                appDataDirectory = new File(System.getenv("APPDATA"));
+            }
+            // If the environment-variable was not set, try defaults, depending on the
+            // detail version of Windows.
+            else {
+                // Vista did things differently.
+                if(SystemUtils.IS_OS_WINDOWS_VISTA) {
+                    appDataDirectory = new File(userHome, "AppData/Roaming");
+                } else {
+                    appDataDirectory = new File(userHome, "Application Data");
+                }
+            }
+            securitySettingsDirectory =
+                    new File(appDataDirectory, "Macromedia/Flash Player/#Security/FlashPlayerTrust");
+        }
+
+        else if(SystemUtils.IS_OS_MAC) {
+            securitySettingsDirectory = new File(userHome,
+                    "Library/Preferences/Macromedia/Flash Player/#Security/FlashPlayerTrust");
+        }
+
+        else if(SystemUtils.IS_OS_LINUX) {
+            securitySettingsDirectory = new File(userHome, ".macromedia/Flash_Player/#Security/FlashPlayerTrust");
+        }
+
+        // As the FlashPlayer is only available on Windows, Mac and Linux, this is all we
can do.
+        else {
+            throw new UnsupportedOperationException(
+                    "FlashplayerSecurityHandler not prepared for handling OS type of: " +
SystemUtils.OS_NAME);
+        }
+
+        // If the directory didn't exist yet, create it now.
+        if(!securitySettingsDirectory.exists()) {
+            if(!securitySettingsDirectory.mkdirs()) {
+                throw new RuntimeException("Could not create FlashPlayer security settings
directory at: " +
+                        securitySettingsDirectory.getPath());
+            }
+        }
+
+        return securitySettingsDirectory;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/96ce1634/flexjs-maven-plugin/pom.xml
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/pom.xml b/flexjs-maven-plugin/pom.xml
index b10f4b8..003f7e1 100644
--- a/flexjs-maven-plugin/pom.xml
+++ b/flexjs-maven-plugin/pom.xml
@@ -35,40 +35,36 @@
 
   <dependencies>
     <dependency>
-      <groupId>org.apache.maven</groupId>
-      <artifactId>maven-core</artifactId>
-      <version>3.0.4</version>
-      <exclusions>
-        <exclusion>
-          <groupId>org.sonatype.sisu</groupId>
-          <artifactId>sisu-guava</artifactId>
-        </exclusion>
-      </exclusions>
+      <groupId>javax.inject</groupId>
+      <artifactId>javax.inject</artifactId>
+      <version>1</version>
     </dependency>
     <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-compiler-api</artifactId>
-      <version>2.2</version>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>${maven.version}</version>
     </dependency>
     <dependency>
-      <groupId>commons-io</groupId>
-      <artifactId>commons-io</artifactId>
-      <version>2.4</version>
+      <groupId>org.apache.maven.plugin-tools</groupId>
+      <artifactId>maven-plugin-annotations</artifactId>
+      <version>3.4</version>
+      <scope>provided</scope>
     </dependency>
+
     <dependency>
       <groupId>org.apache.maven</groupId>
-      <artifactId>maven-plugin-api</artifactId>
-      <version>2.0</version>
+      <artifactId>maven-project</artifactId>
+      <version>2.2.1</version>
     </dependency>
     <dependency>
-      <groupId>org.apache.maven.plugin-tools</groupId>
-      <artifactId>maven-plugin-annotations</artifactId>
-      <version>3.1</version>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>2.4</version>
     </dependency>
     <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-utils</artifactId>
-      <version>3.0.3</version>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+      <version>3.4</version>
     </dependency>
     <dependency>
       <groupId>org.apache.flex</groupId>
@@ -82,9 +78,8 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-plugin-plugin</artifactId>
-        <version>3.1</version>
+        <version>3.4</version>
         <configuration>
-          <goalPrefix>flexjs</goalPrefix>
           <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
         </configuration>
         <executions>
@@ -102,7 +97,48 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.sonatype.plugins</groupId>
+        <artifactId>sisu-maven-plugin</artifactId>
+        <version>1.1</version>
+        <executions>
+          <execution>
+            <id>generate-index</id>
+            <goals>
+              <goal>main-index</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 
+  <!--build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-plugin-plugin</artifactId>
+        <version>3.4</version>
+        <configuration>
+          <goalPrefix>flexjs</goalPrefix>
+          <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
+        </configuration>
+        <executions>
+          <execution>
+            <id>mojo-descriptor</id>
+            <goals>
+              <goal>descriptor</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>help-goal</id>
+            <goals>
+              <goal>helpmojo</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build-->
+
 </project>

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/96ce1634/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileMojo.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileMojo.java
b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileMojo.java
index ca2b28a..660f222 100644
--- a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileMojo.java
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/CompileMojo.java
@@ -26,6 +26,7 @@ import org.apache.maven.plugins.annotations.Mojo;
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.maven.project.MavenProject;
 
+import javax.inject.Inject;
 import java.io.File;
 
 /**
@@ -48,6 +49,9 @@ public class CompileMojo
     @Parameter(defaultValue = "${project.artifactId}-${project.version}.swc")
     private String outputFileName;
 
+    @Inject
+    private SecurityHandler securityHandler;
+
     public void execute()
         throws MojoExecutionException
     {
@@ -63,6 +67,11 @@ public class CompileMojo
                 "-output=" + outputFile.getPath()};
         compc.execute(args);
 
+        // Add the output directory to the FlashPlayer trust files to prevent
+        // the FlashPlayer from complaining about running untrusted content.
+        // TODO: This should be handled somewhere else, but it's enough for now:
+        securityHandler.trustFile(outputDirectory);
+
         // Attach the file created by the compiler as artifact file to maven.
         project.getArtifact().setFile(outputFile);
     }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/96ce1634/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/FlashplayerSecurityHandler.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/FlashplayerSecurityHandler.java
b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/FlashplayerSecurityHandler.java
new file mode 100644
index 0000000..a0be9b1
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/FlashplayerSecurityHandler.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flex.maven.flexjs;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.SystemUtils;
+
+import javax.inject.Named;
+import javax.inject.Singleton;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Little helper that adds a directory to the FlashPlayer trust settings.
+ * This prevents the FlashPlayer from complaining about running untrusted
+ * code, which will prevent the tests using the FlashPlayer from succeeding.
+ *
+ * Created by christoferdutz on 14.04.16.
+ */
+@Named
+@Singleton
+public class FlashplayerSecurityHandler implements SecurityHandler {
+
+    @Override
+    public void trustFile(File directory) {
+        File securityTrustFile = new File(getSecuritySettingsDirectory(), "apache-flex-maven-plugin.cfg");
+
+        if(!securityTrustFile.exists()) {
+            System.out.println(" - Creating new FlashPlayer security trust file at: " + securityTrustFile.getPath());
+            try {
+                if(!securityTrustFile.createNewFile()) {
+                    throw new RuntimeException("Could not create FlashPlayer security trust
file at: " +
+                            securityTrustFile.getPath());
+                }
+            } catch (IOException e) {
+                throw new RuntimeException("Could not create FlashPlayer security trust file
at: " +
+                        securityTrustFile.getPath(), e);
+            }
+        } else {
+            System.out.println(" - Creating new FlashPlayer security trust file at: " + securityTrustFile.getPath());
+        }
+
+        // Check if the current directory is already listed in the file, if not, append it
to the file.
+        try {
+            List<String> trustedDirectories = FileUtils.readLines(securityTrustFile,
"UTF-8");
+            if(!trustedDirectories.contains(directory.getAbsolutePath())) {
+                FileUtils.writeStringToFile(securityTrustFile, directory.getAbsolutePath()
+ "\n", "UTF-8", true);
+                System.out.println(" - Added directory '" + directory.getAbsolutePath() +
+                        "' to FlashPlayer security trust file at: " + securityTrustFile.getPath());
+            } else {
+                System.out.println(" - Directory '" + directory.getAbsolutePath() +
+                        "' already listed in FlashPlayer security trust file at: " + securityTrustFile.getPath());
+            }
+        } catch (IOException e) {
+            throw new RuntimeException("Could not add directory '" + directory.getPath()
+
+                    "' to FlashPlayer security trust file", e);
+        }
+    }
+
+    private File getSecuritySettingsDirectory() {
+        File userHome = new File(System.getProperty("user.home"));
+        File securitySettingsDirectory;
+
+        if(SystemUtils.IS_OS_WINDOWS) {
+            // Try to get the location of the APPDATA directory from an environment-variable.
+            File appDataDirectory;
+            if(System.getenv("APPDATA") != null) {
+                appDataDirectory = new File(System.getenv("APPDATA"));
+            }
+            // If the environment-variable was not set, try defaults, depending on the
+            // detail version of Windows.
+            else {
+                // Vista did things differently.
+                if(SystemUtils.IS_OS_WINDOWS_VISTA) {
+                    appDataDirectory = new File(userHome, "AppData/Roaming");
+                } else {
+                    appDataDirectory = new File(userHome, "Application Data");
+                }
+            }
+            securitySettingsDirectory =
+                    new File(appDataDirectory, "Macromedia/Flash Player/#Security/FlashPlayerTrust");
+        }
+
+        else if(SystemUtils.IS_OS_MAC) {
+            securitySettingsDirectory = new File(userHome,
+                    "Library/Preferences/Macromedia/Flash Player/#Security/FlashPlayerTrust");
+        }
+
+        else if(SystemUtils.IS_OS_LINUX) {
+            securitySettingsDirectory = new File(userHome, ".macromedia/Flash_Player/#Security/FlashPlayerTrust");
+        }
+
+        // As the FlashPlayer is only available on Windows, Mac and Linux, this is all we
can do.
+        else {
+            throw new UnsupportedOperationException(
+                    "FlashplayerSecurityHandler not prepared for handling OS type of: " +
SystemUtils.OS_NAME);
+        }
+
+        // If the directory didn't exist yet, create it now.
+        if(!securitySettingsDirectory.exists()) {
+            if(!securitySettingsDirectory.mkdirs()) {
+                throw new RuntimeException("Could not create FlashPlayer security settings
directory at: " +
+                        securitySettingsDirectory.getPath());
+            }
+        }
+
+        return securitySettingsDirectory;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/96ce1634/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/SecurityHandler.java
----------------------------------------------------------------------
diff --git a/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/SecurityHandler.java
b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/SecurityHandler.java
new file mode 100644
index 0000000..577740c
--- /dev/null
+++ b/flexjs-maven-plugin/src/main/java/org/apache/flex/maven/flexjs/SecurityHandler.java
@@ -0,0 +1,12 @@
+package org.apache.flex.maven.flexjs;
+
+import java.io.File;
+
+/**
+ * Created by christoferdutz on 14.04.16.
+ */
+public interface SecurityHandler {
+
+    void trustFile(File directory);
+
+}


Mime
View raw message