如何签署 Java 小程序以在浏览器中使用? [英] How do I sign a Java applet for use in a browser?

查看:25
本文介绍了如何签署 Java 小程序以在浏览器中使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的网站上部署 Java 小程序.我还需要签名,因为我需要访问剪贴板.我遵循了我能找到的所有签名教程,但没有取得任何成功.这是我到目前为止所做的:

  • 在 NetBeans 中编写了一个小程序.它在小程序查看器中运行良好.
  • 用它制作了一个 .jar 文件.
  • 通过这样做创建了一个证书:
<块引用>

keytool -genkey -keyalg rsa -alias myKeyNamekeytool -export -alias myKeyName -file myCertName.crt

  • 像这样用 jarsigner 签名:
<块引用>

jarsigner "C:\my path\myJar.jar" myKeyName

  • 制作了一个包含此内容的 html 文件:
<块引用>

<身体><applet code="my/path/name/myApplet.class" archive="../dist/myJar.jar"/>

当我打开那个 html 文件时,我从来没有得到安全确认对话框(因此得到java.security.AccessControlException:访问被拒绝"错误).这发生在所有浏览器上.

我错过了一步吗?

解决方案

也许是因为你打开了一些 .class 文件在 jar 文件之外?

那样它可能不会显示警告.我尝试这样做,但它仍然向我显示证书警告,对于一个简单的情况,它实际上阻止我从带有分隔类的 JAR 访问类.

也许您的特定设置或文件组织会导致该行为.如果您可以更详细地进行布局,我们可以提供更好的帮助(或者更确切地说,尝试将所有这些 .class 文件放入另一个已签名的 Jar 中并将其添加到存档中..., anotherJar.jar").

I'm trying to deploy a Java applet on my website. I also need to sign it, because I need to access the clipboard. I've followed all the signing tutorials I could find but have not had any success. Here is what I've done so far:

  • Wrote an applet in NetBeans. It runs fine in the applet viewer.
  • Made a .jar file out of it.
  • Created a certificate by doing this:

keytool -genkey -keyalg rsa -alias myKeyName
keytool -export -alias myKeyName -file myCertName.crt

  • Signed it wtih jarsigner like this:

jarsigner "C:\my path\myJar.jar" myKeyName

  • Made an html file containing this:

<html>
  <body>
<applet code="my/path/name/myApplet.class" archive="../dist/myJar.jar"/>
  </body>
</html>

When I open that html file, I never get the security confirmation dialog box (and thus get the "java.security.AccessControlException: access denied" error). This happens on all browsers.

Am I missing a step?

解决方案

Perhaps it's because you're opening some .class files outside the jar file?

That way it may not display the warning. I tried doing it that way but it still showed me the certificate warning and for a simple case it actually prevented me from accessing a class from the JAR with the separated class.

Maybe your specific setup or file organization causes that behavior. If you can layout that in more detail we could help better (or rather, try putting all those .class files in yet another signed Jar and add it to the archive"..., anotherJar.jar").

这篇关于如何签署 Java 小程序以在浏览器中使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