com.qoppa.pdf.permissions
Class PasswordPermissions

java.lang.Object
  extended by com.qoppa.pdf.permissions.PasswordPermissions
All Implemented Interfaces:
IPDFPermissions
Direct Known Subclasses:
PDFPermissions

public class PasswordPermissions
extends Object
implements IPDFPermissions

This class contains information regarding a PDF document permissions. The list of permissions are the following: assemble the document, change the document, extract text and graphics, extract content for accessibility, fill form fields, modify annotations, print, print high resolution.


Field Summary
static int DO_NOT_USE_ENCRYPTION_AES_256_R5
          Deprecated. DO NOT USE. This encryption type was deprecated by the PDF specifications, DO NOT USE.
static int ENCRYPTION_AES
          Deprecated. Use ENCRYPTION_AES_128 instead
static int ENCRYPTION_AES_128
          AES Encryption - 128 bits
static int ENCRYPTION_AES_256
          AES Encryption 256 bits.
static int ENCRYPTION_RC4
          Deprecated. Use ENCRYPTION_RC4_128 instead
static int ENCRYPTION_RC4_128
          RC4 Encryption - 128 bits
static int ENCRYPTION_RC4_40
          RC4 Encryption - 40 bits
 
Constructor Summary
PasswordPermissions()
          Creates a new PasswordPermissions object with all permissions granted.
PasswordPermissions(boolean allperms)
          Creates a new PasswordPermissions object with all permissions set to allperms.
PasswordPermissions(int perms, boolean ownerPasswordEntered)
          Creates a new PasswordPermissions object using perms, the permissions integer representing the 12 permissions bits as specified in the PDF documentation.
 
Method Summary
 int getPermFlag()
          Returns the permissions int representing the 12 permissions bits as specified in the PDF documentation.
 boolean hasAllPermissions()
          Returns true if all permissions are granted for the document.
 boolean isAssembleDocumentAllowed()
          Returns the permission to assemble the document:
- insert, rotate or delete pages
- create bookmarks
- create thumbnail images
This permission is automatically granted if the permission to change the document is granted (see isChangeDocumentAllowed()).
 boolean isChangeDocumentAllowed()
          Returns the permission to change the document.
 boolean isExtractTextGraphicsAllowed()
          Returns the permission to extract text and graphics.
 boolean isExtractTextGraphicsForAccessibilityAllowed()
          Returns the permission to extract text and graphics in support of accessibility to disabled users or other purposes.
 boolean isFillFormFieldsAllowed()
          Returns the permission to fill form fields and sign the document.
 boolean isModifyAnnotsAllowed()
          Returns the permission to add or modify text annotations in the document.
 boolean isPrintAllowed()
          Returns the permission to print the document.
 boolean isPrintHighResAllowed()
          Returns the permission to print the document at high resolution.
 boolean ownerPasswordEntered()
          Return a flag indicating whether the document was opened using the owner password if the document is encrypted.
 void setAssembleDocumentAllowed(boolean allowed)
          Sets the permission to assemble the document.
 void setChangeDocumentAllowed(boolean allowed)
          Sets the permission to change the document.
 void setExtractTextGraphicsAllowed(boolean allowed)
          Sets the permission to extract text and graphics.
 void setExtractTextGraphicsForAccessibilityAllowed(boolean allowed)
          Sets the permission to extract text and graphics in support of accessibility to disabled users or other purposes.
 void setFillFormFieldsAllowed(boolean allowed)
          Sets the permission to fill form fields and sign the document.
 void setModifyAnnotsAllowed(boolean allowed)
          Sets the permission to add or modify annotations in the document.
 void setPermFlag(int perms)
          Sets the permissions from the int representing the 12 permissions bits as specified in the PDF documentation.
 void setPrintAllowed(boolean allowed)
          Sets the permission to print the document.
 void setPrintHighResAllowed(boolean allowed)
          Sets the permission to print the document at high resolution.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ENCRYPTION_RC4

public static final int ENCRYPTION_RC4
Deprecated. Use ENCRYPTION_RC4_128 instead
RC4 Encryption - 128 bits

See Also:
Constant Field Values

ENCRYPTION_RC4_128

public static final int ENCRYPTION_RC4_128
RC4 Encryption - 128 bits

See Also:
Constant Field Values

ENCRYPTION_AES

public static final int ENCRYPTION_AES
Deprecated. Use ENCRYPTION_AES_128 instead
AES Encryption - 128 bits

See Also:
Constant Field Values

