openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mik...@apache.org
Subject svn commit: r552996 [1/3] - in /openjpa/trunk: ./ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ openjpa-jdbc/src/main/java/org/a...
Date Tue, 03 Jul 2007 21:55:33 GMT
Author: mikedd
Date: Tue Jul  3 14:55:29 2007
New Revision: 552996

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

Added:
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/J2DoPrivHelper.java   (with props)
    openjpa/trunk/openjpa-persistence-jdbc/src/test/resources/j2.security.test.policy
Modified:
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ReverseMappingToolTask.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingRepositoryValue.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/FileSchemaFactory.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java
    openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionaryFactory.java
    openjpa/trunk/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/abstractstore/AbstractStoreBrokerFactory.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASManagedRuntime.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ApplicationIdTool.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/DynamicStorageGenerator.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/Reflection.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/BeanLifecycleCallbacks.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/MethodLifecycleCallbacks.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Filters.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ObjectIdStateManager.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryLanguages.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ResultPacker.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractCFMetaDataFactory.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractMetaDataDefaults.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/FieldMetaData.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/InterfaceImplGenerator.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/SequenceMetaData.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ApplicationIds.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ClassResolverImpl.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Exceptions.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Id.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Proxies.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/ProxyManagerImpl.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/util/Serialization.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/ant/AbstractTask.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ConfigurationImpl.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/Configurations.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/FileValue.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ObjectValue.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/conf/ProductDerivations.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/LoggingConnectionDecorator.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/jdbc/SQLFormatter.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogFactoryImpl.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/log/LogOutputStream.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/CFMetaDataParser.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassArgParser.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClassMetaDataIterator.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ClasspathMetaDataIterator.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/meta/ResourceMetaDataIterator.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/SourceTrackers.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/URLMetaDataIterator.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataParser.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/XMLMetaDataSerializer.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/meta/ZipFileMetaDataIterator.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/CodeFormat.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Files.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/FormatPreservingProperties.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/JavaVersions.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Localizer.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/MultiClassLoader.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Options.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ParameterTemplate.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/Services.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/StreamResourceBundleProvider.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/TemporaryClassLoader.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/ZipResourceBundleProvider.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/util/concurrent/Utils.java
    openjpa/trunk/openjpa-lib/src/main/java/org/apache/openjpa/lib/xml/XMLWriter.java
    openjpa/trunk/openjpa-persistence-jdbc/src/main/java/org/apache/openjpa/persistence/jdbc/JDBCPersistenceProductDerivation.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataDefaults.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.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
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/XMLPersistenceMetaDataParser.java
    openjpa/trunk/openjpa-xmlstore/src/main/java/org/apache/openjpa/xmlstore/XMLFileHandler.java
    openjpa/trunk/pom.xml

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/MappingToolTask.java Tue Jul  3 14:55:29 2007
@@ -18,6 +18,8 @@
  */
 package org.apache.openjpa.jdbc.ant;
 
+import java.security.AccessController;
+
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.types.EnumeratedAttribute;
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
@@ -27,6 +29,7 @@
 import org.apache.openjpa.lib.ant.AbstractTask;
 import org.apache.openjpa.lib.conf.ConfigurationImpl;
 import org.apache.openjpa.lib.util.Files;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.util.MultiLoaderClassResolver;
 
@@ -183,7 +186,8 @@
 
         MultiLoaderClassResolver resolver = new MultiLoaderClassResolver();
         resolver.addClassLoader(loader);
-        resolver.addClassLoader(MappingTool.class.getClassLoader());
+        resolver.addClassLoader((ClassLoader)AccessController.doPrivileged( 
+            J2DoPrivHelper.getClassLoaderAction(MappingTool.class)));
         JDBCConfiguration conf = (JDBCConfiguration) getConfiguration();
         conf.setClassResolver(resolver);
 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ReverseMappingToolTask.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ReverseMappingToolTask.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ReverseMappingToolTask.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/ant/ReverseMappingToolTask.java Tue Jul  3 14:55:29 2007
@@ -20,6 +20,9 @@
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
 import java.util.Properties;
 
 import org.apache.commons.lang.StringUtils;
