public abstract class

ContainedSignaturesSigner

extends Signer
java.lang.Object
   ↳ com.pspdfkit.signatures.signers.Signer
     ↳ com.pspdfkit.signatures.signers.ContainedSignaturesSigner

Class Overview

Signer for contained signatures workflow. Contained digital signatures are especially useful when the cryptographic material to sign a document (keys, certificates) is not available on the local device.

To use contained signatures:

  1. First, you need to “prepare” a document with a signature form field via prepareFormFieldForSigningAsync(SignerOptions). This method stamps a custom signature appearance and reserves space in the PDF for the digital signature.
  2. Second, you “embed” a custom PKCS#7 signature container in a document that was already “prepared” in the first step via embedSignatureInFormFieldAsync(SignatureFormField, SignatureContents, OutputStream). The end result is a digitally signed document.

The recommended way to use this API is to override prepareSignatureContents(SignerOptions, File, PdfDocument, SignatureFormField) and return a valid digital signature in the cryptographic PKCS#7 format for the prepared document. The signFormFieldAsync(SignerOptions) already encapsulates the whole contained signatures flow.

Summary

Protected Constructors
ContainedSignaturesSigner(String displayName)
Create the signer.
ContainedSignaturesSigner(Context context, String displayName)
Create the signer with a digital signature subfilter type set as ADOBE_PKCS7_DETACHED.
ContainedSignaturesSigner(Context context, String displayName, FilterSubtype filterSubtype)
Create the signer with a specific digital signature subfilter type.
Public Methods
Completable signFormFieldAsync(SignerOptions signerOptions)
Signs a SignatureFormField form element (and with that, the document) asynchronously on a background thread.
Protected Methods
abstract SignatureContents prepareSignatureContents(SignerOptions signerOptions, File preparedDocumentFile, PdfDocument preparedDocument, SignatureFormField preparedFormField)
Implement this method to return a custom implementation of SignatureContents that should embedded as a digital signature when signing.
[Expand]
Inherited Methods
From class com.pspdfkit.signatures.signers.Signer
From class java.lang.Object

Protected Constructors

protected ContainedSignaturesSigner (String displayName)

Create the signer.

Parameters
displayName The human readable name of this signer.

protected ContainedSignaturesSigner (Context context, String displayName)

Create the signer with a digital signature subfilter type set as ADOBE_PKCS7_DETACHED.

Parameters
context Context to use during the contained signatures flow.
displayName The human readable name of this signer.

protected ContainedSignaturesSigner (Context context, String displayName, FilterSubtype filterSubtype)

Create the signer with a specific digital signature subfilter type.

Parameters
context Context to use during the contained signatures flow.
displayName The human readable name of this signer.
filterSubtype Signature "SubFilter" type in the PDF.

Public Methods

public Completable signFormFieldAsync (SignerOptions signerOptions)

Signs a SignatureFormField form element (and with that, the document) asynchronously on a background thread.

Parameters
signerOptions The SignerOptions to use for signing this document.
Returns
  • a Completable that can be subscribed to.

Protected Methods

protected abstract SignatureContents prepareSignatureContents (SignerOptions signerOptions, File preparedDocumentFile, PdfDocument preparedDocument, SignatureFormField preparedFormField)

Implement this method to return a custom implementation of SignatureContents that should embedded as a digital signature when signing.

You are responsible for generating a valid digital signature in the cryptographic PKCS#7 format for the prepared document. In order to do that, return a custom implementation of SignatureContents. You'll receive the part of the document that you need to hash, encrypt, and package into a digital signature in signData(byte[]). You can use getHashForDocumentRange(List, HashAlgorithm) to help you calculate the hash value of signed parts of a PDF document. You can generate the PKCS7 signature container with the help of our PKCS7 class or use PKCS7SignatureContents directly.

Parameters
signerOptions Signer options used for signing passed to signFormFieldAsync(SignerOptions).
preparedDocumentFile File with the document prepared via prepareFormFieldForSigningAsync(SignerOptions)
preparedDocument Document prepared via prepareFormFieldForSigningAsync(SignerOptions)
preparedFormField Signature form field in the prepared document.
Returns