ENCRYPTION_AES_128

public static final int ENCRYPTION_AES_128
AES Encryption - 128 bits

See Also:
Constant Field Values

ENCRYPTION_RC4_40

public static final int ENCRYPTION_RC4_40
RC4 Encryption - 40 bits

See Also:
Constant Field Values

ENCRYPTION_AES_256

public static final int ENCRYPTION_AES_256
AES Encryption 256 bits. This is only available if the Java JVM provides unlimited strength encryption.

See Also:
Constant Field Values

DO_NOT_USE_ENCRYPTION_AES_256_R5

public static final int DO_NOT_USE_ENCRYPTION_AES_256_R5
Deprecated. DO NOT USE. This encryption type was deprecated by the PDF specifications, DO NOT USE.
DO NOT USE. This encryption was deprecated by the PDF specifications because it is considered not safe. It was briefly made available by Adbe Acr 9, but is not supported by X or later.

See Also:
Constant Field Values
Constructor Detail

PasswordPermissions

public PasswordPermissions()
Creates a new PasswordPermissions object with all permissions granted.


PasswordPermissions

public PasswordPermissions(boolean allperms)
Creates a new PasswordPermissions object with all permissions set to allperms.

Parameters:
allperms - flag for all permissions

PasswordPermissions

public PasswordPermissions(int perms,
                           boolean ownerPasswordEntered)
Creates a new PasswordPermissions object using perms, the permissions integer representing the 12 permissions bits as specified in the PDF documentation.

Parameters:
perms - the permissions integer representing the 12 permissions bits as specified in the PDF documentation.
ownerPasswordEntered - flag indicating wether the owner password was entered when opening the document
Method Detail

getPermFlag

public int getPermFlag()
Returns the permissions int representing the 12 permissions bits as specified in the PDF documentation.


hasAllPermissions

public boolean hasAllPermissions()
Returns true if all permissions are granted for the document.

Returns:
true if all permissions are granted.

isAssembleDocumentAllowed

public boolean isAssembleDocumentAllowed()
Returns the permission to assemble the document:
- insert, rotate or delete pages
- create bookmarks
- create thumbnail images
This permission is automatically granted if the permission to change the document is granted (see isChangeDocumentAllowed()).

Specified by:
isAssembleDocumentAllowed in interface IPDFPermissions
Returns:
Permission to assemble the document.

isChangeDocumentAllowed

public boolean isChangeDocumentAllowed()
Returns the permission to change the document. When this permission is granted, the 3 following permissions are also granted:
- Assemble document (see isAssembleDocumentAllowed())
- Modify Annotations (see isModifyAnnotsAllowed())
- Fill Form Fields (see isFillFormFieldsAllowed())

Specified by:
isChangeDocumentAllowed in interface IPDFPermissions
Returns:
Permission to change the document.

isExtractTextGraphicsAllowed

public boolean isExtractTextGraphicsAllowed()
Returns the permission to extract text and graphics. When this permission is granted, the permission to extract for accessibility is automatically granted (see isExtractTextGraphicsForAccessibilityAllowed()). When this permission is not granted, the permission to extract for accessibility can be set independently.

Specified by:
isExtractTextGraphicsAllowed in interface IPDFPermissions
Returns:
Permission to extract text and graphics.

isExtractTextGraphicsForAccessibilityAllowed

public boolean isExtractTextGraphicsForAccessibilityAllowed()
Returns the permission to extract text and graphics in support of accessibility to disabled users or other purposes. This permission is automatically granted when the permission to extract text and graphics is granted (see isExtractTextGraphicsAllowed()).

Specified by:
isExtractTextGraphicsForAccessibilityAllowed in interface IPDFPermissions
Returns:
Permission to extract text and graphics for accessibility.

isFillFormFieldsAllowed

public boolean isFillFormFieldsAllowed()
Returns the permission to fill form fields and sign the document. This permission is automatically granted if the modify annotations permissions is granted (see isModifyAnnotsAllowed()) or if the permission to change the document is granted (see isChangeDocumentAllowed()). When this permission is granted and the permission to change document is also granted, create or modify interactive form fields (including signature fields) is allowed.");

Specified by:
isFillFormFieldsAllowed in interface IPDFPermissions
Returns:
Permission to fill form fields.

isModifyAnnotsAllowed

