Agent System POND 1.0 (1.7.2000)

FIM.Util.Crypto
Class JarUtils

java.lang.Object
  |
  +--FIM.Util.Crypto.JarUtils

public class JarUtils
extends Object

A class with utilities for JAR-files. Contains the following:

All procedures require that an jar-file already exists.

This class can also be used directly to sign jar-files: java FIM.Util.JarUtils JAR-file CertificateAndKeyFile NameOfSigner

ATTENTION: This uses undocumented classes from Sun. Might not work in future releases of JDK 1.2.
I couldn't get IAIK to read the SignedData structure of the actual signature files (*.DSA); always dropped with "ParsingException: Couldn't parse object" (Wonderful message!!!!).

Version:
1.0, 1.7.2000
Author:
Michael Sonntag

Constructor Summary
JarUtils()
           
 
Method Summary
static void createSignedJar(String filename, String signerName, X509Certificate[] chain, PrivateKey privateKey)
          Digests a jar-file (MD5 and SHA-1) and signs it afterwards.
static void digestJarFile(String filename, String algorithm)
          Digests a jar-file.
static void main(String[] args)
          This class can also be used directly to sign jar-files:
java FIM.Util.JarUtils JAR-file CertificateAndKeyFile NameOfSigner
static void signJarFile(String filename, String signerName, X509Certificate[] chain, PrivateKey privateKey)
          Signs a jar-file.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JarUtils

public JarUtils()
Method Detail

signJarFile

public static void signJarFile(String filename,
                               String signerName,
                               X509Certificate[] chain,
                               PrivateKey privateKey)
                        throws FileNotFoundException,
                               SignatureException
Signs a jar-file.
Parameters:
filename - the jar-file to sign
signerName - the name of the signer (=entry name for signature file in directory META-INF)
chain - the certificate chain for the signer
privateKey - the private key of the signer
Throws:
SignatureException - if an error occured during signing
FileNotFoundException - if the jar-file could not be found

digestJarFile

public static void digestJarFile(String filename,
                                 String algorithm)
                          throws FileNotFoundException,
                                 DigestException
Digests a jar-file.
Parameters:
filename - the jar-file to digest
algorithm - the algorithm used for digesting
Throws:
DigestException - if an error occured during digesting
FileNotFoundException - if the jar-file could not be found

createSignedJar

public static void createSignedJar(String filename,
                                   String signerName,
                                   X509Certificate[] chain,
                                   PrivateKey privateKey)
                            throws SignatureException,
                                   DigestException,
                                   FileNotFoundException
Digests a jar-file (MD5 and SHA-1) and signs it afterwards.
Parameters:
filename - the jar-file to sign
signerName - the name of the signer (=entry name for signature file in directory META-INF)
chain - the certificate chain for the signer
privateKey - the private key of the signer
Throws:
DigestException - if an error occured during digesting
SignatureException - if an error occured during signing
FileNotFoundException - if the jar-file could not be found

main

public static void main(String[] args)
This class can also be used directly to sign jar-files:
java FIM.Util.JarUtils JAR-file CertificateAndKeyFile NameOfSigner

Agent System POND 1.0 (1.7.2000)

Submit a bug

Copyright 2000 Michael Sonntag & Institute for Information Processing and Microprocessor Technology (FIM), Johannes-Kepler-University Linz, Altenbergerstr. 69, A-4040 Linz, Austria.