@@ -33,6 +36,7 @@
 import org.apache.openjpa.lib.conf.Configurations;
 import org.apache.openjpa.lib.util.CodeFormat;
 import org.apache.openjpa.lib.util.Files;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.tools.ant.types.EnumeratedAttribute;
 
 /**
@@ -258,14 +262,25 @@
         // load customizer properties
         Properties customProps = new Properties();
         File propsFile = Files.getFile(customizerProperties, loader);
-        if (propsFile != null && propsFile.exists())
-            customProps.load(new FileInputStream(propsFile));
+        if (propsFile != null && ((Boolean)AccessController.doPrivileged( 
+            J2DoPrivHelper.existsAction( propsFile ))).booleanValue() ) {
+            FileInputStream fis = null;
+            try {
+                fis = (FileInputStream) AccessController.doPrivileged(
+                    J2DoPrivHelper.newFileInputStreamAction(propsFile));
+            } catch( PrivilegedActionException pae ) {
+                 throw (FileNotFoundException)pae.getException();
+            }
+            customProps.load(fis);
+        }
 
         // create and configure customizer
         JDBCConfiguration conf = (JDBCConfiguration) getConfiguration();
         flags.customizer = (ReverseCustomizer) Configurations.
             newInstance(customizerClass, conf, null,
-                ReverseCustomizer.class.getClassLoader());
+                (ClassLoader)AccessController.doPrivileged( 
+                    J2DoPrivHelper.getClassLoaderAction(
+                        ReverseCustomizer.class)));
         if (flags.customizer != null)
             flags.customizer.setConfiguration(customProps);
 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingRepositoryValue.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingRepositoryValue.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingRepositoryValue.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/conf/MappingRepositoryValue.java Tue Jul  3 14:55:29 2007
@@ -19,10 +19,13 @@
 package org.apache.openjpa.jdbc.conf;
 
 import java.lang.reflect.InvocationTargetException;
+import java.security.AccessController;
 
 import org.apache.openjpa.jdbc.meta.MappingRepository;
 import org.apache.openjpa.lib.conf.Configuration;
 import org.apache.openjpa.lib.conf.PluginValue;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
+
 import serp.util.Strings;
 
 /**
@@ -44,7 +47,9 @@
         // since the MappingRepository takes a JDBConfiguration constructor,
         // we need to manually perform the instantiation
         try {
-            Class cls = Strings.toClass(clsName, type.getClassLoader());
+            Class cls = Strings.toClass(clsName,
+                (ClassLoader)AccessController.doPrivileged( 
+                    J2DoPrivHelper.getClassLoaderAction(type)));        
             return cls.getConstructor(new Class[]{ JDBCConfiguration.class }).
                 newInstance(new Object[]{ conf });
         } catch (RuntimeException e) {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java Tue Jul  3 14:55:29 2007
@@ -19,6 +19,8 @@
 package org.apache.openjpa.jdbc.meta;
 
 import java.lang.reflect.Modifier;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
 import java.sql.Types;
 import java.util.Collection;
 import java.util.HashMap;
@@ -70,6 +72,7 @@
 import org.apache.openjpa.jdbc.sql.JoinSyntaxes;
 import org.apache.openjpa.lib.conf.Configurable;
 import org.apache.openjpa.lib.conf.Configurations;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.meta.FieldMetaData;
@@ -446,12 +449,18 @@
         try {
             if (strat == null)
                 strat = JavaTypes.classForName(name, cls,
-                    ClassStrategy.class.getClassLoader());
-            ClassStrategy strategy = (ClassStrategy) strat.newInstance();
+                    (ClassLoader)AccessController.doPrivileged( 
+                        J2DoPrivHelper.getClassLoaderAction(
+                            ClassStrategy.class)));
+            ClassStrategy strategy = 
+                (ClassStrategy)AccessController.doPrivileged(
+                    J2DoPrivHelper.newInstanceAction(strat));
             Configurations.configureInstance(strategy, getConfiguration(),
                 props);
             return strategy;
         } catch (Exception e) {
+            if (e instanceof PrivilegedActionException)
+                e = ((PrivilegedActionException)e).getException();
             throw new MetaDataException(_loc.get("bad-cls-strategy",
                 cls, name), e);
         }
@@ -474,9 +483,12 @@
         name = Configurations.getClassName(name);
         try {
             Class c = JavaTypes.classForName(name, field,
-                FieldStrategy.class.getClassLoader());
+                (ClassLoader)AccessController.doPrivileged( 
+                    J2DoPrivHelper.getClassLoaderAction(FieldStrategy.class)));
             if (FieldStrategy.class.isAssignableFrom(c)) {
-                FieldStrategy strat = (FieldStrategy) c.newInstance();
+                FieldStrategy strat = (FieldStrategy)
+                    AccessController.doPrivileged(
+                        J2DoPrivHelper.newInstanceAction(c));
                 Configurations.configureInstance(strat, getConfiguration(),
                     props);
                 return strat;
@@ -484,13 +496,16 @@
 
             // must be named handler
             if (installHandlers) {
-                ValueHandler vh = (ValueHandler) c.newInstance();
+                ValueHandler vh = (ValueHandler)AccessController.doPrivileged(
+                    J2DoPrivHelper.newInstanceAction(c));
                 Configurations.configureInstance(vh, getConfiguration(),
                     props);
                 field.setHandler(vh);
             }
             return new HandlerFieldStrategy();
         } catch (Exception e) {
+            if (e instanceof PrivilegedActionException)
+                e = ((PrivilegedActionException )e).getException();
             throw new MetaDataException(_loc.get("bad-field-strategy",
                 field, name), e);
         }
@@ -541,13 +556,18 @@
             if (strat == null)
                 strat = JavaTypes.classForName(name,
                     discrim.getClassMapping(),
-                    DiscriminatorStrategy.class.getClassLoader());
+                    (ClassLoader)AccessController.doPrivileged( 
+                        J2DoPrivHelper.getClassLoaderAction(
+                            DiscriminatorStrategy.class)));
             DiscriminatorStrategy strategy = (DiscriminatorStrategy)
-                strat.newInstance();
+                AccessController.doPrivileged(
+                    J2DoPrivHelper.newInstanceAction(strat));
             Configurations.configureInstance(strategy, getConfiguration(),
                 props);
             return strategy;
         } catch (Exception e) {
+            if (e instanceof PrivilegedActionException)
+                e = ((PrivilegedActionException )e).getException();
             throw new MetaDataException(_loc.get("bad-discrim-strategy",
                 discrim.getClassMapping(), name), e);
         }
@@ -598,7 +618,9 @@
             if (strat == null)
                 strat = JavaTypes.classForName(name,
                     version.getClassMapping(),
-                    VersionStrategy.class.getClassLoader());
+                    (ClassLoader)AccessController.doPrivileged( 
+                        J2DoPrivHelper.getClassLoaderAction(
+                            VersionStrategy.class)));
         } catch (Exception e) {
             throw new MetaDataException(_loc.get("bad-version-strategy",
                 version.getClassMapping(), name), e);
@@ -613,11 +635,15 @@
     protected VersionStrategy instantiateVersionStrategy(Class strat,
         Version version, String props) {
         try {
-            VersionStrategy strategy = (VersionStrategy) strat.newInstance();
+            VersionStrategy strategy = (VersionStrategy)
+                AccessController.doPrivileged(
+                    J2DoPrivHelper.newInstanceAction(strat));
             Configurations.configureInstance(strategy, getConfiguration(),
                 props);
             return strategy;
         } catch (Exception e) {
+            if (e instanceof PrivilegedActionException)
+                e = ((PrivilegedActionException )e).getException();
             throw new MetaDataException(_loc.get("bad-version-strategy",
                 version.getClassMapping(), strat + ""), e);
         }
@@ -914,11 +940,16 @@
         String props = Configurations.getProperties(name);
         name = Configurations.getClassName(name);
         try {
-            Object o = JavaTypes.classForName(name, val,
-                FieldStrategy.class.getClassLoader()).newInstance();
+            Class c = JavaTypes.classForName(name, val,
+                (ClassLoader)AccessController.doPrivileged( 
+                    J2DoPrivHelper.getClassLoaderAction(FieldStrategy.class)));
+            Object o = AccessController.doPrivileged(
+                J2DoPrivHelper.newInstanceAction(c));
             Configurations.configureInstance(o, getConfiguration(), props);
             return o;
         } catch (Exception e) {
+            if (e instanceof PrivilegedActionException)
+                e = ((PrivilegedActionException )e).getException();
             throw new MetaDataException(_loc.get("bad-mapped-strategy",
                 val, name), e);
         }
@@ -937,15 +968,19 @@
         name = Configurations.getClassName(name);
         try {
             Class c = JavaTypes.classForName(name, val,
-                ValueHandler.class.getClassLoader());
+                (ClassLoader)AccessController.doPrivileged( 
+                    J2DoPrivHelper.getClassLoaderAction(ValueHandler.class)));
             if (ValueHandler.class.isAssignableFrom(c)) {
-                ValueHandler vh = (ValueHandler) c.newInstance();
+                ValueHandler vh = (ValueHandler)AccessController.doPrivileged(
+                    J2DoPrivHelper.newInstanceAction(c));
                 Configurations.configureInstance(vh, getConfiguration(),
                     props);
                 return vh;
             }
             return null; // named field strategy
         } catch (Exception e) {
+            if (e instanceof PrivilegedActionException)
+                e = ((PrivilegedActionException )e).getException();
             throw new MetaDataException(_loc.get("bad-value-handler",
                 val, name), e);
         }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingTool.java Tue Jul  3 14:55:29 2007
@@ -22,6 +22,8 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.io.Writer;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
 import java.sql.SQLException;
 import java.util.Arrays;
 import java.util.Collection;
@@ -51,6 +53,7 @@
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.meta.ClassArgParser;
 import org.apache.openjpa.lib.util.Files;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.lib.util.Options;
 import org.apache.openjpa.lib.util.Services;
@@ -1075,9 +1078,12 @@
             Class[] types = Services.getImplementorClasses(ImportExport.class);
             ImportExport[] instances = new ImportExport[types.length];
             for (int i = 0; i < types.length; i++)
-                instances[i] = (ImportExport) types[i].newInstance();
+                instances[i] = (ImportExport)AccessController.doPrivileged(
+                    J2DoPrivHelper.newInstanceAction(types[i]));
             return instances;
         } catch (Throwable t) {
+            if (t instanceof PrivilegedActionException)
+                t = ((PrivilegedActionException)t).getException();
             throw new InternalException(_loc.get("importexport-instantiate"),t);
         }
     }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ReverseMappingTool.java Tue Jul  3 14:55:29 2007
@@ -21,10 +21,13 @@
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.StringWriter;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
 import java.sql.SQLException;
 import java.sql.Types;
 import java.util.ArrayList;
@@ -77,6 +80,7 @@
 import org.apache.openjpa.lib.log.Log;
 import org.apache.openjpa.lib.util.CodeFormat;
 import org.apache.openjpa.lib.util.Files;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.lib.util.Options;
 import org.apache.openjpa.meta.ClassMetaData;
@@ -1891,9 +1895,18 @@
         File customFile = Files.getFile
             (opts.removeProperty("customizerProperties", "cp", null), null);
         Properties customProps = new Properties();
-        if (customFile != null && customFile.exists())
-            customProps.load(new FileInputStream(customFile));
-
+        if (customFile != null && ((Boolean)AccessController.doPrivileged( 
+            J2DoPrivHelper.existsAction( customFile ))).booleanValue()) {
+            FileInputStream fis = null;
+            try {
+                fis = (FileInputStream) AccessController.doPrivileged(
+                    J2DoPrivHelper.newFileInputStreamAction(customFile));
+            } catch( PrivilegedActionException pae ) {
+                 throw (FileNotFoundException)pae.getException();
+            }
+            customProps.load(fis);
+        }
+        
         // separate the properties for the customizer and code format
         Options customOpts = new Options();
         Options formatOpts = new Options();

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/DataSourceFactory.java Tue Jul  3 14:55:29 2007
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.jdbc.schema;
 
+import java.security.AccessController;
 import java.sql.Connection;
 import java.sql.Driver;
 import java.sql.SQLException;
@@ -39,6 +40,7 @@
 import org.apache.openjpa.lib.jdbc.JDBCListener;
 import org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator;
 import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.lib.util.Options;
 import org.apache.openjpa.util.ImplHelper;
@@ -110,7 +112,9 @@
             // see if their driver name is actually a data source
             if (DataSource.class.isAssignableFrom(driverClass)) {
                 return (DataSource) Configurations.newInstance(driver,
-                    conf, props, DataSource.class.getClassLoader());
+                    conf, props, (ClassLoader)AccessController.doPrivileged( 
+                        J2DoPrivHelper.getClassLoaderAction(
+                            DataSource.class))); 
             }
         }
         catch (OpenJPAException ke) {

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/FileSchemaFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/FileSchemaFactory.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/FileSchemaFactory.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/FileSchemaFactory.java Tue Jul  3 14:55:29 2007
@@ -21,11 +21,13 @@
 import java.io.File;
 import java.io.IOException;
 import java.net.URL;
+import java.security.AccessController;
 
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.lib.conf.Configurable;
 import org.apache.openjpa.lib.conf.Configuration;
 import org.apache.openjpa.lib.util.Files;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.util.GeneralException;
 
 /**
@@ -77,7 +79,8 @@
     }
 
     public SchemaGroup readSchema() {
-        URL url = _loader.getResource(_fileName);
+        URL url = (URL)AccessController.doPrivileged( 
+            J2DoPrivHelper.getResourceAction(_loader, _fileName)); 
         if (url == null)
             return new SchemaGroup();
 

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/schema/SimpleDriverDataSource.java Tue Jul  3 14:55:29 2007
@@ -19,6 +19,8 @@
 package org.apache.openjpa.jdbc.schema;
 
 import java.io.PrintWriter;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
 import java.sql.Connection;
 import java.sql.Driver;
 import java.sql.DriverManager;
@@ -27,6 +29,7 @@
 import java.util.Properties;
 
 import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.util.StoreException;
 
 /**
@@ -166,12 +169,16 @@
         }
 
         try {
-            _driver = (Driver) Class.forName(_connectionDriverName,
-                true, _classLoader).newInstance();
+            Class c = Class.forName(_connectionDriverName,
+                true, _classLoader);
+            _driver = (Driver)AccessController.doPrivileged(
+                J2DoPrivHelper.newInstanceAction(c));
             return _driver;
         } catch (Exception e) {
             if (e instanceof RuntimeException)
                 throw(RuntimeException) e;
+            if (e instanceof PrivilegedActionException)
+                e = ((PrivilegedActionException)e).getException();
             throw new StoreException(e);
         }
     }

Modified: openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionaryFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionaryFactory.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionaryFactory.java (original)
+++ openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/DBDictionaryFactory.java Tue Jul  3 14:55:29 2007
@@ -18,6 +18,8 @@
  */
 package org.apache.openjpa.jdbc.sql;
 
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.SQLException;
@@ -27,6 +29,7 @@
 import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.lib.conf.Configurations;
 import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.util.StoreException;
 import org.apache.openjpa.util.UserException;
