signed applet gives AccessControlException: access denied, when calling from javascript

后端 未结 4 2082
名媛妹妹
名媛妹妹 2020-12-11 08:21

I have an easy self-signed an applet (done with keytool and the jarsigner):

public class NetAppletLauncher extends JApplet {

    private static final long s         


        
4条回答
  •  無奈伤痛
    2020-12-11 08:38

    Actually, calling applet from javascript behaves as calling unsigned applet (as specified in the jsnote: http://docs.oracle.com/javase/tutorial/deployment/applet/security.html#jsNote. That is fine and is valid when you're using a class you are not allowed to change, but since you're the author of the java class you can always wrap that specific method you need to call from javascript to be executed in the privileged mode, like this:

    AccessController.doPrivileged(new PrivilegedAction() {
        @Override
        public String run() {
            exec(command);
            return null;
        }
    });
    

    And it should work ok. (This is what is suggested in the upvoted comment by @Jean-Philippe Jodoin but the link provided there is broken)

提交回复
热议问题