试图获得一个签名的小程序在浏览器中工作,但惨遭失败 [英] Trying to get a signed applet to work in a browser but fails miserably

查看:147
本文介绍了试图获得一个签名的小程序在浏览器中工作,但惨遭失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个JApplet的使用两个外部库( JENA 并的 JUNG )。小应用程序工作正常,当我从IDE运行它(使用eclipse)。我创建了一个jar文件,签署了(因为小程序需要从磁盘中读取文本),创建了一个HTML页面来存放小程序,但是当我尝试在Web浏览器中,我得到了Java安全警告对话框,当我运行它preSS运行整个浏览器选项卡似乎挂起。

下面是HTML文件,我写道:

 < HTML和GT;
   < HEAD>
      <标题>本体应用与LT; /标题>
   < /头>
   <身体GT;
      <小程序code =assignment.Launcher.classWIDTH =1000HEIGHT =800归档=Test.jar的>< /小程序>
   < /身体GT;
< / HTML>

启动器类包含初始化,启动,停止和销毁方法,并在项目中使用的所有类都存储在任务包。 Test.jar的是签名的jar文件,并将其放置在同一文件夹中的HTML文件。

我跟着这个线程的步骤来创建我的私人/公共密钥,证书,签署jar文件:
如何注册和小程序(并得到它的工作)

我有关于整个过程的问题​​清单,因为我不确定几个步骤。

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

问题2:如果产生的jar文件来看,如果我双击它?因为它不运行
(我想是因为没有主类指定的,因为一个小程序没有一个主要方法,它不工作,而是我就站在予以纠正)

问题3:因为我使用外部库在我的小程序,我需要数字标牌一切为了使小程序的工作导入jar文件?或签署(包含我的课)的主要jar文件就足够了?

问题4:如果有一天我设法使工作的小程序在浏览器中,将Java安全每个应用程序试图从磁盘读取文本时警告对话框弹出?或安全警告对话框显示出来,只有当小程序加载一次?

在此先感谢,并询问问题负载在一个线程遗憾,但他们密切相关的主题:)


解决方案

  1. 您应该使用< PARAM NAME =档案VALUE =applet.jar,external1.jar,external2.jar'> 在你的applet声明HTML。您也可以尝试添加类路径来您的主罐 MANIFEST.MF (见的这里

  2. 没有。除非你有一个的Main-Class 中指定的 MANIFEST.MF

  3. 是,万一外部罐子做一些安全敏感操作(如读/写文件系统)

  4. 无。

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 :)

解决方案

  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.

这篇关于试图获得一个签名的小程序在浏览器中工作,但惨遭失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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