cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1170390 [1/2] - in /cxf/trunk: api/src/main/java/org/apache/cxf/ api/src/main/java/org/apache/cxf/io/ common/common/src/main/java/org/apache/cxf/common/annotation/ common/common/src/main/java/org/apache/cxf/common/classloader/ common/commo...
Date Tue, 13 Sep 2011 23:36:30 GMT
Author: dkulp
Date: Tue Sep 13 23:36:28 2011
New Revision: 1170390

URL: http://svn.apache.org/viewvc?rev=1170390&view=rev
Log:
Start working on getting calls that require security access to go
through an AccessController to allow configuring via a SecurityManager.
wsdl_first sample now works with basic security setups.

Added:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemPropertyAction.java   (with props)
Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java
    cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/annotation/AnnotationProcessor.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/commands/ForkedCommand.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/commands/JavaHelper.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ReflectionInvokationHandler.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
    cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJFactoryResolver.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/MultipleEndpointObserver.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBEncoderDecoder.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSInvoker.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ClientMessageObserver.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/ServerWebApplicationException.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/CodeGeneratorProvider.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/codegen/SourceGenerator.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/EndpointImpl.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsProxyFactoryBean.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ClientProxyFactoryBean.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/ServerFactoryBean.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    cxf/trunk/rt/management-web/src/main/java/org/apache/cxf/management/web/logging/ReadOnlyFileStorage.java
    cxf/trunk/rt/rs/security/xml/src/main/java/org/apache/cxf/rs/security/common/CryptoLoader.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/ProxyFactory.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/https/SSLUtils.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletController.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/JMSDestination.java
    cxf/trunk/rt/transports/jms/src/main/java/org/apache/cxf/transport/jms/continuations/JMSContinuation.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyOutInterceptor.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/jdbc/RMTxStore.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/BusFactory.java Tue Sep 13 23:36:28 2011
@@ -22,6 +22,7 @@ package org.apache.cxf;
 import java.io.BufferedReader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.security.AccessController;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.WeakHashMap;
