Class SignatureServiceImpl
java.lang.Object
org.nuxeo.runtime.model.DefaultComponent
org.nuxeo.ecm.platform.signature.core.sign.SignatureServiceImpl
- All Implemented Interfaces:
SignatureService
,Adaptable
,Component
,Extensible
,TimestampedService
Base implementation for the signature service (also a Nuxeo component).
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.nuxeo.ecm.platform.signature.api.sign.SignatureService
SignatureService.SigningDisposition, SignatureService.StatusWithBlob
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final int
protected static final String
From JODBasedConverterprotected static final int
protected static final int
protected static final int
protected final Map<String,
SignatureDescriptor> protected static final String
protected static final String
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
certificatePresentInPDF
(Certificate userCert, List<X509Certificate> pdfCertificates) protected List<X509Certificate>
getCertificates
(com.lowagie.text.pdf.PdfReader pdfReader) protected List<X509Certificate>
getCertificates
(Blob pdfBlob) Returns a list of certificates associated with a given document.protected com.lowagie.text.Rectangle
getNextCertificatePosition
(com.lowagie.text.pdf.PdfReader pdfReader, List<X509Certificate> pdfCertificates) protected SignatureAppearanceFactory
protected SignatureService.StatusWithBlob
getSignedPdfBlobAndStatus
(DocumentModel doc, DocumentModel user) Finds the first signed PDF blob.protected String
protected int
getSigningStatus
(Blob pdfBlob, DocumentModel user) getSigningStatus
(DocumentModel doc, DocumentModel user) Finds the signing status for the document.void
registerContribution
(Object contribution, String extensionPoint, ComponentInstance contributor) 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).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.Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, deactivate, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerExtension, setLastModified, setModifiedNow, setName, start, stop, unregister, unregisterExtension
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.nuxeo.runtime.model.Component
getApplicationStartedOrder
-
Field Details
-
SIGNATURE_FIELD_HEIGHT
protected static final int SIGNATURE_FIELD_HEIGHT- See Also:
-
SIGNATURE_FIELD_WIDTH
protected static final int SIGNATURE_FIELD_WIDTH- See Also:
-
SIGNATURE_MARGIN
protected static final int SIGNATURE_MARGIN- See Also:
-
PAGE_TO_SIGN
protected static final int PAGE_TO_SIGN- See Also:
-
XP_SIGNATURE
- See Also:
-
ALREADY_SIGNED_BY
- See Also:
-
MIME_TYPE_PDF
- See Also:
-
PDFA1_PARAM
From JODBasedConverter- See Also:
-
FILE_CONTENT
- See Also:
-
FILES_FILES
- See Also:
-
FILES_FILE
- See Also:
-
USER_EMAIL
- See Also:
-
signatureRegistryMap
-
-
Constructor Details
-
SignatureServiceImpl
public SignatureServiceImpl()
-
-
Method Details
-
registerContribution
public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) - Overrides:
registerContribution
in classDefaultComponent
-
unregisterContribution
public void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor) - Overrides:
unregisterContribution
in classDefaultComponent
-
getSigningStatus
Description copied from interface:SignatureService
Finds the signing status for the document.A signature user is determined according to its email.
- Specified by:
getSigningStatus
in interfaceSignatureService
- Parameters:
doc
- the document- Returns:
- the signing status
-
getSigningStatus
-
getSignedPdfBlobAndStatus
protected SignatureService.StatusWithBlob getSignedPdfBlobAndStatus(DocumentModel doc, DocumentModel user) Finds the first signed PDF blob. -
signDocument
public Blob signDocument(DocumentModel doc, DocumentModel user, String keyPassword, String reason, boolean pdfa, SignatureService.SigningDisposition disposition, String archiveFilename) Description copied from interface:SignatureService
Signs a document with a user certificate (converts it into a PDF first if needed).Requires a password to retrieve the certificate from the user keystore.
Does not save the modified document.
- Specified by:
signDocument
in interfaceSignatureService
- Parameters:
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 archive- Returns:
- a blob containing the signed PDF
-
signPDF
public Blob signPDF(Blob pdfBlob, DocumentModel doc, DocumentModel user, String keyPassword, String reason) Description copied from interface:SignatureService
Signs a PDF document with a user certificate. Requires a password to retrieve the certificate from the user keystore.- Specified by:
signPDF
in interfaceSignatureService
- Parameters:
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 reason- Returns:
- a blob containing the signed PDF
-
getSignatureLayout
- Specified by:
getSignatureLayout
in interfaceSignatureService
- Returns:
- the signature layout. Default one if no contribution.
- Since:
- 5.8
-
getSignatureAppearanceFactory
protected SignatureAppearanceFactory getSignatureAppearanceFactory() throws ReflectiveOperationException- Throws:
ReflectiveOperationException
-
getSigningReason
- Throws:
SignException
-
certificatePresentInPDF
protected boolean certificatePresentInPDF(Certificate userCert, List<X509Certificate> pdfCertificates) throws SignException - Throws:
SignException
-
getNextCertificatePosition
protected com.lowagie.text.Rectangle getNextCertificatePosition(com.lowagie.text.pdf.PdfReader pdfReader, List<X509Certificate> pdfCertificates) throws SignException - Throws:
SignException
- Since:
- 5.8 Provides the position rectangle for the next certificate. An assumption is made that all previous certificates in a given PDF were placed using the same technique and settings. New certificates are added depending of signature layout contributed.
-
validatePageBounds
protected void validatePageBounds(com.lowagie.text.pdf.PdfReader pdfReader, int pageNo, float valueToCheck, boolean isHorizontal) throws SignException Verifies that a provided value fits within the page bounds. If it does not, a sign exception is thrown. This is to verify externally configurable signature positioning.- Parameters:
isHorizontal
- - if false, the current value is checked agains the vertical page dimension- Throws:
SignException
-
getCertificates
Description copied from interface:SignatureService
Returns a list of certificates associated with a given document.- Specified by:
getCertificates
in interfaceSignatureService
- Parameters:
doc
- the document- Returns:
- the list of certificates (may be empty)
-
getCertificates
- Throws:
SignException
-
getCertificates
protected List<X509Certificate> getCertificates(com.lowagie.text.pdf.PdfReader pdfReader) throws SignException - Throws:
SignException
-