Java 2 Network Security



Java 2 Network Security
1.4.1.3 Packing the Applet Class in a JAR File
First of all, we sign the code of the GetPrintJob applet on the server machine.
To do this, the applet file must be packed in the JAR format, through the
command:

jar cvf GetPrintJob.jar GetPrintJob.class
The command above must be launched on the same directory where the file
GetPrintJob.class resides and it automatically creates the JAR file
GetPrintJob.jar, which includes a compressed version of the original class
file. If you examine the contents of GetPrintJob.jar (on Windows systems this
can be done even with the WinZip utility), you will see that it contains also a
file called MANIFEST.MF. This is a text file containing general information
about the files that have been packed in the JAR file. The file MANIFEST.MF
is often called the

manifest
file.
1.4.1.4 Creating a Keystore and a Signer's Key Pair
We also need to generate a

key pair
(a public key and associated private
key). With Java 2, this can be done using the Java 2
keytool
command line
utility with the option
-genkey
, which generates a key pair and wraps the public
key into an X.509 V1 self-signed certificate. The details are shown in the
following session screen:

The process we have just described creates a public and private key pair and
associates the public key with the certificate of the signer, whose alias by
default is mykey. The private key and the certificate are stored in a flat
keystore file called .keystore, located in the user home directory. A

keystore
is
a database of private keys and their associate X.509 certificate chains
C:\>keytool -genkey
Enter keystore password: Paolina
What is your first and last name?
[Unknown]: Marco Pistoia
What is the name of your organizational unit?
[Unknown]: ITSO
What is the name of your organization?
[Unknown]: IBM Corporation
What is the name of your City or Locality?
[Unknown]: Cary
What is the name of your State or Province?
[Unknown]: North Carolina
What is the two-letter country code for this unit?
[Unknown]: US
Is <CN=Marco Pistoia, OU=ITSO, O=IBM Corporation, L=Cary, ST=North Carolina, C=US> correct?
[no]: yes