您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

pdfencryption.xml 8.6KB

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