Package org.apache.tools.ant.taskdefs
Class SignJar
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.AbstractJarSignerTask
org.apache.tools.ant.taskdefs.SignJar
- All Implemented Interfaces:
- Cloneable
Signs JAR or ZIP files with the javasign command line tool. The tool detailed
 dependency checking: files are only signed if they are not signed. The
 
signjar attribute can point to the file to generate; if this file
 exists then its modification date is used as a cue as to whether to resign
 any JAR file.
 Timestamp signature support is based on Java 8- Since:
- Ant 1.1
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected Filethe output directory when using paths.static final Stringerror string for unit test verification: "Cannot map source file to anything sensible: "static final Stringerror string for unit test verification: "The destDir attribute is required if a mapper is set"static final Stringerror string for unit test verification: "alias attribute must be set"static final Stringerror string for unit test verification: "storepass attribute must be set"static final Stringerror string for unit test verification "You cannot specify the signed JAR when using paths or filesets"static final Stringerror string for unit test verification: "\'destdir\' and \'signedjar\' cannot both be set"static final Stringerror string for unit test verification: "Too many mappers"protected booleanflag for internal sf signingprotected booleanWhether to assume a jar which has an appropriate .SF file in is already signed.protected booleansign sections only?protected Stringname to a signature fileprotected Filename of a single jarprotected Stringalias for the TSA in the keystoreprotected StringProxy host to be used when connecting to TSA serverprotected StringProxy port to be used when connecting to TSA serverprotected StringURL for a tsa; null implies no tsa supportFields inherited from class org.apache.tools.ant.taskdefs.AbstractJarSignerTaskalias, ERROR_NO_SOURCE, filesets, jar, JARSIGNER_COMMAND, keypass, keystore, maxMemory, storepass, storetype, strict, verboseFields inherited from class org.apache.tools.ant.ProjectComponentdescription, location, project
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidadd(FileNameMapper newMapper) add a mapper to determine file naming policy.voidexecute()sign the jar(s)Digest Algorithm; optionalget the active mapper; may be nullSignature Algorithm; optionalget the -tsacert optionTSA Digest Algorithm; optionalGet the proxy host to be used when connecting to the TSA urlGet the proxy host to be used when connecting to the TSA urlget the -tsaurl urlbooleanisForce()Should the task force signing of a jar even it is already signed?protected booleantest for a file being signed, by looking for a signature in the META-INF directory with our alias/sigfile.protected booleanisUpToDate(File jarFile, File signedjarFile) Compare a jar file with its corresponding signed jar.voidsetDestDir(File destDir) Optionally sets the output directory to be used.voidsetDigestAlg(String digestAlg) Digest Algorithm; optionalvoidsetForce(boolean b) Whether to force signing of a jar even it is already signed.voidsetInternalsf(boolean internalsf) Flag to include the .SF file inside the signature; optional; default falsevoidsetLazy(boolean lazy) flag to control whether the presence of a signature file means a JAR is signed; optional, default falsevoidsetPreserveLastModified(boolean preserveLastModified) true to indicate that the signed jar modification date remains the same as the original.voidsetSectionsonly(boolean sectionsonly) flag to compute hash of entire manifest; optional, default falsevoidSignature Algorithm; optionalvoidsetSigfile(String sigfile) name of .SF/.DSA file; optionalvoidsetSignedjar(File signedjar) name of signed JAR file; optionalvoidsetTsacert(String tsacert) set the alias in the keystore of the TSA to use;voidsetTSADigestAlg(String digestAlg) TSA Digest Algorithm; optionalvoidsetTsaproxyhost(String tsaproxyhost) voidsetTsaproxyport(String tsaproxyport) voidMethods inherited from class org.apache.tools.ant.taskdefs.AbstractJarSignerTaskaddArg, addArgument, addFileset, addSysproperty, addValue, beginExecution, bindToKeystore, createJarSigner, createPath, createUnifiedSourcePath, createUnifiedSources, declareSysProperty, endExecution, getRedirector, hasResources, setAlias, setCommonOptions, setExecutable, setJar, setKeypass, setKeystore, setMaxmemory, setProviderArg, setProviderClass, setProviderName, setStorepass, setStoretype, setStrict, setVerboseMethods inherited from class org.apache.tools.ant.TaskbindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeMethods inherited from class org.apache.tools.ant.ProjectComponentclone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
- 
Field Details- 
ERROR_TODIR_AND_SIGNEDJARerror string for unit test verification: "\'destdir\' and \'signedjar\' cannot both be set"- See Also:
 
- 
ERROR_TOO_MANY_MAPPERSerror string for unit test verification: "Too many mappers"- See Also:
 
- 
ERROR_SIGNEDJAR_AND_PATHSerror string for unit test verification "You cannot specify the signed JAR when using paths or filesets"- See Also:
 
- 
ERROR_BAD_MAPerror string for unit test verification: "Cannot map source file to anything sensible: "- See Also:
 
- 
ERROR_MAPPER_WITHOUT_DESTerror string for unit test verification: "The destDir attribute is required if a mapper is set"- See Also:
 
- 
ERROR_NO_ALIASerror string for unit test verification: "alias attribute must be set"- See Also:
 
