aspose file tools*
The moose likes Applets and the fly likes Socket Permissions Problem using Java applet on Windows but not on Mac Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Socket Permissions Problem using Java applet on Windows but not on Mac" Watch "Socket Permissions Problem using Java applet on Windows but not on Mac" New topic
Author

Socket Permissions Problem using Java applet on Windows but not on Mac

Philip Underhill
Greenhorn

Joined: Aug 09, 2011
Posts: 2
I have a problem with java.security.AccessControlException.access denied when using any Windows OS / Browser with my java applet.

I get a (java.net.socket permission [IP address]:PORT connect, resolve) error.

However, when I use a Mac OS / Browser the applet works correctly?

The service is running on a Tomcat server and I have looked into security policies but I am new to java applets / sockets etc so I am looking for some guidance.

The applet function basically allows files to be uploaded/downloaded using a MySQL database.

Can anyone help please?

Thanks



Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19762
    
  20

Welcome to the Ranch!

Please read this for applet security issues.

I'll move this thread to our Applets forum.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
john price
Ranch Hand

Joined: Feb 24, 2011
Posts: 495

There are 2 things you need to do.
1. Get the system security manager to do accept your permission checks. Here are 2 examples :

Replace xxx.xxx.xxx.xxx with the server IP address.

The RunTime is for a thread (obviously).
Put the needed lines as your first code in the main method.


2. You have to sign the JAR file
i.
Fill out all this information. It will create a keystore named "keystore" (you can change it to whatever name you would like)
ii. Put a certificate on it. You could pay to have it certificated or sign it yourself :

iii.

NOTE: Remember the passwords you put in these.

Enjoy!
John Price


“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
Nam Ha
Ranch Hand

Joined: Aug 05, 2011
Posts: 50

If you signed the applet and all external libraries (jars), you do not need to write permission checking code.
Remember to sign external jars as well, not only the Applet jar itself. I had permission exception problem and had not figured out until I found some external jars were not signed. I signed all of them then everything was fine.


Java Object Creation
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42639
    
  65
You may also habe to run the code as privileged code, which is described in the link Rob posted.


Ping & DNS - my free Android networking tools app
Philip Underhill
Greenhorn

Joined: Aug 09, 2011
Posts: 2
Thank you for the suggestions.

I will try the jar signing and see what results I get. I am new to this so I don't want to rush into things.

Does it make any sense that the applet works in a Mac environment and not Windows?
 
jQuery in Action, 2nd edition
 
subject: Socket Permissions Problem using Java applet on Windows but not on Mac