tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1178314 - /tuscany/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionHelper.java
Date Mon, 03 Oct 2011 07:26:18 GMT
Author: antelder
Date: Mon Oct  3 07:26:18 2011
New Revision: 1178314

URL: http://svn.apache.org/viewvc?rev=1178314&view=rev
Log:
TUSCANY-3956: Fix Java2 Security exception in ContributionHelper.getNestedJarUrls method

Modified:
    tuscany/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionHelper.java

Modified: tuscany/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionHelper.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionHelper.java?rev=1178314&r1=1178313&r2=1178314&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionHelper.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/java/impl/ContributionHelper.java
Mon Oct  3 07:26:18 2011
@@ -24,6 +24,8 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.zip.ZipEntry;
@@ -36,9 +38,13 @@ public class ContributionHelper {
 
     public static List<URL> getNestedJarUrls(final Contribution contribution) throws
IOException {
         List<URL> urls = new ArrayList<URL>();
-        boolean isZipContribution = contribution.getLocation().endsWith(".zip");
-        URI uri = URI.create(contribution.getLocation());
-        boolean isFolderContribution = !isZipContribution && uri.getScheme().equals("file")
&& new File(uri.getSchemeSpecificPart()).isDirectory();
+        final boolean isZipContribution = contribution.getLocation().endsWith(".zip");
+        final URI uri = URI.create(contribution.getLocation());
+        boolean isFolderContribution = AccessController.doPrivileged(new PrivilegedAction<Boolean>()
{
+            public Boolean run() {
+               return !isZipContribution && uri.getScheme().equals("file") &&
new File(uri.getSchemeSpecificPart()).isDirectory();
+            }
+        });
         if (isZipContribution || isFolderContribution) {
             for (Artifact a : contribution.getArtifacts()) {
                 if (a.getLocation().endsWith(".jar")) {



Mime
View raw message