使用带有策略文件的签名 Applet 时出现问题

发布于 2024-10-19 22:07:56 字数 1894 浏览 11 评论 0原文

我的小程序的 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文