0

Edit: To be clearer, I basically need to differentiate between the different clients doing remote method invocation in objects stored in the server remote object registry. How could I do that?

And here is the situation:

I am currently in the process of creating a client/server command line interface application using Java rmi to exchange data (stored in Strings) between the clients and server.

I'm having problem whereas I must allow a client to send an authentication command with a user/pass. This authentication command (exemple: >user myUserName myPassword) must be sent through the same remotely called method used to send all the other commands for which the server must answer.

My problem : The client must, strictly, only send his commands and display the text result of his command received from the server. As simple a client as it gets, it has no state.

Since some methods requires the client to be logged in or have a different server-side implementation if the client is logged in or not, I need to to keep track of the client logged in state on the server(not a problem, I plan to simply keep a time stamp on each user in the user database and use a timeout) and must also differentiate between different clients.

Now, I think I have a good idea of how remote object works and I've been able to register a remote object on the server side and access a remote method from it using the client.

So, I need to do more, I must not only have client being able to access remote method, I also need the remote method(and the server running them) to know which network client is invoking this method(without passing the client username/pass as parameters in the remote method).

I think the rmiclientsocketfactory and rmiserversocketfactory must be customly used to do this, but I don't know how to proceed.

thanks you all for your time.

Bjergsen
  • 207
  • 1
  • 17

1 Answers1

1

Objects are not stored in the registry. Stubs are stored in the registry. The remote objects are in the server host.

See java.rmi.server.RemoteServer.getClientHost().

Socket factories haven nothing to do with it.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • Thanks you EJP, the getClientHost() method from RemoteServer looks exactly like what I need, I knew threading for different client was done by java RMI itself, but I somehow did not find anything related to that particular method while doing research and I can assure you I looked around a lot. I'll try working forward with this, thx for ur help. – Bjergsen Sep 26 '11 at 21:58
  • @tehjord well it's exactly not in the most obvious place ;-) – user207421 Sep 27 '11 at 00:01