开发者

java.lang.RuntimePermission accessClassInPackage.sun.security.pkcs11.wrapper?

My applet cannot implement following statements:

Method p11Getinstance = PKCS11.class.getMethod("getInstance", String.class,
        String.class, CK_C_INITIALIZE_ARGS.class, Boolean.TYPE);

and throws an exception:

java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.security.pkcs11.wrapper)

If I edit java.policy in javahome, the above exception will disappear, but I don't want to go this way. I want to edit my code.

When I try to add some 开发者_运维技巧statements:

AccessController.doPrivileged(new PrivilegedAction() {

    @Override
    public Object run() {
        try {
            p11Getinstance = PKCS11.class.getMethod("getInstance", String.class, String.class, CK_C_INITIALIZE_ARGS.class, Boolean.TYPE);
        } catch (Exception e) {
        }
        return null;
    }
});

And then use my certificate to sign jar file of the applet, will this exception still appear?


I think you have to add the following permission in the .java.policy file:

permission java.lang.RuntimePermission "accessClassInPackage.sun.security.pkcs11.wrapper";
permission java.lang.RuntimePermission "accessClassInPackage.sun.security.pkcs11";
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