Trying to get a signed applet to work in a browser but fails miserably

喜欢而已 提交于 2019-12-01 05:59:26

问题


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:


  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.


来源:https://stackoverflow.com/questions/1965537/trying-to-get-a-signed-applet-to-work-in-a-browser-but-fails-miserably

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!