提交 52ccf43c 编写于 作者: M mchung

8017196: Ensure Proxies are handled appropriately

Reviewed-by: dfuchs, jrose, jdn, ahgross, chegar
上级 f374fa80
...@@ -43,6 +43,8 @@ import com.sun.corba.se.spi.orbutil.proxy.InvocationHandlerFactory ; ...@@ -43,6 +43,8 @@ import com.sun.corba.se.spi.orbutil.proxy.InvocationHandlerFactory ;
import com.sun.corba.se.spi.orbutil.proxy.DelegateInvocationHandlerImpl ; import com.sun.corba.se.spi.orbutil.proxy.DelegateInvocationHandlerImpl ;
import com.sun.corba.se.spi.orbutil.proxy.CompositeInvocationHandler ; import com.sun.corba.se.spi.orbutil.proxy.CompositeInvocationHandler ;
import com.sun.corba.se.spi.orbutil.proxy.CompositeInvocationHandlerImpl ; import com.sun.corba.se.spi.orbutil.proxy.CompositeInvocationHandlerImpl ;
import java.security.AccessController;
import java.security.PrivilegedAction;
public class InvocationHandlerFactoryImpl implements InvocationHandlerFactory public class InvocationHandlerFactoryImpl implements InvocationHandlerFactory
{ {
...@@ -114,24 +116,32 @@ public class InvocationHandlerFactoryImpl implements InvocationHandlerFactory ...@@ -114,24 +116,32 @@ public class InvocationHandlerFactoryImpl implements InvocationHandlerFactory
// which extends org.omg.CORBA.Object. This handler delegates all // which extends org.omg.CORBA.Object. This handler delegates all
// calls directly to a DynamicStubImpl, which extends // calls directly to a DynamicStubImpl, which extends
// org.omg.CORBA.portable.ObjectImpl. // org.omg.CORBA.portable.ObjectImpl.
InvocationHandler dynamicStubHandler = final InvocationHandler dynamicStubHandler =
DelegateInvocationHandlerImpl.create( stub ) ; DelegateInvocationHandlerImpl.create( stub ) ;
// Create an invocation handler that handles any remote interface // Create an invocation handler that handles any remote interface
// methods. // methods.
InvocationHandler stubMethodHandler = new StubInvocationHandlerImpl( final InvocationHandler stubMethodHandler = new StubInvocationHandlerImpl(
pm, classData, stub ) ; pm, classData, stub ) ;
// Create a composite handler that handles the DynamicStub interface // Create a composite handler that handles the DynamicStub interface
// as well as the remote interfaces. // as well as the remote interfaces.
final CompositeInvocationHandler handler = final CompositeInvocationHandler handler =
new CustomCompositeInvocationHandlerImpl( stub ) ; new CustomCompositeInvocationHandlerImpl( stub ) ;
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override
public Void run() {
handler.addInvocationHandler( DynamicStub.class, handler.addInvocationHandler( DynamicStub.class,
dynamicStubHandler ) ; dynamicStubHandler ) ;
handler.addInvocationHandler( org.omg.CORBA.Object.class, handler.addInvocationHandler( org.omg.CORBA.Object.class,
dynamicStubHandler ) ; dynamicStubHandler ) ;
handler.addInvocationHandler( Object.class, handler.addInvocationHandler( Object.class,
dynamicStubHandler ) ; dynamicStubHandler ) ;
return null;
}
});
// If the method passed to invoke is not from DynamicStub or its superclasses, // If the method passed to invoke is not from DynamicStub or its superclasses,
// it must be from an implemented interface, so we just handle // it must be from an implemented interface, so we just handle
......
...@@ -36,6 +36,7 @@ import java.lang.reflect.InvocationHandler ; ...@@ -36,6 +36,7 @@ import java.lang.reflect.InvocationHandler ;
import com.sun.corba.se.spi.logging.CORBALogDomains ; import com.sun.corba.se.spi.logging.CORBALogDomains ;
import com.sun.corba.se.impl.logging.ORBUtilSystemException ; import com.sun.corba.se.impl.logging.ORBUtilSystemException ;
import com.sun.corba.se.impl.presentation.rmi.DynamicAccessPermission;
public class CompositeInvocationHandlerImpl implements public class CompositeInvocationHandlerImpl implements
CompositeInvocationHandler CompositeInvocationHandler
...@@ -46,11 +47,13 @@ public class CompositeInvocationHandlerImpl implements ...@@ -46,11 +47,13 @@ public class CompositeInvocationHandlerImpl implements
public void addInvocationHandler( Class interf, public void addInvocationHandler( Class interf,
InvocationHandler handler ) InvocationHandler handler )
{ {
checkAccess();
classToInvocationHandler.put( interf, handler ) ; classToInvocationHandler.put( interf, handler ) ;
} }
public void setDefaultHandler( InvocationHandler handler ) public void setDefaultHandler( InvocationHandler handler )
{ {
checkAccess();
defaultHandler = handler ; defaultHandler = handler ;
} }
...@@ -78,4 +81,12 @@ public class CompositeInvocationHandlerImpl implements ...@@ -78,4 +81,12 @@ public class CompositeInvocationHandlerImpl implements
return handler.invoke( proxy, method, args ) ; return handler.invoke( proxy, method, args ) ;
} }
private static final DynamicAccessPermission perm = new DynamicAccessPermission("access");
private void checkAccess() {
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(perm);
}
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册