openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r570288 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/meta/ openjpa-kernel/src/main/java/org/apache/openjpa/util/ openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ openjpa-lib/src/main/java/org/apache/openjpa/lib...
Date Tue, 28 Aug 2007 01:05:18 GMT
Author: mikedd
Date: Mon Aug 27 18:05:18 2007
New Revision: 570288

URL: http://svn.apache.org/viewvc?rev=570288&view=rev
Log:
OPENJPA-339 committing on behalf of Albert

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/FileMetaDataIterator.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/J2DoPrivHelper.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java?rev=570288&r1=570287&r2=570288&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java
Mon Aug 27 18:05:18 2007
@@ -19,6 +19,7 @@
 package org.apache.openjpa.meta;
 
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
@@ -656,9 +657,15 @@
                     if (log.isTraceEnabled())
                         log.trace(_loc.get("scan-found-names", clss, file));
                     names.addAll(Arrays.asList(clss));
-                    mapPersistentTypeNames(((File) AccessController
+                    File f = (File) AccessController
                         .doPrivileged(J2DoPrivHelper
-                            .getAbsoluteFileAction(file))).toURL(), clss);
+                            .getAbsoluteFileAction(file));
+                    try {
+                        mapPersistentTypeNames(AccessController
+                            .doPrivileged(J2DoPrivHelper.toURLAction(f)), clss);
+                    } catch (PrivilegedActionException pae) {
+                        throw (FileNotFoundException) pae.getException();
+                    }
                 }
             }
         }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java?rev=570288&r1=570287&r2=570288&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
