我有一个小程序,允许用户使用他们的个人证书签署文档。小程序已签名,但当它尝试加载其密钥库时,我收到与 sunMSCAPI 相关的访问被拒绝错误。这是由以下代码行引起的:
store = KeyStore.getInstance("Windows-MY");
store.load(null, null);
根据我对小程序签名的了解,在我需要跳过的签名过程之后没有其他步骤(编辑策略文件等)。我尝试将所有小程序功能包装在:
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
etc...
但这没有帮助。我已经在各个论坛上找到了一些评论,认为 sunMSCAPI 仅在 JDK 6 中可用......我已经得到了。我的想法不多了,任何帮助将不胜感激。
对于潜在的帮助,这里是拒绝访问错误的堆栈跟踪:
java.security.AccessControlException: access denied (java.security.SecurityPermission authProvider.SunMSCAPI)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at sun.security.mscapi.KeyStore.engineLoad(KeyStore.java:736)
at sun.security.mscapi.KeyStore$MY.engineLoad(KeyStore.java:43)
at java.security.KeyStore.load(Unknown Source)
at com.bloop.signature.PKCS11.loadKeyStore(PKCS11.java:42)
at com.bloop.signature.PKCS11.sign(PKCS11.java:29)
at com.bloop.signature.applet.SignApplet.signDocument(SignApplet.java:103)
at com.bloop.signature.applet.SignApplet.access$200(SignApplet.java:19)
at com.bloop.signature.applet.SignApplet$1.run(SignApplet.java:64)
at java.lang.Thread.run(Unknown Source)