public class SigningService extends Object
The service expects the existence of a valid X509 certificate stored in the keystore.
The service supports the following environment variables:
See also here: https://jvmfy.com/2018/11/17/how-to-digitally-sign-pdf-files/ https://github.com/apache/pdfbox/blob/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature2.java https://ordina-jworks.github.io/security/2019/08/14/Using-Lets-Encrypt-Certificates-In-Java.html
| Modifier and Type | Field and Description |
|---|---|
static String |
ENV_SIGNATURE_ROOTCERT_ALIAS |
static String |
ENV_SIGNATURE_ROOTCERT_PASSWORD |
static String |
ENV_SIGNATURE_TSA_URL |
| Constructor and Description |
|---|
SigningService() |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
signPDF(byte[] inputFileData,
String certAlias,
String certPassword,
boolean externalSigning)
Method Opens the keystore with the given password and creates a new signed
PDF file based on the given PDF File and a signature image.
|
byte[] |
signPDF(byte[] inputFileData,
String certAlias,
String certPassword,
boolean externalSigning,
Rectangle2D humanRect,
int page,
String signatureFieldName,
byte[] imageFile,
String reason)
Sign pdf file and create new file that ends with "_signed.pdf".
|
public static final String ENV_SIGNATURE_TSA_URL
public static final String ENV_SIGNATURE_ROOTCERT_ALIAS
public static final String ENV_SIGNATURE_ROOTCERT_PASSWORD
public byte[] signPDF(byte[] inputFileData,
String certAlias,
String certPassword,
boolean externalSigning)
throws CertificateVerificationException,
SigningException
generate pkcs12-keystore-file with
keytool -storepass 123456 -storetype PKCS12 -keystore file.p12 -genkey -alias client -keyalg RSA
inputFileData - A byte array containing the source PDF document.certAlias - Certificate alias name to be used for signingcertPassword - optional private key passwordexternalSigning - optional boolean flag to trigger an external signing
processSigningExceptionCertificateVerificationExceptionpublic byte[] signPDF(byte[] inputFileData,
String certAlias,
String certPassword,
boolean externalSigning,
Rectangle2D humanRect,
int page,
String signatureFieldName,
byte[] imageFile,
String reason)
throws CertificateVerificationException,
SigningException
inputFileData - A byte array containing the source PDF document.certAlias - Certificate alias name to be used for signingcertPassword - optional private key passwordexternalSigning - optional boolean flag to trigger an external
signing processhumanRect - rectangle from a human viewpoint (coordinates start
at top left)page - page number (beginning with 1) to place the visual
signaturetsaUrl - optional TSA urlsignatureFieldName - optional name of an existing (unsigned) signature
fieldimageFile - optional image filereason - workflow statusCertificateVerificationExceptionSigningExceptionCopyright © 2016–2021 Imixs Software Solutions GmbH. All rights reserved.