使用带有策略文件的签名 Applet 时出现问题
我的小程序的 .java.policy 条目有问题。
我会尝试使用小程序创建文件夹和文件。我已经签署了我的 jar 并在 ${user.home}/.java.policy-file 中添加了以下几行:
grant {
permission java.io.FilePermission "<<ALL FILES>>", "read";
permission java.io.FilePermission "<<ALL FILES>>", "write";
};
通过添加这些行,我的小程序工作得很好,但这不是一个好的样式,因为每个任何地方的 jar 也成为文件权限。
在oracle页面上有一些示例,将codeBase设置为指定的applet.jar并将signedBy(jar文件签名的别名)设置为grand权限。
我已经尝试了很多次,但它不起作用。
我尝试过的代码:
grant codeBase "http://www.wkmovies.de/appletDemo/-" {
permission java.io.FilePermission "<<ALL FILES>>", "read";
permission java.io.FilePermission "<<ALL FILES>>", "write";
};
或者
grant signedBy "AKlettke" {
permission java.io.FilePermission "<<ALL FILES>>", "read";
permission java.io.FilePermission "<<ALL FILES>>", "write";
};
我已将此示例上传到: www.wkmovies.de/appletDemo/index .html
我如何设置策略文件,使我的小程序能够正常工作?
这里是我的代码片段: HTML:
<a href="javascript:document.applet1.createFolder();">
Create Folder at C:\\Temp
</a>
<applet name="applet1" id="applet1" width="0" height="0" alt=""
archive="applets/Demo.jar,applets/lib/commons-lang-2.4.jar"
code="demo.FolderCreator.class">
</applet>
FolderCreator 类:
try {
File f = new File("C:\\temp");
f.mkdir();
JOptionPane.showMessageDialog(null, "folder created",
"successfull", JOptionPane.INFORMATION_MESSAGE);
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, e.getMessage(),
e.getClass().getName(), JOptionPane.ERROR_MESSAGE);
}
(JDK1.6.0_23、Firefox 3.0.19、WinXP 32 位)
i have a problem with the .java.policy entries for my applet.
I would try to create folders and files with an applet. I had already signed my jar and added in the ${user.home}/.java.policy-file the following lines:
grant {
permission java.io.FilePermission "<<ALL FILES>>", "read";
permission java.io.FilePermission "<<ALL FILES>>", "write";
};
with this added lines, my applet works great, but this is not a good style, because every jar at any places becomes the file permissions too.
At the oracle pages are examples to set the codeBase to the specified applet.jar and set the signedBy (the alias wich the jar-file is signed) to grand permissions.
I have tried this many times, but it doesn't work.
The code i have tried:
grant codeBase "http://www.wkmovies.de/appletDemo/-" {
permission java.io.FilePermission "<<ALL FILES>>", "read";
permission java.io.FilePermission "<<ALL FILES>>", "write";
};
or
grant signedBy "AKlettke" {
permission java.io.FilePermission "<<ALL FILES>>", "read";
permission java.io.FilePermission "<<ALL FILES>>", "write";
};
I have uploaded this example to: www.wkmovies.de/appletDemo/index.html
How can i set up the policy file, that my applet will work?
Here my code snips:
HTML:
<a href="javascript:document.applet1.createFolder();">
Create Folder at C:\\Temp
</a>
<applet name="applet1" id="applet1" width="0" height="0" alt=""
archive="applets/Demo.jar,applets/lib/commons-lang-2.4.jar"
code="demo.FolderCreator.class">
</applet>
FolderCreator class:
try {
File f = new File("C:\\temp");
f.mkdir();
JOptionPane.showMessageDialog(null, "folder created",
"successfull", JOptionPane.INFORMATION_MESSAGE);
} catch (Exception e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, e.getMessage(),
e.getClass().getName(), JOptionPane.ERROR_MESSAGE);
}
(JDK1.6.0_23, Firefox 3.0.19, WinXP 32bit)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试特权 API:
http://download.oracle.com/javase/1.4 .2/docs/guide/security/doprivileged.html
Try priveleged API:
http://download.oracle.com/javase/1.4.2/docs/guide/security/doprivileged.html