< prev index next >

jdk/src/jdk.jartool/share/classes/jdk/security/jarsigner/JarSigner.java

Print this page




  60  * some parameters, and calls {@link JarSigner.Builder#build build} to create
  61  * a {@code JarSigner} object. This {@code JarSigner} object can then
  62  * be used to sign a jar file.
  63  * <p>
  64  * Unless otherwise stated, calling a method of {@code JarSigner} or
  65  * {@code JarSigner.Builder} with a null argument will throw
  66  * a {@link NullPointerException}.
  67  * <p>
  68  * Example:
  69  * <pre>
  70  * JarSigner signer = new JarSigner.Builder(key, certPath)
  71  *         .digestAlgorithm("SHA-1")
  72  *         .signatureAlgorithm("SHA1withDSA")
  73  *         .build();
  74  * try (ZipFile in = new ZipFile(inputFile);
  75  *         FileOutputStream out = new FileOutputStream(outputFile)) {
  76  *     signer.sign(in, out);
  77  * }
  78  * </pre>
  79  *
  80  * @since 1.9
  81  */
  82 public final class JarSigner {
  83 
  84     /**
  85      * A mutable builder class that can create an immutable {@code JarSigner}
  86      * from various signing-related parameters.
  87      *
  88      * @since 1.9
  89      */
  90     public static class Builder {
  91 
  92         // Signer materials:
  93         final PrivateKey privateKey;
  94         final X509Certificate[] certChain;
  95 
  96         // JarSigner options:
  97         // Support multiple digestalg internally. Can be null, but not empty
  98         String[] digestalg;
  99         String sigalg;
 100         // Precisely should be one provider for each digestalg, maybe later
 101         Provider digestProvider;
 102         Provider sigProvider;
 103         URI tsaUrl;
 104         String signerName;
 105         BiConsumer<String,String> handler;
 106 
 107         // Implementation-specific properties:
 108         String tSAPolicyID;




  60  * some parameters, and calls {@link JarSigner.Builder#build build} to create
  61  * a {@code JarSigner} object. This {@code JarSigner} object can then
  62  * be used to sign a jar file.
  63  * <p>
  64  * Unless otherwise stated, calling a method of {@code JarSigner} or
  65  * {@code JarSigner.Builder} with a null argument will throw
  66  * a {@link NullPointerException}.
  67  * <p>
  68  * Example:
  69  * <pre>
  70  * JarSigner signer = new JarSigner.Builder(key, certPath)
  71  *         .digestAlgorithm("SHA-1")
  72  *         .signatureAlgorithm("SHA1withDSA")
  73  *         .build();
  74  * try (ZipFile in = new ZipFile(inputFile);
  75  *         FileOutputStream out = new FileOutputStream(outputFile)) {
  76  *     signer.sign(in, out);
  77  * }
  78  * </pre>
  79  *
  80  * @since 9
  81  */
  82 public final class JarSigner {
  83 
  84     /**
  85      * A mutable builder class that can create an immutable {@code JarSigner}
  86      * from various signing-related parameters.
  87      *
  88      * @since 9
  89      */
  90     public static class Builder {
  91 
  92         // Signer materials:
  93         final PrivateKey privateKey;
  94         final X509Certificate[] certChain;
  95 
  96         // JarSigner options:
  97         // Support multiple digestalg internally. Can be null, but not empty
  98         String[] digestalg;
  99         String sigalg;
 100         // Precisely should be one provider for each digestalg, maybe later
 101         Provider digestProvider;
 102         Provider sigProvider;
 103         URI tsaUrl;
 104         String signerName;
 105         BiConsumer<String,String> handler;
 106 
 107         // Implementation-specific properties:
 108         String tSAPolicyID;


< prev index next >