@@ -117,9 +120,15 @@
         String dclass, String props, Connection conn) {
         DBDictionary dict = null;
         try {
-            dict = (DBDictionary) Class.forName(dclass, true,
-                DBDictionary.class.getClassLoader()).newInstance();
+            Class c = Class.forName(dclass, true,
+                (ClassLoader)AccessController.doPrivileged( 
+                    J2DoPrivHelper.getClassLoaderAction(
+                        DBDictionary.class)));
+            dict = (DBDictionary)AccessController.doPrivileged(
+                J2DoPrivHelper.newInstanceAction(c));
         } catch (Exception e) {
+            if (e instanceof PrivilegedActionException)
+                e = ((PrivilegedActionException)e).getException();
             throw new UserException(e).setFatal(true);
         }
 
@@ -236,7 +245,7 @@
      */
     public static String toString(DatabaseMetaData meta)
         throws SQLException {
-        String lineSep = System.getProperty("line.separator");
+        String lineSep = J2DoPrivHelper.getLineSeparator();
         StringBuffer buf = new StringBuffer();
         try {
             buf.append("catalogSeparator: ")

Modified: openjpa/trunk/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java (original)
+++ openjpa/trunk/openjpa-kernel-5/src/main/java/org/apache/openjpa/enhance/PCEnhancerAgent.java Tue Jul  3 14:55:29 2007
@@ -19,10 +19,12 @@
 package org.apache.openjpa.enhance;
 
 import java.lang.instrument.Instrumentation;
+import java.security.AccessController;
 
 import org.apache.openjpa.conf.OpenJPAConfiguration;
 import org.apache.openjpa.conf.OpenJPAConfigurationImpl;
 import org.apache.openjpa.lib.conf.Configurations;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Options;
 import org.apache.openjpa.lib.util.TemporaryClassLoader;
 import org.apache.openjpa.util.ClassResolver;
@@ -54,8 +56,9 @@
         conf.setConnectionDriverName(null);
         conf.setConnectionFactoryName(null);
         // set single class resolver
-        final ClassLoader tmpLoader = new TemporaryClassLoader(Thread.
-            currentThread().getContextClassLoader());
+        final ClassLoader tmpLoader = new TemporaryClassLoader(
+            (ClassLoader)AccessController.doPrivileged( 
+                J2DoPrivHelper.getContextClassLoaderAction()));
         conf.setClassResolver(new ClassResolver() {
             public ClassLoader getClassLoader(Class context, ClassLoader env) {
                 return tmpLoader;

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/abstractstore/AbstractStoreBrokerFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/abstractstore/AbstractStoreBrokerFactory.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/abstractstore/AbstractStoreBrokerFactory.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/abstractstore/AbstractStoreBrokerFactory.java Tue Jul  3 14:55:29 2007
@@ -18,6 +18,7 @@
  */
 package org.apache.openjpa.abstractstore;
 
+import java.security.AccessController;
 import java.util.Map;
 import java.util.Properties;
 
@@ -29,6 +30,7 @@
 import org.apache.openjpa.lib.conf.ConfigurationProvider;
 import org.apache.openjpa.lib.conf.Configurations;
 import org.apache.openjpa.lib.conf.ProductDerivations;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.util.UserException;
 
@@ -131,7 +133,9 @@
     private static AbstractStoreManager createStoreManager(String cls,
         String props) {
         AbstractStoreManager store = (AbstractStoreManager) Configurations.
-            newInstance(cls, AbstractStoreManager.class.getClassLoader());
+            newInstance(cls, (ClassLoader)AccessController.doPrivileged( 
+                J2DoPrivHelper.getClassLoaderAction(
+                    AbstractStoreManager.class))); 
         Configurations.configureInstance(store, null, props,
             PROP_ABSTRACT_STORE);
         if (store == null)

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/conf/OpenJPAVersion.java Tue Jul  3 14:55:29 2007
@@ -20,9 +20,12 @@
 
 import java.io.File;
 import java.io.InputStream;
+import java.security.AccessController;
 import java.util.Properties;
 import java.util.StringTokenizer;
 
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
+
 /**
  * This class contains version information for OpenJPA. It uses
  * Ant's filter tokens to convert the template into a java
@@ -110,7 +113,9 @@
 
         buf.append("java.class.path:\n");
         StringTokenizer tok = new StringTokenizer
-            (System.getProperty("java.class.path"), File.pathSeparator);
+            ((String)AccessController.doPrivileged( 
+                J2DoPrivHelper.getPropertyAction("java.class.path")),
+            File.pathSeparator);
         while (tok.hasMoreTokens()) {
             buf.append("\t").append(tok.nextToken());
             buf.append("\n");
@@ -132,6 +137,8 @@
     }
 
     private StringBuffer appendProperty(String prop, StringBuffer buf) {
-        return buf.append(prop).append(": ").append(System.getProperty(prop));
+        return buf.append(prop).append(": ")
+            .append((String)AccessController.doPrivileged( 
+                J2DoPrivHelper.getPropertyAction(prop)));
     }
 }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASManagedRuntime.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASManagedRuntime.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASManagedRuntime.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/ee/WASManagedRuntime.java Tue Jul  3 14:55:29 2007
@@ -21,6 +21,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.Method;
+import java.security.AccessController;
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
@@ -39,6 +40,7 @@
 import org.apache.openjpa.lib.conf.Configurable;
 import org.apache.openjpa.lib.conf.Configuration;
 import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.util.InvalidStateException;
 import org.apache.openjpa.util.NoTransactionException;

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ApplicationIdTool.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ApplicationIdTool.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ApplicationIdTool.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/ApplicationIdTool.java Tue Jul  3 14:55:29 2007
@@ -24,6 +24,7 @@
 import java.io.PrintWriter;
 import java.io.Writer;
 import java.lang.reflect.Modifier;
+import java.security.AccessController;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -44,6 +45,7 @@
 import org.apache.openjpa.lib.meta.ClassArgParser;
 import org.apache.openjpa.lib.util.CodeFormat;
 import org.apache.openjpa.lib.util.Files;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.JavaVersions;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.lib.util.Options;
@@ -438,8 +440,8 @@
             // indent the entire code block one level to make it
             // a propertly indented innder class
             _code = code.getTab() + Strings.replace(_code,
-                System.getProperty("line.separator"),
-                System.getProperty("line.separator") + code.getTab());
+                J2DoPrivHelper.getLineSeparator(),
+                J2DoPrivHelper.getLineSeparator() + code.getTab());
         }
 
         return true;
@@ -1417,9 +1419,11 @@
             name = Strings.getPackageName(context) + "." + name;
 
         // first try with regular class loader
-        ClassLoader loader = context.getClassLoader();
+        ClassLoader loader = (ClassLoader)AccessController.doPrivileged( 
+            J2DoPrivHelper.getClassLoaderAction(context)); 
         if (loader == null)
-            loader = Thread.currentThread().getContextClassLoader();
+            loader = (ClassLoader)AccessController.doPrivileged( 
+                J2DoPrivHelper.getContextClassLoaderAction()); 
         try {
             return Class.forName(name, false, loader);
         } catch (Throwable t) {

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/DynamicStorageGenerator.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/DynamicStorageGenerator.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/DynamicStorageGenerator.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/DynamicStorageGenerator.java Tue Jul  3 14:55:29 2007
@@ -19,8 +19,10 @@
 package org.apache.openjpa.enhance;
 
 import java.lang.reflect.Constructor;
+import java.security.AccessController;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.meta.JavaTypes;
 import org.apache.openjpa.util.InternalException;
 import serp.bytecode.BCClass;
@@ -95,7 +97,8 @@
     // the project/classloader for the classes.
     private final Project _project = new Project();
     private final BCClassLoader _loader = new BCClassLoader(_project,
-        DynamicStorage.class.getClassLoader());
+        (ClassLoader)AccessController.doPrivileged( 
+            J2DoPrivHelper.getClassLoaderAction(DynamicStorage.class)));
 
     /**
      * Generate a generic {@link DynamicStorage} instance with the given

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/PCEnhancer.java Tue Jul  3 14:55:29 2007
@@ -30,6 +30,8 @@
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -50,6 +52,7 @@
 import org.apache.openjpa.lib.meta.ClassArgParser;
 import org.apache.openjpa.lib.util.BytecodeWriter;
 import org.apache.openjpa.lib.util.Files;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.lib.util.Options;
 import org.apache.openjpa.lib.util.Services;
@@ -130,11 +133,13 @@
     static {
         Class[] classes = Services.getImplementorClasses(
             AuxiliaryEnhancer.class, 
-            AuxiliaryEnhancer.class.getClassLoader());
+            (ClassLoader)AccessController.doPrivileged( 
+                J2DoPrivHelper.getClassLoaderAction(AuxiliaryEnhancer.class)));
         List auxEnhancers = new ArrayList(classes.length);
         for (int i = 0; i < classes.length; i++) {
             try {
-                auxEnhancers.add(classes[i].newInstance());
+                auxEnhancers.add(AccessController.doPrivileged(
+                    J2DoPrivHelper.newInstanceAction(classes[i])));
 		    } catch (Throwable t) {
                 // aux enhancer may rely on non-existant spec classes, etc
 		    }
@@ -479,8 +484,9 @@
      * Package-protected and static for testing.
      */
     static BCField getReturnedField(BCMethod meth) {
-        return findField(meth, new Code().xreturn().setType
-            (meth.getReturnType()), false);
+        return findField(meth, ((Code)AccessController.doPrivileged( 
+            J2DoPrivHelper.newCodeAction())).xreturn()
+            .setType(meth.getReturnType()), false);
     }
 
     /**
@@ -488,7 +494,8 @@
      * Package-protected and static for testing.
      */
     static BCField getAssignedField(BCMethod meth) {
-        return findField(meth, new Code().putfield(), true);
+        return findField(meth, ((Code)AccessController.doPrivileged( 
+            J2DoPrivHelper.newCodeAction())).putfield(), true);
     }
 
     /**
@@ -567,7 +574,7 @@
         if (_violations == null)
             return;
 
-        String sep = System.getProperty("line.separator");
+        String sep = J2DoPrivHelper.getLineSeparator();
         StringBuffer buf = new StringBuffer();
         for (Iterator itr = _violations.iterator(); itr.hasNext();) {
             buf.append(itr.next());
@@ -589,7 +596,8 @@
      */
     private void replaceAndValidateFieldAccess() {
         // create template putfield/getfield instructions to search for
-        Code template = new Code();
+        Code template = (Code)AccessController.doPrivileged( 
+            J2DoPrivHelper.newCodeAction());
         Instruction put = template.putfield();
         Instruction get = template.getfield();
         Instruction stat = template.invokestatic();
@@ -1193,51 +1201,73 @@
      */
     private void addStockMethods()
         throws NoSuchMethodException {
-        // pcGetGenericContext
-        translateFromStateManagerMethod(SMTYPE.getDeclaredMethod
-            ("get" + CONTEXTNAME, (Class[]) null));
-
-        // pcFetchObjectId
-        translateFromStateManagerMethod(SMTYPE.getDeclaredMethod
-            ("fetchObjectId", (Class[]) null));
-
-        // pcIsDeleted
-        translateFromStateManagerMethod(SMTYPE.getDeclaredMethod
-            ("isDeleted", (Class[]) null));
-
-        // pcIsDirty
-        translateFromStateManagerMethod(SMTYPE.getDeclaredMethod
-            ("isDirty", (Class[]) null));
-
-        // pcIsNew
-        translateFromStateManagerMethod(SMTYPE.getDeclaredMethod
-            ("isNew", (Class[]) null));
-
-        // pcIsPersistent
-        translateFromStateManagerMethod(SMTYPE.getDeclaredMethod
-            ("isPersistent", (Class[]) null));
-
-        // pcIsTransactional
-        translateFromStateManagerMethod(SMTYPE.getDeclaredMethod
-            ("isTransactional", (Class[]) null));
-
-        // pcSerializing
-        translateFromStateManagerMethod(SMTYPE.getDeclaredMethod
-            ("serializing", (Class[]) null));
-
-        // pcDirty
-        translateFromStateManagerMethod(SMTYPE.getDeclaredMethod("dirty",
-            new Class[]{ String.class }));
-
-        // pcGetStateManager
-        BCMethod meth = _pc.declareMethod(PRE + "GetStateManager",
-            StateManager.class, null);
-        Code code = meth.getCode(true);
-        loadManagedInstance(code, false);
-        code.getfield().setField(SM, StateManager.class);
-        code.areturn();
-        code.calculateMaxStack();
-        code.calculateMaxLocals();
+        try {
+            // pcGetGenericContext
+            translateFromStateManagerMethod(
+                (Method)AccessController.doPrivileged(
+                    J2DoPrivHelper.getDeclaredMethodAction(
+                        SMTYPE, "get" + CONTEXTNAME, (Class[]) null)));
+    
+            // pcFetchObjectId
+            translateFromStateManagerMethod(
+                (Method)AccessController.doPrivileged(
+                    J2DoPrivHelper.getDeclaredMethodAction(
+                        SMTYPE, "fetchObjectId", (Class[]) null)));
+    
+            // pcIsDeleted
+            translateFromStateManagerMethod(
+                (Method)AccessController.doPrivileged(
+                    J2DoPrivHelper.getDeclaredMethodAction(
+                        SMTYPE, "isDeleted", (Class[]) null)));
+    
+            // pcIsDirty
+            translateFromStateManagerMethod(
+                (Method)AccessController.doPrivileged(
+                    J2DoPrivHelper.getDeclaredMethodAction(
+                        SMTYPE, "isDirty", (Class[]) null)));
+    
+            // pcIsNew
+            translateFromStateManagerMethod(
+                (Method)AccessController.doPrivileged(
+                    J2DoPrivHelper.getDeclaredMethodAction(
+                        SMTYPE, "isNew", (Class[]) null)));
+    
+            // pcIsPersistent
+            translateFromStateManagerMethod(
+                (Method)AccessController.doPrivileged(
+                    J2DoPrivHelper.getDeclaredMethodAction(
+                        SMTYPE, "isPersistent", (Class[]) null)));
+    
+            // pcIsTransactional
+            translateFromStateManagerMethod(
+                (Method)AccessController.doPrivileged(
+                    J2DoPrivHelper.getDeclaredMethodAction(
+                        SMTYPE, "isTransactional", (Class[]) null)));
+    
+            // pcSerializing
+            translateFromStateManagerMethod(
+                (Method)AccessController.doPrivileged(
+                    J2DoPrivHelper.getDeclaredMethodAction(
+                        SMTYPE, "serializing", (Class[]) null)));
+    
+            // pcDirty
+            translateFromStateManagerMethod(
+                (Method)AccessController.doPrivileged(
+                    J2DoPrivHelper.getDeclaredMethodAction(
+                        SMTYPE, "dirty", new Class[]{ String.class })));
+    
+            // pcGetStateManager
+            BCMethod meth = _pc.declareMethod(PRE + "GetStateManager",
+                StateManager.class, null);
+            Code code = meth.getCode(true);
+            loadManagedInstance(code, false);
+            code.getfield().setField(SM, StateManager.class);
+            code.areturn();
+            code.calculateMaxStack();
+            code.calculateMaxLocals();
+        } catch( PrivilegedActionException pae ) {
+             throw (NoSuchMethodException)pae.getException();
+        }
     }
 
     /**
@@ -2160,7 +2190,15 @@
         // use reflection to return the right method
         String name = prefix + typeName + "Field";
         Class[] params = (Class[]) plist.toArray(new Class[plist.size()]);
-        return owner.getDeclaredMethod(name, params);
+        
+        Method method = null;
+        try {
+            method = (Method) AccessController.doPrivileged(
+                J2DoPrivHelper.getDeclaredMethodAction(owner, name, params));
+        } catch( PrivilegedActionException pae ) {
+             throw (NoSuchMethodException)pae.getException();
+        }
+        return method;
     }
 
     /**
@@ -2459,7 +2497,8 @@
             code.vreturn();
         }
 
-        Instruction tmplate = new Code().vreturn();
+        Instruction tmplate = ((Code)AccessController.doPrivileged( 
+            J2DoPrivHelper.newCodeAction())).vreturn();
         JumpInstruction toret;
         Instruction ret;
         code.beforeFirst();
@@ -2727,7 +2766,8 @@
         if (clinit != null) {
             code = clinit.getCode(true);
             if (replaceLast) {
-                Code template = new Code();
+                Code template = (Code)AccessController.doPrivileged( 
+                    J2DoPrivHelper.newCodeAction());
                 code.searchForward(template.vreturn());
                 code.previous();
                 code.set(template.nop());
@@ -2768,7 +2808,9 @@
         if (clone == null) {
             // add clone support for base classes
             // which also implement cloneable
-            if (!_pc.isInstanceOf(Cloneable.class)
+            if (!((Boolean)AccessController.doPrivileged( 
+                    J2DoPrivHelper.isInstanceOfAction( _pc, Cloneable.class )))
+                    .booleanValue()
                 || !superName.equals(Object.class.getName()))
                 return;
 
@@ -2796,8 +2838,9 @@
         }
 
         // create template super.clone () instruction to match against
-        Instruction template = new Code().invokespecial().setMethod
-            (superName, "clone", Object.class.getName(), null);
+        Instruction template = ((Code)AccessController.doPrivileged( 
+            J2DoPrivHelper.newCodeAction())).invokespecial()
+            .setMethod(superName, "clone", Object.class.getName(), null);
 
         // find calls to the template instruction; on match
         // clone will be on stack

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/Reflection.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/Reflection.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/Reflection.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/enhance/Reflection.java Tue Jul  3 14:55:29 2007
@@ -23,8 +23,10 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.security.AccessController;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.util.GeneralException; 
 import org.apache.openjpa.util.UserException; 
@@ -116,7 +118,8 @@
      */
     private static Method getDeclaredMethod(Class cls, String name,
         Class param) {
-        Method[] methods = cls.getDeclaredMethods();
+        Method[] methods = (Method[])AccessController.doPrivileged( 
+            J2DoPrivHelper.getDeclaredMethodsAction( cls ));
         for (int i = 0 ; i < methods.length; i++) {
     	    if (name.equals(methods[i].getName())) {
                 Class[] methodParams = methods[i].getParameterTypes();
@@ -160,7 +163,8 @@
      * @since 0.9.8
      */
     private static Field getDeclaredField(Class cls, String name) {
-        Field[] fields = cls.getDeclaredFields();
+        Field[] fields = (Field[])AccessController.doPrivileged( 
+            J2DoPrivHelper.getDeclaredFieldsAction( cls ));
         for (int i = 0 ; i < fields.length; i++) {
     	    if (name.equals(fields[i].getName()))
 		        return fields[i];

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/BeanLifecycleCallbacks.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/BeanLifecycleCallbacks.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/BeanLifecycleCallbacks.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/BeanLifecycleCallbacks.java Tue Jul  3 14:55:29 2007
@@ -22,7 +22,10 @@
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
 
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.util.UserException;
 
@@ -60,8 +63,11 @@
     
     private Object newListener(Class cls) {
         try {
-            return cls.newInstance();
+            return AccessController.doPrivileged(
+                J2DoPrivHelper.newInstanceAction(cls));
         } catch (Throwable t) {
+            if (t instanceof PrivilegedActionException)
+                t = ((PrivilegedActionException )t).getException();            
             throw new UserException(_loc.get("bean-constructor",
                 cls.getName()), t);
         }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/MethodLifecycleCallbacks.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/MethodLifecycleCallbacks.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/MethodLifecycleCallbacks.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/event/MethodLifecycleCallbacks.java Tue Jul  3 14:55:29 2007
@@ -23,8 +23,10 @@
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.lang.reflect.Method;
+import java.security.AccessController;
 import java.util.Arrays;
 
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.util.UserException;
 
@@ -101,7 +103,8 @@
     protected static Method getMethod(Class cls, String method, Class[] args) {
         Class currentClass = cls;
         do {
-            Method[] methods = currentClass.getDeclaredMethods();
+            Method[] methods = (Method[])AccessController.doPrivileged( 
+                J2DoPrivHelper.getDeclaredMethodsAction( currentClass )); 
             for (int i = 0; i < methods.length; i++) {
                 if (!method.equals(methods[i].getName()))
                     continue;

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/AbstractBrokerFactory.java Tue Jul  3 14:55:29 2007
@@ -41,6 +41,7 @@
 import org.apache.openjpa.event.RemoteCommitEventManager;
 import org.apache.openjpa.event.BrokerFactoryEvent;
 import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.lib.util.ReferenceHashSet;
 import org.apache.openjpa.lib.util.concurrent.ConcurrentHashMap;
@@ -553,7 +554,7 @@
                 log.info(getFactoryInitializationBanner());
             if (log.isTraceEnabled()) {
                 Map props = _conf.toProperties(true);
-                String lineSep = System.getProperty("line.separator");
+                String lineSep = J2DoPrivHelper.getLineSeparator();
                 StringBuffer buf = new StringBuffer();
                 Map.Entry entry;
                 for (Iterator itr = props.entrySet().iterator();

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Bootstrap.java Tue Jul  3 14:55:29 2007
@@ -20,11 +20,13 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.security.AccessController;
 
 import org.apache.openjpa.conf.BrokerFactoryValue;
 import org.apache.openjpa.lib.conf.ConfigurationProvider;
 import org.apache.openjpa.lib.conf.MapConfigurationProvider;
 import org.apache.openjpa.lib.conf.ProductDerivations;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.util.InternalException;
 import org.apache.openjpa.util.OpenJPAException;
@@ -113,7 +115,9 @@
         } catch (NoSuchMethodException nsme) {
             // handle cases where there is a mismatch between loaders by falling
             // back to the configuration's class loader for broker resolution
-            cls = getFactoryClass(conf, conf.getClass().getClassLoader());
+            cls = getFactoryClass(conf,
+                (ClassLoader)AccessController.doPrivileged( 
+                    J2DoPrivHelper.getClassLoaderAction(conf.getClass()))); 
             meth = cls.getMethod(methodName, FACTORY_ARGS); 
         }
 
@@ -135,7 +139,8 @@
     private static Class getFactoryClass(ConfigurationProvider conf,
         ClassLoader loader) {
         if (loader == null)
-            loader = Thread.currentThread().getContextClassLoader();
+            loader = (ClassLoader)AccessController.doPrivileged( 
+                J2DoPrivHelper.getContextClassLoaderAction()); 
 
         Object cls = BrokerFactoryValue.get(conf);
         if (cls instanceof Class)

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java Tue Jul  3 14:55:29 2007
@@ -20,6 +20,7 @@
 
 import java.io.Serializable;
 import java.lang.reflect.Modifier;
+import java.security.AccessController;
 import java.util.AbstractCollection;
 import java.util.ArrayList;
 import java.util.BitSet;
@@ -62,6 +63,7 @@
 import org.apache.openjpa.event.TransactionEventManager;
 import org.apache.openjpa.kernel.exps.ExpressionParser;
 import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.lib.util.ReferenceHashMap;
 import org.apache.openjpa.lib.util.ReferenceHashSet;
@@ -256,7 +258,8 @@
     public void initialize(AbstractBrokerFactory factory,
         DelegatingStoreManager sm, boolean managed, int connMode) {
         _initializeWasInvoked = true;
-        _loader = Thread.currentThread().getContextClassLoader();
+        _loader = (ClassLoader)AccessController.doPrivileged( 
+            J2DoPrivHelper.getContextClassLoaderAction());
         _jca = new JCAHelper();
         _conf = factory.getConfiguration();
         _compat = _conf.getCompatibilityInstance();
@@ -4131,7 +4134,9 @@
         // 1.5 doesn't initialize classes without a true Class.forName
         if (!PCRegistry.isRegistered(cls)) {
             try {
-                Class.forName(cls.getName(), true, cls.getClassLoader());
+                Class.forName(cls.getName(), true, 
+                    (ClassLoader)AccessController.doPrivileged( 
+                        J2DoPrivHelper.getClassLoaderAction(cls)));
             } catch (Throwable t) {
             }
         }
@@ -4270,8 +4275,12 @@
             if (intfs[i].getName().equals(PersistenceCapable.class.getName())) {
                 throw new UserException(_loc.get("pc-loader-different",
                     Exceptions.toString(obj),
-                    PersistenceCapable.class.getClassLoader(),
-                    intfs[i].getClassLoader())).setFailedObject(obj);
+                    (ClassLoader)AccessController.doPrivileged( 
+                        J2DoPrivHelper.getClassLoaderAction(
+                            PersistenceCapable.class)),
+                    (ClassLoader)AccessController.doPrivileged( 
+                        J2DoPrivHelper.getClassLoaderAction(intfs[i]))))
+                    .setFailedObject(obj);
             }
         }
 

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Filters.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Filters.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Filters.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Filters.java Tue Jul  3 14:55:29 2007
@@ -18,10 +18,11 @@
  */
 package org.apache.openjpa.kernel;
 
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collection;
@@ -31,10 +32,10 @@
 import org.apache.openjpa.enhance.Reflection;
 import org.apache.openjpa.kernel.exps.AggregateListener;
 import org.apache.openjpa.kernel.exps.FilterListener;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.meta.JavaTypes;
-import org.apache.openjpa.util.ImplHelper;
 import org.apache.openjpa.util.InternalException;
 import org.apache.openjpa.util.UserException;
 import serp.util.Numbers;
@@ -746,9 +747,12 @@
         Exception cause = null;
         if (hint instanceof String) {
             try {
-                return (AggregateListener) Class.forName((String) hint, true,
-                    loader).newInstance();
+                return (AggregateListener) AccessController.doPrivileged(
+                    J2DoPrivHelper.newInstanceAction(
+                        Class.forName((String) hint, true, loader)));
             } catch (Exception e) {
+                if (e instanceof PrivilegedActionException)
+                    e = ((PrivilegedActionException)e).getException();
                 cause = e;
             }
         }
@@ -781,10 +785,13 @@
             AggregateListener[] aggs = new AggregateListener[clss.length];
             try {
                 for (int i = 0; i < clss.length; i++)
-                    aggs[i] = (AggregateListener) Class.forName(clss[i], true,
-                        loader).newInstance();
+                    aggs[i] = (AggregateListener)AccessController.doPrivileged(
+                        J2DoPrivHelper.newInstanceAction(
+                            Class.forName(clss[i], true, loader))); 
                 return aggs;
             } catch (Exception e) {
+                if (e instanceof PrivilegedActionException)
+                    e = ((PrivilegedActionException)e).getException();
                 cause = e;
             }
         }
@@ -806,9 +813,12 @@
         Exception cause = null;
         if (hint instanceof String) {
             try {
-                return (FilterListener) Class.forName((String) hint, true,
-                    loader).newInstance();
+                return (FilterListener)AccessController.doPrivileged(
+                    J2DoPrivHelper.newInstanceAction(
+                        Class.forName((String) hint, true, loader))); 
             } catch (Exception e) {
+                if (e instanceof PrivilegedActionException)
+                    e = ((PrivilegedActionException)e).getException();
                 cause = e;
             }
         }
@@ -840,10 +850,13 @@
             FilterListener[] filts = new FilterListener[clss.length];
             try {
                 for (int i = 0; i < clss.length; i++)
-                    filts[i] = (FilterListener) Class.forName(clss[i], true,
-                        loader).newInstance();
+                    filts[i] = (FilterListener)AccessController.doPrivileged(
+                        J2DoPrivHelper.newInstanceAction(
+                            Class.forName(clss[i], true, loader)));
                 return filts;
             } catch (Exception e) {
+                if (e instanceof PrivilegedActionException)
+                    e = ((PrivilegedActionException)e).getException();
                 cause = e;
             }
         }

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ObjectIdStateManager.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ObjectIdStateManager.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ObjectIdStateManager.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ObjectIdStateManager.java Tue Jul  3 14:55:29 2007
@@ -22,12 +22,14 @@
 import java.io.ObjectOutput;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
 import java.util.BitSet;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.enhance.PersistenceCapable;
 import org.apache.openjpa.enhance.StateManager;
 import org.apache.openjpa.enhance.Reflection;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.meta.FieldMetaData;
 import org.apache.openjpa.meta.JavaTypes;
@@ -710,8 +712,12 @@
     private void setValue(int field, Object val, boolean forceInst) {
         if (_oid == null && forceInst) {
             try {
-                _oid = getMetaData().getDescribedType().newInstance();
+                _oid = AccessController.doPrivileged(
+                    J2DoPrivHelper.newInstanceAction(
+                        getMetaData().getDescribedType()));
             } catch (Exception e) {
+                if (e instanceof PrivilegedActionException)
+                    e = ((PrivilegedActionException)e).getException();
                 throw new GeneralException(e);
             }
         } else if (_oid == null)

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryImpl.java Tue Jul  3 14:55:29 2007
@@ -19,6 +19,7 @@
 package org.apache.openjpa.kernel;
 
 import java.io.Serializable;
+import java.security.AccessController;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -45,6 +46,7 @@
 import org.apache.openjpa.lib.rop.RangeResultObjectProvider;
 import org.apache.openjpa.lib.rop.ResultList;
 import org.apache.openjpa.lib.rop.ResultObjectProvider;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.lib.util.ReferenceHashSet;
 import org.apache.openjpa.lib.util.concurrent.ReentrantLock;
@@ -1555,7 +1557,8 @@
 
         // first check the aliases map in the MetaDataRepository
         ClassLoader loader = (_class == null) ? _loader
-            : _class.getClassLoader();
+            : (ClassLoader)AccessController.doPrivileged( 
+                J2DoPrivHelper.getClassLoaderAction(_class)); 
         ClassMetaData meta = _broker.getConfiguration().
             getMetaDataRepositoryInstance().getMetaData(name, loader, false);
         if (meta != null)

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryLanguages.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryLanguages.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryLanguages.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/QueryLanguages.java Tue Jul  3 14:55:29 2007
@@ -18,10 +18,13 @@
  */
 package org.apache.openjpa.kernel;
 
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.openjpa.kernel.exps.ExpressionParser;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Services;
 import org.apache.openjpa.util.InternalException;
 
@@ -37,11 +40,16 @@
     static {
         // Load and cache all the query languages available in the system.
         Class[] classes = Services.getImplementorClasses(
-            ExpressionParser.class, ExpressionParser.class.getClassLoader());
+            ExpressionParser.class,
+            (ClassLoader)AccessController.doPrivileged( 
+                J2DoPrivHelper.getClassLoaderAction(ExpressionParser.class)));
         for (int i = 0; i < classes.length; i++) {
             ExpressionParser ep;
             try {
-                ep = (ExpressionParser) classes[i].newInstance();
+                ep = (ExpressionParser)AccessController.doPrivileged(
+                    J2DoPrivHelper.newInstanceAction(classes[i]));
+            } catch( PrivilegedActionException pae ) {
+                throw new InternalException(pae.getException());
             } catch (InstantiationException e) {
                 throw new InternalException(e);
             } catch (IllegalAccessException e) {

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ResultPacker.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ResultPacker.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ResultPacker.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ResultPacker.java Tue Jul  3 14:55:29 2007
@@ -24,6 +24,8 @@
 import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.math.BigInteger;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
 import java.util.Arrays;
 import java.util.Calendar;
 import java.util.Date;
@@ -34,6 +36,7 @@
 import java.util.Set;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.util.OpenJPAException;
 import org.apache.openjpa.util.UserException;
@@ -231,7 +234,8 @@
             if (_constructor != null)
                 return _constructor.newInstance(result);
 
-            Object user = _resultClass.newInstance();
+            Object user = AccessController.doPrivileged(
+                J2DoPrivHelper.newInstanceAction(_resultClass));
             for (int i = 0; i < _aliases.length; i++) {
                 if (_sets[i] instanceof Method) {
                     Method meth = (Method) _sets[i];
@@ -248,6 +252,9 @@
             return user;
         } catch (OpenJPAException ke) {
             throw ke;
+        } catch( PrivilegedActionException pae ) {
+            throw new UserException(_loc.get("pack-instantiation-err",
+                _resultClass), pae.getException());
         } catch (InstantiationException ie) {
             throw new UserException(_loc.get("pack-instantiation-err",
                 _resultClass), ie);

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/JPQLExpressionBuilder.java Tue Jul  3 14:55:29 2007
@@ -22,6 +22,7 @@
 import java.io.Serializable;
 import java.lang.reflect.Field;
 import java.math.BigDecimal;
+import java.security.AccessController;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
@@ -43,6 +44,7 @@
 import org.apache.openjpa.kernel.exps.QueryExpressions;
 import org.apache.openjpa.kernel.exps.Subquery;
 import org.apache.openjpa.kernel.exps.Value;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.meta.ClassMetaData;
 import org.apache.openjpa.meta.FieldMetaData;

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?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- 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 Tue Jul  3 14:55:29 2007
@@ -20,8 +20,11 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -47,6 +50,7 @@
 import org.apache.openjpa.lib.meta.ZipFileMetaDataIterator;
 import org.apache.openjpa.lib.meta.ZipStreamMetaDataIterator;
 import org.apache.openjpa.lib.util.Files;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.util.GeneralException;
 import org.apache.openjpa.util.UserException;
@@ -93,7 +97,8 @@
             File file;
             for (int i = 0; i < strs.length; i++) {
                 file = new File(strs[i]);
-                if (file.exists())
+                if (((Boolean)AccessController.doPrivileged( 
+                    J2DoPrivHelper.existsAction( file ))).booleanValue())
                     this.files.add(file);
             }
         }
@@ -372,7 +377,9 @@
                 queries[i].setSource(defaultSourceFile(queries[i],
                     clsNames), queries[i].getSourceScope(),
                     queries[i].getSourceType());
-            if (queries[i].getSourceFile().exists()) {
+            if (((Boolean)AccessController.doPrivileged( 
+                J2DoPrivHelper.existsAction( queries[i].getSourceFile())))
+                .booleanValue()) {
                 if (files == null)
                     files = new HashSet();
                 files.add(queries[i].getSourceFile());
@@ -383,7 +390,9 @@
                 if (getSourceFile(seqs[i]) == null)
                     setSourceFile(seqs[i], defaultSourceFile(seqs[i],
                         clsNames));
-                if (getSourceFile(seqs[i]).exists()) {
+                if (((Boolean)AccessController.doPrivileged( 
+                    J2DoPrivHelper.existsAction(getSourceFile(seqs[i]))))
+                    .booleanValue()) {
                     if (files == null)
                         files = new HashSet();
                     files.add(getSourceFile(seqs[i]));
@@ -409,7 +418,9 @@
             if (queries[i].getSourceFile() == null)
                 queries[i].setSource(defaultSourceFile(queries[i], clsNames),
                     queries[i].getSourceScope(), queries[i].getSourceType());
-            if (queries[i].getSourceFile().exists()) {
+            if (((Boolean)AccessController.doPrivileged( 
+                J2DoPrivHelper.existsAction( queries[i].getSourceFile() )))
+                .booleanValue()) {
                 if (files == null)
                     files = new HashSet();
                 files.add(queries[i].getSourceFile());
@@ -665,9 +676,16 @@
                 } else if (url.getPath().endsWith(".jar")) {
                     if (log.isTraceEnabled())
                         log.trace(_loc.get("scanning-jar-at-url", url));
-                    scan(new ZipStreamMetaDataIterator(
-                        new ZipInputStream(url.openStream()),
-                        newMetaDataFilter()), cparser, names, true, url);
+                    try {
+                        InputStream is = (InputStream)
+                            AccessController.doPrivileged(
+                                J2DoPrivHelper.openStreamAction(url));
+                        scan(new ZipStreamMetaDataIterator(
+                            new ZipInputStream(is),
+                            newMetaDataFilter()), cparser, names, true, url);
+                    } catch( PrivilegedActionException pae ) {
+                        throw (IOException)pae.getException();
+                    }
                 } else {
                     if (log.isTraceEnabled())
                         log.trace(_loc.get("scanning-url", url));
@@ -685,14 +703,22 @@
             for (Iterator itr = rsrcs.iterator(); itr.hasNext();) {
                 rsrc = (String) itr.next();
                 if (rsrc.endsWith(".jar")) {
-                    url = loader.getResource(rsrc);
+                    url = (URL)AccessController.doPrivileged( 
+                        J2DoPrivHelper.getResourceAction(loader, rsrc)); 
                     if (url != null) {
                         if (log.isTraceEnabled())
                             log.trace(_loc.get("scanning-jar-stream-url", url));
-                        scan(new ZipStreamMetaDataIterator
-                            (new ZipInputStream(url.openStream()),
+                        try {
+                            InputStream is = (InputStream)
+                                AccessController.doPrivileged(
+                                    J2DoPrivHelper.openStreamAction(url));
+                            scan(new ZipStreamMetaDataIterator
+                                (new ZipInputStream(is),
                                 newMetaDataFilter()), cparser, names, true,
                                 url);
+                        } catch( PrivilegedActionException pae ) {
+                            throw (IOException)pae.getException();
+                        }
                     }
                 } else {
                     if (log.isTraceEnabled())

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractMetaDataDefaults.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractMetaDataDefaults.java?view=diff&rev=552996&r1=552995&r2=552996
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractMetaDataDefaults.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractMetaDataDefaults.java Tue Jul  3 14:55:29 2007
@@ -22,11 +22,13 @@
 import java.lang.reflect.Member;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.openjpa.enhance.PCRegistry;
 import org.apache.openjpa.enhance.Reflection;
 import org.apache.openjpa.lib.log.Log;
+import org.apache.openjpa.lib.util.J2DoPrivHelper;
 import org.apache.openjpa.lib.util.Localizer;
 import org.apache.openjpa.util.InternalException;
 import org.apache.openjpa.util.OpenJPAException;
@@ -185,7 +187,9 @@
             FieldMetaData fmd;
             for (int i = 0; i < fieldNames.length; i ++) {
                 if (meta.getAccessType() == ClassMetaData.ACCESS_FIELD)
-                    member = cls.getDeclaredField(fieldNames[i]);
+                    member = (Field)AccessController.doPrivileged(
+                        J2DoPrivHelper.getDeclaredFieldAction(
+                            cls,fieldNames[i])); 
                 else
                     member = Reflection.findGetter(meta.getDescribedType(),
                         fieldNames[i], true);
@@ -200,6 +204,8 @@
         } catch (OpenJPAException ke) {
             throw ke;
         } catch (Exception e) {
+            if (e instanceof PrivilegedActionException)
+                e = ((PrivilegedActionException)e).getException();
             throw new UserException(e);
         }
     }
@@ -211,9 +217,13 @@
         Member[] members;
         boolean iface = meta.getDescribedType().isInterface();
         if (meta.getAccessType() == ClassMetaData.ACCESS_FIELD && !iface)
-            members = meta.getDescribedType().getDeclaredFields();
+            members = (Field[])AccessController.doPrivileged( 
+                J2DoPrivHelper.getDeclaredFieldsAction(
+                    meta.getDescribedType())); 
         else
-            members = meta.getDescribedType().getDeclaredMethods();
+            members = (Method[])AccessController.doPrivileged( 
+                J2DoPrivHelper.getDeclaredMethodsAction(
+                    meta.getDescribedType())); 
 
         int mods;
         String name;
@@ -313,12 +323,16 @@
             //### where the superclass uses a different access type
             if (fmd.getDefiningMetaData().getAccessType() ==
                 ClassMetaData.ACCESS_FIELD)
-                return fmd.getDeclaringType().getDeclaredField(fmd.getName());
+                return (Field) AccessController.doPrivileged(
+                    J2DoPrivHelper.getDeclaredFieldAction(
+                        fmd.getDeclaringType(), fmd.getName())); 
             return Reflection.findGetter(fmd.getDeclaringType(), fmd.getName(),
                 true);
         } catch (OpenJPAException ke) {
             throw ke;
         } catch (Exception e) {
+            if (e instanceof PrivilegedActionException)
+                e = ((PrivilegedActionException)e).getException();
             throw new InternalException(e);
         }
     }



Mime
View raw message