You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

signjar.html 6.9 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  5. <title>SignJar Task</title>
  6. </head>
  7. <body>
  8. <h2><a name="signjar">SignJar</a></h2>
  9. <h3>Description</h3>
  10. <p>Signs JAR files with the <tt>jarsigner</tt> command line tool.
  11. It will take a named file in the <tt>jar</tt> attribute, and an optional
  12. <tt>destDir</tt> or <tt>signedJar</tt> attribute. Nested filesets are also
  13. supported; here only an (optional) <tt>destDir</tt> is allowed. If a destination
  14. directory or explicit JAR file name is not provided, JARs are signed in place.
  15. </p>
  16. <p>
  17. Dependency rules
  18. </p>
  19. <ul>
  20. <li>Nonexistent destination JARs are created/signed</li>
  21. <li>Out of date destination JARs are created/signed</li>
  22. <li>If a destination file and a source file are the same,
  23. and <tt>lazy</tt> is true, the JAR is only signed if it does not
  24. contain a signature by this alias.</li>
  25. <li>If a destination file and a source file are the same,
  26. and <tt>lazy</tt> is false, the JAR is signed.</li>
  27. </ul>
  28. <h3>Parameters</h3>
  29. <table border="1" cellpadding="2" cellspacing="0">
  30. <tr>
  31. <td valign="top"><b>Attribute</b></td>
  32. <td valign="top"><b>Description</b></td>
  33. <td align="center" valign="top"><b>Required</b></td>
  34. </tr>
  35. <tr>
  36. <td valign="top">jar</td>
  37. <td valign="top">the jar file to sign</td>
  38. <td valign="top" align="center">Yes, unless nested filesets have
  39. been used.</td>
  40. </tr>
  41. <tr>
  42. <td valign="top">alias</td>
  43. <td valign="top">the alias to sign under</td>
  44. <td valign="top" align="center">Yes.</td>
  45. </tr>
  46. <tr>
  47. <td valign="top">storepass</td>
  48. <td valign="top">password for keystore integrity.</td>
  49. <td valign="top" align="center">Yes.</td>
  50. </tr>
  51. <tr>
  52. <td valign="top">keystore</td>
  53. <td valign="top">keystore location</td>
  54. <td valign="top" align="center">No</td>
  55. </tr>
  56. <tr>
  57. <td valign="top">storetype</td>
  58. <td valign="top">keystore type</td>
  59. <td valign="top" align="center">No</td>
  60. </tr>
  61. <tr>
  62. <td valign="top">keypass</td>
  63. <td valign="top">password for private key (if different)</td>
  64. <td valign="top" align="center">No</td>
  65. </tr>
  66. <tr>
  67. <td valign="top">sigfile</td>
  68. <td valign="top">name of .SF/.DSA file</td>
  69. <td valign="top" align="center">No</td>
  70. </tr>
  71. <tr>
  72. <td valign="top">signedjar</td>
  73. <td valign="top">name of signed JAR file. This can only be set when
  74. the <tt>jar</tt> attribute is set.</td>
  75. <td valign="top" align="center">No.</td>
  76. </tr>
  77. <tr>
  78. <td valign="top">verbose</td>
  79. <td valign="top">(true | false) verbose output when signing</td>
  80. <td valign="top" align="center">No; default false</td>
  81. </tr>
  82. <tr>
  83. <td valign="top">internalsf</td>
  84. <td valign="top">(true | false) include the .SF file inside the signature
  85. block</td>
  86. <td valign="top" align="center">No; default false</td>
  87. </tr>
  88. <tr>
  89. <td valign="top">sectionsonly</td>
  90. <td valign="top">(true | false) don't compute hash of entire manifest</td>
  91. <td valign="top" align="center">No; default false</td>
  92. </tr>
  93. <tr>
  94. <td valign="top">lazy</td>
  95. <td valign="top">flag to control whether the presence of a signature
  96. file means a JAR is signed. This is only used when the target JAR matches
  97. the source JAR</td>
  98. <td valign="top" align="center">No; default false</td>
  99. </tr>
  100. <tr>
  101. <td valign="top">maxmemory</td>
  102. <td valign="top">Specifies the maximum memory the jarsigner VM will use. Specified in the
  103. style of standard java memory specs (e.g. 128m = 128 MBytes)</td>
  104. <td valign="top" align="center">No</td>
  105. </tr>
  106. <tr>
  107. <td valign="top">preservelastmodified</td>
  108. <td valign="top">Give the signed files the same last modified
  109. time as the original jar files.</td>
  110. <td valign="top" align="center">No; default false.</td>
  111. </tr>
  112. <tr>
  113. <td valign="top">tsaurl</td>
  114. <td valign="top">URL for a timestamp authority for timestamped
  115. JAR files in Java1.5+</td>
  116. <td valign="top" align="center">No</td>
  117. </tr>
  118. <tr>
  119. <td valign="top">tsacert</td>
  120. <td valign="top">alias in the keystore for a timestamp authority for
  121. timestamped JAR files in Java1.5+</td>
  122. <td valign="top" align="center">No</td>
  123. </tr>
  124. </table>
  125. <h3>Parameters as nested elements</h3>
  126. <table border="1" cellpadding="2" cellspacing="0">
  127. <tr>
  128. <td valign="top"><b>Attribute</b></td>
  129. <td valign="top"><b>Description</b></td>
  130. <td align="center" valign="top"><b>Required</b></td>
  131. </tr>
  132. <tr>
  133. <td valign="top">fileset</td>
  134. <td valign="top">fileset of JAR files to sign. </td>
  135. <td valign="top" align="center">No</td>
  136. </tr>
  137. <tr>
  138. <td valign="top">mapper</td>
  139. <td valign="top">A mapper to rename jar files during signing</td>
  140. <td valign="top" align="center">No, and only one can be supplied</td>
  141. </tr>
  142. <tr>
  143. <td valign="top">sysproperty</td>
  144. <td valign="top">JVM system properties, with the syntax of Ant
  145. <a href="exec.html#env">environment variables</a> </td>
  146. <td valign="top" align="center">No, and only one can be supplied</td>
  147. </tr>
  148. </table>
  149. <h3>Examples</h3>
  150. <blockquote><pre>
  151. &lt;signjar jar=&quot;${dist}/lib/ant.jar&quot;
  152. alias=&quot;apache-group&quot; storepass=&quot;secret&quot;/&gt;
  153. </pre></blockquote>
  154. <p>
  155. signs the ant.jar with alias &quot;apache-group&quot; accessing the
  156. keystore and private key via &quot;secret&quot; password.
  157. </p>
  158. <blockquote><pre>
  159. &lt;signjar destDir="signed"
  160. alias="testonly" keystore="testkeystore"
  161. storepass="apacheant"
  162. preservelastmodified="true"&gt;
  163. &lt;fileset dir="dist" includes="**/*.jar" /&gt;
  164. &lt;flattenmapper /&gt;
  165. &lt;/signjar&gt;
  166. </pre></blockquote>
  167. <p>
  168. Sign all JAR files matching the dist/**/*.jar pattern, copying them to the
  169. directory "signed" afterwards. The flatten mapper means that they will
  170. all be copied to this directory, not to subdirectories.
  171. </p>
  172. <blockquote><pre>
  173. &lt;signjar
  174. alias="testonly" keystore="testkeystore"
  175. storepass="apacheant"
  176. lazy="true"
  177. &gt;
  178. &lt;fileset dir="dist" includes="**/*.jar" /&gt;
  179. &lt;/signjar&gt;
  180. </pre></blockquote>
  181. <p>
  182. Sign all the JAR files in dist/**/*.jar <i>in-situ</i>. Lazy signing is used,
  183. so the files will only be signed if they are not already signed.
  184. </p>
  185. <h3>About timestamp signing</h3>
  186. <p>
  187. Timestamped JAR files are a new feature in Java1.5; a feature supported in Ant since
  188. Ant 1.7. Ant does not yet support proxy setup for this singing process, and
  189. the whole TSA feature is not tested yet. Furthermore, the
  190. <a href="http://java.sun.com/j2se/1.5.0/docs/guide/security/time-of-signing-beta1.html">
  191. official TSA documentation</a>
  192. warns that the API is subject to change. If a future version of Java changes the
  193. API, Ant will break. It may be possible to hide changes if and when they occur,
  194. but this can not be guaranteed.
  195. </p>
  196. <hr>
  197. <p align="center">Copyright &copy; 2000-2005 The Apache Software Foundation. All rights
  198. Reserved.</p>
  199. </body>
  200. </html>