RMI: how to get client info?

L

linuxadmin

hello!


how can my RMI server get information about connected clients?
i found only the method inside the class RemoteServer named
'getClientHost'.
but it returns just a stupid string with the IP address.

i would like to be able to distinguish which client makes a remote
method call.
my idea was, that an ip address AND a port number would identify a
client.
or are there any better possibilities to distinguish between RMI
clients?


thanks in advice!
 
E

Esmond Pitt

'getClientHost'.
but it returns just a stupid string with the IP address.

It returns a string with the IP address. Stupidity is strictly in the
eye of the beholder.
i would like to be able to distinguish which client makes a remote
method call.
my idea was, that an ip address AND a port number would identify a
client.

Well, what's a client? RMI will use a different TCP local port number at
the client end depending on whether it is reusing the same connection or
starting a new one, which it does for reasons hidden under the hood of
RMI. One of those is two threads calling the same server at the same
time. This will use two connections, and therefore two ports. Is that
one client, or two? What about two independent applications in the same
JVM? is that one client or two? What about two JVMs in the same client
host? What about a single thread in a single thread which makes two
calls an hour apart which use two separate connections and therefore two
port numbers? Is that really two clients?

All in all I think identifying clients with IP addresses is as sensible
as anything. Qualifying them by port number as well is pretty meaningless.
 
L

linuxadmin

On Jun 15, 3:12 am, Esmond Pitt <[email protected]>
wrote:

thank you for a such detailed reply.
All in all I think identifying clients with IP addresses is as sensible
as anything. Qualifying them by port number as well is pretty meaningless.

could you suggest a better possibility please?

i really don't want to let the clients tell by themselves who they
are, this concept could be spoofed.
 
L

Lew

On Jun 15, 3:12 am, Esmond Pitt <[email protected]>
wrote:

thank you for a such detailed reply.


could you suggest a better possibility please?

i really don't want to let the clients tell by themselves who they
are, this concept could be spoofed.

Certificates. PKI.
 
A

Allan Valeriano

i would like to be able to distinguish which client makes a remote
method call.

Take a look at the class ThreadLocal. You can declare a
ThreadLocal<User> inside the server and then on every server call, you
call a method like:

public void setAccessUser(User user)
{
localThread.set(user);
}

and specify who is calling.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top