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 9.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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">strict</td>
  98. <td valign="top">(true | false) strict checking when signing.<br/><em>since Ant 1.9.1</em>.</td>
  99. <td valign="top" align="center">No; default false</td>
  100. </tr>
  101. <tr>
  102. <td valign="top">internalsf</td>
  103. <td valign="top">(true | false) include the .SF file inside the signature
  104. block</td>
  105. <td valign="top" align="center">No; default false</td>
  106. </tr>
  107. <tr>
  108. <td valign="top">sectionsonly</td>
  109. <td valign="top">(true | false) don't compute hash of entire manifest</td>
  110. <td valign="top" align="center">No; default false</td>
  111. </tr>
  112. <tr>
  113. <td valign="top">lazy</td>
  114. <td valign="top">flag to control whether the presence of a signature
  115. file means a JAR is signed. This is only used when the target JAR matches
  116. the source JAR</td>
  117. <td valign="top" align="center">No; default false</td>
  118. </tr>
  119. <tr>
  120. <td valign="top">maxmemory</td>
  121. <td valign="top">Specifies the maximum memory the jarsigner VM will use. Specified in the
  122. style of standard java memory specs (e.g. 128m = 128 MBytes)</td>
  123. <td valign="top" align="center">No</td>
  124. </tr>
  125. <tr>
  126. <td valign="top">preservelastmodified</td>
  127. <td valign="top">Give the signed files the same last modified
  128. time as the original jar files.</td>
  129. <td valign="top" align="center">No; default false.</td>
  130. </tr>
  131. <tr>
  132. <td valign="top">tsaurl</td>
  133. <td valign="top">URL for a timestamp authority for timestamped
  134. JAR files in Java1.5+</td>
  135. <td valign="top" align="center">No</td>
  136. </tr>
  137. <tr>
  138. <td valign="top">tsacert</td>
  139. <td valign="top">alias in the keystore for a timestamp authority for
  140. timestamped JAR files in Java1.5+</td>
  141. <td valign="top" align="center">No</td>
  142. </tr>
  143. <tr>
  144. <td valign="top">executable</td>
  145. <td valign="top">Specify a particular <code>jarsigner</code> executable
  146. to use in place of the default binary (found in the same JDK as
  147. Apache Ant is running in).<br/>
  148. Must support the same command line options as the Sun JDK
  149. jarsigner command.
  150. <em>since Ant 1.8.0</em>.</td>
  151. <td align="center" valign="top">No</td>
  152. </tr>
  153. <tr>
  154. <td valign="top">force</td>
  155. <td valign="top">Whether to force signing of the jar file even if
  156. it doesn't seem to be out of date or already signed.
  157. <em>since Ant 1.8.0</em>.</td>
  158. <td align="center" valign="top">No; default false</td>
  159. </tr>
  160. <tr>
  161. <td valign="top">sigalg</td>
  162. <td valign="top">name of signature algorithm</td>
  163. <td valign="top" align="center">No</td>
  164. </tr>
  165. <tr>
  166. <td valign="top">digestalg</td>
  167. <td valign="top">name of digest algorithm</td>
  168. <td valign="top" align="center">No</td>
  169. </tr>
  170. </table>
  171. <h3>Parameters as nested elements</h3>
  172. <table border="1" cellpadding="2" cellspacing="0">
  173. <tr>
  174. <td valign="top"><b>Attribute</b></td>
  175. <td valign="top"><b>Description</b></td>
  176. <td align="center" valign="top"><b>Required</b></td>
  177. </tr>
  178. <tr>
  179. <td valign="top">path</td>
  180. <td valign="top">path of JAR files to sign. <em>since Ant 1.7</em></td>
  181. <td valign="top" align="center">No</td>
  182. </tr>
  183. <tr>
  184. <td valign="top">fileset</td>
  185. <td valign="top">fileset of JAR files to sign. </td>
  186. <td valign="top" align="center">No</td>
  187. </tr>
  188. <tr>
  189. <td valign="top">mapper</td>
  190. <td valign="top">A mapper to rename jar files during signing</td>
  191. <td valign="top" align="center">No, and only one can be supplied</td>
  192. </tr>
  193. <tr>
  194. <td valign="top">sysproperty</td>
  195. <td valign="top">JVM system properties, with the syntax of Ant
  196. <a href="exec.html#env">environment variables</a> </td>
  197. <td valign="top" align="center">No, and only one can be supplied</td>
  198. </tr>
  199. </table>
  200. <h3>Examples</h3>
  201. <blockquote><pre>
  202. &lt;signjar jar=&quot;${dist}/lib/ant.jar&quot;
  203. alias=&quot;apache-group&quot; storepass=&quot;secret&quot;/&gt;
  204. </pre></blockquote>
  205. <p>
  206. signs the ant.jar with alias &quot;apache-group&quot; accessing the
  207. keystore and private key via &quot;secret&quot; password.
  208. </p>
  209. <blockquote><pre>
  210. &lt;signjar destDir="signed"
  211. alias="testonly" keystore="testkeystore"
  212. storepass="apacheant"
  213. preservelastmodified="true"&gt;
  214. &lt;path&gt;
  215. &lt;fileset dir="dist" includes="**/*.jar" /&gt;
  216. &lt;/path&gt;
  217. &lt;flattenmapper /&gt;
  218. &lt;/signjar&gt;
  219. </pre></blockquote>
  220. <p>
  221. Sign all JAR files matching the dist/**/*.jar pattern, copying them to the
  222. directory "signed" afterwards. The flatten mapper means that they will
  223. all be copied to this directory, not to subdirectories.
  224. </p>
  225. <blockquote><pre>
  226. &lt;signjar
  227. alias="testonly" keystore="testkeystore"
  228. storepass="apacheant"
  229. lazy="true"
  230. &gt;
  231. &lt;path&gt;
  232. &lt;fileset dir="dist" includes="**/*.jar" /&gt;
  233. &lt;/path&gt;
  234. &lt;/signjar&gt;
  235. </pre></blockquote>
  236. <p>
  237. Sign all the JAR files in dist/**/*.jar <i>in-situ</i>. Lazy signing is used,
  238. so the files will only be signed if they are not already signed.
  239. </p>
  240. <blockquote><pre>
  241. &lt;signjar
  242. alias="testonly" keystore="testkeystore"
  243. storepass="apacheant"
  244. sigalg="MD5withRSA"
  245. digestalg="SHA1"&gt;
  246. &lt;path&gt;
  247. &lt;fileset dir="dist" includes="**/*.jar" /&gt;
  248. &lt;/path&gt;
  249. &lt;/signjar&gt;
  250. </pre></blockquote>
  251. <p>
  252. Sign all the JAR files in dist/**/*.jar using the digest algorithm SHA1 and the
  253. signature algorithm MD5withRSA. This is especially useful when you want to use
  254. the JDK 7 jarsigner (which uses SHA256 and SHA256withRSA as default) to create
  255. signed jars that will be deployed on platforms not supporting SHA256 and
  256. SHA256withRSA.
  257. </p>
  258. <h3>About timestamp signing</h3>
  259. <p>
  260. Timestamped JAR files are a new feature in Java1.5; a feature supported in Ant since
  261. Ant 1.7. Ant does not yet support proxy setup for this signing process.
  262. </p>
  263. </body>
  264. </html>