mirror of https://github.com/apache/openjpa.git
OPENJPA-339 committing on behalf of Albert
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@570288 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
99029c0bda
commit
62b3725596
|
@ -19,6 +19,7 @@
|
||||||
package org.apache.openjpa.meta;
|
package org.apache.openjpa.meta;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
|
@ -656,9 +657,15 @@ public abstract class AbstractCFMetaDataFactory
|
||||||
if (log.isTraceEnabled())
|
if (log.isTraceEnabled())
|
||||||
log.trace(_loc.get("scan-found-names", clss, file));
|
log.trace(_loc.get("scan-found-names", clss, file));
|
||||||
names.addAll(Arrays.asList(clss));
|
names.addAll(Arrays.asList(clss));
|
||||||
mapPersistentTypeNames(((File) AccessController
|
File f = (File) AccessController
|
||||||
.doPrivileged(J2DoPrivHelper
|
.doPrivileged(J2DoPrivHelper
|
||||||
.getAbsoluteFileAction(file))).toURL(), clss);
|
.getAbsoluteFileAction(file));
|
||||||
|
try {
|
||||||
|
mapPersistentTypeNames(AccessController
|
||||||
|
.doPrivileged(J2DoPrivHelper.toURLAction(f)), clss);
|
||||||
|
} catch (PrivilegedActionException pae) {
|
||||||
|
throw (FileNotFoundException) pae.getException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -517,7 +517,8 @@ public class ProxyManagerImpl
|
||||||
boolean runtime) {
|
boolean runtime) {
|
||||||
assertNotFinal(type);
|
assertNotFinal(type);
|
||||||
Project project = new Project();
|
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.setSuperclass(type);
|
||||||
bc.declareInterface(ProxyCollection.class);
|
bc.declareInterface(ProxyCollection.class);
|
||||||
|
|
||||||
|
@ -554,7 +555,8 @@ public class ProxyManagerImpl
|
||||||
protected BCClass generateProxyMapBytecode(Class type, boolean runtime) {
|
protected BCClass generateProxyMapBytecode(Class type, boolean runtime) {
|
||||||
assertNotFinal(type);
|
assertNotFinal(type);
|
||||||
Project project = new Project();
|
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.setSuperclass(type);
|
||||||
bc.declareInterface(ProxyMap.class);
|
bc.declareInterface(ProxyMap.class);
|
||||||
|
|
||||||
|
@ -573,7 +575,8 @@ public class ProxyManagerImpl
|
||||||
protected BCClass generateProxyDateBytecode(Class type, boolean runtime) {
|
protected BCClass generateProxyDateBytecode(Class type, boolean runtime) {
|
||||||
assertNotFinal(type);
|
assertNotFinal(type);
|
||||||
Project project = new Project();
|
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.setSuperclass(type);
|
||||||
bc.declareInterface(ProxyDate.class);
|
bc.declareInterface(ProxyDate.class);
|
||||||
|
|
||||||
|
@ -592,7 +595,8 @@ public class ProxyManagerImpl
|
||||||
boolean runtime) {
|
boolean runtime) {
|
||||||
assertNotFinal(type);
|
assertNotFinal(type);
|
||||||
Project project = new Project();
|
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.setSuperclass(type);
|
||||||
bc.declareInterface(ProxyCalendar.class);
|
bc.declareInterface(ProxyCalendar.class);
|
||||||
|
|
||||||
|
@ -626,7 +630,8 @@ public class ProxyManagerImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
Project project = new Project();
|
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.setSuperclass(type);
|
||||||
bc.declareInterface(ProxyBean.class);
|
bc.declareInterface(ProxyBean.class);
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedActionException;
|
import java.security.PrivilegedActionException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -111,8 +112,14 @@ public class FileMetaDataIterator implements MetaDataIterator {
|
||||||
throw new NoSuchElementException();
|
throw new NoSuchElementException();
|
||||||
|
|
||||||
_file = (File) _itr.next();
|
_file = (File) _itr.next();
|
||||||
return ((File) AccessController.doPrivileged(J2DoPrivHelper
|
try {
|
||||||
.getAbsoluteFileAction(_file))).toURL();
|
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 {
|
public InputStream getInputStream() throws IOException {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.AccessibleObject;
|
import java.lang.reflect.AccessibleObject;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -69,6 +70,7 @@ import serp.bytecode.Project;
|
||||||
* <li>File.isDirectory
|
* <li>File.isDirectory
|
||||||
* <li>File.mkdirs
|
* <li>File.mkdirs
|
||||||
* <li>File.renameTo
|
* <li>File.renameTo
|
||||||
|
* <li>File.toURL
|
||||||
* <li>FileInputStream new
|
* <li>FileInputStream new
|
||||||
* <li>FileOutputStream new
|
* <li>FileOutputStream new
|
||||||
* <li>System.getProperties
|
* <li>System.getProperties
|
||||||
|
@ -593,6 +595,24 @@ public abstract class J2DoPrivHelper {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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().
|
* Return a PrivilegedExceptionAction object for new FileInputStream().
|
||||||
*
|
*
|
||||||
|
@ -966,4 +986,21 @@ public abstract class J2DoPrivHelper {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.openjpa.persistence;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedActionException;
|
import java.security.PrivilegedActionException;
|
||||||
|
@ -458,7 +459,12 @@ public class PersistenceProductDerivation
|
||||||
@Override
|
@Override
|
||||||
public void parse(File file)
|
public void parse(File file)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
_source = file.toURL();
|
try {
|
||||||
|
_source = (URL) AccessController.doPrivileged(J2DoPrivHelper
|
||||||
|
.toURLAction(file));
|
||||||
|
} catch (PrivilegedActionException pae) {
|
||||||
|
throw (MalformedURLException) pae.getException();
|
||||||
|
}
|
||||||
super.parse(file);
|
super.parse(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedActionException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -219,8 +220,12 @@ public class PersistenceUnitInfoImpl
|
||||||
if (cp[i].equals(name)
|
if (cp[i].equals(name)
|
||||||
|| cp[i].endsWith(File.separatorChar + name)) {
|
|| cp[i].endsWith(File.separatorChar + name)) {
|
||||||
try {
|
try {
|
||||||
addJarFile(new File(cp[i]).toURL());
|
addJarFile((URL) AccessController
|
||||||
|
.doPrivileged(J2DoPrivHelper
|
||||||
|
.toURLAction(new File(cp[i]))));
|
||||||
return;
|
return;
|
||||||
|
} catch (PrivilegedActionException pae) {
|
||||||
|
break;
|
||||||
} catch (MalformedURLException mue) {
|
} catch (MalformedURLException mue) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue