diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2012-01-28 09:24:39 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2012-01-28 09:24:39 +0000 |
commit | 5f20c970942b7c4af9cf1a92df1495d4ce657d84 (patch) | |
tree | 024f1c3be7f2c3ed43dc903225cfc73f62b3b81b /sca-java-2.x/trunk/modules | |
parent | a6f183dd825a8280fd7647e2c8153405da0c5bfb (diff) |
TUSCANY-4009: Apply patch from Jennifer Thompson to fix Java2 Secuity Errors in JMSMessageProcessorUtil
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1237030 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules')
-rw-r--r-- | sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java index 4df8ca2353..e96f273d4a 100644 --- a/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java +++ b/sca-java-2.x/trunk/modules/binding-jms-runtime/src/main/java/org/apache/tuscany/sca/binding/jms/provider/JMSMessageProcessorUtil.java @@ -20,6 +20,10 @@ package org.apache.tuscany.sca.binding.jms.provider; import java.lang.reflect.Constructor; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedExceptionAction; +import java.security.PrivilegedActionException; import org.apache.tuscany.sca.binding.jms.JMSBinding; import org.apache.tuscany.sca.binding.jms.JMSBindingException; @@ -41,10 +45,14 @@ public class JMSMessageProcessorUtil { * @param className the string based class name to load and instantiate * @return the new object */ - private static Object instantiate(ClassLoader cl, String className, JMSBinding binding) { + private static Object instantiate(ClassLoader cl, final String className, final JMSBinding binding) { Object instance; if (cl == null) { - cl = binding.getClass().getClassLoader(); + cl = cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { + public ClassLoader run() { + return binding.getClass().getClassLoader(); + } + }); } try { @@ -53,7 +61,16 @@ public class JMSMessageProcessorUtil { try { clazz = cl.loadClass(className); } catch (ClassNotFoundException e) { - clazz = binding.getClass().getClassLoader().loadClass(className); + try{ + clazz = AccessController.doPrivileged(new PrivilegedExceptionAction<Class>() { + public Class run() throws ClassNotFoundException{ + return binding.getClass().getClassLoader().loadClass(className); + } + }); + } catch (PrivilegedActionException ex) { + throw (ClassNotFoundException) ex.getException(); + } + } Constructor<?> constructor = clazz.getDeclaredConstructor(new Class[] {JMSBinding.class}); @@ -78,8 +95,17 @@ public class JMSMessageProcessorUtil { try { for (ServiceDeclaration sd : registry.getServiceDiscovery().getServiceDeclarations(JMSMessageProcessor.class)) { if (className.equals(sd.getClassName())) { - Class<?> clazz = sd.loadClass(); - Constructor<?> constructor = clazz.getDeclaredConstructor(new Class[] {JMSBinding.class, ExtensionPointRegistry.class}); + final Class<?> clazz = sd.loadClass(); + Constructor<?> constructor; + try { + constructor = AccessController.doPrivileged(new PrivilegedExceptionAction<Constructor<?>>() { + public Constructor<?> run() throws NoSuchMethodException{ + return clazz.getDeclaredConstructor(new Class[] {JMSBinding.class, ExtensionPointRegistry.class}); + } + }); + } catch (PrivilegedActionException ex) { + throw (NoSuchMethodException) ex.getException(); + } return constructor.newInstance(binding, registry); } |