Server code
here server.config_address is set to my external ip
SERVER:
PHP Code:
public class Server extends Thread
{
public static void Start() throws IOException
{
running = false;
try{
System.setProperty("java.rmi.server.hostname",Config.server_address);
if (Config.ssl_enabled && Config.multihomed_enabled)
serverImpl = new ServerImpl(new MultihomeRMIClientSocketFactory(new SslRMIClientSocketFactory(),
InetAdrUtility.getLocalIPAdresses()),new SslRMIServerSocketFactory(null, null, true));
//An SslRMIClientSocketFactory instance is used by the RMI runtime in order to obtain client sockets for RMI calls via SSL.
else if (Config.ssl_enabled && !Config.multihomed_enabled)
serverImpl = new ServerImpl(new SslRMIClientSocketFactory(),new SslRMIServerSocketFactory(null, null, true));
else if (!Config.ssl_enabled && Config.multihomed_enabled)
serverImpl = new ServerImpl(new MultihomeRMIClientSocketFactory(null,InetAdrUtility.getLocalIPAdresses()), null);
else if (!Config.ssl_enabled && !Config.multihomed_enabled)
serverImpl = new ServerImpl();
if (Config.ssl_enabled)
registry = LocateRegistry.createRegistry(Config.server_port,new SslRMIClientSocketFactory(),
new SslRMIServerSocketFactory(null, null, true));
// Creates and exports a Registry instance on the local host that uses custom socket factories for communication with that instance.
else
registry = LocateRegistry.createRegistry(Config.server_port);
registry.rebind("ServerImpl", serverImpl);
} catch (Exception e)
{
e.getStackTrace();
Stop();
JOptionPane.showMessageDialog(null, e.getMessage(), "Error !!",JOptionPane.ERROR_MESSAGE);
return;
}
System.out.println(getStatus());
running = true;
clipbrdUtility = new ClipbrdUtility();
String currentDirectory = null;
currentDirectory = new File(".").getCanonicalPath() + File.separatorChar;
uploadingFolder = currentDirectory;
}
interface Implementation:
using custom socket factort
As u mentioned in ur post..i have called the constructor
PHP Code:
public class ServerImpl extends UnicastRemoteObject implements ServerInterface
{
public ServerImpl () throws RemoteException {
super(Config.server_port);
}
public ServerImpl (RMIClientSocketFactory csf,RMIServerSocketFactory ssf) throws RemoteException
{
super(0, csf, ssf);
}
by doing so it is not allowing rmi over internet or lan
Bookmarks