public class AuthenticodeSigner extends Object
| Constructor and Description |
|---|
AuthenticodeSigner(Certificate[] chain,
PrivateKey privateKey)
Create a signer with the specified certificate chain and private key.
|
AuthenticodeSigner(KeyStore keystore,
String alias,
String password)
Create a signer with a certificate chain and private key from the specified keystore.
|
| Modifier and Type | Method and Description |
|---|---|
void |
sign(Signable file)
Sign the specified file.
|
AuthenticodeSigner |
withDigestAlgorithm(DigestAlgorithm algorithm)
Set the digest algorithm to use (SHA-256 by default)
|
AuthenticodeSigner |
withProgramName(String programName)
Set the program name embedded in the signature.
|
AuthenticodeSigner |
withProgramURL(String programURL)
Set the program URL embedded in the signature.
|
AuthenticodeSigner |
withSignatureAlgorithm(String signatureAlgorithm)
Explicitly sets the signature algorithm to use.
|
AuthenticodeSigner |
withSignatureAlgorithm(String signatureAlgorithm,
Provider signatureProvider)
Explicitly sets the signature algorithm and provider to use.
|
AuthenticodeSigner |
withSignatureAlgorithm(String signatureAlgorithm,
String signatureProvider)
Explicitly sets the signature algorithm and provider to use.
|
AuthenticodeSigner |
withSignatureProvider(Provider signatureProvider)
Set the signature provider to use.
|
AuthenticodeSigner |
withSignaturesReplaced(boolean replace)
Enable or disable the replacement of the previous signatures (disabled by default).
|
AuthenticodeSigner |
withTimestamper(Timestamper timestamper)
Set the Timestamper implementation.
|
AuthenticodeSigner |
withTimestamping(boolean timestamping)
Enable or disable the timestamping (enabled by default).
|
AuthenticodeSigner |
withTimestampingAuthority(String... urls)
Set the URLs of the timestamping authorities.
|
AuthenticodeSigner |
withTimestampingAuthority(String url)
Set the URL of the timestamping authority.
|
AuthenticodeSigner |
withTimestampingMode(TimestampingMode tsmode)
RFC3161 or Authenticode (Authenticode by default).
|
AuthenticodeSigner |
withTimestampingRetries(int timestampingRetries)
Set the number of retries for timestamping.
|
AuthenticodeSigner |
withTimestampingRetryWait(int timestampingRetryWait)
Set the number of seconds to wait between timestamping retries.
|
public AuthenticodeSigner(Certificate[] chain, PrivateKey privateKey)
chain - the certificate chain. The first certificate is the signing certificateprivateKey - the private keyIllegalArgumentException - if the chain is emptypublic AuthenticodeSigner(KeyStore keystore, String alias, String password) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException
keystore - the keystore holding the certificate and the private keyalias - the alias of the certificate in the keystorepassword - the password to get the private keyKeyStoreException - if the keystore has not been initialized (loaded).NoSuchAlgorithmException - if the algorithm for recovering the key cannot be foundUnrecoverableKeyException - if the key cannot be recovered (e.g., the given password is wrong).public void sign(Signable file) throws Exception
file - the file to signException - if signing failspublic AuthenticodeSigner withDigestAlgorithm(DigestAlgorithm algorithm)
algorithm - the digest algorithmpublic AuthenticodeSigner withProgramName(String programName)
programName - the program namepublic AuthenticodeSigner withProgramURL(String programURL)
programURL - the program URLpublic AuthenticodeSigner withSignatureAlgorithm(String signatureAlgorithm)
signatureAlgorithm - the signature algorithmpublic AuthenticodeSigner withSignatureAlgorithm(String signatureAlgorithm, Provider signatureProvider)
signatureAlgorithm - the signature algorithmsignatureProvider - the security provider for the specified algorithmpublic AuthenticodeSigner withSignatureAlgorithm(String signatureAlgorithm, String signatureProvider)
signatureAlgorithm - the signature algorithmsignatureProvider - the security provider for the specified algorithmpublic AuthenticodeSigner withSignatureProvider(Provider signatureProvider)
signatureProvider - the security provider for the signature algorithmpublic AuthenticodeSigner withSignaturesReplaced(boolean replace)
replace - true if the new signature should replace the existing ones, false to append itpublic AuthenticodeSigner withTimestamper(Timestamper timestamper)
timestamper - the timestamper implementation to usepublic AuthenticodeSigner withTimestamping(boolean timestamping)
timestamping - true to enable timestamping, false to disable itpublic AuthenticodeSigner withTimestampingAuthority(String... urls)
urls - the URLs of the timestamping authoritiespublic AuthenticodeSigner withTimestampingAuthority(String url)
url - the URL of the timestamping authoritypublic AuthenticodeSigner withTimestampingMode(TimestampingMode tsmode)
tsmode - the timestamping modepublic AuthenticodeSigner withTimestampingRetries(int timestampingRetries)
timestampingRetries - the number of retriespublic AuthenticodeSigner withTimestampingRetryWait(int timestampingRetryWait)
timestampingRetryWait - the wait time between retries (in seconds)Copyright © 2012–2020. All rights reserved.