From: paul-strain@hlp.com
Date: Tue, 5 May 1998 13:21:54 -0500
Subject: Applet cannot connect to originating host
To: java-security@web1.javasoft.com
Found the answer.
socket = new Socket( applet.getCodeBase().getHost(), 2000 ) works
(where applet is of type Applet, naturally).
The host name and the IP address cannot be used interchangably. This
code is safe(r).
Add this tip to your JDK documentation, if you havene't already.
L8er,
Paul
______________________________ Forward Header __________________________________
Subject: Applet cannot connect to originating host
Author: Paul Strain at PO6
Date: 5/5/98 12:06 PM
Java Security,
My applet cannot open a socket with a Java server application running
on the originating host. I get securtiy exceptions.
When I run the applet as a Java (client) application, there are no
problems.
I tried using the JDK 1.1.5 appletviewer and IE 4.0. I'm also running
the Windows NT Personal Web Server.
Here's the output from appetviewer:
Exception occurred during event dispatching:
sun.applet.AppletSecurityException: checkconnect.networkhost1
at
sun.applet.AppletSecurity.checkConnect(AppletSecurity.java:564)
at
sun.applet.AppletSecurity.checkConnect(AppletSecurity.java:606)
at
sun.applet.AppletSecurity.checkConnect(AppletSecurity.java:506)
at java.net.InetAddress.getAllByName0(InetAddress.java:445)
at java.net.InetAddress.getAllByName(InetAddress.java:429)
at java.net.InetAddress.getLocalHost(InetAddress.java:515)
at MainFrame.connect(MainFrame.java:28)
at MainFrame.<init>(MainFrame.java:103)
at PhoneBook.actionPerformed(PhoneBook.java:19)
at java.awt.Button.processActionEvent(Button.java:254)
at java.awt.Button.processEvent(Button.java:227)
at java.awt.Component.dispatchEventImpl(Component.java:1764)
at java.awt.Component.dispatchEvent(Component.java:1704)
at
java.awt.EventDispatchThread.run(EventDispatchThread.java:63)
I'm confused because according to http://java.sun.com/sfaq/, it
appears that I should be having this problem.
"In general, applets loaded over the net are prevented from reading
and writing files on the client file system, and from making network
connections except to the originating host."
I looked at the last Q&A archive
(http://java.sun.com/security/hypermail/java-security-archive-3/index.
html). Eric Lee had the same problem (see:
http://java.sun.com/security/hypermail/java-security-archive-3/0737.ht
ml), but there was no answer to his question.
Any help would be GREATLY appreciated.
Thanks,
Paul Strain
713-207-8760