Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <?xml version="1.0" standalone="no"?>
  2. <!--
  3. Copyright 1999-2006 The Apache Software Foundation
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. -->
  14. <!-- $Id$ -->
  15. <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
  16. <document>
  17. <header>
  18. <title>PDF encryption.</title>
  19. <version>$Revision$</version>
  20. <authors>
  21. <person name="J.Pietschmann" email="pietsch@apache.org"/>
  22. <person name="Jeremias Märki" email="jeremias@apache.org"/>
  23. </authors>
  24. </header>
  25. <body>
  26. <section>
  27. <title>Overview</title>
  28. <warning>
  29. PDF Encryption is available in Release 0.20.5 and later. The comments on this page do
  30. not apply to releases earlier than 0.20.5.
  31. </warning>
  32. <p>
  33. FOP supports encryption of PDF output, thanks to Patrick
  34. C. Lankswert. This feature is commonly used to prevent
  35. unauthorized viewing, printing, editing, copying text from the
  36. document and doing annotations. It is also possible to ask the
  37. user for a password in order to view the contents. Note that
  38. there already exist third party applications which can decrypt
  39. an encrypted PDF without effort and allow the aforementioned
  40. operations, therefore the degree of protection is limited.
  41. </p>
  42. <p>
  43. For further information about features and restrictions regarding PDF
  44. encryption, look at the documentation coming with Adobe Acrobat or the
  45. technical documentation on the Adobe web site.
  46. </p>
  47. </section>
  48. <section>
  49. <title>Usage (command line)</title>
  50. <p>
  51. Encryption is enabled by supplying any of the encryption related
  52. options.
  53. </p>
  54. <p>
  55. An owner password is set with the <code>-o</code> option. This
  56. password is actually used as encryption key. Many tools for
  57. PDF processing ask for this password to disregard any
  58. restriction imposed on the PDF document.
  59. </p>
  60. <p>
  61. If no owner password has been supplied but FOP was asked to apply some
  62. restrictions, a random password is used. In this case it is obviously
  63. impossiible to disregard restrictions in PDF processing tools.
  64. </p>
  65. <p>
  66. A user password, supplied with the <code>-u</code> option, will
  67. cause the PDF display software to ask the reader for this password in
  68. order to view the contents of the document. If no user password was
  69. supplied, viewing the content is not restricted.
  70. </p>
  71. <p>
  72. Further restrictions can be imposed by using the <code>-noprint</code>,
  73. <code>-nocopy</code>, <code>-noedit</code> and
  74. <code>-noannotations</code> options, which disable printing, copying
  75. text, editing in Adobe Acrobat and making annotations, respectively.
  76. </p>
  77. </section>
  78. <section>
  79. <title>Usage (embedded)</title>
  80. <p>
  81. When FOP is embedded in another Java application you need to set an
  82. options map on the renderer. These are the supported options:
  83. </p>
  84. <table>
  85. <tr>
  86. <th>Option</th>
  87. <th>Description</th>
  88. <th>Values</th>
  89. <th>Default</th>
  90. </tr>
  91. <tr>
  92. <td>ownerPassword</td>
  93. <td>The owner password</td>
  94. <td>String</td>
  95. <td/>
  96. </tr>
  97. <tr>
  98. <td>userPassword</td>
  99. <td>The user password</td>
  100. <td>String</td>
  101. <td/>
  102. </tr>
  103. <tr>
  104. <td>allowPrint</td>
  105. <td>Allows/disallows printing of the PDF</td>
  106. <td>"TRUE" or "FALSE"</td>
  107. <td>"TRUE"</td>
  108. </tr>
  109. <tr>
  110. <td>allowCopyContent</td>
  111. <td>Allows/disallows copy/paste of content</td>
  112. <td>"TRUE" or "FALSE"</td>
  113. <td>"TRUE"</td>
  114. </tr>
  115. <tr>
  116. <td>allowEditContent</td>
  117. <td>Allows/disallows editing of content</td>
  118. <td>"TRUE" or "FALSE"</td>
  119. <td>"TRUE"</td>
  120. </tr>
  121. <tr>
  122. <td>allowEditAnnotations</td>
  123. <td>Allows/disallows editing of annotations</td>
  124. <td>"TRUE" or "FALSE"</td>
  125. <td>"TRUE"</td>
  126. </tr>
  127. </table>
  128. <note>
  129. Encryption is enabled as soon as one of these options is set.
  130. </note>
  131. <p>
  132. An example to enable PDF encryption in Java code:
  133. </p>
  134. <source><![CDATA[
  135. import org.apache.fop.pdf.PDFEncryptionParams;
  136. [..]
  137. FOUserAgent userAgent = fopFactory.newFOUserAgent();
  138. useragent.getRendererOptions().put("encryption-params", new PDFEncryptionParams(
  139. null, "password", false, false, true, true));
  140. Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, userAgent);
  141. [..]]]></source>
  142. <p>
  143. The parameters for the constructor of PDFEncryptionParams are:
  144. </p>
  145. <ol>
  146. <li>userPassword: String, may be null</li>
  147. <li>ownerPassword: String, may be null</li>
  148. <li>allowPrint: true if printing is allowed</li>
  149. <li>allowCopyContent: true if copying content is allowed</li>
  150. <li>allowEditContent: true if editing content is allowed</li>
  151. <li>allowEditAnnotations: true if editing annotations is allowed</li>
  152. </ol>
  153. <p>
  154. Alternatively, you can set each value separately in the Map provided by
  155. FOUserAgent.getRendererOptions() by using the following keys:
  156. </p>
  157. <ol>
  158. <li>user-password: String</li>
  159. <li>owner-password: String</li>
  160. <li>noprint: Boolean or "true"/"false"</li>
  161. <li>nocopy: Boolean or "true"/"false"</li>
  162. <li>noedit: Boolean or "true"/"false"</li>
  163. <li>noannotations: Boolean or "true"/"false"</li>
  164. </ol>
  165. </section>
  166. <section>
  167. <title>Environment</title>
  168. <p>
  169. In order to use PDF encryption, FOP has to be compiled with
  170. cryptography support. Currently, only <a
  171. href="http://java.sun.com/j2se/1.4/docs/guide/security/jce/JCERefGuide.html">JCE</a>
  172. is supported. JCE is part of JDK 1.4. For earlier JDKs, it can
  173. be installed separately. The build process automatically
  174. detects JCE presence and installs PDF encryption support if
  175. possible, otherwise a stub is compiled in.
  176. </p>
  177. <p>
  178. Cryptography support must also be present at run time. In particular, a
  179. provider for the RC4 cipher is needed. Unfortunately, the sample JCE
  180. provider in Sun's JDK 1.4 does <strong>not</strong> provide RC4. If you
  181. get a message saying
  182. </p>
  183. <source>"Cannot find any provider supporting RC4"</source>
  184. <p>
  185. then you don't have the needed infrastructure.
  186. </p>
  187. <p>
  188. There are several commercial and a few Open Source packages which
  189. provide RC4. A pure Java implementation is produced by <a
  190. href="http://www.bouncycastle.org/">The Legion of the Bouncy
  191. Castle</a>. <a
  192. href="http://www.mozilla.org/projects/security/pki/jss/">Mozilla
  193. JSS</a> is an interface to a native implementation.
  194. </p>
  195. </section>
  196. <section id="install_crypto">
  197. <title>Installing a crypto provider</title>
  198. <p>
  199. The pure Java implementation from <a
  200. href="http://www.bouncycastle.org/">Bouncy Castle</a> is easy to
  201. install.
  202. </p>
  203. <ol>
  204. <li>
  205. Download the binary distribution for your JDK version. If you have JDK
  206. 1.3 or earlier you must also download a JCE from the same page.
  207. </li>
  208. <li>
  209. Unpack the distribution. Add the jar file to your classpath. A
  210. convenient way to use the jar on Linux is to simply drop it into the
  211. FOP lib directory, it will be automatically picked up by
  212. <code>fop.sh</code>. If you have JDK 1.3 or earlier don't forget to
  213. install the JCE as well.
  214. </li>
  215. <li>
  216. Open the <code>java.security</code> file and add<br/>
  217. <code>security.provider.6=org.bouncycastle.jce.provider.BouncyCastleProvider</code>,<br/>
  218. preferably at the end of the block defining the other crypto
  219. providers. For JDK 1.4 this is detailed on <a href="http://java.sun.com/j2se/1.4/docs/guide/security/jce/JCERefGuide.html#InstallProvider">Sun's web site</a>.
  220. </li>
  221. </ol>
  222. <p>
  223. If you have any experience with Mozilla JSS or any other
  224. cryptography provider, please post it to the fop-user list.
  225. </p>
  226. </section>
  227. </body>
  228. </document>