From 092551bd4fcaabf20fe8698a2b95dcc84549421f Mon Sep 17 00:00:00 2001 From: slaws Date: Thu, 1 Dec 2011 16:51:18 +0000 Subject: Create model resolvers in doPrivileged block. The primary concern here is the ClassLoaderModelResolver which extends the URIClassLoader and requires permissions. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1209147 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/contribution/resolver/ExtensibleModelResolver.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java index e3a088fd96..12e0238ee9 100644 --- a/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java +++ b/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java @@ -20,6 +20,9 @@ package org.apache.tuscany.sca.contribution.resolver; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.security.AccessController; +import java.security.PrivilegedExceptionAction; import java.util.HashMap; import java.util.Map; @@ -94,12 +97,18 @@ public class ExtensibleModelResolver implements ModelResolver { return resolverInstance; } try { - Constructor constructor = + final Constructor constructor = resolverClass .getConstructor(new Class[] {Contribution.class, FactoryExtensionPoint.class}); if (constructor != null) { - resolverInstance = constructor.newInstance(contribution, modelFactories); + resolverInstance = AccessController.doPrivileged(new PrivilegedExceptionAction() { + public ModelResolver run() throws Exception { + ModelResolver resolverInstance = constructor.newInstance(contribution, modelFactories); + return resolverInstance; + } + }); + resolversByImplementationClass.put(resolverClass, resolverInstance); resolversByModelType.put(c, resolverInstance); return resolverInstance; -- cgit v1.2.3