having trouble using signed java applet

D

Darren

Roedy Green said:
or quoted :
That's interesting. I tried to open the jar i created and winzip replied
"failed to load main-class manifest attribute" and when i compress the class
file with jar i get "manifest added"
 
D

Darren

Dag Sunde said:
Signing does not presume/need packages, but I agree with you.
(One should use them to keep things globally unique)

I suspect "jar" messes up a little when he doesn't use packages,
but gives a full ms-dos path to his .class file

<quote>
c:\j2sdk1.4.2_06\bin\jar cvf c:\applets\Helloserver.jar
c:\applets\Helloserver.class
c:\j2sdk1.4.2_06\bin\jarsigner c:\applets\Helloserver.jar dazkey
c:\j2sdk1.4.2_06\bin\jarsigner -verify -verbose -certs
c:\applets\Helloserver.jar
</quote>

I think the results will be different if he change to "c:\applets"
and try to jar, and sign it from there, the results might be different:
c:\applets> jar cvf helloserver.jar Helloserver.class
c:\applets> jarsigner helloserver.jar dazkey
c:\applets> jarsigner -verify -verbose -certs helloserver.jar

And Darren...

Can you give us the result the last command you run:
"jarsigner -verify -verbose -certs helloserver.jar"

141 Wed Sep 21 11:46:20 BST 2005 META-INF/MANIFEST.MF
194 Wed Sep 21 11:46:22 BST 2005 META-INF/DAZKEY.SF
932 Wed Sep 21 11:46:22 BST 2005 META-INF/DAZKEY.RSA
0 Wed Sep 21 11:38:40 BST 2005 META-INF/
smk 2224 Wed Sep 21 01:30:54 BST 2005 Helloserver.class

X.509, CN=myname, OU=Unknown, O=g7wap, L=myhome, ST=mylocal, C=uk (
dazkey)


s = signature was verified
m = entry is listed in manifest
k = at least one certificate was found in keystore
i = at least one certificate was found in identity scope

jar verified.
 
D

Dag Sunde

Darren said:
141 Wed Sep 21 11:46:20 BST 2005 META-INF/MANIFEST.MF
194 Wed Sep 21 11:46:22 BST 2005 META-INF/DAZKEY.SF
932 Wed Sep 21 11:46:22 BST 2005 META-INF/DAZKEY.RSA
0 Wed Sep 21 11:38:40 BST 2005 META-INF/
smk 2224 Wed Sep 21 01:30:54 BST 2005 Helloserver.class

X.509, CN=myname, OU=Unknown, O=g7wap, L=myhome, ST=mylocal, C=uk (
dazkey)


s = signature was verified
m = entry is listed in manifest
k = at least one certificate was found in keystore
i = at least one certificate was found in identity scope

jar verified.

Looks perfectly Ok!

Can you send me your mail-address?
 
R

Roedy Green

hat's interesting. I tried to open the jar i created and winzip replied
"failed to load main-class manifest attribute" and when i compress the class
file with jar i get "manifest added"

This makes no sense. Winzip knows nothing about manifests.

Start winzip.

Do a file open of xxx.jar

View the contents.

You don't use Winzip to manipulate jars, just peek inside them.

Jar.exe requires you to write a tiny skeleton manifest file, that
jar.exe includes and augments. This is all described under
http://mindprod.com/jgloss/jarexe.html
and
http://mindprod.com/jgloss/jar.html

When you look in the jar you should see at least two members,
your main class and the manifest file.
 
R

Roedy Green

141 Wed Sep 21 11:46:20 BST 2005 META-INF/MANIFEST.MF
194 Wed Sep 21 11:46:22 BST 2005 META-INF/DAZKEY.SF
932 Wed Sep 21 11:46:22 BST 2005 META-INF/DAZKEY.RSA
0 Wed Sep 21 11:38:40 BST 2005 META-INF/
smk 2224 Wed Sep 21 01:30:54 BST 2005 Helloserver.class

this is looking good, with one exception. Your main class still is not
in a package.

Does it have no dependent classes, not even those $ ones?
 
D

Dag Sunde

Roedy Green said:
you can download the source and jar for a signed applet at
http://mindprod.com/products1.html#WASSUP
It also has an ant script for building it.

Sorry for the confusion, Rondey...

I promised Darren to write and sign the applet he needs
in another thread.

Just so he could verify that a signed applet would solve his
problem...

It was not meant as a response to your post...
 
D

Darren

Roedy Green said:
This makes no sense. Winzip knows nothing about manifests. Apparently it does

Start winzip.

Do a file open of xxx.jar

Yep that's what i did and i got the error message
View the contents. That was my intention

