Ejemplo n.º 1
0
 /** Sets the encryption options for this document. The userPassword and the
  *  ownerPassword can be null or have zero length. In this case the ownerPassword
  *  is replaced by a random string. The open permissions for the document can be
  *  AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations,
  *  AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.
  *  The permissions can be combined by ORing them.
  * @param userPassword the user password. Can be null or empty
  * @param ownerPassword the owner password. Can be null or empty
  * @param permissions the user permissions
  * @param encryptionType the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128.
  * Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext
  * @throws DocumentException if the document is already open
  */
 public void SetEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType)
 {
     if (stamper.IsAppend())
     {
         throw new DocumentException(MessageLocalization.GetComposedMessage("append.mode.does.not.support.changing.the.encryption.status"));
     }
     if (stamper.ContentWritten)
     {
         throw new DocumentException(MessageLocalization.GetComposedMessage("content.was.already.written.to.the.output"));
     }
     stamper.SetEncryption(userPassword, ownerPassword, permissions, encryptionType);
 }
Ejemplo n.º 2
0
 /** Sets the encryption options for this document. The userPassword and the
  *  ownerPassword can be null or have zero length. In this case the ownerPassword
  *  is replaced by a random string. The open permissions for the document can be
  *  AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations,
  *  AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.
  *  The permissions can be combined by ORing them.
  * @param userPassword the user password. Can be null or empty
  * @param ownerPassword the owner password. Can be null or empty
  * @param permissions the user permissions
  * @param encryptionType the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128.
  * Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext
  * @throws DocumentException if the document is already open
  */
 public void SetEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType)
 {
     if (stamper.IsAppend())
     {
         throw new DocumentException("Append mode does not support changing the encryption status.");
     }
     if (stamper.ContentWritten)
     {
         throw new DocumentException("Content was already written to the output.");
     }
     stamper.SetEncryption(userPassword, ownerPassword, permissions, encryptionType);
 }