public boolean isModifyAnnotsAllowed()
Returns the permission to add or modify text annotations in the document. When this permission is granted, the permission to fill form fields is automatically granted (see isFillFormFieldsAllowed()). When this permission is not granted, then the permission to fill form fields can be granted independently. When this permission is granted and the permission to change document is also granted (see isChangeDocumentAllowed()), create or modify interactive form fields (including signature fields) is allowed."); This permission is automatically granted if the permission to change the document is granted (see isChangeDocumentAllowed()).

Specified by:
isModifyAnnotsAllowed in interface IPDFPermissions
Returns:
Permission to add or modify text annotations.

isPrintAllowed

public boolean isPrintAllowed()
Returns the permission to print the document. This permission is automatically granted if the permission to print the document at high resolution is granted (see isPrintHighResAllowed())

Specified by:
isPrintAllowed in interface IPDFPermissions
Returns:
Permission to print the document.

isPrintHighResAllowed

public boolean isPrintHighResAllowed()
Returns the permission to print the document at high resolution. When this permission is granted, the permission to print the document is automatically granted (see isPrintAllowed()). When this permission is not granted, then the permission to print the document can be granted independently.

Specified by:
isPrintHighResAllowed in interface IPDFPermissions
Returns:
Permission to print the document at high resolution.

ownerPasswordEntered

public boolean ownerPasswordEntered()
Return a flag indicating whether the document was opened using the owner password if the document is encrypted. This flag is useful when enforcing permissions, if the document was opened with the owner password then application should allow any operations on the PDF document. If the document is not encrypted, this flag will return true


setAssembleDocumentAllowed

public void setAssembleDocumentAllowed(boolean allowed)
Sets the permission to assemble the document. Assembling the document can be done by:
- inserting, rotating or deleting pages
- creating bookmarks
- creating thumbnail images

Parameters:
allowed - the permission to assemble the document.
See Also:
setChangeDocumentAllowed(boolean)

setChangeDocumentAllowed

public void setChangeDocumentAllowed(boolean allowed)
Sets the permission to change the document. When this permission is granted, the 3 permissions:
- Assemble Document (see setAssembleDocumentAllowed(boolean))
- Modify Annotations (see setModifyAnnotsAllowed(boolean))
- Fill Form Fields (see setFillFormFieldsAllowed(boolean))
are also automatically granted. When this permission is not granted, the 3 permissions mentioned above can independently be granted.

Parameters:
allowed - the permission to change the document

setExtractTextGraphicsAllowed

public void setExtractTextGraphicsAllowed(boolean allowed)
Sets the permission to extract text and graphics. When this permission is granted, the permission to extract for accessibility is automatically granted (see isExtractTextGraphicsForAccessibilityAllowed()). When this permission is not granted, the permission to extract for accessibility can be set independently.

Parameters:
allowed - the permission to extract text and graphics.

setExtractTextGraphicsForAccessibilityAllowed

public void setExtractTextGraphicsForAccessibilityAllowed(boolean allowed)
Sets the permission to extract text and graphics in support of accessibility to disabled users or other purposes.

Parameters:
allowed - the permission to extract text and graphics.
See Also:
isExtractTextGraphicsAllowed()

setFillFormFieldsAllowed

public void setFillFormFieldsAllowed(boolean allowed)
Sets the permission to fill form fields and sign the document.

Parameters:
allowed - the permission to fill form fields.
See Also:
setChangeDocumentAllowed(boolean)

setModifyAnnotsAllowed

public void setModifyAnnotsAllowed(boolean allowed)
Sets the permission to add or modify annotations in the document. When this permission is granted, the permission to fill form fields is automatically granted (see setFillFormFieldsAllowed(boolean fillFormsAllowed)). When this permission is not granted, then the permission to fill form fields can be granted independently. When this permission is granted and the permission to change document is also granted (see setChangeDocumentAllowed(boolean)), create or modify interactive form fields (including signature fields) is allowed.");

Parameters:
allowed - the permission to add or modify annotations.

setPermFlag

public void setPermFlag(int perms)
Sets the permissions from the int representing the 12 permissions bits as specified in the PDF documentation.

Parameters:
perms - the permissions int.

setPrintAllowed

public void setPrintAllowed(boolean allowed)
Sets the permission to print the document.

Parameters:
allowed - to print the document.
See Also:
setPrintHighResAllowed(boolean)

setPrintHighResAllowed

public void setPrintHighResAllowed(boolean allowed)
Sets the permission to print the document at high resolution. When this permission is granted, the Print permission is also automatically granted (see isPrintAllowed()). When this permission is not granted, the Print permission can be granted independently.

Parameters:
allowed - the permission to print at high resolution