SetaPDF_Core_SecHandler Main class for PDF security handlers

File: /SetaPDF v2/Core/SecHandler.php

Class hierarchy

Summary

Constants

AES

const string SetaPDF_Core_SecHandler::AES = 32

Encryption constant

AES_128

const string SetaPDF_Core_SecHandler::AES_128 = 96

Encryption constant

AES_256

const string SetaPDF_Core_SecHandler::AES_256 = 160

Encryption constant

ARCFOUR

Encryption constant

ARCFOUR_128

Encryption constant

ARCFOUR_40

Encryption constant

OWNER

const string SetaPDF_Core_SecHandler::OWNER = 'owner'

Owner auth mode

PERM_ACCESSIBILITY

Permission constant.

For handlers of revision 3 or greater: Extract text and graphics (in support of accessibility to users with disabilities or for other purposes).

See
  • PDF 32000-1:2008 - Table 22 - User access permissions

PERM_ANNOT

Permission constant.

Add or modify text annotations, fill in interactive form fields, and, if SetaPDF_Core_SecHandler is also set, create or modify interactive form fields (including signature fields).

See
  • PDF 32000-1:2008 - Table 22 - User access permissions

PERM_ASSEMBLE

Permission constant.

For handlers of revision 3 or greater: Assemble the document (insert, rotate, or delete pages and create bookmarks or thumbnail images), even if SetaPDF_Core_SecHandler is not set.

See
  • PDF 32000-1:2008 - Table 22 - User access permissions

PERM_COPY

Permission constant.

For handlers of revision 2: Copy or otherwise extract text and graphics from the document, including extracting text and graphics (in support of accessibility to users with disabilities or for other purposes).

For handlers of revision 3 or greater: Copy or otherwise extract text and graphics from the document by operations other than that controlled by bit SetaPDF_Core_SecHandler.

See
  • PDF 32000-1:2008 - Table 22 - User access permissions

PERM_DIGITAL_PRINT

Permission constant.

Print the document to a representation from which a faithful digital copy of the PDF content could be generated. When this is not set (and SetaPDF_Core_SecHandler is set), printing is limited to a low-level representation of the appearance, possibly of degraded quality.

See
  • PDF 32000-1:2008 - Table 22 - User access permissions

PERM_FILL_FORM

Permission constant.

For handlers of revision 3 or greater: Fill in existing interactive form fields (including signature fields), even if SetaPDF_Core_SecHandler is not set.

See
  • PDF 32000-1:2008 - Table 22 - User access permissions

PERM_MODIFY

Permission constant.

Modify the contents of the document by operations other than those controlled by SetaPDF_Core_SecHandler, SetaPDF_Core_SecHandler and SetaPDF_Core_SecHandler.

See
  • PDF 32000-1:2008 - Table 22 - User access permissions

PERM_PRINT

Permission constant.

For handlers of revision 2: Print the document.

Handlers of a revision of 3 or greater: Print the document (possibly not at the highest quality level, depending on whether SetaPDF_Core_SecHandler is also set).

See
  • PDF 32000-1:2008 - Table 22 - User access permissions

PUB_KEY

const string SetaPDF_Core_SecHandler::PUB_KEY = 'publicKey'

Public Key Security Handler

STANDARD

const string SetaPDF_Core_SecHandler::STANDARD = 'standard'

Standard Security Handler

USER

const string SetaPDF_Core_SecHandler::USER = 'user'

User auth mode


Static Properties

$engine

static public string SetaPDF_Core_SecHandler::$engine = 'openssl'

The encryption engine to use (mcrypt or openssl).


Static Methods

aes128Decrypt()

public static SetaPDF_Core_SecHandler::aes128Decrypt (
string $key, string $data
): string

Decrypts data using AES 128 bit algorithm.

Parameters
$key : string
 
$data : string
 

aes128Encrypt()

public static SetaPDF_Core_SecHandler::aes128Encrypt (
string $key, string $data
): string

Encrypts data using AES 128 bit algorithm.

Parameters
$key : string
 
$data : string
 

aes256Decrypt()

public static SetaPDF_Core_SecHandler::aes256Decrypt (
string $key, string $data
): string

Decrypts data using AES 256 bit algorithm.

Parameters
$key : string
 
$data : string
 

aes256Encrypt()

public static SetaPDF_Core_SecHandler::aes256Encrypt (
string $key, string $data
): string

Encrypts data using AES 256 bit algorithm.

Parameters
$key : string
 
$data : string
 

arcfour()

public static SetaPDF_Core_SecHandler::arcfour (
string $key, string $data
): string

Encrypts or decrypts data using the RC4/Arcfour algorithm.

Parameters
$key : string
 
$data : string
 

checkPermission()

public static SetaPDF_Core_SecHandler::checkPermission (
SetaPDF_Core_Document $document, integer $permission [, null|string $message = null ]
): bool

Checks a permission against the security handler of a document.

Parameters
$document : SetaPDF_Core_Document

The document instance

$permission : integer

Permission to check

$message : null|string

Custom error message

Exceptions

Throws SetaPDF_Core_SecHandler_Exception if no rights are granted for the permission.

factory()

Returns a standard predefined security handler.

The type parameter will define things like algorithm and key length. Additionally the type could be an encryption dictionary, which will setup the desired security handler.

Parameters
$document : SetaPDF_Core_Document
 
$encryptionDictionary : SetaPDF_Core_Type_Dictionary
 
Exceptions

Throws SetaPDF_Core_Exception

Throws SetaPDF_Exception_NotImplemented