尝试让签名的小程序在浏览器中运行但惨败

发布于 2024-08-16 07:15:45 字数 1405 浏览 8 评论 0原文

我创建了一个 JApplet,它使用两个外部库(JENAJENA ) sourceforge.net/" rel="nofollow noreferrer">JUNG)。当我从 IDE 运行小程序(使用 eclipse)时,它可以正常工作。我创建了一个 jar 文件,对其进行了签名(因为小程序需要从磁盘读取文本),创建了一个 HTML 页面来保存小程序,但是当我尝试在 Web 浏览器中运行它时,我收到了 java 安全警告对话框,当我按运行整个浏览器选项卡似乎挂起。

下面是我写的HTML文件:

<html>
   <head>
      <title>Ontology Application</title>
   </head>
   <body>
      <applet code="assignment.Launcher.class" width="1000" height="800" archive="test.jar"></applet>
   </body>
</html>

Launcher类包含了init、start、stop和destroy方法,项目中用到的所有类都存放在作业包中。 test.jar 是签名的 jar 文件,它与 HTML 文件放在同一文件夹中。

我按照此线程中的步骤创建我的私钥/公钥、证书并对 jar 文件进行签名: 如何签名和小程序(并使其正常工作)

我有一个列表关于整个过程的问题,因为我不确定几个步骤。

问题 1:我使用 eclipse 创建了 jar 文件(右键单击项目 -> 导出 -> JAR 文件)并保留默认设置。生成的 jar 文件是否包含我导入到项目中的引用库?如果答案是否定的,我如何在 jar 文件中包含引用的库?

问题 2:双击生成的 jar 文件是否应该运行?因为它不运行 (我认为它不起作用,因为没有指定主类,因为小程序没有主方法,但我需要纠正)

问题3:由于我在我的小程序中使用外部库,我是否需要数字化签署所有导入的 jar 文件以使小程序正常工作?或者签署主 jar 文件(包含我的类)就足够了?

问题 4:如果有一天我设法使小程序在浏览器中运行,那么每次应用程序尝试从磁盘读取文本时都会弹出 java 安全警告对话框吗?或者安全警告对话框仅在小程序加载时显示一次?

预先感谢,很抱歉在一个线程中提出大量问题,但它们与主题密切相关:)

I created a JApplet which uses two external libraries (JENA and JUNG). The applet works correctly when i run it from the IDE (using eclipse). I created a jar file, signed it (since the applet needs to read text from disk), created an HTML page to hold the applet, however when i try to run it in a web browser i get the java security warning dialog and when i press run the whole browser tab seems to hang.

Here is the HTML file i wrote:

<html>
   <head>
      <title>Ontology Application</title>
   </head>
   <body>
      <applet code="assignment.Launcher.class" width="1000" height="800" archive="test.jar"></applet>
   </body>
</html>

The Launcher class contains the init, start, stop and destroy methods, and all the classes used in the project are stored in the assignment package. test.jar is the signed jar file and it is placed in the same folder as the HTML file.

I followed the steps in this thread to create my private/public key, certificate and to sign the jar file:
How to sign and applet (and get it to work)

I have a list of questions about the whole process since i am unsure about a couple of steps.

Question 1: I created the jar file using eclipse (Right Click project -> export -> JAR file) and kept the default settings. Does the resultant jar file contain the references libraries i imported into the project? if the answer is no, how do i include referenced libraries in the jar file?

Question 2: Should the resultant jar file run if I double click it? since it doesn't run
(I think it doesn't work because no main class is specified since an applet doesn't have a main method, but i stand to be corrected)

Question 3: Since I am using external libraries in my applet, do i need to digital sign all the imported jar files in order to make the applet work? or signing the main jar file (containing my classes) is enough?

Question 4: If someday i manage to make the applet work in a browser, will the java security warning dialog pop up every time the application tries to read text from disk? or the security warning dialog shows up only once when the applet is loading?

Thanks in advance, and sorry for asking loads of questions in one thread, however they are closely related to the subject :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绝不放开 2024-08-23 07:15:45
  1. 您应该在 HTML 的小程序声明中使用 。您还可以尝试将 Class-Path 添加到主 jar 的 MANIFEST.MF 中(请参阅 此处
  2. 否。除非您在 MANIFEST.MF 中指定了 Main-Class
  3. 的,以防外部 jar 执行一些安全敏感操作(例如读/写文件系统)
  1. You should use <PARAM NAME="archive" VALUE='applet.jar, external1.jar, external2.jar'> in your applet declaration in the HTML. You can also try adding Class-Path to your MANIFEST.MF of the main jar (see here)
  2. No. Unless you have a Main-Class specified in your MANIFEST.MF
  3. Yes, in case the external jars do some security-sensitive operations (like reading/writing the file system)
  4. No.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文