![]()
(chat, newsreader, calendar)
|
![]() |
|
|
|
Course Notes Table of Contents Exercises | Online Training Index
|
|
Signing Declarations with John Hancock
MageLang Institute
|
[Help | Solution |
API Docs |
Behavior |
Course Notes |
Exercises]
PrerequisitesIf you sell a Bean that requires it to be trusted when downloaded over the Internet, you need to digitally sign it. Then, for each and every user, they need to identify you as trusted and install your public X.509 key, into their Java key database. (Code signing is only one way of limiting access in Java. See the Java Security API Overview for more.) This exercise takes you through the steps to sign an applet that uses the results from the Reflective Programming with Freud exercise.
Perform the following tasks:
javakey -r "John Hancock" Once removed, we can run the program unsigned to see what happens. Unpack the AllHancock.jar file and run appletviewer with the Declaration.html file. Now, press the 'Introspect' button while there is nothing in the 'Enter class name' text field. The applet is able to reflect on itself with no security problems. Then 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. In 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:
Now 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:
Now 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:
Finally, 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. Okay, 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.
|
|
Copyright © 1997 MageLang Institute. All Rights Reserved May-97 Copyright © 1996, 1997 Sun Microsystems Inc. All Rights Reserved |