public class SignJar extends AbstractJarSignerTask
| Modifier and Type | Field and Description | 
|---|---|
| protected File | destDirthe output directory when using paths. | 
| static String | ERROR_BAD_MAPerror string for unit test verification: "Cannot map source file to anything sensible: " | 
| static String | ERROR_MAPPER_WITHOUT_DESTerror string for unit test verification: "The destDir attribute is required if a mapper is set" | 
| static String | ERROR_NO_ALIASerror string for unit test verification: "alias attribute must be set" | 
| static String | ERROR_NO_STOREPASSerror string for unit test verification: "storepass attribute must be set" | 
| static String | ERROR_SIGNEDJAR_AND_PATHSerror string for unit test verification "You cannot specify the signed JAR when using paths or filesets" | 
| static String | ERROR_TODIR_AND_SIGNEDJARerror string for unit test verification: "\'destdir\' and \'signedjar\' cannot both be set" | 
| static String | ERROR_TOO_MANY_MAPPERSerror string for unit test verification: "Too many mappers" | 
| protected boolean | internalsfflag for internal sf signing | 
| protected boolean | lazyWhether to assume a jar which has an appropriate .SF file in is already
 signed. | 
| protected boolean | sectionsonlysign sections only? | 
| protected String | sigfilename to a signature file | 
| protected File | signedjarname of a single jar | 
| protected String | tsacertalias for the TSA in the keystore | 
| protected String | tsaproxyhostProxy host to be used when connecting to TSA server | 
| protected String | tsaproxyportProxy port to be used when connecting to TSA server | 
| protected String | tsaurlURL for a tsa; null implies no tsa support | 
alias, ERROR_NO_SOURCE, filesets, jar, JARSIGNER_COMMAND, keypass, keystore, maxMemory, storepass, storetype, strict, verbose| Constructor and Description | 
|---|
| SignJar() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | add(FileNameMapper newMapper)add a mapper to determine file naming policy. | 
| void | execute()sign the jar(s) | 
| String | getDigestAlg()Digest Algorithm; optional | 
| FileNameMapper | getMapper()get the active mapper; may be null | 
| String | getSigAlg()Signature Algorithm; optional | 
| String | getTsacert()get the -tsacert option | 
| String | getTsaproxyhost()Get the proxy host to be used when connecting to the TSA url | 
| String | getTsaproxyport()Get the proxy host to be used when connecting to the TSA url | 
| String | getTsaurl()get the -tsaurl url | 
| boolean | isForce()Should the task force signing of a jar even it is already
 signed? | 
| protected boolean | isSigned(File file)test for a file being signed, by looking for a signature in the META-INF
 directory with our alias/sigfile. | 
| protected boolean | isUpToDate(File jarFile,
          File signedjarFile)Compare a jar file with its corresponding signed jar. | 
| void | setDestDir(File destDir)Optionally sets the output directory to be used. | 
| void | setDigestAlg(String digestAlg)Digest Algorithm; optional | 
| void | setForce(boolean b)Whether to force signing of a jar even it is already signed. | 
| void | setInternalsf(boolean internalsf)Flag to include the .SF file inside the signature; optional; default
 false | 
| void | setLazy(boolean lazy)flag to control whether the presence of a signature file means a JAR is
 signed; optional, default false | 
| void | setPreserveLastModified(boolean preserveLastModified)true to indicate that the signed jar modification date remains the same
 as the original. | 
| void | setSectionsonly(boolean sectionsonly)flag to compute hash of entire manifest; optional, default false | 
| void | setSigAlg(String sigAlg)Signature Algorithm; optional | 
| void | setSigfile(String sigfile)name of .SF/.DSA file; optional | 
| void | setSignedjar(File signedjar)name of signed JAR file; optional | 
| void | setTsacert(String tsacert)set the alias in the keystore of the TSA to use; | 
| void | setTsaproxyhost(String tsaproxyhost) | 
| void | setTsaproxyport(String tsaproxyport) | 
| void | setTsaurl(String tsaurl) | 
addFileset, addSysproperty, addValue, beginExecution, bindToKeystore, createJarSigner, createPath, createUnifiedSourcePath, createUnifiedSources, declareSysProperty, endExecution, getRedirector, hasResources, setAlias, setCommonOptions, setExecutable, setJar, setKeypass, setKeystore, setMaxmemory, setStorepass, setStoretype, setStrict, setVerbosebindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeclone, getDescription, getLocation, getProject, setDescription, setLocation, setProjectprotected File destDir
public static final String ERROR_BAD_MAP
public static final String ERROR_MAPPER_WITHOUT_DEST
public static final String ERROR_NO_ALIAS
public static final String ERROR_NO_STOREPASS
public static final String ERROR_SIGNEDJAR_AND_PATHS
public static final String ERROR_TODIR_AND_SIGNEDJAR
public static final String ERROR_TOO_MANY_MAPPERS
protected boolean internalsf
protected boolean lazy
protected boolean sectionsonly
protected String sigfile
protected File signedjar
protected String tsacert
protected String tsaproxyhost
protected String tsaproxyport
protected String tsaurl
public void add(FileNameMapper newMapper)
newMapper - the mapper to add.public void execute()
             throws BuildException
execute in class TaskBuildException - on errorspublic String getDigestAlg()
public FileNameMapper getMapper()
public String getSigAlg()
public String getTsacert()
public String getTsaproxyhost()
public String getTsaproxyport()
public String getTsaurl()
public boolean isForce()
protected boolean isSigned(File file)
file - the file to be checkedIsSigned.isSigned(File, String)protected boolean isUpToDate(File jarFile, File signedjarFile)
Compare 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.
jarFile - the unsigned jar filesignedjarFile - the result signed jar filepublic void setDestDir(File destDir)
destDir - the directory in which to place signed jarspublic void setDigestAlg(String digestAlg)
digestAlg - the digest algorithmpublic void setForce(boolean b)
public void setInternalsf(boolean internalsf)
internalsf - if true include the .SF file inside the signaturepublic void setLazy(boolean lazy)
lazy - flag to control whether the presence of a signaturepublic void setPreserveLastModified(boolean preserveLastModified)
preserveLastModified - if true preserve the last modified timepublic void setSectionsonly(boolean sectionsonly)
sectionsonly - flag to compute hash of entire manifestpublic void setSigAlg(String sigAlg)
sigAlg - the signature algorithmpublic void setSigfile(String sigfile)
sigfile - the name of the .SF/.DSA filepublic void setSignedjar(File signedjar)
signedjar - the name of the signed jar filepublic void setTsacert(String tsacert)
tsacert - the cert alias.public void setTsaproxyhost(String tsaproxyhost)
tsaproxyhost - the proxy host to be used when connecting to the TSA.public void setTsaproxyport(String tsaproxyport)
tsaproxyport - the proxy port to be used when connecting to the TSA.public void setTsaurl(String tsaurl)
tsaurl - the tsa url.