Object SigningManager
-
- All Implemented Interfaces:
public class SigningManager
SigningManager provides a public API to digitally sign documents with either PAdES advanced digital signatures or basic CMS signatures (see DigitalSignatureType)
Use TrustedKeyStore to add trusted certificates for signature validation.
-
-
Field Summary
Fields Modifier and Type Field Description public final static SigningManager
INSTANCE
-
Method Summary
Modifier and Type Method Description final Unit
signDocument(Context context, SignerOptions signerOptions, SuspendFunction2<ByteArray, String, ByteArray> customSigning, Function1<Throwable, Unit> onFailure, Function0<Unit> onSuccess)
signDocument provides functionality to insert a digital signature in a document final Response<Pair<ByteArray, HashAlgorithm>>
getDataToSign(Context context, SignerOptions signerOptions)
This function provides unsigned byte array that needs to be signed. final Response<Void>
embedSignature(Context context, SignerOptions signerOptions, ByteArray signedData, ByteArray unsignedData, HashAlgorithm hashAlgorithm)
This function is used to embed a PKCS#1 signature in the document. final Response<Void>
embedPKCS7Signature(Context context, SignerOptions signerOptions, ByteArray signedData)
This function is used to embed a complete PKCS@7 signature in the document. final Response<ByteArray>
signWithBasicSignature(Context context, SignerOptions signerOptions, ByteArray unsignedData, HashAlgorithm hashAlgorithm)
This function is used to provide a complete PKCS#7 signature in the document with com.pspdfkit.signatures.DigitalSignatureType.BASIC digital signature type. final Response<ByteArray>
signWithCAdESSignature(Context context, SignerOptions signerOptions, ByteArray unsignedData, HashAlgorithm hashAlgorithm)
This function is used to provide a complete PKCS#7 signature in the document with com.pspdfkit.signatures.DigitalSignatureType.CADES digital signature type. -
-
Method Detail
-
signDocument
final Unit signDocument(Context context, SignerOptions signerOptions, SuspendFunction2<ByteArray, String, ByteArray> customSigning, Function1<Throwable, Unit> onFailure, Function0<Unit> onSuccess)
signDocument provides functionality to insert a digital signature in a document
- Parameters:
signerOptions
- contains various configurations needed for the signing.customSigning
- if you want custom signing behaviour, add it here.onFailure
- is called when any exception is thrownonSuccess
- provides a callback where customer can use com.pspdfkit.signatures.SignerOptions.outputDataProvider as a result param.
-
getDataToSign
final Response<Pair<ByteArray, HashAlgorithm>> getDataToSign(Context context, SignerOptions signerOptions)
This function provides unsigned byte array that needs to be signed.
The list of certificates may be empty to retrieve unsigned byte array, this is for cases where the certificate chain is not known beforehand (for instance, a signing service that issues short-lived certificates). In that case, it's assumed that the
signed_data
parameter passed tofinish_signature
will embed a complete signature with certificates, CRLs, etc., created by the external signing service. in such cases embedPKCS7Signature is used to embed the signature.Where the certificate chain is known beforehand, the certificates are passed in the
certificates
parameter to retrieve unsigned byte array. In this case embedSignature can be used to embed the signature. And can be signed with java.security.Signature.sign method.Results can be extracted by com.pspdfkit.utils.Response.onSuccess or com.pspdfkit.utils.Response.onError
- Parameters:
context
- Context of the applicationsignerOptions
- SignerOptions contains various configurations needed for the signing.- Returns:
com.pspdfkit.utils.Response with pair of ByteArray and HashAlgorithm
-
embedSignature
final Response<Void> embedSignature(Context context, SignerOptions signerOptions, ByteArray signedData, ByteArray unsignedData, HashAlgorithm hashAlgorithm)
This function is used to embed a PKCS#1 signature in the document. Results can be extracted by com.pspdfkit.utils.Response.onSuccessEmpty or com.pspdfkit.utils.Response.onError
- Parameters:
context
- Context of the applicationsignerOptions
- SignerOptions contains various configurations needed for the signing.signedData
- ByteArrayunsignedData
- ByteArrayhashAlgorithm
- HashAlgorithm used for the signature- Returns:
com.pspdfkit.utils.Response with Nothing as a result.
-
embedPKCS7Signature
final Response<Void> embedPKCS7Signature(Context context, SignerOptions signerOptions, ByteArray signedData)
This function is used to embed a complete PKCS@7 signature in the document. Results can be extracted by com.pspdfkit.utils.Response.onSuccessEmpty or com.pspdfkit.utils.Response.onError
- Parameters:
context
- Context of the applicationsignerOptions
- SignerOptions contains various configurations needed for the signing.signedData
- ByteArray- Returns:
com.pspdfkit.utils.Response with Nothing as a result.
-
signWithBasicSignature
final Response<ByteArray> signWithBasicSignature(Context context, SignerOptions signerOptions, ByteArray unsignedData, HashAlgorithm hashAlgorithm)
This function is used to provide a complete PKCS#7 signature in the document with com.pspdfkit.signatures.DigitalSignatureType.BASIC digital signature type. Results can be extracted by com.pspdfkit.utils.Response.onSuccess or com.pspdfkit.utils.Response.onError
- Parameters:
context
- Context of the applicationsignerOptions
- SignerOptions contains various configurations needed for the signing.unsignedData
- ByteArrayhashAlgorithm
- HashAlgorithm used for the signature- Returns:
com.pspdfkit.utils.Response with ByteArray as a result.
-
signWithCAdESSignature
final Response<ByteArray> signWithCAdESSignature(Context context, SignerOptions signerOptions, ByteArray unsignedData, HashAlgorithm hashAlgorithm)
This function is used to provide a complete PKCS#7 signature in the document with com.pspdfkit.signatures.DigitalSignatureType.CADES digital signature type. Results can be extracted by com.pspdfkit.utils.Response.onSuccess or com.pspdfkit.utils.Response.onError
- Parameters:
context
- Context of the applicationsignerOptions
- SignerOptions contains various configurations needed for the signing.unsignedData
- ByteArrayhashAlgorithm
- HashAlgorithm used for the signature- Returns:
com.pspdfkit.utils.Response with ByteArray as a result.
-
-
-
-