java applet java.security.AccessControlException:

2019-09-19 20:22发布

问题:

I friend of mine gave me a script to run minecraft skins on my site but i keep getting this error and i dont have any clue how to go about this... =( http://allcitybuilder.com/new/example.html

java.security.AccessControlException: access denied (java.net.SocketPermission www.minecraft.net:80 connect,resolve)
   at java.security.AccessControlContext.checkPermission(Unknown Source)
   at java.security.AccessController.checkPermission(Unknown Source)
   at java.lang.SecurityManager.checkPermission(Unknown Source)
   at java.lang.SecurityManager.checkConnect(Unknown Source)
   at sun.plugin2.applet.Applet2SecurityManager.checkConnect(Unknown Source)
   at sun.net.www.http.HttpClient.openServer(Unknown Source)
   at sun.net.www.http.HttpClient.<init>(Unknown Source)
   at sun.net.www.http.HttpClient.New(Unknown Source)
   at sun.net.www.http.HttpClient.New(Unknown Source)
   at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
   at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
   at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
   at net.minecraft.skintest.math.Zombie$1.run(Zombie.java:82)

回答1:

You must allow the Applet to connect to a resource.

Have a look at the sigend Applet tutorial: http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html



回答2:

Normally Applets are only allowed to access the host they came from (in your case allcitybuilder.com). Thus, you either have to put the file to view also to this host (or install a proxy there), or your applet needs additional privileges to have more access.

For the applet to have more access, it needs to be digitally signed, and the user needs to confirm the applet loading.

But there is no way to say "I need only access to minecraft.net" and for the user to grant you only this permission (without manual editing of policy files), so it is an "all or nothing". Also, if the user refuses, the applet may either run with usual applet permissions (on Sun's Plugin) or not run at all (on IcedTea).

With JNLP you can get a confirmation for the user for individual actions, but this is only for local access, no remote one.



回答3:

Probably the easiest thing would be to copy the resources to your site, making sure you have been granted appropriate rights by the copyright holder.

Alternatively, the site may add a crossdomain.xml file to allow access to code loaded from non-same-origin sites.

It is possibly to sign the code to gain full access to the local machine. However, this requires the user to accept the risk and writing secure code is surprisingly difficult.