1

With Java 1.6.0.22 i'm not able to open a socket to localhost, the applet is unsigned and is being loaded from the webserver http://localhost/myapplet

If i load it from my computer ip 192.168.1.x and open a socket to that ip it works

With a simple demo that only open a socket it works, but as soon as my applet use JavaScript to Java calls the socket not work.

If I add a crossdomain.xml file the socket works again.

If I allow only 127.0.0.1 it doesn't work

With 1.6.0.17 it works fine

That is similar to question Socket connection to originating server of an unsigned Java applet

But in my case i loading applet from a webserver not from local file system.

Community
  • 1
  • 1
José
  • 3,041
  • 8
  • 37
  • 58
  • Sorry, but what's your actual question? – Ivo Wetzel Nov 17 '10 at 10:53
  • Why the socket cannot be open to localhost when using JavaScript, and. And why work when add the crossdomain.xml to my webserver root, i always in the same domain '127.0.0.1' – José Nov 17 '10 at 11:21

4 Answers4

2

Via this user having a similar problem i found the relevant oracle bug

access denied (java.net.SocketPermission 127.0.0.1:8080 connect,resolve)

http://www.oracle.com/technetwork/java/javase/6u22releasenotes-176121.html

Community
  • 1
  • 1
José
  • 3,041
  • 8
  • 37
  • 58
0

Unsigned applets can only open connections to the host they were loaded from.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • That is not truth, unsigned applets can open connection to other hosts if they provide a crossdomain.xml file, that was introduced in 1.6.0.10. – José Nov 18 '10 at 11:54
  • Your answer is unrelated to the original question, what i asked for is why connection to the same host fails when using JavaScript integration and success when it not, are there any additional restrictions for JavaScript and localhost. – José Nov 18 '10 at 11:56
0

Oracle knows of this Java problem that severely restricts use of Applets: A Security Vulnerability in the Java Runtime Environment may Allow Code Loaded From the Local Filesystem to Access LocalHost. The translation: if you wish to run Java Applets that talk to a server like Tomcat, you can’t do it with recent Java releases

And their solution is: There is no workaround for this issue.

And how long have they known of this problem? 03-Dec-2008, Bug Id 6704154

You can validate the above information at, https://identity.sun.com/amserver/UI/Login?org=self_registered_users&goto=http://sunsolve.sun.com/show.do?target=home

ckemp
  • 11
  • 1
  • I loading the applet from a webserver not from filesystem, and Socket connection to localhost works, but if i use JSObject JavaScript integration the socket to localhost stop to works, if i add a crossdomain.xml file it works again. – José Nov 22 '10 at 22:32
-1

While the documentation says an applet can only open a connection to the host it was loaded from, with Tomcat 5, that statement is not true. I have an applet that invariably generates a, "AccessControlException:access denied (java.net.SocketPermission 66.167.210:80 connect, resolve" even though I've given socket permission to this URL. I'm still trying to solve this issue and am open to any recommendations.

ckemp
  • 11
  • 1