RMI Registry Creation - How to set interface?

N

Neo_0815

Hello,

i got following Problem.

If i create a Registry with the LocateRegistry Object,

LocateRegistry.createRegistry("PORT");

a Registry is successfully created.

I then can rebind to this factory like registry.rebind(
//127.0.0.1:pORT/Service, server) .

All is working fine, but a look at netstat shows that the registry is
listening on all interfaces, the server too as all client connections
also.
How can i forbidd this, the registry should only listen to localhost
interface, and only to that, no to all like it is now.

I searched a little bit but the only thing i've found is the second
methd:

LocateRegistry.createRegistry(int port, RMIClientSocketFactory csf,
RMIServerSocketFactory ssf)

This SocketFactory is only an abstract class, do i really have to
implement my own factory, to reach my goal, or are there some
properties i missed or how do u solve this problem?

best regards

Torsten
 
N

Neo_0815

I respond to myself.

I got it, but its really pain design.

U have to implement your own RMISocketFactory and have to overwrite the
createServerSocket Method.

The java interface restricts u, that u can only submit a port, so u
have to "hardcode" the network interface in the creation of the socket
in your method, best choice to do it as a property from a ressource
bundle.

In creation of the Factory, the ServerSocket Method is called
automatically at instantiation, so you cant set hostname and port
afterwards.
You arent able to have one factory with a changeable interface per
parameter, you have to write an implementation for every new Interface.

If i am wrong and its possible, any help is welcome.

best regards

Torsten
 
E

Esmond Pitt

I respond to myself.

I got it, but its really pain design.

U have to implement your own RMISocketFactory and have to overwrite the
createServerSocket Method.

The java interface restricts u, that u can only submit a port, so u
have to "hardcode" the network interface in the creation of the socket
in your method, best choice to do it as a property from a ressource
bundle.

In creation of the Factory, the ServerSocket Method is called
automatically at instantiation, so you cant set hostname and port
afterwards.
You arent able to have one factory with a changeable interface per
parameter, you have to write an implementation for every new Interface.

If i am wrong and its possible, any help is welcome.

You are correct, if you want for some reason to listen at only one
interface you have to supply an RMIServerSocketFactory which creates
ServerSockets which do so. The circumstances under which you want to do
this are pretty rare.
 
N

Neo_0815

Rare - hm imagine an root server environment, perhapt a VPN too, web
interface & Co, where RMI is needed but not on all interfaces to listen
to all people of the net.

I think it quite common to set the interface, not really in programmers
view, but in admins view of making the server secure, its imho a mus
thave feature.

thx for answer.

best regards

Torsten
 

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,769
Messages
2,569,582
Members
45,060
Latest member
BuyKetozenseACV

Latest Threads

Top