开发者

java applet AccessControlException in 3rd party library

I'm using a 3rd party library (jar) in my java applet and I'm getting this error:

java.security.AccessControlException: access denied ("java.util.PropertyPermission" "*" "read,write")
    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.checkPropertiesAccess(Unknown Source)
   开发者_如何学Go at java.lang.System.getProperties(Unknown Source)
    at sfs2x.client.core.sockets.TCPSocketLayer.initNetty(TCPSocketLayer.java:63)
    at sfs2x.client.core.sockets.TCPSocketLayer.<init>(TCPSocketLayer.java:59)
    at sfs2x.client.bitswarm.BitSwarmClient.init(BitSwarmClient.java:90)
    at sfs2x.client.SmartFox.initialize(SmartFox.java:148)
    at sfs2x.client.SmartFox.<init>(SmartFox.java:127)
    at bfwd.RedemptionOnline.Client.RedemptionOnlineApplet.init(RedemptionOnlineApplet.java:29)
    at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

I'm testing this on my development server and trying to connect to localhost. Why would I be getting this error now, and how would I prevent it in the future?

Ok, I even self-signed my jar, yet it STILL comes up with this error.


at sfs2x.client.core.sockets.TCPSocketLayer.initNetty(TCPSocketLayer.java:63)

SFS2X seems to be a game server. Netty is a TCP/IP server. Why are you trying to run a game server on the client side? I'm not sure if your webpage visitors are ever going to be happy with this. What's the functional requirement after all? Did you consider letting your webserver do the job?

Regardless, you need to sign the applet in order to get it to work. Unsigned applets have very restrictive security rules (otherwise it would be very easy to leech the entire "My Documents" down and send it to the server, for example). Basically, you need to send your code to some RSA signing company and have them to review the code and get some RSA certificate back which you provide along your applet so that clients know that it's trusted software.

You can also sign your applet with a homemade certificate which is valid for only 6 months. But the enduser would still get a security warning when your applet is to be loaded; the enduser is asked for confirmation if this is really trusted software and may be executed. You however still need to wrap the applet main init() inside an AccessController#doPrivileged().

public void init() {
    AccessController.doPrivileged(new PrivilegedAction<Void>() {
        @Override public Void run() {
            // Put your original init() here.
        }
    });
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