Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.encryption

public abstract Class ProtectionPolicy

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.pdfbox.pdmodel.encryption.PublicKeyProtectionPolicy, org.apache.pdfbox.pdmodel.encryption.StandardProtectionPolicy

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 ([email protected])
See Also
org.apache.pdfbox.pdmodel.PDDocument#protect(ProtectionPolicy)

Field Summary

Modifier and TypeField and Description
private static final short
private short
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

The length (in bits) of the encryption key.
getEncryptionKeyLength
()

Get the length of the secrete key that will be used to encrypt document data.

public boolean

Returns:

true if AES encryption is preferred
isPreferAES
()

Tell whether AES encryption is preferred when several encryption methods are available for the chosen key length.

public void
setEncryptionKeyLength(int
the length in bits (must be 40, 128 or 256)
l
)

set the length in (bits) of the secret key that will be used to encrypt document data.

public void
setPreferAES(boolean
indicates whether AES encryption is preferred or not
preferAES
)

Set whether AES encryption is preferred when several encryption methods are available for the chosen key length.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_KEY_LENGTHback to summary
private static final short DEFAULT_KEY_LENGTH
encryptionKeyLengthback to summary
private short encryptionKeyLength
preferAESback to summary
private boolean preferAES

Constructor Detail

ProtectionPolicyback to summary
public ProtectionPolicy()

Method Detail

getEncryptionKeyLengthback to summary
public int getEncryptionKeyLength()

Get the length of the secrete key that will be used to encrypt document data.

Returns:int

The length (in bits) of the encryption key.

isPreferAESback to summary
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:boolean

true if AES encryption is preferred

setEncryptionKeyLengthback to summary
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:int

the length in bits (must be 40, 128 or 256)

setPreferAESback to summary
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:boolean

indicates whether AES encryption is preferred or not