public class SignatureServiceImpl extends DefaultComponent implements SignatureService
The main document is signed. If it's not already a PDF, then a PDF conversion is done.
Once signed, it can replace the main document or be stored as the first attachment. If replacing the main document, an archive of the original can be kept.
SignatureService.SigningDisposition, SignatureService.StatusWithBlob
Modifier and Type | Field and Description |
---|---|
protected static String |
ALREADY_SIGNED_BY |
protected static String |
FILE_CONTENT |
protected static String |
FILES_FILE |
protected static String |
FILES_FILENAME |
protected static String |
FILES_FILES |
protected static String |
MIME_TYPE_PDF |
protected static int |
PAGE_TO_SIGN |
protected static String |
PDFA1_PARAM
From JODBasedConverter
|
protected static int |
SIGNATURE_FIELD_HEIGHT |
protected static int |
SIGNATURE_FIELD_WIDTH |
protected static int |
SIGNATURE_MARGIN |
protected Map<String,SignatureDescriptor> |
signatureRegistryMap |
protected static String |
USER_EMAIL |
protected static String |
XP_SIGNATURE |
lastModified
Constructor and Description |
---|
SignatureServiceImpl() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
certificatePresentInPDF(Certificate userCert,
List<X509Certificate> pdfCertificates) |
protected List<X509Certificate> |
getCertificates(Blob pdfBlob) |
List<X509Certificate> |
getCertificates(DocumentModel doc)
Returns a list of certificates associated with a given document.
|
protected List<X509Certificate> |
getCertificates(com.lowagie.text.pdf.PdfReader pdfReader) |
protected com.lowagie.text.Rectangle |
getNextCertificatePosition(com.lowagie.text.pdf.PdfReader pdfReader,
List<X509Certificate> pdfCertificates) |
protected SignatureAppearanceFactory |
getSignatureAppearanceFactory() |
SignatureLayout |
getSignatureLayout() |
protected SignatureService.StatusWithBlob |
getSignedPdfBlobAndStatus(DocumentModel doc,
DocumentModel user)
Finds the first signed PDF blob.
|
protected String |
getSigningReason() |
protected int |
getSigningStatus(Blob pdfBlob,
DocumentModel user) |
SignatureService.StatusWithBlob |
getSigningStatus(DocumentModel doc,
DocumentModel user)
Finds the signing status for the document.
|
void |
registerContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
Blob |
signDocument(DocumentModel doc,
DocumentModel user,
String keyPassword,
String reason,
boolean pdfa,
SignatureService.SigningDisposition disposition,
String archiveFilename)
Signs a document with a user certificate (converts it into a PDF first if needed).
|
Blob |
signPDF(Blob pdfBlob,
DocumentModel doc,
DocumentModel user,
String keyPassword,
String reason)
Signs a PDF document with a user certificate.
|
void |
unregisterContribution(Object contribution,
String extensionPoint,
ComponentInstance contributor) |
protected void |
validatePageBounds(com.lowagie.text.pdf.PdfReader pdfReader,
int pageNo,
float valueToCheck,
boolean isHorizontal)
Verifies that a provided value fits within the page bounds.
|
activate, applicationStarted, deactivate, getAdapter, getApplicationStartedOrder, getLastModified, registerExtension, setLastModified, setModifiedNow, unregisterExtension
protected static final int SIGNATURE_FIELD_HEIGHT
protected static final int SIGNATURE_FIELD_WIDTH
protected static final int SIGNATURE_MARGIN
protected static final int PAGE_TO_SIGN
protected static final String XP_SIGNATURE
protected static final String ALREADY_SIGNED_BY
protected static final String MIME_TYPE_PDF
protected static final String PDFA1_PARAM
protected static final String FILE_CONTENT
protected static final String FILES_FILES
protected static final String FILES_FILE
protected static final String FILES_FILENAME
protected static final String USER_EMAIL
protected final Map<String,SignatureDescriptor> signatureRegistryMap
public SignatureServiceImpl()
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
registerContribution
in class DefaultComponent
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
unregisterContribution
in class DefaultComponent
public SignatureService.StatusWithBlob getSigningStatus(DocumentModel doc, DocumentModel user)
SignatureService
A signature user is determined according to its email.
getSigningStatus
in interface SignatureService
doc
- the documentprotected int getSigningStatus(Blob pdfBlob, DocumentModel user)
protected SignatureService.StatusWithBlob getSignedPdfBlobAndStatus(DocumentModel doc, DocumentModel user)
public Blob signDocument(DocumentModel doc, DocumentModel user, String keyPassword, String reason, boolean pdfa, SignatureService.SigningDisposition disposition, String archiveFilename)
SignatureService
Requires a password to retrieve the certificate from the user keystore.
Does not save the modified document.
signDocument
in interface SignatureService
doc
- the document to signuser
- the signing userkeyPassword
- the password for the user's signing certificatereason
- the signing reasonpdfa
- true
if the generated PDF should be a PDF/A-1bdisposition
- the signing dispositionarchiveFilename
- the archive filename when using an archivepublic Blob signPDF(Blob pdfBlob, DocumentModel doc, DocumentModel user, String keyPassword, String reason)
SignatureService
signPDF
in interface SignatureService
pdfBlob
- the blob containing the PDF to signdoc
- Document model beign signeduser
- the signing userkeyPassword
- the password for the user's signing certificatereason
- the signing reasonpublic SignatureLayout getSignatureLayout()
getSignatureLayout
in interface SignatureService
protected SignatureAppearanceFactory getSignatureAppearanceFactory() throws InstantiationException, IllegalAccessException
protected String getSigningReason() throws SignException
SignException
protected boolean certificatePresentInPDF(Certificate userCert, List<X509Certificate> pdfCertificates) throws SignException
SignException
protected com.lowagie.text.Rectangle getNextCertificatePosition(com.lowagie.text.pdf.PdfReader pdfReader, List<X509Certificate> pdfCertificates) throws SignException
SignException
protected void validatePageBounds(com.lowagie.text.pdf.PdfReader pdfReader, int pageNo, float valueToCheck, boolean isHorizontal) throws SignException
isHorizontal
- - if false, the current value is checked agains the vertical page dimensionSignException
public List<X509Certificate> getCertificates(DocumentModel doc)
SignatureService
getCertificates
in interface SignatureService
doc
- the documentprotected List<X509Certificate> getCertificates(Blob pdfBlob) throws SignException
SignException
protected List<X509Certificate> getCertificates(com.lowagie.text.pdf.PdfReader pdfReader) throws SignException
SignException
Copyright © 2015 Nuxeo SA. All rights reserved.