setasign\SetaPDF2\Signer

TmpDocument Class for handling an intermediate version of the document that should be signed.

File: /SetaPDF v2/Signer/TmpDocument.php
Old class name (alias): \SetaPDF_Signer_TmpDocument

This class is used for an asyncron signature flow. Otherwise it is used internally.

Class hierarchy

Summary

Properties

$_byteRange

protected array TmpDocument::$_byteRange

The byte range value

$_documentIdentification

protected array TmpDocument::$_documentIdentification = array(...)

Document identification related data

$_hashFileWriter

The writer instance for the 2nd temporary file, that represents the data to hash

$_identficationHash

protected string TmpDocument::$_identficationHash

Hash of the last state of the intermediate document version.

$_writer

The file writer for the temporary version


Methods

__construct()

The constructor

The $writer parameter is optional and can be used in an asyncron workflow to have control over the temporary version of the document.

Parameters
$writer : ?\SetaPDF_Core_Writer_FileInterface
 

_getHashByDocument()

Get the SHA-256 hash by a document instance.

Parameters
$document : \SetaPDF_Core_Document
 
Exceptions

Throws Exception

destroy()

public TmpDocument::destroy (
void
): void

Unlinks the temporary file.

getByteRange()

public TmpDocument::getByteRange (
void
): array

Get the byte range.

getHashFile()

Create and get the file path to a temporary file that represents the bytes that should be be used for hashing.

getSignatureContentLength()

Get the signature content length.

getWriter()

Get the writer instance.

matchesDocument()

Checks whether the document instance matches this temporary version.

The checks are done by the instance identification of the class instance frist. If this does not match, because of an asyncron workflow the document identifications are compared.

Parameters
$document : \SetaPDF_Core_Document
 

save()

Saves the temporary document to a writer instance.

Parameters
$writer : \SetaPDF_Core_Writer_WriterInterface
 

setByteRange()

public TmpDocument::setByteRange (
array $byteRange
): void

Set the final byte range.

Parameters
$byteRange : array
 

setDocumentIdentification()

Set the document identification related data.

Parameters
$document : \SetaPDF_Core_Document
 

setWriter()

Set the writer instance.

Parameters
$writer : \SetaPDF_Core_Writer_FileInterface
 

updateIdentificationHash()

public TmpDocument::updateIdentificationHash (
void
): void

Updates the identification hash of the intermediate document version.

updateLastByteOffset()

public TmpDocument::updateLastByteOffset (
int $offset,
int $position,
int $length
): void

Updates the last byte offset in the /ByteRange entry in the to be signed document.

Parameters
$offset : int
 
$position : int
 
$length : int
 

writeSignature()

public TmpDocument::writeSignature (
string $signature
): void

Writes the signature into the reserved gap.

The signature string needs to have the same length as the gap.

Parameters
$signature : string