@@ -30,6 +31,7 @@ import java.util.logging.Logger;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.SystemPropertyAction;
 
 /**
  * Factory to create CXF Bus objects.
@@ -258,7 +260,8 @@ public abstract class BusFactory {
         String busFactoryCondition = null;
 
         // next check system properties
-        busFactoryClass = System.getProperty(BusFactory.BUS_FACTORY_PROPERTY_NAME);
+        busFactoryClass = AccessController
+            .doPrivileged(new SystemPropertyAction(BusFactory.BUS_FACTORY_PROPERTY_NAME));
         if (isValidBusFactoryClass(busFactoryClass)) {
             return busFactoryClass;
         }

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Tue Sep 13 23:36:28 2011
@@ -31,10 +31,12 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
+import java.security.AccessController;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.helpers.LoadingByteArrayOutputStream;
@@ -43,15 +45,17 @@ public class CachedOutputStream extends 
     private static final File DEFAULT_TEMP_DIR;
     private static final int DEFAULT_THRESHOLD;
     static {
-        String s = System.getProperty("org.apache.cxf.io.CachedOutputStream.Threshold",
-                                      "-1");
+        String s = AccessController
+            .doPrivileged(new SystemPropertyAction("org.apache.cxf.io.CachedOutputStream.Threshold",
+                                                   "-1"));
         int i = Integer.parseInt(s);
         if (i <= 0) {
             i = 64 * 1024;
         }
         DEFAULT_THRESHOLD = i;
         
-        s = System.getProperty("org.apache.cxf.io.CachedOutputStream.OutputDirectory");
+        s = AccessController
+            .doPrivileged(new SystemPropertyAction("org.apache.cxf.io.CachedOutputStream.OutputDirectory"));
         if (s != null) {
             File f = new File(s);
             if (f.exists() && f.isDirectory()) {

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/annotation/AnnotationProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/annotation/AnnotationProcessor.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/annotation/AnnotationProcessor.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/annotation/AnnotationProcessor.java Tue Sep 13 23:36:28 2011
@@ -25,8 +25,10 @@ import java.lang.reflect.Method;
 import java.util.List;
 import java.util.logging.Logger;
 
+
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.ReflectionUtil;
 
 
 /** Process instance of an annotated class.  This is a visitable
@@ -80,7 +82,7 @@ public  class AnnotationProcessor {
         if (targetClass.getSuperclass() != null) {
             processMethods(visitor, targetClass.getSuperclass());
         }
-        for (Method element : targetClass.getDeclaredMethods()) {
+        for (Method element : ReflectionUtil.getDeclaredMethods(targetClass)) {
             for (Class<? extends Annotation> clz : annotationTypes) {
                 Annotation ann = element.getAnnotation(clz); 
                 if (ann != null) {
@@ -94,7 +96,7 @@ public  class AnnotationProcessor {
         if (targetClass.getSuperclass() != null) {
             processFields(visitor, targetClass.getSuperclass());
         }
-        for (Field element : targetClass.getDeclaredFields()) {
+        for (Field element : ReflectionUtil.getDeclaredFields(targetClass)) {
             for (Class<? extends Annotation> clz : annotationTypes) {
                 Annotation ann = element.getAnnotation(clz); 
                 if (ann != null) {

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java Tue Sep 13 23:36:28 2011
@@ -22,6 +22,8 @@ package org.apache.cxf.common.classloade
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
@@ -37,6 +39,27 @@ public final class ClassLoaderUtils {
     private ClassLoaderUtils() {
     }
     
+    public static class ClassLoaderHolder {
+        ClassLoader loader;
+        ClassLoaderHolder(ClassLoader c) {
+            loader = c;
+        }
+        
+        public void reset() {
+            ClassLoaderUtils.setThreadContextClassloader(loader);
+        }
+    }
+    public static ClassLoaderHolder setThreadContextClassloader(final ClassLoader newLoader) {
+        return AccessController.doPrivileged(new PrivilegedAction<ClassLoaderHolder>() {
+            public ClassLoaderHolder run() {
+                ClassLoader l = Thread.currentThread().getContextClassLoader();
+                Thread.currentThread().setContextClassLoader(newLoader);
+                return new ClassLoaderHolder(l);
+            }
+        });
+    }
+    
+    
     /**
      * Load a given resource. <p/> This method will try to load the resource
      * using the following methods (in order):

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/commands/ForkedCommand.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/commands/ForkedCommand.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/commands/ForkedCommand.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/commands/ForkedCommand.java Tue Sep 13 23:36:28 2011
@@ -26,6 +26,7 @@ import java.util.logging.Logger;
 
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.SystemPropertyAction;
 
 
 public class ForkedCommand extends Thread {
@@ -42,7 +43,7 @@ public class ForkedCommand extends Threa
     private boolean joinErrOut = true;
 
     static {
-        if (System.getProperty("os.name").startsWith("Windows")) {
+        if (SystemPropertyAction.getProperty("os.name").startsWith("Windows")) {
             EXE_SUFFIX = ".exe";
         } else {
             EXE_SUFFIX = "";

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/commands/JavaHelper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/commands/JavaHelper.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/commands/JavaHelper.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/commands/JavaHelper.java Tue Sep 13 23:36:28 2011
@@ -21,6 +21,8 @@ package org.apache.cxf.common.commands;
 
 import java.io.File;
 
+import org.apache.cxf.common.util.SystemPropertyAction;
+
 public final class JavaHelper {
 
     private JavaHelper() {
@@ -34,7 +36,7 @@ public final class JavaHelper {
      *
      */
     public static String getJavaCommand() { 
-        String javaHome = System.getProperty("java.home");
+        String javaHome = SystemPropertyAction.getProperty("java.home");
         if (null != javaHome) { 
             return javaHome + File.separator + "bin"  
                 + File.separator  + "java" + ForkedCommand.EXE_SUFFIX; 

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java Tue Sep 13 23:36:28 2011
@@ -40,6 +40,7 @@ import org.apache.cxf.common.annotation.
 import org.apache.cxf.common.annotation.AnnotationProcessor;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.ClassHelper;
+import org.apache.cxf.common.util.ReflectionUtil;
 import org.apache.cxf.resource.ResourceManager;
 import org.apache.cxf.resource.ResourceResolver;
 
@@ -94,7 +95,7 @@ public class ResourceInjector extends Ab
             for (String s : njsr.unlessNull()) {
                 try {
                     Field f = getField(cls, s);
-                    f.setAccessible(true);
+                    ReflectionUtil.setAccessible(f);
                     if (f.get(o) == null) {
                         return true;
                     }
@@ -281,7 +282,7 @@ public class ResourceInjector extends Ab
 
     private void invokeSetter(Method method, Object resource) { 
         try {
-            method.setAccessible(true);
+            ReflectionUtil.setAccessible(method);
             if (method.getDeclaringClass().isAssignableFrom(getTarget().getClass())) {
                 method.invoke(getTarget(), resource);
             } else { // deal with the proxy setter method
@@ -321,15 +322,15 @@ public class ResourceInjector extends Ab
 
         boolean accessible = field.isAccessible(); 
         try {
-            if (field.getType().isAssignableFrom(resource.getClass())) { 
-                field.setAccessible(true); 
+            if (field.getType().isAssignableFrom(resource.getClass())) {
+                ReflectionUtil.setAccessible(field);
                 field.set(ClassHelper.getRealObject(getTarget()), resource);
             }
         } catch (IllegalAccessException e) { 
             e.printStackTrace();
             LOG.severe("FAILED_TO_INJECT_FIELD"); 
         } finally {
-            field.setAccessible(accessible); 
+            ReflectionUtil.setAccessible(field, accessible);
         }
     } 
 
@@ -341,14 +342,14 @@ public class ResourceInjector extends Ab
             PostConstruct pc = method.getAnnotation(PostConstruct.class);
             if (pc != null) {
                 try {
-                    method.setAccessible(true);
+                    ReflectionUtil.setAccessible(method);
                     method.invoke(target);
                 } catch (IllegalAccessException e) {
                     LOG.log(Level.WARNING, "INJECTION_COMPLETE_NOT_VISIBLE", method);
                 } catch (InvocationTargetException e) {
                     LOG.log(Level.WARNING, "INJECTION_COMPLETE_THREW_EXCEPTION", e);
                 } finally {
-                    method.setAccessible(accessible); 
+                    ReflectionUtil.setAccessible(method, accessible);
                 }
             }
         }
@@ -361,14 +362,14 @@ public class ResourceInjector extends Ab
             PreDestroy pd = method.getAnnotation(PreDestroy.class);
             if (pd != null) {
                 try {
-                    method.setAccessible(true);
+                    ReflectionUtil.setAccessible(method);
                     method.invoke(target);
                 } catch (IllegalAccessException e) {
                     LOG.log(Level.WARNING, "PRE_DESTROY_NOT_VISIBLE", method);
                 } catch (InvocationTargetException e) {
                     LOG.log(Level.WARNING, "PRE_DESTROY_THREW_EXCEPTION", e);
                 } finally {
-                    method.setAccessible(accessible); 
+                    ReflectionUtil.setAccessible(method, accessible);
                 }
             }
         }

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/logging/LogUtils.java Tue Sep 13 23:36:28 2011
@@ -33,6 +33,7 @@ import java.util.logging.Logger;
 
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.common.util.SystemPropertyAction;
 
 
 /**
@@ -66,7 +67,7 @@ public final class LogUtils {
         JDKBugHacks.doHacks();
         
         try {
-            String cname = System.getProperty(KEY);
+            String cname = SystemPropertyAction.getProperty(KEY);
             if (StringUtils.isEmpty(cname)) {
                 InputStream ins = Thread.currentThread().getContextClassLoader()
                     .getResourceAsStream("META-INF/cxf/" + KEY);

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/Compiler.java Tue Sep 13 23:36:28 2011
@@ -83,7 +83,7 @@ public class Compiler {
         }
         
         if (StringUtils.isEmpty(classPath)) {
-            String javaClasspath = System.getProperty("java.class.path");
+            String javaClasspath = SystemPropertyAction.getProperty("java.class.path");
             boolean classpathSetted = javaClasspath != null ? true : false;
             if (!classpathSetted) {
                 File f = new File(getClass().getClassLoader().getResource(".").getFile());
@@ -117,7 +117,7 @@ public class Compiler {
         return compileFiles(f.toArray(new String[files.size()]));
     }
     public boolean compileFiles(String[] files) {
-        String endorsed = System.getProperty("java.endorsed.dirs");
+        String endorsed = SystemPropertyAction.getProperty("java.endorsed.dirs");
         if (!forceFork) {
             try { 
                 Class.forName("javax.tools.JavaCompiler");
@@ -130,21 +130,21 @@ public class Compiler {
         List<String> list = new ArrayList<String>();
 
         // Start of honoring java.home for used javac
-        String fsep = System.getProperty("file.separator");
+        String fsep = SystemPropertyAction.getProperty("file.separator");
         String javacstr = "javac";
         String platformjavacname = "javac";
 
-        if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
+        if (SystemPropertyAction.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
             platformjavacname = "javac.exe";
         }
 
-        if (new File(System.getProperty("java.home") + fsep + platformjavacname).exists()) {
+        if (new File(SystemPropertyAction.getProperty("java.home") + fsep + platformjavacname).exists()) {
             // check if java.home is jdk home
-            javacstr = System.getProperty("java.home") + fsep + platformjavacname;
-        } else if (new File(System.getProperty("java.home") + fsep + ".." + fsep + "bin" + fsep
+            javacstr = SystemPropertyAction.getProperty("java.home") + fsep + platformjavacname;
+        } else if (new File(SystemPropertyAction.getProperty("java.home") + fsep + ".." + fsep + "bin" + fsep
                             + platformjavacname).exists()) {
             // check if java.home is jre home
-            javacstr = System.getProperty("java.home") + fsep + ".." + fsep + "bin" + fsep
+            javacstr = SystemPropertyAction.getProperty("java.home") + fsep + ".." + fsep + "bin" + fsep
                        + platformjavacname;
         }
 
@@ -214,7 +214,8 @@ public class Compiler {
                         // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6198196
                         //
                         if (args[i].indexOf("package-info.java") > -1
-                            && System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
+                            && SystemPropertyAction.getProperty("os.name")
+                                .toLowerCase().indexOf("windows") > -1) {
                             out.println("\"" + args[i].replaceAll("/", "\\\\\\\\") + "\"");
                         } else {
                             out.println("\"" + args[i] + "\"");
@@ -233,7 +234,7 @@ public class Compiler {
                 System.arraycopy(args, 0, cmdArray, 0, args.length);
             }
 
-            if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
+            if (SystemPropertyAction.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
                 for (int i = 0; i < cmdArray.length; i++) {
                     if (cmdArray[i].indexOf("package-info") == -1) {
                         cmdArray[i] = cmdArray[i].replace('\\', '/');

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ReflectionInvokationHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ReflectionInvokationHandler.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ReflectionInvokationHandler.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ReflectionInvokationHandler.java Tue Sep 13 23:36:28 2011
@@ -48,7 +48,7 @@ public class ReflectionInvokationHandler
         WrapReturn wr = method.getAnnotation(WrapReturn.class);
         try {
             Method m = target.getClass().getMethod(method.getName(), method.getParameterTypes());
-            m.setAccessible(true);
+            ReflectionUtil.setAccessible(m);
             return wrapReturn(wr, m.invoke(target, args));                
         } catch (NoSuchMethodException e) {
             for (Method m2 : target.getClass().getMethods()) {
@@ -62,7 +62,7 @@ public class ReflectionInvokationHandler
                         }
                     }
                     if (found) {
-                        m2.setAccessible(true);
+                        ReflectionUtil.setAccessible(m2);
                         return wrapReturn(wr, m2.invoke(target, args));                            
                     }
                 }

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ReflectionUtil.java Tue Sep 13 23:36:28 2011
@@ -23,9 +23,14 @@ import java.beans.BeanInfo;
 import java.beans.PropertyDescriptor;
 import java.io.File;
 import java.io.IOException;
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.*;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.*;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
@@ -38,7 +43,81 @@ public final class ReflectionUtil {
     private ReflectionUtil() {
         // intentionally empty
     }
+    
+    public static Field getDeclaredField(final Class<?> cls, final String name) {
+        return AccessController.doPrivileged(new PrivilegedAction<Field>() {
+            public Field run() {
+                try {
+                    return cls.getDeclaredField(name);
+                } catch (SecurityException e) {
+                    return null;
+                } catch (NoSuchFieldException e) {
+                    return null;
+                }
+            }
+        });
+    }
+
+    public static Constructor getDeclaredConstructor(final Class<?> cls, final Class<?> ... args) {
+        return AccessController.doPrivileged(new PrivilegedAction<Constructor>() {
+            public Constructor run() {
+                try {
+                    return cls.getDeclaredConstructor(args);
+                } catch (SecurityException e) {
+                    return null;
+                } catch (NoSuchMethodException e) {
+                    return null;
+                }
+            }
+        });
+        
+    }
+    public static Constructor getConstructor(final Class<?> cls, final Class<?> ... args) {
+        return AccessController.doPrivileged(new PrivilegedAction<Constructor>() {
+            public Constructor run() {
+                try {
+                    return cls.getConstructor(args);
+                } catch (SecurityException e) {
+                    return null;
+                } catch (NoSuchMethodException e) {
+                    return null;
+                }
+            }
+        });
+        
+    }
+    
+    public static Method[] getDeclaredMethods(final Class<?> cls) {
+        return AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
+            public Method[] run() {
+                return cls.getDeclaredMethods();
+            }
+        });
+    }
+    public static Field[] getDeclaredFields(final Class<?> cls) {
+        return AccessController.doPrivileged(new PrivilegedAction<Field[]>() {
+            public Field[] run() {
+                return cls.getDeclaredFields();
+            }
+        });
+    }
 
+    public static void setAccessible(final AccessibleObject o) {
+        AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+            public Boolean run() {
+                o.setAccessible(true);
+                return true;
+            }
+        });
+    }
+    public static void setAccessible(final AccessibleObject o, final boolean b) {
+        AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+            public Boolean run() {
+                o.setAccessible(b);
+                return true;
+            }
+        });
+    }
     public static List<String> getPackagesFromJar(File jarFile) throws IOException {
         List<String> packageNames = new ArrayList<String>();
         if (jarFile.isDirectory()) {

Added: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemPropertyAction.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemPropertyAction.java?rev=1170390&view=auto
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemPropertyAction.java (added)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemPropertyAction.java Tue Sep 13 23:36:28 2011
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.common.util;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * 
+ */
+public class SystemPropertyAction implements PrivilegedAction<String> {
+    final String property;
+    final String def;
+    public SystemPropertyAction(String name) {
+        property = name;
+        def = null;
+    }
+    public SystemPropertyAction(String name, String d) {
+        property = name;
+        def = d;
+    }
+    
+    /* (non-Javadoc)
+     * @see java.security.PrivilegedAction#run()
+     */
+    public String run() {
+        if (def != null) {
+            return System.getProperty(property, def);
+        }
+        return System.getProperty(property);
+    }
+    
+    public static String getProperty(String name) {
+        return AccessController.doPrivileged(new SystemPropertyAction(name));
+    }
+    public static String getProperty(String name, String def) {
+        return AccessController.doPrivileged(new SystemPropertyAction(name, def));
+    }
+}

Propchange: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemPropertyAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemPropertyAction.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemUtils.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/SystemUtils.java Tue Sep 13 23:36:28 2011
@@ -19,6 +19,9 @@
 
 package org.apache.cxf.common.util;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
 /**
  * Utility class for checking well-known system properties
  *
@@ -36,11 +39,15 @@ public final class SystemUtils {
      * @return Spring validation mode
      */
     public static String getSpringValidationMode() {
-        String mode = System.getProperty(SPRING_VALIDATION_MODE);
-        if (mode == null) {
-            mode = System.getProperty("spring.validation.mode");
-        }
-        return mode;
+        return AccessController.doPrivileged(new PrivilegedAction<String>() {
+            public String run() {
+                String mode = SystemPropertyAction.getProperty(SPRING_VALIDATION_MODE);
+                if (mode == null) {
+                    mode = SystemPropertyAction.getProperty("spring.validation.mode");
+                }
+                return mode;
+            }
+        });
     }
     
 }

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java Tue Sep 13 23:36:28 2011
@@ -32,6 +32,8 @@ import java.util.Locale;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import org.apache.cxf.common.util.SystemPropertyAction;
+
 public final class FileUtils {
     private static final int RETRY_SLEEP_MILLIS = 10;
     private static File defaultTempDir;
@@ -49,7 +51,7 @@ public final class FileUtils {
         
         String s = null;
         try {
-            s = System.getProperty(FileUtils.class.getName() + ".TempDirectory");
+            s = SystemPropertyAction.getProperty(FileUtils.class.getName() + ".TempDirectory");
         } catch (SecurityException e) {
             //Ignorable, we'll use the default
         }
@@ -62,7 +64,7 @@ public final class FileUtils {
         }
         if (defaultTempDir == null) {
             int x = (int)(Math.random() * 1000000);
-            s = System.getProperty("java.io.tmpdir");
+            s = SystemPropertyAction.getProperty("java.io.tmpdir");
             File checkExists = new File(s);
             if (!checkExists.exists() || !checkExists.isDirectory()) {
                 throw new RuntimeException("The directory " 
@@ -171,7 +173,7 @@ public final class FileUtils {
     }
 
     private static boolean isWindows() {
-        String osName = System.getProperty("os.name").toLowerCase(Locale.US);
+        String osName = SystemPropertyAction.getProperty("os.name").toLowerCase(Locale.US);
         return osName.indexOf("windows") > -1;
     }
 

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/XPathUtils.java Tue Sep 13 23:36:28 2011
@@ -30,6 +30,10 @@ import javax.xml.xpath.XPathFactory;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
+
+
 public class XPathUtils {
     private XPath xpath;
 
@@ -51,14 +55,16 @@ public class XPathUtils {
     }
 
     public Object getValue(String xpathExpression, Node node, QName type) {
-        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+        ClassLoaderHolder loader 
+            = ClassLoaderUtils.setThreadContextClassloader(xpath.getClass().getClassLoader());
         try {
-            Thread.currentThread().setContextClassLoader(xpath.getClass().getClassLoader());
             return xpath.evaluate(xpathExpression, node, type);
         } catch (Exception e) {
             return null;
         } finally {
-            Thread.currentThread().setContextClassLoader(loader);
+            if (loader != null) {
+                loader.reset();
+            }
         }
     }
     public NodeList getValueList(String xpathExpression, Node node) {

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBContextCache.java Tue Sep 13 23:36:28 2011
@@ -24,6 +24,9 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.lang.ref.WeakReference;
 import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -116,7 +119,7 @@ public final class JAXBContextCache {
         return getCachedContextAndSchemas(classes, null, props, null, true);
     }
     
-    public static CachedContextAndSchemas getCachedContextAndSchemas(Set<Class<?>> classes,
+    public static CachedContextAndSchemas getCachedContextAndSchemas(final Set<Class<?>> classes,
                                                                      String defaultNs,
                                                                      Map<String, Object> props,
                                                                      Collection<Object> typeRefs,
@@ -172,10 +175,13 @@ public final class JAXBContextCache {
                 boolean added = addJaxbObjectFactory(ex, classes);
                 while (cachedContextAndSchemas == null && added) {
                     try {
-                        context = JAXBContext.newInstance(classes
-                                                      .toArray(new Class[classes.size()]), null);
-                    } catch (JAXBException e) {
-                        //second attempt failed as well, rethrow the original exception
+                        context = AccessController.doPrivileged(new PrivilegedExceptionAction<JAXBContext>() {
+                            public JAXBContext run() throws Exception {
+                                return JAXBContext.newInstance(classes
+                                                              .toArray(new Class[classes.size()]), null);
+                            }
+                        });
+                    } catch (PrivilegedActionException e) {
                         throw ex;
                     }
                 }
@@ -208,8 +214,8 @@ public final class JAXBContextCache {
     }
     
     
-    private static JAXBContext createContext(Set<Class<?>> classes,
-                                      Map<String, Object> map,
+    private static JAXBContext createContext(final Set<Class<?>> classes,
+                                      final Map<String, Object> map,
                                       Collection<Object> typeRefs)
         throws JAXBException {
         JAXBContext ctx;
@@ -257,16 +263,25 @@ public final class JAXBContextCache {
             }
         }
         try {
-            ctx = JAXBContext.newInstance(classes.toArray(new Class[classes.size()]), map);
-        } catch (JAXBException ex) {
-            if (map.containsKey("com.sun.xml.bind.defaultNamespaceRemap")
-                && ex.getMessage() != null
-                && ex.getMessage().contains("com.sun.xml.bind.defaultNamespaceRemap")) {
-                map.put("com.sun.xml.internal.bind.defaultNamespaceRemap",
-                        map.remove("com.sun.xml.bind.defaultNamespaceRemap"));
-                ctx = JAXBContext.newInstance(classes.toArray(new Class[classes.size()]), map);
+            ctx = AccessController.doPrivileged(new PrivilegedExceptionAction<JAXBContext>() {
+                public JAXBContext run() throws Exception {
+                    return JAXBContext.newInstance(classes.toArray(new Class[classes.size()]), map);
+                }
+            });
+        } catch (PrivilegedActionException e2) {
+            if (e2.getException() instanceof JAXBException) {
+                JAXBException ex = (JAXBException)e2.getException();
+                if (map.containsKey("com.sun.xml.bind.defaultNamespaceRemap")
+                    && ex.getMessage() != null
+                    && ex.getMessage().contains("com.sun.xml.bind.defaultNamespaceRemap")) {
+                    map.put("com.sun.xml.internal.bind.defaultNamespaceRemap",
+                            map.remove("com.sun.xml.bind.defaultNamespaceRemap"));
+                    ctx = JAXBContext.newInstance(classes.toArray(new Class[classes.size()]), map);
+                } else {
+                    throw ex;
+                }
             } else {
-                throw ex;
+                throw new RuntimeException(e2.getException());
             }
         }
         return ctx;

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/jaxb/JAXBUtils.java Tue Sep 13 23:36:28 2011
@@ -73,7 +73,9 @@ import org.apache.cxf.common.util.Cached
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.ReflectionInvokationHandler;
 import org.apache.cxf.common.util.ReflectionInvokationHandler.WrapReturn;
+import org.apache.cxf.common.util.ReflectionUtil;
 import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.helpers.JavaUtils;
 import org.objectweb.asm.ClassWriter;
 import org.objectweb.asm.FieldVisitor;
@@ -512,15 +514,9 @@ public final class JAXBUtils {
             if (cls.getName().equals("javax.xml.ws.wsaddressing.W3CEndpointReference")) {
                 return cls;
             }
-            Constructor cons = null;
-            try {
-                cons = cls.getDeclaredConstructor(new Class[0]);
-            } catch (NoSuchMethodException ex) {
-                try {
-                    cons = cls.getConstructor(new Class[0]);
-                } catch (NoSuchMethodException ex2) {
-                    cons = null;
-                }
+            Constructor cons = ReflectionUtil.getDeclaredConstructor(cls);
+            if (cons == null) {
+                cons = ReflectionUtil.getConstructor(cls);
             }
             if (cons == null) {
                 cls = null;
@@ -537,7 +533,7 @@ public final class JAXBUtils {
             } catch (Exception t2) {
                 //couldn't find either, probably cause tools.jar isn't on 
                 //the classpath.   Let's see if we can find the tools jar
-                String s = System.getProperty("java.home");
+                String s = SystemPropertyAction.getProperty("java.home");
                 if (!StringUtils.isEmpty(s)) {
                     File home = new File(s);
                     File jar = new File(home, "lib/tools.jar");

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/resource/URIResolver.java Tue Sep 13 23:36:28 2011
@@ -38,6 +38,7 @@ import org.apache.cxf.common.classloader
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.Base64Utility;
 import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.helpers.LoadingByteArrayOutputStream;
 
@@ -145,17 +146,17 @@ public class URIResolver {
                 try {
                     HttpURLConnection huc = (HttpURLConnection)url.openConnection();
 
-                    String host = System.getProperty("http.proxyHost");
+                    String host = SystemPropertyAction.getProperty("http.proxyHost");
                     if (host != null) {
                         //comment out unused port to pass pmd check
-                        /*String ports = System.getProperty("http.proxyPort");
+                        /*String ports = SystemPropertyAction.getProperty("http.proxyPort");
                         int port = 80;
                         if (ports != null) {
                             port = Integer.parseInt(ports);
                         }*/
 
-                        String username = System.getProperty("http.proxy.user");
-                        String password = System.getProperty("http.proxy.password");
+                        String username = SystemPropertyAction.getProperty("http.proxy.user");
+                        String password = SystemPropertyAction.getProperty("http.proxy.password");
 
                         if (username != null && password != null) {
                             String encoded = Base64Utility.encode((username + ":" + password).getBytes());

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java (original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/StaxUtils.java Tue Sep 13 23:36:28 2011
@@ -76,6 +76,7 @@ import org.xml.sax.XMLReader;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.XMLUtils;
@@ -101,7 +102,7 @@ public final class StaxUtils {
         int i = 20;
     
         try {
-            String s = System.getProperty("org.apache.cxf.staxutils.pool-size",
+            String s = SystemPropertyAction.getProperty("org.apache.cxf.staxutils.pool-size",
                                           "-1");
             i = Integer.parseInt(s);
         } catch (Throwable t) {
@@ -114,8 +115,9 @@ public final class StaxUtils {
         NS_AWARE_INPUT_FACTORY_POOL = new LinkedBlockingQueue<XMLInputFactory>(i);
         OUTPUT_FACTORY_POOL = new LinkedBlockingQueue<XMLOutputFactory>(i);
         try {
-            String s =  System.getProperty("org.apache.cxf.staxutils.innerElementLevelThreshold",
-                                    "-1");
+            String s =  SystemPropertyAction
+                    .getProperty("org.apache.cxf.staxutils.innerElementLevelThreshold",
+                                 "-1");
             innerElementLevelThreshold = Integer.parseInt(s);
         } catch (Throwable t) {
             innerElementLevelThreshold = -1;
@@ -124,7 +126,8 @@ public final class StaxUtils {
             innerElementLevelThreshold = -1;
         }
         try {
-            String s =  System.getProperty("org.apache.cxf.staxutils.innerElementCountThreshold",
+            String s =  SystemPropertyAction
+                .getProperty("org.apache.cxf.staxutils.innerElementCountThreshold",
                                     "-1");
             innerElementCountThreshold = Integer.parseInt(s);
         } catch (Throwable t) {

Modified: cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java (original)
+++ cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocMessageObserver.java Tue Sep 13 23:36:28 2011
@@ -31,6 +31,8 @@ import javax.xml.transform.Source;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.binding.Binding;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Interceptor;
@@ -59,10 +61,10 @@ public class ColocMessageObserver extend
 
     public void onMessage(Message m) {
         Bus origBus = BusFactory.getThreadDefaultBus(false);
-        ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
+        ClassLoaderHolder origLoader = null;
         try {
             if (loader != null) {
-                Thread.currentThread().setContextClassLoader(loader);
+                origLoader = ClassLoaderUtils.setThreadContextClassloader(loader);
             }
             BusFactory.setThreadDefaultBus(bus);
             if (LOG.isLoggable(Level.FINER)) {
@@ -130,7 +132,9 @@ public class ColocMessageObserver extend
             setOutBoundMessage(ex, m.getExchange());
         } finally {
             BusFactory.setThreadDefaultBus(origBus);
-            Thread.currentThread().setContextClassLoader(origLoader);
+            if (origLoader != null) {
+                origLoader.reset();
+            }
         }
     }
     

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJFactoryResolver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJFactoryResolver.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJFactoryResolver.java (original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJFactoryResolver.java Tue Sep 13 23:36:28 2011
@@ -27,6 +27,7 @@ import javax.xml.soap.SOAPFactory;
 import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.Soap12;
 import org.apache.cxf.binding.soap.SoapVersion;
+import org.apache.cxf.common.util.SystemPropertyAction;
 
 /**
  * 
@@ -44,7 +45,7 @@ public final class SAAJFactoryResolver {
 
     public static MessageFactory createMessageFactory(SoapVersion version) throws SOAPException {
         MessageFactory messageFactory;
-        String messageFactoryClassName = System.getProperty(MESSAGE_FACTORY_KEY);
+        String messageFactoryClassName = SystemPropertyAction.getProperty(MESSAGE_FACTORY_KEY);
         if (messageFactoryClassName != null) {
             messageFactory = newInstanceCxfSAAJFactory(messageFactoryClassName,
                                                           MessageFactory.class);
@@ -68,7 +69,7 @@ public final class SAAJFactoryResolver {
 
     public static SOAPFactory createSOAPFactory(SoapVersion version) throws SOAPException {
         SOAPFactory soapFactory;
-        String soapFactoryClassName = System.getProperty(SOAP_FACTORY_KEY);
+        String soapFactoryClassName = SystemPropertyAction.getProperty(SOAP_FACTORY_KEY);
         if (soapFactoryClassName != null) {
             soapFactory = newInstanceCxfSAAJFactory(soapFactoryClassName,
                                                        SOAPFactory.class);

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java Tue Sep 13 23:36:28 2011
@@ -19,6 +19,7 @@
 package org.apache.cxf.bus.extension;
 
 import java.io.InputStream;
+import java.security.AccessController;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -27,6 +28,7 @@ import org.apache.cxf.binding.BindingFac
 import org.apache.cxf.bus.BusState;
 import org.apache.cxf.bus.CXFBusImpl;
 import org.apache.cxf.buslifecycle.BusLifeCycleManager;
+import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.configuration.ConfiguredBeanLocator;
 import org.apache.cxf.configuration.Configurer;
 import org.apache.cxf.configuration.NullConfigurer;
@@ -179,7 +181,7 @@ public class ExtensionManagerBus extends
         }
 
         // next check system properties
-        busId = System.getProperty(BUS_ID_PROPERTY_NAME);
+        busId = AccessController.doPrivileged(new SystemPropertyAction(BUS_ID_PROPERTY_NAME));
         if (null != busId && !"".equals(busId)) {
             return busId;
         }

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationContext.java Tue Sep 13 23:36:28 2011
@@ -25,6 +25,11 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.security.AccessControlException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -34,8 +39,10 @@ import java.util.logging.Logger;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.common.util.SystemUtils;
 import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.interceptor.Fault;
 import org.springframework.beans.factory.support.DefaultListableBeanFactory;
 import org.springframework.beans.factory.xml.BeansDtdResolver;
 import org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver;
@@ -88,19 +95,44 @@ public class BusApplicationContext exten
         super(new String[0], false, parent);
         cfgFiles = cf;
         includeDefaults = include;
-        refresh();
+        try {
+            AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() {
+                public Boolean run() throws Exception {
+                    refresh();
+                    return Boolean.TRUE;
+                }
+                
+            });
+        } catch (PrivilegedActionException e) {
+            if (e.getException() instanceof RuntimeException) {
+                throw (RuntimeException)e.getException();
+            }
+            throw new Fault(e);
+        }
     }
     
     public BusApplicationContext(URL[] url, boolean include, ApplicationContext parent) {
         super(new String[0], false, parent);
         cfgFileURLs = url;
         includeDefaults = include;
-        refresh();
+        try {
+            AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() {
+                public Boolean run() throws Exception {
+                    refresh();
+                    return Boolean.TRUE;
+                }
+                
+            });
+        } catch (PrivilegedActionException e) {
+            if (e.getException() instanceof RuntimeException) {
+                throw (RuntimeException)e.getException();
+            }
+            throw new Fault(e);
+        }
     } 
     
     @Override
     protected Resource[] getConfigResources() {
-  
         List<Resource> resources = new ArrayList<Resource>();
        
         if (includeDefaults) {
@@ -131,7 +163,8 @@ public class BusApplicationContext exten
         
         boolean usingDefault = false;
         if (null == cfgFiles) {
-            String cfgFile = System.getProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME);
+            String cfgFile = AccessController
+                .doPrivileged(new SystemPropertyAction(Configurer.USER_CFG_FILE_PROPERTY_NAME));
             if (cfgFile != null) {
                 cfgFiles = new String[] {cfgFile};
             }
@@ -141,8 +174,14 @@ public class BusApplicationContext exten
             usingDefault = true;
         }
         for (String cfgFile : cfgFiles) {
-            Resource cpr = findResource(cfgFile);
-            if (cpr != null && cpr.exists()) {
+            final Resource cpr = findResource(cfgFile);
+            boolean exists = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+                public Boolean run() {
+                    return cpr != null && cpr.exists();
+                }
+                
+            });
+            if (exists) {
                 resources.add(cpr);
                 LogUtils.log(LOG, Level.INFO, "USER_CFG_FILE_IN_USE", cfgFile);
             } else {
@@ -165,7 +204,8 @@ public class BusApplicationContext exten
             }
         } 
         
-        String sysCfgFileUrl = System.getProperty(Configurer.USER_CFG_FILE_PROPERTY_URL);
+        String sysCfgFileUrl = AccessController
+            .doPrivileged(new SystemPropertyAction(Configurer.USER_CFG_FILE_PROPERTY_URL));
         if (null != sysCfgFileUrl) {
             try {
                 UrlResource ur = new UrlResource(sysCfgFileUrl);
@@ -191,34 +231,43 @@ public class BusApplicationContext exten
         return res;
     }
     
-    public static Resource findResource(String cfgFile) {
-        Resource cpr = new ClassPathResource(cfgFile);
-        if (cpr.exists()) {
-            return cpr;
-        }
+    public static Resource findResource(final String cfgFile) {
         try {
-            //see if it's a URL
-            URL url = new URL(cfgFile);
-            cpr = new UrlResource(url);
-            if (cpr.exists()) {
-                return cpr;
-            }
-        } catch (MalformedURLException e) {
-            //ignore
-        }
-        //try loading it our way
-        URL url = ClassLoaderUtils.getResource(cfgFile, BusApplicationContext.class);
-        if (url != null) {
-            cpr = new UrlResource(url);
-            if (cpr.exists()) {
-                return cpr;
-            }
-        }
-        cpr = new FileSystemResource(cfgFile);
-        if (cpr.exists()) {
-            return cpr;
+            return AccessController.doPrivileged(new PrivilegedAction<Resource>() {
+                public Resource run() {
+                    Resource cpr = new ClassPathResource(cfgFile);
+                    if (cpr.exists()) {
+                        return cpr;
+                    }
+                    try {
+                        //see if it's a URL
+                        URL url = new URL(cfgFile);
+                        cpr = new UrlResource(url);
+                        if (cpr.exists()) {
+                            return cpr;
+                        }
+                    } catch (MalformedURLException e) {
+                        //ignore
+                    }
+                    //try loading it our way
+                    URL url = ClassLoaderUtils.getResource(cfgFile, BusApplicationContext.class);
+                    if (url != null) {
+                        cpr = new UrlResource(url);
+                        if (cpr.exists()) {
+                            return cpr;
+                        }
+                    }
+                    cpr = new FileSystemResource(cfgFile);
+                    if (cpr.exists()) {
+                        return cpr;
+                    }
+                    return null;
+                }
+            });
+        } catch (AccessControlException ex) {
+            //cannot read the user config file
+            return null;
         }
-        return null;
     }
     
     @Override

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/ControlledValidationXmlBeanDefinitionReader.java Tue Sep 13 23:36:28 2011
@@ -22,6 +22,9 @@ package org.apache.cxf.bus.spring;
 import java.io.IOException;
 import java.net.URL;
 import java.net.URLConnection;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.stream.XMLStreamException;
@@ -30,6 +33,7 @@ import org.w3c.dom.Document;
 
 import org.xml.sax.InputSource;
 
+import org.apache.cxf.common.util.SystemPropertyAction;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
 import org.springframework.beans.factory.support.BeanDefinitionRegistry;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
@@ -82,7 +86,8 @@ public class ControlledValidationXmlBean
         super(beanFactory);
         tunedDocumentLoader = new TunedDocumentLoader();
         this.setDocumentLoader(tunedDocumentLoader);
-        noFastinfoset = System.getProperty("org.apache.cxf.nofastinfoset") != null 
+        noFastinfoset = AccessController
+            .doPrivileged(new SystemPropertyAction("org.apache.cxf.nofastinfoset")) != null 
             || !TunedDocumentLoader.hasFastInfoSet();
     }
 
@@ -118,7 +123,8 @@ public class ControlledValidationXmlBean
     }
 
     @Override
-    public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefinitionStoreException {
+    public int loadBeanDefinitions(final EncodedResource encodedResource)
+        throws BeanDefinitionStoreException {
         if (!noFastinfoset) {
             try {
                 return fastInfosetLoadBeanDefinitions(encodedResource);
@@ -128,6 +134,22 @@ public class ControlledValidationXmlBean
                 //ignore - just call the super to load them
             }
         }
+        try {
+            return AccessController.doPrivileged(new PrivilegedExceptionAction<Integer>() {
+                public Integer run() throws Exception {
+                    return internalLoadBeanDefinitions(encodedResource);
+                }
+                
+            });
+        } catch (PrivilegedActionException e) {
+            if (e.getException() instanceof RuntimeException) {
+                throw (RuntimeException)e.getException();
+            }
+            throw (BeanDefinitionStoreException)e.getException();
+        }
+    }
+    
+    private int internalLoadBeanDefinitions(EncodedResource encodedResource) {
         return super.loadBeanDefinitions(encodedResource);
     }
     

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBusFactory.java Tue Sep 13 23:36:28 2011
@@ -20,6 +20,8 @@
 package org.apache.cxf.bus.spring;
 
 import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -28,6 +30,7 @@ import org.apache.cxf.BusFactory;
 import org.apache.cxf.buslifecycle.BusLifeCycleListener;
 import org.apache.cxf.buslifecycle.BusLifeCycleManager;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.configuration.Configurer;
 import org.springframework.beans.BeansException;
 import org.springframework.context.ApplicationContext;
@@ -92,11 +95,23 @@ public class SpringBusFactory extends Bu
     
     public Bus createBus(String cfgFiles[], boolean includeDefaults) {
         try {
-            String userCfgFile = System.getProperty(Configurer.USER_CFG_FILE_PROPERTY_NAME);
-            String sysCfgFileUrl = System.getProperty(Configurer.USER_CFG_FILE_PROPERTY_URL);
-            Resource r = BusApplicationContext.findResource(Configurer.DEFAULT_USER_CFG_FILE);
+            String userCfgFile = AccessController
+                .doPrivileged(new SystemPropertyAction(Configurer.USER_CFG_FILE_PROPERTY_NAME));
+            String sysCfgFileUrl = AccessController
+                .doPrivileged(new SystemPropertyAction(Configurer.USER_CFG_FILE_PROPERTY_URL));
+            final Resource r = BusApplicationContext.findResource(Configurer.DEFAULT_USER_CFG_FILE);
+
+            boolean exists = true;
+            if (r != null) {
+                exists = AccessController
+                    .doPrivileged(new PrivilegedAction<Boolean>() {
+                        public Boolean run() {
+                            return r.exists();
+                        }
+                    });
+            }
             if (context == null && userCfgFile == null && cfgFiles == null && sysCfgFileUrl == null 
-                && (r == null || !r.exists()) && includeDefaults) {
+                && (r == null || !exists) && includeDefaults) {
                 return new org.apache.cxf.bus.CXFBusFactory().createBus();
             }
             return finishCreatingBus(createApplicationContext(cfgFiles, includeDefaults));

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/catalog/OASISCatalogManager.java Tue Sep 13 23:36:28 2011
@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.security.AccessController;
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashSet;
@@ -36,6 +37,7 @@ import javax.annotation.Resource;
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.xml.resolver.Catalog;
 import org.apache.xml.resolver.CatalogManager;
 import org.apache.xml.resolver.tools.CatalogResolver;
@@ -47,7 +49,8 @@ public class OASISCatalogManager {
 
     private static final Logger LOG =
         LogUtils.getL7dLogger(OASISCatalogManager.class);
-    private static final String DEBUG_LEVEL = System.getProperty(CATALOG_DEBUG_KEY);
+    private static final String DEBUG_LEVEL 
+        = AccessController.doPrivileged(new SystemPropertyAction(CATALOG_DEBUG_KEY));
     
 
     private Object resolver;

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java Tue Sep 13 23:36:28 2011
@@ -43,6 +43,8 @@ import com.ibm.wsdl.extensions.soap.SOAP
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.binding.Binding;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
 import org.apache.cxf.common.i18n.UncheckedException;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.helpers.CastUtils;
@@ -469,12 +471,12 @@ public class ClientImpl
                               Map<String, Object> context,
                               Exchange exchange) throws Exception {
         Bus origBus = BusFactory.getThreadDefaultBus(false);
-        ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
+        ClassLoaderHolder origLoader = null;
         try {
             BusFactory.setThreadDefaultBus(bus);
             ClassLoader loader = bus.getExtension(ClassLoader.class);
             if (loader != null) {
-                Thread.currentThread().setContextClassLoader(loader);
+                origLoader = ClassLoaderUtils.setThreadContextClassloader(loader);
             }
             if (exchange == null) {
                 exchange = new ExchangeImpl();
@@ -542,7 +544,9 @@ public class ClientImpl
                 return processResult(message, exchange, oi, resContext);
             }
         } finally {
-            Thread.currentThread().setContextClassLoader(origLoader);
+            if (origLoader != null) {
+                origLoader.reset();
+            }
             BusFactory.setThreadDefaultBus(origBus);
         }
     }

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/AbstractFaultChainInitiatorObserver.java Tue Sep 13 23:36:28 2011
@@ -25,6 +25,8 @@ import java.util.logging.Logger;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.message.Exchange;
@@ -54,10 +56,10 @@ public abstract class AbstractFaultChain
         
         Bus origBus = BusFactory.getThreadDefaultBus(false);
         BusFactory.setThreadDefaultBus(bus);
-        ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
+        ClassLoaderHolder origLoader = null;
         try {
             if (loader != null) {
-                Thread.currentThread().setContextClassLoader(loader);
+                origLoader = ClassLoaderUtils.setThreadContextClassloader(loader);
             }
             
             Exchange exchange = message.getExchange();
@@ -109,7 +111,9 @@ public abstract class AbstractFaultChain
             }
         } finally {
             BusFactory.setThreadDefaultBus(origBus);
-            Thread.currentThread().setContextClassLoader(origLoader);
+            if (origLoader != null) {
+                origLoader.reset();
+            }
         }
     }
 

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java Tue Sep 13 23:36:28 2011
@@ -29,6 +29,8 @@ import javax.xml.namespace.QName;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.binding.Binding;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Interceptor;
@@ -62,10 +64,10 @@ public class ChainInitiationObserver imp
     public void onMessage(Message m) {
         Bus origBus = BusFactory.getThreadDefaultBus(false);
         BusFactory.setThreadDefaultBus(bus);
-        ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
+        ClassLoaderHolder origLoader = null;
         try {
             if (loader != null) {
-                Thread.currentThread().setContextClassLoader(loader);
+                origLoader = ClassLoaderUtils.setThreadContextClassloader(loader);
             }
             InterceptorChain phaseChain = null;
             
@@ -122,7 +124,9 @@ public class ChainInitiationObserver imp
             
         } finally {
             BusFactory.setThreadDefaultBus(origBus);
-            Thread.currentThread().setContextClassLoader(origLoader);
+            if (origLoader != null) {
+                origLoader.reset();
+            }
         }
     }
     private void addToChain(InterceptorChain chain, Message m) {

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/MultipleEndpointObserver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/MultipleEndpointObserver.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/MultipleEndpointObserver.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/MultipleEndpointObserver.java Tue Sep 13 23:36:28 2011
@@ -25,6 +25,8 @@ import java.util.concurrent.CopyOnWriteA
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Exchange;
@@ -50,20 +52,21 @@ public class MultipleEndpointObserver im
     protected List<Interceptor<? extends Message>> routingInterceptors
         = new CopyOnWriteArrayList<Interceptor<? extends Message>>();
     private Set<Endpoint> endpoints = new CopyOnWriteArraySet<Endpoint>();
+    private ClassLoader loader;
     
     public MultipleEndpointObserver(Bus bus) {
         super();
         this.bus = bus;
+        this.loader = bus.getExtension(ClassLoader.class);
     }
 
     public void onMessage(Message message) {
         Bus origBus = BusFactory.getThreadDefaultBus(false);
         BusFactory.setThreadDefaultBus(bus);
-        ClassLoader origLoader = Thread.currentThread().getContextClassLoader();
+        ClassLoaderHolder origLoader = null;
         try {
-            ClassLoader loader = bus.getExtension(ClassLoader.class);
             if (loader != null) {
-                Thread.currentThread().setContextClassLoader(loader);
+                origLoader = ClassLoaderUtils.setThreadContextClassloader(loader);
             }
             Exchange exchange = message.getExchange();
             if (exchange == null) {
@@ -96,7 +99,9 @@ public class MultipleEndpointObserver im
             chain.doIntercept(message);
         } finally {
             BusFactory.setThreadDefaultBus(origBus);
-            Thread.currentThread().setContextClassLoader(origLoader);
+            if (origLoader != null) {
+                origLoader.reset();
+            }
         }
     }
 

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/workqueue/AutomaticWorkQueueImpl.java Tue Sep 13 23:36:28 2011
@@ -40,6 +40,8 @@ import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
 import javax.management.JMException;
 
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.management.InstrumentationManager;
 
@@ -261,11 +263,16 @@ public class AutomaticWorkQueueImpl exte
             if (group.isDestroyed()) {
                 group = new ThreadGroup(group.getParent(), name + "-workqueue");
             }
-            Thread t = new Thread(group, 
+            final Thread t = new Thread(group, 
                                   r, 
                                   name + "-workqueue-" + threadNumber.getAndIncrement(),
                                   0);
-            t.setContextClassLoader(loader);
+            AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+                public Boolean run() {
+                    t.setContextClassLoader(loader);
+                    return true;
+                }
+            });
             t.setDaemon(true);
             if (t.getPriority() != Thread.NORM_PRIORITY) {
                 t.setPriority(Thread.NORM_PRIORITY);
@@ -347,12 +354,13 @@ public class AutomaticWorkQueueImpl exte
         final ClassLoader loader = Thread.currentThread().getContextClassLoader();
         Runnable r = new Runnable() {
             public void run() {
-                ClassLoader orig = Thread.currentThread().getContextClassLoader();
+                ClassLoaderHolder orig = ClassLoaderUtils.setThreadContextClassloader(loader);
                 try {
-                    Thread.currentThread().setContextClassLoader(loader);
                     command.run();
                 } finally {
-                    Thread.currentThread().setContextClassLoader(orig);
+                    if (orig != null) {
+                        orig.reset();
+                    }
                 }
             }
         };

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java (original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/endpoint/dynamic/DynamicClientFactory.java Tue Sep 13 23:36:28 2011
@@ -54,10 +54,12 @@ import org.xml.sax.SAXParseException;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.bus.CXFBusFactory;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.ReflectionInvokationHandler;
 import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.ClientImpl;
 import org.apache.cxf.endpoint.EndpointImplFactory;
@@ -96,7 +98,7 @@ public class DynamicClientFactory {
 
     private Bus bus;
 
-    private String tmpdir = System.getProperty("java.io.tmpdir");
+    private String tmpdir = SystemPropertyAction.getProperty("java.io.tmpdir");
 
     private boolean simpleBindingEnabled = true;
     private boolean allowRefs;
@@ -363,7 +365,7 @@ public class DynamicClientFactory {
         ServiceInfo svcfo = client.getEndpoint().getEndpointInfo().getService();
 
         // Setup the new classloader!
-        Thread.currentThread().setContextClassLoader(cl);
+        ClassLoaderUtils.setThreadContextClassloader(cl);
 
         TypeClassInitializer visitor = new TypeClassInitializer(svcfo, 
                                                                 intermediateModel,
@@ -492,7 +494,7 @@ public class DynamicClientFactory {
                 }
                 if (f2.exists()) {
                     classPath.append(f2.getAbsolutePath());
-                    classPath.append(System.getProperty("path.separator"));
+                    classPath.append(SystemPropertyAction.getProperty("path.separator"));
                 }
             }
         }         
@@ -543,7 +545,7 @@ public class DynamicClientFactory {
                     Method method = tcl.getClass().getMethod("getClassPath");
                     Object weblogicClassPath = method.invoke(tcl);
                     classPath.append(weblogicClassPath)
-                        .append(System.getProperty("path.separator")); 
+                        .append(SystemPropertyAction.getProperty("path.separator")); 
                 } catch (Exception e) {
                     LOG.log(Level.FINE, "unsuccessfully tried getClassPath method", e);
                 }

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java (original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBContextInitializer.java Tue Sep 13 23:36:28 2011
@@ -44,6 +44,7 @@ import javax.xml.bind.annotation.adapter
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.util.ReflectionUtil;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.service.ServiceModelVisitor;
 import org.apache.cxf.service.model.MessageInfo;
@@ -334,7 +335,7 @@ class JAXBContextInitializer extends Ser
         if (accessType != XmlAccessType.PROPERTY) {   // only look for fields if we are instructed to
             //fields are accessible even if not public, must look at the declared fields
             //then walk to parents declared fields, etc...
-            Field fields[] = cls.getDeclaredFields(); 
+            Field fields[] = ReflectionUtil.getDeclaredFields(cls); 
             for (Field f : fields) {
                 if (isFieldAccepted(f, accessType)) {
                     addType(f.getGenericType());
@@ -344,7 +345,7 @@ class JAXBContextInitializer extends Ser
         }
 
         if (accessType != XmlAccessType.FIELD) {   // only look for methods if we are instructed to
-            Method methods[] = cls.getDeclaredMethods(); 
+            Method methods[] = ReflectionUtil.getDeclaredMethods(cls); 
             for (Method m : methods) {
                 if (isMethodAccepted(m, accessType)) {
                     addType(m.getGenericReturnType());

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java?rev=1170390&r1=1170389&r2=1170390&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java (original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java Tue Sep 13 23:36:28 2011
@@ -60,6 +60,7 @@ import org.apache.cxf.common.injection.N
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.ModCountCopyOnWriteArrayList;
 import org.apache.cxf.common.util.PackageUtils;
+import org.apache.cxf.common.util.ReflectionUtil;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
 import org.apache.cxf.databinding.AbstractDataBinding;
 import org.apache.cxf.databinding.AbstractWrapperHelper;
@@ -699,7 +700,7 @@ public class JAXBDataBinding extends Abs
                 if (el != null
                     && (partName.equals(el.name())
                         || "##default".equals(el.name()))) {
-                    elField.setAccessible(true);
+                    ReflectionUtil.setAccessible(elField);
                     fields.add(elField);
                 } else {
                     if (getMethod == null && setMethod == null) {



Mime
View raw message