Class JarSigner

java.lang.Object
com.iizix.security.JarSigner

public class JarSigner extends Object
Helper class to sign a Jar file.
Author:
Christopher Mindus
  • Method Details

    • getJarsigner

      public static String getJarsigner() throws NotFoundException
      Gets the jarsigner executable that is present in the JDK.
      Returns:
      The jarsigner executable.
      Throws:
      NotFoundException - If jarsigner[.exe] is not found.
    • signJar

      public static void signJar(File jarFile, KeyStore keystore, File keystoreFile, String storetype, String storePassword, String keyPassword, String alias, String tsa) throws IOException
      Signs the Jar file.

      Note: if tsa parameter is set, i.e. timestamping is used, an Internet connection must be present, otherwise this call will fail.

      Parameters:
      jarFile - The Jar file to sign.
      keystore - The keystore, or null for keystore from a file.
      keystoreFile - The keystore file must be specified if keystore parameter is null.
      storetype - The keystore type, e.g. JKS or PKCS12.
      storePassword - The password for the keystore.
      keyPassword - The password for the private key, if different than storePassword, null otherwise.
      alias - The alias to use.
      tsa - The timestamping authority URL, null for none.
      Throws:
      IOException - For I/O errors.