Module jdk.jartool

Class JarSigner

java.lang.Object
jdk.security.jarsigner.JarSigner

public final class JarSigner extends Object
An immutable utility class to sign a jar file.

A caller creates a JarSigner.Builder object, (optionally) sets some parameters, and calls build to create a JarSigner object. This JarSigner object can then be used to sign a jar file.

Unless otherwise stated, calling a method of JarSigner or JarSigner.Builder with a null argument will throw a NullPointerException.

Example:

    JarSigner signer = new JarSigner.Builder(key, certPath)
            .digestAlgorithm("SHA-256")
            .signatureAlgorithm("SHA256withRSA")
            .build();
    try (ZipFile  in = new ZipFile(inputFile);
            FileOutputStream out = new FileOutputStream(outputFile)) {
        signer.sign(in, out);
    }
Since:
9