Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.net.SocketPermission in Applet

I'm developing an applet that requires to save a text file on the server. After wrestling with this problem for a while I stumbled on the internet on the Lynlin.class which can send files using ftp connection. That works fine provided I add to my C:\Program Files\Java\jre7\lib\security\java.policy file a following line:

permission java.net.SocketPermission "192.168.33.15:*", "connect, accept ,resolve, listen";

If I try to run this applet from the computer that did not have the java.policy file edited I get the following error:

java.security.AccessControlException: access denied 
    ("java.net.SocketPermission" "192.168.33.15:21" "connect,resolve")*

Does anybody know how could I get rid of this problem other than editing java.policy file at each and every computer that will be using this applet?

Just to claryfy:

  • my applet at the moment is not signed, but the server with which it tries to send a file is the same at which the applet is located

  • the http and ftp server are microsoft IIS running on the Windows Server 2003 (ip 192.168.33.15)

like image 691
Przemek Avatar asked Nov 04 '22 16:11

Przemek


1 Answers

The exact URL is "\pwaidc9...

That's not a URL. It is a Windows UNC file name. You downloaded the applet from a file system, not a TCP host at all, so you can't connect to it with a socket.

Sign the applet.

like image 51
user207421 Avatar answered Nov 15 '22 00:11

user207421