tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sl...@apache.org
Subject svn commit: r1209147 - /tuscany/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java
Date Thu, 01 Dec 2011 16:51:19 GMT
Author: slaws
Date: Thu Dec  1 16:51:18 2011
New Revision: 1209147

URL: http://svn.apache.org/viewvc?rev=1209147&view=rev
Log:
Create model resolvers in doPrivileged block. The primary concern here is the ClassLoaderModelResolver
which extends the URIClassLoader and requires permissions. 

Modified:
    tuscany/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java

Modified: tuscany/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java?rev=1209147&r1=1209146&r2=1209147&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java
Thu Dec  1 16:51:18 2011
@@ -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 imp
                     return resolverInstance;
                 }
                 try {
-                    Constructor<? extends ModelResolver> constructor =
+                    final Constructor<? extends ModelResolver> constructor =
                         resolverClass
                             .getConstructor(new Class[] {Contribution.class, FactoryExtensionPoint.class});
                     if (constructor != null) {
 
-                        resolverInstance = constructor.newInstance(contribution, modelFactories);
+                        resolverInstance = AccessController.doPrivileged(new PrivilegedExceptionAction<ModelResolver>()
{
+                            public ModelResolver run() throws Exception {
+                                ModelResolver resolverInstance = constructor.newInstance(contribution,
modelFactories);
+                                return resolverInstance;
+                            }
+                        });
+                        
                         resolversByImplementationClass.put(resolverClass, resolverInstance);
                         resolversByModelType.put(c, resolverInstance);
                         return resolverInstance;



Mime
View raw message