[英]calling signed applet function from javascript with java.security.AccessControlException: access denied
everyone! 大家!
I have a signed applet (named result in html) with a simple function as below: 我有一个签名的小程序(以html命名结果),具有以下简单功能:
public void killApplet()
{
AccessController.doPrivileged(new PrivilegedAction<Object>(){
//@Override
public Object run() {
// kill the JVM
System.exit(0); // or any other line here
String str = "any string";
return null;
}
});
}
The Java script code is like: Java脚本代码类似于:
function exec_java() {
document.result.killApplet();
}
When I click the button to execute the java function: 当我单击按钮以执行java函数时:
<button type="button" id="buttontest" onclick="exec_java()">test</button>
It shows up an exception as below: 它显示如下异常:
java.security.AccessControlException: access denied
(java.io.FilePermission C:\Program Files\Java\jdk1.6.0_18\bin read)
I am using Windows XP with IE version as below: 我使用Windows XP和IE版本,如下所示:
IE 7 IE 7
Vision: 7.0.5730.13 视野:7.0.5730.13
Any expert and give me a clue how to make this exception gone? 有专家可以给我一个提示,使这种异常消失吗? Additionally, the weird thing here is I can call a simple function without problem like below: 另外,这很奇怪,我可以调用一个简单的函数而不会出现如下问题:
public int getNumberOfLines(){
return number_of_lines;
}
Any help would be appreciated! 任何帮助,将不胜感激! PS: Can't post any images cos apparently I am 'new'! PS:无法张贴任何图片,因为我显然是“新手”! Does anyone have a working sample using? 有人在使用工作样本吗?
AccessController.doPrivileged(new PrivilegedAction<Object>()
Thanks! 谢谢!
Wu Bi 吴Bi
// kill the JVM
System.exit(0);
An applet is a guest in a web page that might host other applets. 小程序是网页上的访客,该网页可能承载其他小程序。 Calling System.exit(n)
is like the guest burning down the guest-house. 调用System.exit(n)
就像来宾在烧毁旅馆一样。 Don't do that! 不要那样做! As such, even a trusted applet is not allowed to invoke the method. 这样,即使是受信任的applet也不允许调用该方法。
A better way to end an applet is to call: 结束applet的更好方法是调用:
showDocument(thanksForUsingOurAppletURL);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.