Mon Aug 27 18:05:18 2007
@@ -517,7 +517,8 @@
         boolean runtime) {
         assertNotFinal(type);
         Project project = new Project(); 
-        BCClass bc = project.loadClass(getProxyClassName(type, runtime));
+        BCClass bc = (BCClass) AccessController.doPrivileged(J2DoPrivHelper
+            .loadProjectClassAction(project, getProxyClassName(type, runtime))); 
         bc.setSuperclass(type);
         bc.declareInterface(ProxyCollection.class);
  
@@ -554,7 +555,8 @@
     protected BCClass generateProxyMapBytecode(Class type, boolean runtime) {
         assertNotFinal(type);
         Project project = new Project(); 
-        BCClass bc = project.loadClass(getProxyClassName(type, runtime));
+        BCClass bc = (BCClass) AccessController.doPrivileged(J2DoPrivHelper
+            .loadProjectClassAction(project, getProxyClassName(type, runtime))); 
         bc.setSuperclass(type);
         bc.declareInterface(ProxyMap.class);
  
@@ -573,7 +575,8 @@
     protected BCClass generateProxyDateBytecode(Class type, boolean runtime) {
         assertNotFinal(type);
         Project project = new Project(); 
-        BCClass bc = project.loadClass(getProxyClassName(type, runtime));
+        BCClass bc = (BCClass) AccessController.doPrivileged(J2DoPrivHelper
+            .loadProjectClassAction(project, getProxyClassName(type, runtime))); 
         bc.setSuperclass(type);
         bc.declareInterface(ProxyDate.class);
  
@@ -592,7 +595,8 @@
         boolean runtime) {
         assertNotFinal(type);
         Project project = new Project(); 
-        BCClass bc = project.loadClass(getProxyClassName(type, runtime));
+        BCClass bc = (BCClass) AccessController.doPrivileged(J2DoPrivHelper
+            .loadProjectClassAction(project, getProxyClassName(type, runtime))); 
         bc.setSuperclass(type);
         bc.declareInterface(ProxyCalendar.class);
  
@@ -626,7 +630,8 @@
         }
 
         Project project = new Project(); 
-        BCClass bc = project.loadClass(getProxyClassName(type, runtime));
+        BCClass bc = (BCClass) AccessController.doPrivileged(J2DoPrivHelper
+            .loadProjectClassAction(project, getProxyClassName(type, runtime))); 
         bc.setSuperclass(type);
         bc.declareInterface(ProxyBean.class);
  

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/FileMetaDataIterator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/FileMetaDataIterator.java?rev=570288&r1=570287&r2=570288&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/FileMetaDataIterator.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/FileMetaDataIterator.java
Mon Aug 27 18:05:18 2007
@@ -24,6 +24,7 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.MalformedURLException;
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
 import java.util.ArrayList;
@@ -111,8 +112,14 @@
             throw new NoSuchElementException();
 
         _file = (File) _itr.next();
-        return ((File) AccessController.doPrivileged(J2DoPrivHelper
-            .getAbsoluteFileAction(_file))).toURL();
+        try {
+            File f = (File) AccessController.doPrivileged(J2DoPrivHelper
+                .getAbsoluteFileAction(_file));
+            return AccessController.doPrivileged(
+                J2DoPrivHelper.toURLAction(f));
+        } catch (PrivilegedActionException pae) {
+            throw (MalformedURLException) pae.getException();
+        }
     }
 
     public InputStream getInputStream() throws IOException {

Modified: openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/J2DoPrivHelper.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/J2DoPrivHelper.java?rev=570288&r1=570287&r2=570288&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/J2DoPrivHelper.java
(original)
+++ openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/J2DoPrivHelper.java
Mon Aug 27 18:05:18 2007
@@ -25,6 +25,7 @@
 import java.io.IOException;
 import java.lang.reflect.AccessibleObject;
 import java.net.InetAddress;
+import java.net.MalformedURLException;
 import java.net.ServerSocket;
 import java.net.Socket;
 import java.net.URL;
@@ -69,6 +70,7 @@
  * <li>File.isDirectory
  * <li>File.mkdirs
  * <li>File.renameTo
+ * <li>File.toURL
  * <li>FileInputStream new
  * <li>FileOutputStream new
  * <li>System.getProperties
@@ -594,6 +596,24 @@
     }
 
     /**
+     * Return a PrivilegedExceptionAction object for f.toURL().
+     * 
+     * Requires security policy:
+     *   'permission java.io.FilePermission "read";'
+     *   
+     * @return Boolean
+     * @throws MalformedURLException
+     */
+    public static final PrivilegedExceptionAction toURLAction(final File file)
+        throws MalformedURLException {
+        return new PrivilegedExceptionAction() {
+            public Object run() throws MalformedURLException {
+                return file.toURL();
+            }
+        };
+    }
+
+    /**
      * Return a PrivilegedExceptionAction object for new FileInputStream().
      * 
      * Requires security policy:
@@ -963,6 +983,23 @@
         return new PrivilegedAction() {
             public Object run() {
                 return project.loadClass(clazz);
+            }
+        };
+    }
+    
+    /**
+     * Return a PrivilegeAction object for Project.loadClass().
+     * 
+     * Requires security policy:
+     *   'permission java.lang.RuntimePermission "getClassLoader";'
+     *   
+     * @return BCClass
+     */
+    public static final PrivilegedAction loadProjectClassAction(
+        final Project project, final String clazzName) {
+        return new PrivilegedAction() {
+            public Object run() {
+                return project.loadClass(clazzName);
             }
         };
     }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java?rev=570288&r1=570287&r2=570288&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceProductDerivation.java
Mon Aug 27 18:05:18 2007
@@ -20,6 +20,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URL;
 import java.security.AccessController;
 import java.security.PrivilegedActionException;
@@ -458,7 +459,12 @@
         @Override
         public void parse(File file)
             throws IOException {
-            _source = file.toURL();
+            try {
+                _source = (URL) AccessController.doPrivileged(J2DoPrivHelper
+                    .toURLAction(file));
+            } catch (PrivilegedActionException pae) {
+                throw (MalformedURLException) pae.getException();
+            }
             super.parse(file);
         }
 

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java?rev=570288&r1=570287&r2=570288&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceUnitInfoImpl.java
Mon Aug 27 18:05:18 2007
@@ -24,6 +24,7 @@
 import java.net.URL;
 import java.net.URLDecoder;
 import java.security.AccessController;
+import java.security.PrivilegedActionException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -219,8 +220,12 @@
             if (cp[i].equals(name)
                 || cp[i].endsWith(File.separatorChar + name)) {
                 try {
-                    addJarFile(new File(cp[i]).toURL());
+                    addJarFile((URL) AccessController
+                        .doPrivileged(J2DoPrivHelper
+                            .toURLAction(new File(cp[i]))));
                     return;
+                } catch (PrivilegedActionException pae) {
+                    break;
                 } catch (MalformedURLException mue) {
                     break;
                 }



Mime
View raw message