AccessControlException: 访问被拒绝 - FilePermission [英] AccessControlException: access denied - FilePermission
问题描述
我正在使用 JRE7.我已经使用 jarsigner 对 jar 文件进行了签名.但我仍然得到例外
I am using JRE7. I have signed the jar file using jarsigner. But still I get the exception
java.security.AccessControlException: access denied ("java.io.FilePermission"
"C:\Program Files\Java\jre7\lib\ext\Cert.P12" "read")
我正在尝试读取存储在该目录中的 Cert.P12.
I am trying to read the Cert.P12 stored in that directory.
我使用 keytool 生成了证书并对 jar 进行了签名.当浏览器提示我时,我接受了证书.是不是因为它不是真正的证书我收到此错误?
I generated certificate using keytool and signed the jar. When the browser prompted me i accepted the certificate. Is it because it is not a real certificate I am getting this error?
这个读取文件的代码是一个小程序代码.
This code to read the file is an applet code.
http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html 提到如果它被签名,错误就会消失.但它不适合我.
http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html mentions that if it is signed the error will vanish. But it did not for me.
推荐答案
如果,即使在签署小程序后,您仍然收到 SecurityException,请尝试将代码作为特权代码运行:
If, even after signing the applet, you still get a SecurityException, try running the code as privileged code:
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
// perform the security-sensitive operation here
return null;
}
});
这篇关于AccessControlException: 访问被拒绝 - FilePermission的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!