![]()
(chat, newsreader, calendar)
|
![]() |
|
|
|
Course Notes Table of Contents Exercises | Online Training Index
|
|
Help: Signing Declarations with John Hancock
MageLang Institute
|
|
Help is available for each task, or you can go straight to
the solution source code.
If John doesn't exist in your system, you will see the message "No one named John Hancock in the system." If John did exist, you will see the message "Removed John Hancock." Task 2Once removed, we can run the program unsigned to see what happens. Unpack the AllHancock.jar file and run appletviewer with the Declaration.html file.To save the file, in Netscape Navigator, shift-click over the AllHancock.jar link. To extract the files from the .jar file, from the directory you saved it in, execute:
Task 4Then try to inspect a system class like java.lang.String. When you press the 'Introspect' button with java.lang.String in the text field, you will see a lengthy security exception message on the display. This basically is saying that the applet is untrusted by you, so cannot access restricted things. In order to be trusted, it must be signed by someone. Then, the user of the applet must tell their system that they trust that someone AND install their public key into their system.Task 5In order for our applet to be trusted, we need to generate a certificate, create a jar file, sign it, and tell our .html file to use it. To generate the certificate, involves four steps:
For more information on the format of the signer profile file, see JavaSoft's online description of javakey. Task 6Now we can sign our code. First, we need to package our code up to be signed. The Freud.class file is the only one that has to be signed. If we include our general applet code in the signed package and the user does not trust the signer, they will get an empty screen on startup and will think they did something wrong. By not packaging the front-end, this won't happen. The command to place the Freud class in a jar file is:jar cf Freud.jar Freud.class This creates the file Freud.jar with the contents of Freud.class. To examine the contents: jar tf Freud.jar Task 7Now we need to sign the .jar file. This requires a signing directive file similar to the signer profile file earlier. For purposes of this exercise, just use the Hancock.sign file provided. Once the directives file is setup, execute:javakey -gs Hancock.sign Freud.jarto create the file Freud.jar.sig. Rename Freud.jar.sig to be signedFreud.jar. ren Freud.jar.sig signedFreud.jar For more information on the format of the signing directive file, see JavaSoft's online description of javakey. This added the following files:
Task 8Finally, create an html file that uses the signed file and test it. In the <APPLET> tag, include an archive=signedFreud.jar parameter. Then test it.<APPLET archive=signedFreud.jar code=Declaration width=400 height=400> </APPLET> Task 9Okay, now that you have this. What is necessary for a user to use it as trusted? Basically, only three steps. First, you need to provide the user with the Hancock.x509 file you created earlier. Then, they need to identify the signer as trusted on their system. Finally, they need to import the certificate file into their system.
You may have used a different name for your .html file. Also, if you want to re-enable "John Hancock" as a signer, remove him with javakey -r "John Hancock", reinstate him as a trusted signer with javakey -cs "John Hancock" true, then import the public-private key pair back into the system with javakey -ikp "John Hancock" Hancock_pub Hancock_priv. If you do not do this and just regenerate the key, the 'signed' applet will become invalid because it won't pass the verification test.
|
|
Copyright © 1997 MageLang Institute. All Rights Reserved May-97 Copyright © 1996, 1997 Sun Microsystems Inc. All Rights Reserved |