JarSignerpublic static class JarSigner.Builder extends Object
JarSigner from various signing-related parameters.| Constructor | Description | 
|---|---|
| Builder | Creates a  JarSigner.Builderobject with aKeyStore.PrivateKeyEntryobject. | 
| Builder | Creates a  JarSigner.Builderobject with a private key and a certification path. | 
| Modifier and Type | Method | Description | 
|---|---|---|
| JarSigner | build() | Builds a  JarSignerobject from the parameters set by the setter methods. | 
| JarSigner.Builder | digestAlgorithm | Sets the digest algorithm. | 
| JarSigner.Builder | digestAlgorithm | Sets the digest algorithm from the specified provider. | 
| JarSigner.Builder | eventHandler | Sets en event handler that will be triggered when a  JarEntryis to be added, signed, or updated during the signing process. | 
| static String | getDefaultDigestAlgorithm() | Gets the default digest algorithm. | 
| static String | getDefaultSignatureAlgorithm | Gets the default signature algorithm for a private key. | 
| JarSigner.Builder | setProperty | Sets an additional implementation-specific property indicated by the specified key. | 
| JarSigner.Builder | signatureAlgorithm | Sets the signature algorithm. | 
| JarSigner.Builder | signatureAlgorithm | Sets the signature algorithm from the specified provider. | 
| JarSigner.Builder | signerName | Sets the signer name. | 
| JarSigner.Builder | tsa | Sets the URI of the Time Stamping Authority (TSA). | 
public Builder(KeyStore.PrivateKeyEntry entry)
JarSigner.Builder object with a KeyStore.PrivateKeyEntry object.entry - the KeyStore.PrivateKeyEntry of the signer.public Builder(PrivateKey privateKey, CertPath certPath)
JarSigner.Builder object with a private key and a certification path.privateKey - the private key of the signer.certPath - the certification path of the signer.IllegalArgumentException - if certPath is empty, or the privateKey algorithm does not match the algorithm of the PublicKey in the end entity certificate (the first certificate in certPath).public JarSigner.Builder digestAlgorithm(String algorithm) throws NoSuchAlgorithmException
getDefaultDigestAlgorithm() will be used.algorithm - the standard name of the algorithm. See the MessageDigest section in the  Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard algorithm names.JarSigner.Builder itself.NoSuchAlgorithmException - if algorithm is not available.public JarSigner.Builder digestAlgorithm(String algorithm, Provider provider) throws NoSuchAlgorithmException
getDefaultDigestAlgorithm() will be used.algorithm - the standard name of the algorithm. See the MessageDigest section in the  Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard algorithm names.provider - the provider.JarSigner.Builder itself.NoSuchAlgorithmException - if algorithm is not available in the specified provider.public JarSigner.Builder signatureAlgorithm(String algorithm) throws NoSuchAlgorithmException
getDefaultSignatureAlgorithm(java.security.PrivateKey) for the private key will be used.algorithm - the standard name of the algorithm. See the Signature section in the  Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard algorithm names.JarSigner.Builder itself.NoSuchAlgorithmException - if algorithm is not available.IllegalArgumentException - if algorithm is not compatible with the algorithm of the signer's private key.public JarSigner.Builder signatureAlgorithm(String algorithm, Provider provider) throws NoSuchAlgorithmException
getDefaultSignatureAlgorithm(java.security.PrivateKey) for the private key will be used.algorithm - the standard name of the algorithm. See the Signature section in the  Java Cryptography Architecture Standard Algorithm Name Documentation for information about standard algorithm names.provider - the provider.JarSigner.Builder itself.NoSuchAlgorithmException - if algorithm is not available in the specified provider.IllegalArgumentException - if algorithm is not compatible with the algorithm of the signer's private key.public JarSigner.Builder tsa(URI uri)
uri - the URI.JarSigner.Builder itself.public JarSigner.Builder signerName(String name)
name - the signer name.JarSigner.Builder itself.IllegalArgumentException - if name is empty or has a size bigger than 8, or it contains characters not from the set "a-zA-Z0-9_-".public JarSigner.Builder eventHandler(BiConsumer<String,String> handler)
JarEntry is to be added, signed, or updated during the signing process.  The handler can be used to display signing progress. The first argument of the handler can be "adding", "signing", or "updating", and the second argument is the name of the JarEntry being processed.
handler - the event handler.JarSigner.Builder itself.public JarSigner.Builder setProperty(String key, String value)
getDefaultDigestAlgorithm(). key - the name of the property.value - the value of the property.JarSigner.Builder itself.UnsupportedOperationException - if the key is not supported by this implementation.IllegalArgumentException - if the value is not accepted as a legal value for this key.public static String getDefaultDigestAlgorithm()
public static String getDefaultSignatureAlgorithm(PrivateKey key)
key - the private key.signatureAlgorithm(java.lang.String) must be called to specify a signature algorithm. Otherwise, the build() method will throw an IllegalArgumentException.public JarSigner build()
JarSigner object from the parameters set by the setter methods.  This method does not modify internal state of this Builder object and can be called multiple times to generate multiple JarSigner objects. After this method is called, calling any method on this Builder will have no effect on the newly built JarSigner object.
JarSigner object.IllegalArgumentException - if a signature algorithm is not set and cannot be derived from the private key using the getDefaultSignatureAlgorithm(java.security.PrivateKey) method.
    © 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
    https://docs.oracle.com/en/java/javase/21/docs/api/jdk.jartool/jdk/security/jarsigner/JarSigner.Builder.html