summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-12-20 19:32:07 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-12-20 19:32:07 +0000
commit73dfbf3e677f329c1eb3d1f6edbb3d81c5931be8 (patch)
tree59945d44e1112df0aa3f6039db0917cea7afb692 /sca-java-2.x/trunk/modules
parent87e69e61ada2e05e58519225ceb984510b3cd1a7 (diff)
TUSCANY-3992: Apply patch from Greg Dritschler to fix AccessControlException occurs when calling SCAClientFactory.getService
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1221454 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules')
-rw-r--r--sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java56
-rw-r--r--sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaIntrospectionHelper.java10
2 files changed, 32 insertions, 34 deletions
diff --git a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java
index d3b813f7aa..6611c6af79 100644
--- a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java
+++ b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java
@@ -28,6 +28,8 @@ import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.rmi.Remote;
import java.rmi.RemoteException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -147,33 +149,39 @@ public class JavaInterfaceIntrospectorImpl {
// Check if any methods have disallowed annotations
// Check if any private methods have illegal annotations that should be raised as errors
- Set<Method> methods = JavaIntrospectionHelper.getMethods(clazz);
- for (Method method : methods) {
- checkMethodAnnotations(method, javaInterface);
- } // end for
+ checkMethodAnnotations(clazz, javaInterface);
} // end method introspectInterface
- private void checkMethodAnnotations(Method method, JavaInterface javaInterface) throws InvalidAnnotationException {
- for ( Annotation a : method.getAnnotations() ) {
- if( a instanceof Remotable ) {
- // [JCA90053] @Remotable annotation cannot be on a method that is not a setter method
- if( !JavaIntrospectionHelper.isSetter(method) ) {
- throw new InvalidAnnotationException("[JCA90053] @Remotable annotation present on an interface method" +
- " which is not a Setter method: " + javaInterface.getName() + "/" + method.getName(), Remotable.class);
- } // end if
- } // end if
- } // end for
+ private void checkMethodAnnotations(Class clazz, JavaInterface javaInterface) throws InvalidAnnotationException {
- // Parameter annotations
- for (Annotation[] parmAnnotations : method.getParameterAnnotations()) {
- for (Annotation annotation : parmAnnotations) {
- if (annotation instanceof Remotable ) {
- throw new InvalidAnnotationException("[JCA90053] @Remotable annotation present on an interface method" +
- " parameter: " + javaInterface.getName() + "/" + method.getName(), Remotable.class);
- } // end if
- } // end for
- } // end for
- method.getParameterAnnotations();
+ final Class _clazz = clazz;
+ Method[] declaredMethods = (Method[])AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
+ public Method[] run() {
+ return _clazz.getDeclaredMethods();
+ }
+ });
+
+ for (final Method method : declaredMethods) {
+ for ( Annotation a : method.getAnnotations() ) {
+ if( a instanceof Remotable ) {
+ // [JCA90053] @Remotable annotation cannot be on a method that is not a setter method
+ if( !JavaIntrospectionHelper.isSetter(method) ) {
+ throw new InvalidAnnotationException("[JCA90053] @Remotable annotation present on an interface method" +
+ " which is not a Setter method: " + javaInterface.getName() + "/" + method.getName(), Remotable.class);
+ } // end if
+ } // end if
+ } // end for
+
+ // Parameter annotations
+ for (Annotation[] parmAnnotations : method.getParameterAnnotations()) {
+ for (Annotation annotation : parmAnnotations) {
+ if (annotation instanceof Remotable ) {
+ throw new InvalidAnnotationException("[JCA90053] @Remotable annotation present on an interface method" +
+ " parameter: " + javaInterface.getName() + "/" + method.getName(), Remotable.class);
+ } // end if
+ } // end for
+ } // end for
+ }
} // end method checkMethodAnnotations
private Class<?>[] getActualTypes(Type[] types, Class<?>[] rawTypes, Map<String, Type> typeBindings, boolean ignoreAsyncHolder) {
diff --git a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaIntrospectionHelper.java b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaIntrospectionHelper.java
index a363c1ff16..c207245a0e 100644
--- a/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaIntrospectionHelper.java
+++ b/sca-java-2.x/trunk/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaIntrospectionHelper.java
@@ -616,16 +616,6 @@ public final class JavaIntrospectionHelper {
return Class.forName(buf.toString(), false, componentType.getClassLoader());
}
- public static Set<Method> getMethods(Class<?> clazz) {
- Set<Method> methods = new HashSet<Method>();
- Method[] declaredMethods = clazz.getDeclaredMethods();
- for (final Method declaredMethod : declaredMethods) {
- methods.add(declaredMethod);
- } // end for
-
- return methods;
- } // end method getMethods
-
public static Set<Field> getPrivateFields(Class<?> clazz) {
Set<Field> fields = new HashSet<Field>();
Field[] declaredFields = clazz.getDeclaredFields();