Question

permission java.net.SocketPermission "192.168.1.1:31337", "connect, accept, resolve";

What does the following permission allow? Is my Application allowed to accept connections only from 192.168.1.1:31337 (maybe an external client) or to accept connections on to 192.168.1.1:31337 (my application is running on 192.168.1.1:31337, where is the difference to 'listen'?).

Was it helpful?

Solution

If your code is an applet or running under a java security manager you need to explicitly grant it permissions to do stuff.

In order for a resource access to be allowed for an applet (or an application running with a security manager), the corresponding permission must be explicitly granted to the code attempting the access.

By default your code has no socket permission. Your permission says that your code has the permission to accept connection on, to connect to and to resolve only the host with IP 192.168.1.1 on port 31337.

The "accept" and "connect" actions are obvious.

The "resolve" action is implied when any of the other actions are present. The action "resolve" refers to host/ip name service lookups.

The "listen" action is only meaningful when used with "localhost".

The difference between listen and accept is that listening means "be prepared for connection and see if there is a connection waiting" and accepting means "ok, accept it".

See the docs for permissions in java 7. and java.net.SocketPermission java docs

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top