You don't use Winzip to manipulate jars, just peek inside them.
I know, but it knows how to handle jar files apparently.
Jar.exe requires you to write a tiny skeleton manifest file, that
jar.exe includes and augments. This is all described under
http://mindprod.com/jgloss/jarexe.html
and
http://mindprod.com/jgloss/jar.html

When you look in the jar you should see at least two members,
your main class and the manifest file.

I tried viewing with jar itself.
Jar -t -f Helloserver.jar
and it sat there waiting for me as if it was trying to get standard input. I
got the same without the -f flag so i assumned the -f flag would cover it
but i guess not.
 
D

Darren

Roedy Green said:
You need at least a main class. Its java name is for example:

com.mindprod.wassup.Wassup.class

In the jar in will have the name:

com/mindprod/wassup/Wassup.class
Strange. I added a package to the java
uk.me.g7wap.helloserver
and when i compiled it, it created a directory tree that matched the package
path $CODEBASE/uk/me/g7wap/helloserver/
where it placed the class file, then i jar it
then i read the jar file with jar

H:\public_html>c:\j2sdk1.4.2_06\bin\jar tf helloserver.jar
META-INF/
META-INF/MANIFEST.MF
Helloserver.class

Shouldn't the Helloserver.class be in a directory namely
uk/me/g7wap/helloserver or is jar taking that as red for the codebase?
You don't need an entry for each directory level, just the files.
Jar.exe handles that. You just tell it which classes and resources you
want in there.

When you sign it will add some additional files of the digests and
digital signatures.


Verify you got it right with Winzip or something similar.

Winzip won't open it
 
D

Darren

Roedy Green said:
this is looking good, with one exception. Your main class still is not
in a package.

Does it have no dependent classes, not even those $ ones?
It proves your claim that it definately did need to be in a package.

Now what was the applet tag for adding the package data?
 
D

Darren

Roedy Green said:
This makes no sense. Winzip knows nothing about manifests.

Start winzip.

Do a file open of xxx.jar

View the contents.

You don't use Winzip to manipulate jars, just peek inside them.

Jar.exe requires you to write a tiny skeleton manifest file, that
jar.exe includes and augments. This is all described under
http://mindprod.com/jgloss/jarexe.html
and
http://mindprod.com/jgloss/jar.html

When you look in the jar you should see at least two members,
your main class and the manifest file.

ok now i'm getting this from the java console
Why is it giving me a wrong name? the name of the package mathed the one
specified below (replacing slashes with dots of course)

java.lang.NoClassDefFoundError: Helloserver (wrong name:
uk/me/g7wap/helloserver/Helloserver)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-5" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "Thread-9" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception in thread "thread applet-null" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
 
R

Roedy Green

Apparently it does

I have been bugging Winzip for many years to add some jar support, but
every time they refuse. They won't even make jar a configurable
extension.

Are you using Beta 10.0?

I am trying to figure out how Winzip could possibly generate that
message. Main-Class in an entry INSIDE the manifest. Winzip is not
involved with content. It is just a container.

If you posted the weird jar somewhere, perhaps I could figure out what
you did.
 
R

Roedy Green

java.lang.NoClassDefFoundError: Helloserver (wrong name:
uk/me/g7wap/helloserver/Helloserver)

If you posted your code and your bat files we would not be playing
doctor in the dark.

I trust you have code like this:

package uk.me.g7wap/helloserver;
public class Helloserver

in a file called C:\uk\me\g7wap\helloserver\Helloserver.java

I trust you created your jar with some code like this:

c:
cd \

rem your main.mft should look like this:
rem Main-Class uk/me/g7wap/helloserver.Helloserver
rem following should be on one line:
jar.exe -cvfm
uk\me\g7wap\helloserver.jar
uk\me\g7wap\helloserver\main.mft
uk\me\g7wap\helloserver\*.class

then you signed it with:

jarsigner.exe helloserver.jar mycert
 
R

Roedy Green

Shouldn't the Helloserver.class be in a directory namely
uk/me/g7wap/helloserver or is jar taking that as red for the codebase?

Please re-read the examples I gave you at:

http://mindprod.com/jgloss/javacexe.html
http://mindprod.com/jgloss/jarexe.html
http://mindprod.com/jgloss/jar.html
http://mindprod.com/jgloss/jarsigner.html
http://mindprod.com/jgloss/classpath.html

You have repeatedly refused to post code or bat files. I can't tell
what you are doing. You are demanding surgery by flashlight.

Your class should be in a package. That package name should be
reflected in its member name in the jar.

I think what you are doing is:

c:
cd \uk\me\g7wap\helloserver
jar.exe -cvfm helloserver.jar main.mft *.class

which is wrong. Jar.exe is incredibly stupid. You must have the
precise package info on the command line as I show you at
http://mindprod.com/jgloss/jarexe.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top