34 import java.lang.reflect.Method ; |
34 import java.lang.reflect.Method ; |
35 import java.lang.reflect.InvocationHandler ; |
35 import java.lang.reflect.InvocationHandler ; |
36 |
36 |
37 import com.sun.corba.se.spi.logging.CORBALogDomains ; |
37 import com.sun.corba.se.spi.logging.CORBALogDomains ; |
38 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; |
38 import com.sun.corba.se.impl.logging.ORBUtilSystemException ; |
|
39 import com.sun.corba.se.impl.presentation.rmi.DynamicAccessPermission; |
39 |
40 |
40 public class CompositeInvocationHandlerImpl implements |
41 public class CompositeInvocationHandlerImpl implements |
41 CompositeInvocationHandler |
42 CompositeInvocationHandler |
42 { |
43 { |
43 private Map classToInvocationHandler = new LinkedHashMap() ; |
44 private Map classToInvocationHandler = new LinkedHashMap() ; |
44 private InvocationHandler defaultHandler = null ; |
45 private InvocationHandler defaultHandler = null ; |
45 |
46 |
46 public void addInvocationHandler( Class interf, |
47 public void addInvocationHandler( Class interf, |
47 InvocationHandler handler ) |
48 InvocationHandler handler ) |
48 { |
49 { |
|
50 checkAccess(); |
49 classToInvocationHandler.put( interf, handler ) ; |
51 classToInvocationHandler.put( interf, handler ) ; |
50 } |
52 } |
51 |
53 |
52 public void setDefaultHandler( InvocationHandler handler ) |
54 public void setDefaultHandler( InvocationHandler handler ) |
53 { |
55 { |
|
56 checkAccess(); |
54 defaultHandler = handler ; |
57 defaultHandler = handler ; |
55 } |
58 } |
56 |
59 |
57 public Object invoke( Object proxy, Method method, Object[] args ) |
60 public Object invoke( Object proxy, Method method, Object[] args ) |
58 throws Throwable |
61 throws Throwable |
76 |
79 |
77 // handler should never be null here. |
80 // handler should never be null here. |
78 |
81 |
79 return handler.invoke( proxy, method, args ) ; |
82 return handler.invoke( proxy, method, args ) ; |
80 } |
83 } |
|
84 |
|
85 private static final DynamicAccessPermission perm = new DynamicAccessPermission("access"); |
|
86 private void checkAccess() { |
|
87 final SecurityManager sm = System.getSecurityManager(); |
|
88 if (sm != null) { |
|
89 sm.checkPermission(perm); |
81 } |
90 } |
|
91 } |
|
92 } |