- 
ERROR_NO_STOREPASSerror string for unit test verification: "storepass attribute must be set"- See Also:
 
- 
sigfilename to a signature file
- 
signedjarname of a single jar
- 
internalsfprotected boolean internalsfflag for internal sf signing
- 
sectionsonlyprotected boolean sectionsonlysign sections only?
- 
lazyprotected boolean lazyWhether to assume a jar which has an appropriate .SF file in is already signed.
- 
destDirthe output directory when using paths.
- 
tsaurlURL for a tsa; null implies no tsa support
- 
tsaproxyhostProxy host to be used when connecting to TSA server
- 
tsaproxyportProxy port to be used when connecting to TSA server
- 
tsacertalias for the TSA in the keystore
 
- 
- 
Constructor Details- 
SignJarpublic SignJar()
 
- 
- 
Method Details- 
setSigfilename of .SF/.DSA file; optional- Parameters:
- sigfile- the name of the .SF/.DSA file
 
- 
setSignedjarname of signed JAR file; optional- Parameters:
- signedjar- the name of the signed jar file
 
- 
setInternalsfpublic void setInternalsf(boolean internalsf) Flag to include the .SF file inside the signature; optional; default false- Parameters:
- internalsf- if true include the .SF file inside the signature
 
- 
setSectionsonlypublic void setSectionsonly(boolean sectionsonly) flag to compute hash of entire manifest; optional, default false- Parameters:
- sectionsonly- flag to compute hash of entire manifest
 
- 
setLazypublic void setLazy(boolean lazy) flag to control whether the presence of a signature file means a JAR is signed; optional, default false- Parameters:
- lazy- flag to control whether the presence of a signature
 
- 
setDestDirOptionally sets the output directory to be used.- Parameters:
- destDir- the directory in which to place signed jars
- Since:
- Ant 1.7
 
- 
addadd a mapper to determine file naming policy. Only used with toDir processing.- Parameters:
- newMapper- the mapper to add.
- Since:
- Ant 1.7
 
- 
getMapperget the active mapper; may be null- Returns:
- mapper or null
- Since:
- Ant 1.7
 
- 
getTsaurlget the -tsaurl url- Returns:
- url or null
- Since:
- Ant 1.7
 
- 
setTsaurl- Parameters:
- tsaurl- the tsa url.
- Since:
- Ant 1.7
 
- 
getTsaproxyhostGet the proxy host to be used when connecting to the TSA url- Returns:
- url or null
- Since:
- Ant 1.9.5
 
- 
setTsaproxyhost- Parameters:
- tsaproxyhost- the proxy host to be used when connecting to the TSA.
- Since:
- Ant 1.9.5
 
- 
getTsaproxyportGet the proxy host to be used when connecting to the TSA url- Returns:
- url or null
- Since:
- Ant 1.9.5
 
- 
setTsaproxyport- Parameters:
- tsaproxyport- the proxy port to be used when connecting to the TSA.
- Since:
- Ant 1.9.5
 
- 
getTsacertget the -tsacert option- Returns:
- a certificate alias or null
- Since:
- Ant 1.7
 
- 
setTsacertset the alias in the keystore of the TSA to use;- Parameters:
- tsacert- the cert alias.
 
- 
setForcepublic void setForce(boolean b) Whether to force signing of a jar even it is already signed.- Parameters:
- b- boolean
- Since:
- Ant 1.8.0
 
- 
isForcepublic boolean isForce()Should the task force signing of a jar even it is already signed?- Returns:
- boolean
- Since:
- Ant 1.8.0
 
- 
setSigAlgSignature Algorithm; optional- Parameters:
- sigAlg- the signature algorithm
 
- 
getSigAlgSignature Algorithm; optional- Returns:
- String
 
- 
setDigestAlgDigest Algorithm; optional- Parameters:
- digestAlg- the digest algorithm
 
- 
getDigestAlgDigest Algorithm; optional- Returns:
- String
 
- 
setTSADigestAlgTSA Digest Algorithm; optional- Parameters:
- digestAlg- the tsa digest algorithm
- Since:
- Ant 1.10.2
 
- 
getTSADigestAlgTSA Digest Algorithm; optional- Returns:
- String
- Since:
- Ant 1.10.2
 
- 
executesign the jar(s)- Overrides:
- executein class- Task
- Throws:
- BuildException- on errors
 
- 
isUpToDateCompare a jar file with its corresponding signed jar. The logic for this is complex, and best explained in the source itself. Essentially if either file doesn't exist, or the destfile has an out of date timestamp, then the return value is false. If we are signing ourself, the check isSigned(File)is used to trigger the process.- Parameters:
- jarFile- the unsigned jar file
- signedjarFile- the result signed jar file
- Returns:
- true if the signedjarFile is considered up to date
 
- 
isSignedtest for a file being signed, by looking for a signature in the META-INF directory with our alias/sigfile.- Parameters:
- file- the file to be checked
- Returns:
- true if the file is signed
- See Also:
 
- 
setPreserveLastModifiedpublic void setPreserveLastModified(boolean preserveLastModified) true to indicate that the signed jar modification date remains the same as the original. Defaults to false- Parameters:
- preserveLastModified- if true preserve the last modified time
 
 
-