From 6fb01453f4d9d760dc2a9117d421a3639c4a6b90 Mon Sep 17 00:00:00 2001 From: slaws Date: Mon, 14 Sep 2009 08:44:42 +0000 Subject: TUSCANY-3235 - Java2 security problem - Thanks for the patch Hasan git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@814524 13f79535-47bb-0310-9956-ffa450edef68 --- .../tuscany/sca/databinding/jaxb/JAXBContextCache.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'branches/sca-java-1.5.1/modules') diff --git a/branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java b/branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java index 4eaaf3db7f..c685f5cc19 100644 --- a/branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java +++ b/branches/sca-java-1.5.1/modules/databinding-jaxb/src/main/java/org/apache/tuscany/sca/databinding/jaxb/JAXBContextCache.java @@ -24,8 +24,10 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.ref.SoftReference; +import java.net.MalformedURLException; import java.net.URI; import java.security.AccessController; +import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.ArrayList; @@ -464,11 +466,19 @@ public class JAXBContextCache { for (Class cls : classes) { Package pkg = getPackage(cls); if (pkg != null) { - pkgs.put(pkg, cls.getClassLoader()); + pkgs.put(pkg, getClassLoader(cls)); } } return pkgs; } + + private static ClassLoader getClassLoader(final Class cls) { + return AccessController.doPrivileged(new PrivilegedAction() { + public ClassLoader run(){ //throws ClassNotFoundException{ + return cls.getClassLoader(); + } + }); + } /** * Find ObjectFactory and indexed JAXB classes for the package -- cgit v1.2.3