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

public final Class StandardProtectionPolicy

extends ProtectionPolicy
Class Inheritance

The protection policy to add to a document for password-based protection. The following example shows how to protect a PDF document with password. In this example, the document will be protected so that someone opening the document with the user password user_pwd will not be able to modify the document.
AccessPermission ap = new AccessPermission();
ap.setCanModify(false);
StandardProtectionPolicy policy = new StandardProtectionPolicy(owner_pwd, user_pwd, ap);
doc.protect(policy);
Author
Benoit Guillon

Field Summary

Modifier and TypeField and Description
private String
private AccessPermission
private String

Constructor Summary

AccessConstructor and Description
public
StandardProtectionPolicy(String
The owner password.
ownerPassword
,
String
The user password.
userPassword
,
AccessPermission
The access permissions given to the user.
permissions
)

Creates an new instance of the standard protection policy in order to protect a PDF document with passwords.

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

the owner password
getOwnerPassword
()

Returns the owner password.

public AccessPermission

Returns:

the access permissions
getPermissions
()

Returns the access permissions

public String

Returns:

the user password
getUserPassword
()

Returns the user password.

public void
setOwnerPassword(String
the new owner password
ownerPassword
)

Sets the owner password

public void
setPermissions(AccessPermission
the new access permissions
permissions
)

Sets the access permissions

public void
setUserPassword(String
the new user password
userPassword
)

Sets the user password.

Inherited from org.apache.pdfbox.pdmodel.encryption.ProtectionPolicy:
getEncryptionKeyLengthisPreferAESsetEncryptionKeyLengthsetPreferAES

Field Detail

ownerPasswordback to summary
private String ownerPassword
Annotations
@SuppressWarnings:squid:S2068
permissionsback to summary
private AccessPermission permissions
userPasswordback to summary
private String userPassword
Annotations
@SuppressWarnings:squid:S2068

Constructor Detail

StandardProtectionPolicyback to summary
public StandardProtectionPolicy(String ownerPassword, String userPassword, AccessPermission permissions)

Creates an new instance of the standard protection policy in order to protect a PDF document with passwords.

Parameters
ownerPassword:String

The owner password.

userPassword:String

The user password.

permissions:AccessPermission

The access permissions given to the user.

Method Detail

getOwnerPasswordback to summary
public String getOwnerPassword()

Returns the owner password.

Returns:String

the owner password

getPermissionsback to summary
public AccessPermission getPermissions()

Returns the access permissions

Returns:AccessPermission

the access permissions

getUserPasswordback to summary
public String getUserPassword()

Returns the user password.

Returns:String

the user password

setOwnerPasswordback to summary
public void setOwnerPassword(String ownerPassword)

Sets the owner password

Parameters
ownerPassword:String

the new owner password

setPermissionsback to summary
public void setPermissions(AccessPermission permissions)

Sets the access permissions

Parameters
permissions:AccessPermission

the new access permissions

setUserPasswordback to summary
public void setUserPassword(String userPassword)

Sets the user password.

Parameters
userPassword:String

the new user password