Embedding Java JApplet in an HTML page using sockets

I am having problems getting and an applet to work on an HTML page. When I remove the socket connection from the applet class and check the applet on the HTML page, the applet is displayed, but when I add the socket connection back to the class file, the applet is not displayed, and the Java console is displayed without a stack trace. I'm sure this is a security reason because I use socket connections, so I created a signed jar file and put it in the applet tag as follows:

<APPLET codebase="classes" archive="captureaudio/AppletTest.jar" code="captureaudio/AppletTest.class" width=350 height=200></APPLET> 

But the creation of this signature did not work.

Can someone help me with this?

UPDATED

In response to Andrew Thompson

  • No, they were not asked to accept the digitally signed code.
  • No, im is currently testing locally.
  • Yes, the applet is trying to connect to the server, the server is running locally
  • I am not sure if the java console shows me any exceptions.

HOW I CREATED A SIGNATURE JAR FILE

The namespace of my applet is captureaudio. Class appletTest

At the cmd command line where the class file is located:

  • You need to use keytool.exe, this is where I found how to create a jar signature for applets www.xinotes.org/notes/note/434/

  • jar -cf AppletTest.jar AppletTest.class

  • > jarsigner AppletTest.jar MyCert Warning: this bank contains entries whose subscriber certificate expires within six months.

4.> jarsigner -verify -verbose -certs AppletTest.jar

sk 153 Thu Oct 13 11:28:38 BST 2011 META-INF / MANIFEST.MF

  X.509, CN=xxxxx, OU=None, O=None, L=xxxxx, ST=xxxxx, C=GB (myce 

ct) [certificate expires 10/01/12 20:55]

  315 Thu Oct 13 11:28:40 BST 2011 META-INF/MYCERT.SF 1352 Thu Oct 13 11:28:40 BST 2011 META-INF/MYCERT.RSA 0 Thu Oct 13 11:28:10 BST 2011 META-INF/ 

smk 11015 Thu Oct 13 10:49:08 BST 2011 AppletTest.class

  X.509, CN=xxxxxx, OU=None, O=None, L=xxxxxxxx, ST=xxxxx, C=GB (myce 

ct) [certificate expires 10/01/12 20:55]

s = signature was verified m = record specified in manifest k = at least one certificate was found in the keystore i = at least one certificate was found in the authentication area

jar verified.

JAVA CONSOLE

Java Plug-in 10.0.0.147 Using the JRE Version 1.7.0-b147 Java Client Virtual Machine HotSpot (TM)

User home directory = C: \ Users \ xxxxxxx

c: clear the console window f: complete the objects in the completion queue g: garbage collection h: display this help message l: list of class loaders dump m: use print memory o: start the trigger q: hide the console r: configure the reboot policy s: dump system and deployment properties t: downstream list v: dump stack pile x: clear class loader cache

0-5: set trace level to

Found from bootclasspath: C: \ PROGRA ~ 1 \ Java \ jre7 \ lib \ deploy.jar

UPDATE

Folder location

  web root> ------AppletTest.jar ------classes> -----------captureaudio> ---------------------AppletTest.class 
+6
source share
1 answer

Use Java Network Launch Protocol (JNLP). This is the right way to distribute your applet. And yes, it must be signed in order to access socket functions.

http://en.wikipedia.org/wiki/Java_Web_Start#Java_Network_Launching_Protocol_.28JNLP.29 http://www.oracle.com/technetwork/articles/javase/jnlp-142088.html

0
source

Source: https://habr.com/ru/post/899212/


All Articles