org.foray.pdf.object
Class PDFEncryption

java.lang.Object
  extended by org.foray.pdf.object.PDFObject
      extended by org.foray.pdf.object.PDFEncryption
All Implemented Interfaces:
org.axsl.pdf.PdfEncryption

public class PDFEncryption
extends PDFObject
implements org.axsl.pdf.PdfEncryption

class representing a /Filter /Standard object.


Nested Class Summary
 class PDFEncryption.EncryptionFilter
          Private inner class for the encryption filter.
 
Field Summary
static int PERMISSION_COPY_CONTENT
          Constant for content extraction permission.
static int PERMISSION_EDIT_ANNOTATIONS
          Constant for annotation editing permission.
static int PERMISSION_EDIT_CONTENT
          Constant for content editing permission.
static int PERMISSION_PRINT
          Constant for printing permission.
 
Fields inherited from class org.foray.pdf.object.PDFObject
EOL, MSG_EOL, XREF_EOL
 
Constructor Summary
PDFEncryption(PDFDocument doc)
          Create a /Filter /Standard object.
 
Method Summary
 byte[] encryptData(byte[] data, int number, int generation)
          This method encrypts the passed data using the generated keys.
static boolean encryptionAvailable()
          Indicates whether encryption is available in the current environment.
 byte[] getFileID()
          Returns the document file ID.
 String getFileID(int index)
          This method returns the indexed file ID.
 String getOwnerPassword()
          Returns the owner password for the PDF.
 String getUserPassword()
          Returns the current user password.
 void init()
          Initializes the encryption algorithms and values.
 OutputStream makeFilter(OutputStream outputStream)
          Creates PSEncodeFilter for the encryption object.
 void setAllowCopyContent(boolean value)
           
 void setAllowEditAnnotation(boolean value)
          Set whether the document will allow annotation modifications.
 void setAllowEditContent(boolean value)
           
 void setAllowPrint(boolean value)
           
 void setOwnerPassword(String value)
           
 void setUserPassword(String value)
           
 String toPDF()
          Generates the PDF text necessary to represent the object, returning it as a String.
 
Methods inherited from class org.foray.pdf.object.PDFObject
bufferToByteArray, byteArrayToStream, getCharsPerLine, getGeneration, getLogger, getNumber, getPDFDocument, output, pdfID, pdfReference, setNumber, stringToByteArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERMISSION_PRINT

public static final int PERMISSION_PRINT
Constant for printing permission.

See Also:
Constant Field Values

PERMISSION_EDIT_CONTENT

public static final int PERMISSION_EDIT_CONTENT
Constant for content editing permission.

See Also:
Constant Field Values

PERMISSION_COPY_CONTENT

public static final int PERMISSION_COPY_CONTENT
Constant for content extraction permission.

See Also:
Constant Field Values

PERMISSION_EDIT_ANNOTATIONS

public static final int PERMISSION_EDIT_ANNOTATIONS
Constant for annotation editing permission.

See Also:
Constant Field Values
Constructor Detail

PDFEncryption

public PDFEncryption(PDFDocument doc)
Create a /Filter /Standard object.

Parameters:
doc - The parent PDF document.
Method Detail

setUserPassword

public void setUserPassword(String value)
Specified by:
setUserPassword in interface org.axsl.pdf.PdfEncryption

getUserPassword

public String getUserPassword()
Returns the current user password.

Returns:
The user password.

setOwnerPassword

public void setOwnerPassword(String value)
Specified by:
setOwnerPassword in interface org.axsl.pdf.PdfEncryption

getOwnerPassword

public String getOwnerPassword()
Returns the owner password for the PDF.

Returns:
The owner password.

setAllowPrint

public void setAllowPrint(boolean value)
Specified by:
setAllowPrint in interface org.axsl.pdf.PdfEncryption

setAllowCopyContent

public void setAllowCopyContent(boolean value)
Specified by:
setAllowCopyContent in interface org.axsl.pdf.PdfEncryption

setAllowEditContent

public void setAllowEditContent(boolean value)
Specified by:
setAllowEditContent in interface org.axsl.pdf.PdfEncryption

setAllowEditAnnotation

public void setAllowEditAnnotation(boolean value)
Set whether the document will allow annotation modifications.

Specified by:
setAllowEditAnnotation in interface org.axsl.pdf.PdfEncryption
Parameters:
value - The new permission value.

getFileID

public byte[] getFileID()
Returns the document file ID.

Returns:
The file ID.

getFileID

public String getFileID(int index)
This method returns the indexed file ID.

Parameters:
index - The index to access the file ID.
Returns:
The file ID.

init

public void init()
Initializes the encryption algorithms and values.

Specified by:
init in interface org.axsl.pdf.PdfEncryption

encryptData

public byte[] encryptData(byte[] data,
                          int number,
                          int generation)
This method encrypts the passed data using the generated keys.

Parameters:
data - The data to be encrypted
number - The block number
generation - The block generation
Returns:
The encrypted data

makeFilter

public OutputStream makeFilter(OutputStream outputStream)
Creates PSEncodeFilter for the encryption object.

Parameters:
outputStream - The output stream to which the encrypted data should be written.
Returns:
The resulting filter.

toPDF

public String toPDF()
Description copied from class: PDFObject
Generates the PDF text necessary to represent the object, returning it as a String.

Returns:
The PDF text necessary to represent the object.

encryptionAvailable

public static boolean encryptionAvailable()
Indicates whether encryption is available in the current environment.

Returns:
True iff encryption is available in the current environment.


Copyright © 2017. All rights reserved.