提交 9753729b 编写于 作者: R rriggs

8230967: Improve Registry support of clients

Reviewed-by: skoivu, smarks, rhalade
上级 caf6c986
/* /*
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -29,6 +29,7 @@ import java.lang.reflect.InvocationHandler; ...@@ -29,6 +29,7 @@ import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Proxy; import java.lang.reflect.Proxy;
import java.rmi.Remote; import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.UnexpectedException; import java.rmi.UnexpectedException;
import java.rmi.activation.Activatable; import java.rmi.activation.Activatable;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
...@@ -224,6 +225,13 @@ public class RemoteObjectInvocationHandler ...@@ -224,6 +225,13 @@ public class RemoteObjectInvocationHandler
throw new IllegalArgumentException( throw new IllegalArgumentException(
"proxy not Remote instance"); "proxy not Remote instance");
} }
// Verify that the method is declared on an interface that extends Remote
Class<?> decl = method.getDeclaringClass();
if (!Remote.class.isAssignableFrom(decl)) {
throw new RemoteException("Method is not Remote: " + decl + "::" + method);
}
return ref.invoke((Remote) proxy, method, args, return ref.invoke((Remote) proxy, method, args,
getMethodHash(method)); getMethodHash(method));
} catch (Exception e) { } catch (Exception e) {
......
/* /*
* Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -29,6 +29,7 @@ import java.io.DataOutput; ...@@ -29,6 +29,7 @@ import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
import java.io.ObjectInput; import java.io.ObjectInput;
import java.io.ObjectOutput; import java.io.ObjectOutput;
import java.lang.reflect.Proxy;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.net.Socket; import java.net.Socket;
...@@ -553,6 +554,9 @@ public class TCPEndpoint implements Endpoint { ...@@ -553,6 +554,9 @@ public class TCPEndpoint implements Endpoint {
host = in.readUTF(); host = in.readUTF();
port = in.readInt(); port = in.readInt();
csf = (RMIClientSocketFactory) in.readObject(); csf = (RMIClientSocketFactory) in.readObject();
if (Proxy.isProxyClass(csf.getClass())) {
throw new IOException("Invalid SocketFactory");
}
break; break;
default: default:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册