use of sun.rmi.server.UnicastServerRef in project jdk8u_jdk by JetBrains.
the class FilterUSRTest method UnicastServerRef.
/*
* Test exporting an object with a serialFilter using UnicastServerRef.exportObject().
* Send some objects and check the number of calls to the serialFilter.
*/
@Test(dataProvider = "bindData")
public void UnicastServerRef(String name, Object obj, int expectedFilterCount) throws RemoteException {
try {
RemoteImpl impl = RemoteImpl.create();
UnicastServerRef ref = new UnicastServerRef(new LiveRef(0), impl.checker);
Echo client = (Echo) ref.exportObject(impl, null, false);
int count = client.filterCount(obj);
System.out.printf("count: %d, obj: %s%n", count, obj);
Assert.assertEquals(count, expectedFilterCount, "wrong number of filter calls");
} catch (RemoteException rex) {
if (expectedFilterCount == -1 && UnmarshalException.class.equals(rex.getCause().getClass()) && InvalidClassException.class.equals(rex.getCause().getCause().getClass())) {
// normal expected exception
return;
}
rex.printStackTrace();
Assert.fail("unexpected remote exception", rex);
} catch (Exception ex) {
Assert.fail("unexpected exception", ex);
}
}
use of sun.rmi.server.UnicastServerRef in project jdk8u_jdk by JetBrains.
the class RMIJRMPServerImpl method export.
private void export(Remote obj) throws RemoteException {
final RMIExporter exporter = (RMIExporter) env.get(RMIExporter.EXPORTER_ATTRIBUTE);
final boolean daemon = EnvHelp.isServerDaemon(env);
if (daemon && exporter != null) {
throw new IllegalArgumentException("If " + EnvHelp.JMX_SERVER_DAEMON + " is specified as true, " + RMIExporter.EXPORTER_ATTRIBUTE + " cannot be used to specify an exporter!");
}
if (daemon) {
if (csf == null && ssf == null) {
new UnicastServerRef(port).exportObject(obj, null, true);
} else {
new UnicastServerRef2(port, csf, ssf).exportObject(obj, null, true);
}
} else if (exporter != null) {
exporter.exportObject(obj, port, csf, ssf);
} else {
UnicastRemoteObject.exportObject(obj, port, csf, ssf);
}
}
use of sun.rmi.server.UnicastServerRef in project jdk8u_jdk by JetBrains.
the class TestLibrary method getRegistryPort.
/**
* Returns the port number the RMI {@link Registry} is running on.
*
* @param registry the registry to find the port of.
* @return the port number the registry is using.
* @throws RuntimeException if there was a problem getting the port number.
*/
public static int getRegistryPort(Registry registry) {
int port = -1;
try {
RemoteRef remoteRef = ((RegistryImpl) registry).getRef();
LiveRef liveRef = ((UnicastServerRef) remoteRef).getLiveRef();
Endpoint endpoint = liveRef.getChannel().getEndpoint();
TCPEndpoint tcpEndpoint = (TCPEndpoint) endpoint;
port = tcpEndpoint.getPort();
} catch (Exception ex) {
throw new RuntimeException("Error getting registry port.", ex);
}
return port;
}
use of sun.rmi.server.UnicastServerRef in project ysoserial by frohoff.
the class JRMPListener method getObject.
public UnicastRemoteObject getObject(final String command) throws Exception {
int jrmpPort = Integer.parseInt(command);
UnicastRemoteObject uro = Reflections.createWithConstructor(ActivationGroupImpl.class, RemoteObject.class, new Class[] { RemoteRef.class }, new Object[] { new UnicastServerRef(jrmpPort) });
Reflections.getField(UnicastRemoteObject.class, "port").set(uro, jrmpPort);
return uro;
}
Aggregations