Class ProtectionPolicy

  • Direct Known Subclasses:
    PublicKeyProtectionPolicy, StandardProtectionPolicy

    public abstract class ProtectionPolicy
    extends java.lang.Object
    This class represents the protection policy to apply to a document. Objects implementing this abstract class can be passed to the protect method of PDDocument to protect a document.
    Author:
    Benoit Guillon (benoit.guillon@snv.jussieu.fr)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getEncryptionKeyLength()
      Get the length of the secrete key that will be used to encrypt document data.
      boolean isPreferAES()
      Tell whether AES encryption is preferred when several encryption methods are available for the chosen key length.
      void setEncryptionKeyLength​(int l)
      set the length in (bits) of the secret key that will be used to encrypt document data.
      void setPreferAES​(boolean preferAES)
      Set whether AES encryption is preferred when several encryption methods are available for the chosen key length.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ProtectionPolicy

        public ProtectionPolicy()
    • Method Detail

      • setEncryptionKeyLength

        public void setEncryptionKeyLength​(int l)
        set the length in (bits) of the secret key that will be used to encrypt document data. The default value is 40 bits, which provides a low security level but is compatible with old versions of Acrobat Reader.
        Parameters:
        l - the length in bits (must be 40, 128 or 256)
      • getEncryptionKeyLength

        public int getEncryptionKeyLength()
        Get the length of the secrete key that will be used to encrypt document data.
        Returns:
        The length (in bits) of the encryption key.
      • isPreferAES

        public boolean isPreferAES()
        Tell whether AES encryption is preferred when several encryption methods are available for the chosen key length. The default is false. This setting is only relevant if the key length is 128 bits.
        Returns:
        true if AES encryption is preferred
      • setPreferAES

        public void setPreferAES​(boolean preferAES)
        Set whether AES encryption is preferred when several encryption methods are available for the chosen key length. The default is false. This setting is only relevant if the key length is 128 bits.
        Parameters:
        preferAES - true if AES encryption is preferred