How signing applets works

I have a lot of questions.

I've programmed a game in a java applet that will require me to save the state of a game character. I thought it would be best to have my character class implement Serializable and write the object to a file. Then read the file to load the saved game.

So I found out how to write the object and set that up, but then I quickly realized that I needed to sign the applet in order to write to a text file.

Everything is run locally, not on the net.

So I found some good instructions on how to sign an applet and followed them directly.

http://www.captain.at/programming/java/

Now the problem is when I follow these directions, I get this error in the console:

java.lang.SecurityException: class "Character"'s signer information does not match signer information of other classes in the same package

at java.lang.ClassLoader.checkCerts(Unknown Source)

at java.lang.ClassLoader.preDefineClass(Unknown Source)

at java.lang.ClassLoader.defineClass(Unknown Source)

at java.security.SecureClassLoader.defineClass(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 java.lang.ClassLoader.loadClassInternal(Unknown Source)

at java.lang.Class.getDeclaredConstructors0(Native Method)

at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)

at java.lang.Class.getConstructor0(Unknown Source)

at java.lang.Class.newInstance0(Unknown Source)

at java.lang.Class.newInstance(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-4" 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-World.class" 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)

So I guess my question is, do I only need to sign the applet class, as described in the link, in order for a sub class of the Character class mentioned above to write an object to file?

How can I get this to work?

Thanks,

Mike

[3225 byte] By [mikey_pa] at [2007-10-2 7:08:41]
# 1

Assuming you've got one jar you sign it like this:

Signing applets:

http://forum.java.sun.com/thread.jsp?forum=63&thread=524815

second post and reply 18 for the java class file using doprivileged

http://forum.java.sun.com/thread.jsp?forum=63&thread=409341

4th post explaining how to set up your own policy with your own keystore

If you have more that one jar make sure you sign them with the same key.

harmmeijera at 2007-7-16 20:41:09 > top of Java-index,Security,Signed Applets...