Jefferson Hudson
Jefferson Hudson

Reputation: 738

Stop java from requesting permission to accept connections

I am writing a java webstart application for internal company use. It uses JSch to connect and allow port forwarding to a server in one of our datacenters. I do not want users to see this message every time they run the application:

http://img33.imageshack.us/img33/5103/permissionsr.jpg

Is there any way I suppress this message?

Upvotes: 2

Views: 147

Answers (1)

Paŭlo Ebermann
Paŭlo Ebermann

Reputation: 74760

Do you actually need to forward connections from outside of your program, or is your program itself the only one using the forwarded ports?

If the former, there isn't much what can be done. You might try to configure the permissions differently, but then you would instead get a question for those permissions. Or you could setup the permissions on the client's JREs, though I'm not sure how that would be done.

If your Webstart program itself is trying to access the internal servers via the SSH connection, and is currently opening a Socket to the local port where your JSch session is listening, you can do better:

Instead of opening a Socket, open a direct-tcp channel and use its input and output streams. Now no local port has to be opened, and there will be no security question.

ChannelDirectTCPIP channel = (ChannelDirectTCPIP)gateway.openChannel("direct-tcpip");
channel.setHost(host);
channel.setPort(port);
// important: first create the streams, then connect.
InputStream iStream = channel.getInputStream();
OutputStream oStream = channel.getOutputStream();
channel.connect();

// now write to oStream and read from iStream

I used this to tunnel JSch sessions through another JSch session, see my ProxySSH example.

Upvotes: 1

Related Questions