Class JarsignerSignMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
- Since:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interfaceThread.sleep(long millis) interface to make testing easier(package private) static interfaceWait/sleep after a signing failure before the next re-try should happen. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate FileLocation of the extra certificate chain file.private StringSee options.private static final intExponent limit for exponential wait after failure function.private intMaximum delay, in seconds, to wait after a failed attempt before re-trying.private intHow many times to try to sign a jar (assuming each previous attempt is a failure).private booleanIndicates whether existing signatures should be removed from the processed JAR files prior to signing them.private StringSee options.private intMaximum number of parallel threads to use when signing jar files.private String[]URL(s) to Time Stamping Authority (TSA) server(s) to use to timestamp the signing.private String[]Alias(es) for certificate(s) in the active keystore used to find a TSA URL.private StringThe message digest algorithm to use in the messageImprint that the TSA server will timestamp.private String[]OID(s) to send to the TSA server to identify the policy ID the server should use.private TsaSelectorprivate JarsignerSignMojo.WaitStrategyCurrent WaitStrategy, to allow for sleeping after a signing failure.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.maven.shared.jarsigner.JarSignerRequestcreateRequest(File archive) Creates the jar signer request to be executed.private voiddefaultWaitStrategy(int attempt, Duration maxRetryDelay) protected voidexecuteJarSigner(org.apache.maven.shared.jarsigner.JarSigner jarSigner, org.apache.maven.shared.jarsigner.JarSignerRequest request) Executes jarsigner (execute signing or verification for a jar file).protected StringgetCommandlineInfo(org.apache.maven.shared.utils.cli.Commandline commandLine) Gets a string representation of aCommandline.protected voidpreProcessArchive(File archive) Pre-processes a given archive.protected voidprocessArchives(List<File> archives) Process (sign/verify) a list of archives.(package private) voidsetWaitStrategy(JarsignerSignMojo.WaitStrategy waitStrategy) Set current WaitStrategy.private voidupdateJarSignerRequestWithTsa(org.apache.maven.shared.jarsigner.JarSignerSignRequest request, TsaSelector.TsaServer tsaServer) Modifies JarSignerRequest with TSA parametersprotected voidValidate the user supplied configuration/parameters.(package private) voidwaitAfterFailure(int attempt, Duration maxRetryDelay, JarsignerSignMojo.Sleeper sleeper) Package private for testingMethods inherited from class org.apache.maven.plugins.jarsigner.AbstractJarsignerMojo
decrypt, execute, getMessage, getStorepass, getStoretype, processArchiveMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
keypass
See options. -
sigfile
See options. -
removeExistingSignatures
@Parameter(property="jarsigner.removeExistingSignatures", defaultValue="false") private boolean removeExistingSignaturesIndicates whether existing signatures should be removed from the processed JAR files prior to signing them. If enabled, the resulting JAR will appear as being signed only once.- Since:
- 1.1
-
tsa
URL(s) to Time Stamping Authority (TSA) server(s) to use to timestamp the signing. See options. Separate multiple TSA URLs with comma (without space) or a nested XML tag.
<configuration> <tsa>http://timestamp.digicert.com,http://timestamp.globalsign.com/tsa/r6advanced1</tsa> </configuration><configuration> <tsa> <url>http://timestamp.digicert.com</url> <url>http://timestamp.globalsign.com/tsa/r6advanced1</url> </tsa> </configuration>Usage of multiple TSA servers only makes sense when
maxTriesis more than 1. A different TSA server will only be used at retries.Changed to a list since 3.1.0. Single XML element (without comma) is still supported.
- Since:
- 1.3
-
tsacert
Alias(es) for certificate(s) in the active keystore used to find a TSA URL. From the certificate the X509v3 extension "Subject Information Access" field is examined to find the TSA server URL. See options. Separate multiple aliases with comma (without space) or a nested XML tag.
<configuration> <tsacert>alias1,alias2</tsacert> </configuration><configuration> <tsacert> <alias>alias1</alias> <alias>alias2</alias> </tsacert> </configuration>Should not be used at the same time as the
tsaparameter (because jarsigner will typically ignore tsacert, if tsa is set).Usage of multiple aliases only makes sense when
maxTriesis more than 1. A different TSA server will only be used at retries.Changed to a list since 3.1.0. Single XML element (without comma) is still supported.
- Since:
- 1.3
-
tsapolicyid
OID(s) to send to the TSA server to identify the policy ID the server should use. If not specified TSA server will choose a default policy ID. Each TSA server vendor will typically define their own policy OIDs. See options. Separate multiple OIDs with comma (without space) or a nested XML tag.
<configuration> <tsapolicyid>1.3.6.1.4.1.4146.2.3.1.2,2.16.840.1.114412.7.1</tsapolicyid> </configuration><configuration> <tsapolicyid> <oid>1.3.6.1.4.1.4146.2.3.1.2</oid> <oid>2.16.840.1.114412.7.1</oid> </tsapolicyid> </configuration>If used, the number of OIDs should be the same as the number of elements in
tsaortsacert. The first OID will be used for the first TSA server, the second OID for the second TSA server and so on.- Since:
- 3.1.0
-
tsadigestalg
The message digest algorithm to use in the messageImprint that the TSA server will timestamp. A default value (for exampleSHA-384) will be selected by jarsigner if this parameter is not set. Only available in Java 11 and later. See options.- Since:
- 3.1.0
-
certchain
Location of the extra certificate chain file. See options.- Since:
- 1.5
-
maxTries
@Parameter(property="jarsigner.maxTries", defaultValue="1") private int maxTriesHow many times to try to sign a jar (assuming each previous attempt is a failure). This option may be desirable if any network operations are used during signing, for example using a Time Stamp Authority or network based PKCS11 HSM solution for storing code signing keys. The default value of 1 indicates that no retries should be made.- Since:
- 3.1.0
-
maxRetryDelaySeconds
@Parameter(property="jarsigner.maxRetryDelaySeconds", defaultValue="0") private int maxRetryDelaySecondsMaximum delay, in seconds, to wait after a failed attempt before re-trying. The delay after a failed attempt follows an exponential backoff strategy, with increasing delay times.- Since:
- 3.1.0
-
threadCount
@Parameter(property="jarsigner.threadCount", defaultValue="1") private int threadCountMaximum number of parallel threads to use when signing jar files. Increases performance when signing multiple jar files, especially when network operations are used during signing, for example when using a Time Stamp Authority or network based PKCS11 HSM solution for storing code signing keys. Note: the logging from the signing process will be interleaved, and harder to read, when using many threads.- Since:
- 3.1.0
-
waitStrategy
Current WaitStrategy, to allow for sleeping after a signing failure. -
tsaSelector
-
MAX_WAIT_EXPONENT_ATTEMPT
private static final int MAX_WAIT_EXPONENT_ATTEMPTExponent limit for exponential wait after failure function. 2^20 = 1048576 sec ~= 12 days.- See Also:
-
-
Constructor Details
-
JarsignerSignMojo
public JarsignerSignMojo()
-
-
Method Details
-
preProcessArchive
protected void preProcessArchive(File archive) throws org.apache.maven.plugin.MojoExecutionException Description copied from class:AbstractJarsignerMojoPre-processes a given archive.- Overrides:
preProcessArchivein classAbstractJarsignerMojo- Parameters:
archive- The archive to process, must not benull.- Throws:
org.apache.maven.plugin.MojoExecutionException- if pre-processing failed
-
validateParameters
protected void validateParameters() throws org.apache.maven.plugin.MojoExecutionExceptionDescription copied from class:AbstractJarsignerMojoValidate the user supplied configuration/parameters.- Overrides:
validateParametersin classAbstractJarsignerMojo- Throws:
org.apache.maven.plugin.MojoExecutionException- if the user supplied configuration make further execution impossible
-
createRequest
protected org.apache.maven.shared.jarsigner.JarSignerRequest createRequest(File archive) throws org.apache.maven.plugin.MojoExecutionException Creates the jar signer request to be executed.- Specified by:
createRequestin classAbstractJarsignerMojo- Parameters:
archive- the archive file to treat by jarsigner- Returns:
- the request
- Throws:
org.apache.maven.plugin.MojoExecutionException- if an exception occurs
-
processArchives
protected void processArchives(List<File> archives) throws org.apache.maven.plugin.MojoExecutionException Process (sign/verify) a list of archives. Processing of files may be parallelized for increased performance.- Overrides:
processArchivesin classAbstractJarsignerMojo- Parameters:
archives- list of jar files to process- Throws:
org.apache.maven.plugin.MojoExecutionException- if an error occurs during the processing of archives
-
setWaitStrategy
Set current WaitStrategy. Package private for testing. -
defaultWaitStrategy
private void defaultWaitStrategy(int attempt, Duration maxRetryDelay) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
waitAfterFailure
void waitAfterFailure(int attempt, Duration maxRetryDelay, JarsignerSignMojo.Sleeper sleeper) throws org.apache.maven.plugin.MojoExecutionException Package private for testing- Throws:
org.apache.maven.plugin.MojoExecutionException