db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krist...@apache.org
Subject svn commit: r1295609 - /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
Date Thu, 01 Mar 2012 15:08:33 GMT
Author: kristwaa
Date: Thu Mar  1 15:08:33 2012
New Revision: 1295609

URL: http://svn.apache.org/viewvc?rev=1295609&view=rev
Log:
DERBY-5631: Extend SecurityManagerSetup to add extra privileges to the set of default privileges
(merge two policy files)

Deal with errors in the URL handling.

Patch file: derby-5631-1e-merge_policy_files-fix-url.diff

Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java?rev=1295609&r1=1295608&r2=1295609&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/SecurityManagerSetup.java
Thu Mar  1 15:08:33 2012
@@ -23,6 +23,7 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.security.AccessController;
 import java.security.Policy;
@@ -493,10 +494,10 @@ public final class SecurityManagerSetup 
             throws IOException {
         String resource = policy1;
         if (!NO_POLICY.equals(resource)) {
-            URL url1 = BaseTestCase.getTestResource(policy1);
+            URL url1 = getResourceURL(policy1);
             resource = url1.toExternalForm();
             if (policy2 != null) {
-                URL url2 = BaseTestCase.getTestResource(policy2);
+                URL url2 = getResourceURL(policy2);
                 // Don't use URL.equals - it blocks and goes onto the network.
                 if (!url1.toExternalForm().equals(url2.toExternalForm())) {
                     resource = mergePolicies(url1, url2);
@@ -507,6 +508,24 @@ public final class SecurityManagerSetup 
     }
 
     /**
+     * Returns a URL for the given policy resource.
+     *
+     * @param policy the policy resource
+     * @return A {@code URL} denoting the policy resource.
+     * @throws MalformedURLException if the resource string not a valid URL
+     */
+    private static URL getResourceURL(final String policy)
+            throws MalformedURLException {
+        URL url = BaseTestCase.getTestResource(policy);
+        if (url == null) {
+            // Assume the policy is expressed as an URL already, probably
+            // as a file.
+            url =  new URL(policy);
+        }
+        return url;       
+    }
+
+    /**
      * Merges the two specified policy resources (typically files), and writes
      * the combined policy to a new file.
      *



Mime
View raw message