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 8.4 KiB

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