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
public class SignatureServiceImpl extends DefaultComponent implements SignatureService
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
Fields Modifier and Type Field Description protected static String
ALREADY_SIGNED_BY
protected static String
FILE_CONTENT
protected static String
FILES_FILE
protected static String
FILES_FILES
protected static String
MIME_TYPE_PDF
protected static int
PAGE_TO_SIGN
protected static String
PDFA1_PARAM
From JODBasedConverterprotected 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
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description SignatureServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
certificatePresentInPDF(Certificate userCert, List<X509Certificate> pdfCertificates)
protected List<X509Certificate>
getCertificates(com.lowagie.text.pdf.PdfReader pdfReader)
protected List<X509Certificate>
getCertificates(Blob pdfBlob)
List<X509Certificate>
getCertificates(DocumentModel doc)
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
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.-
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
applicationStarted, getApplicationStartedOrder
-
-
-
-
Field Detail
-
SIGNATURE_FIELD_HEIGHT
protected static final int SIGNATURE_FIELD_HEIGHT
- See Also:
- Constant Field Values
-
SIGNATURE_FIELD_WIDTH
protected static final int SIGNATURE_FIELD_WIDTH
- See Also:
- Constant Field Values
-
SIGNATURE_MARGIN
protected static final int SIGNATURE_MARGIN
- See Also:
- Constant Field Values
-
PAGE_TO_SIGN
protected static final int PAGE_TO_SIGN
- See Also:
- Constant Field Values
-
XP_SIGNATURE
protected static final String XP_SIGNATURE
- See Also:
- Constant Field Values
-
ALREADY_SIGNED_BY
protected static final String ALREADY_SIGNED_BY
- See Also:
- Constant Field Values
-
MIME_TYPE_PDF
protected static final String MIME_TYPE_PDF
- See Also:
- Constant Field Values
-
PDFA1_PARAM
protected static final String PDFA1_PARAM
From JODBasedConverter- See Also:
- Constant Field Values
-
FILE_CONTENT
protected static final String FILE_CONTENT
- See Also:
- Constant Field Values
-
FILES_FILES
protected static final String FILES_FILES
- See Also:
- Constant Field Values
-
FILES_FILE
protected static final String FILES_FILE
- See Also:
- Constant Field Values
-
USER_EMAIL
protected static final String USER_EMAIL
- See Also:
- Constant Field Values
-
signatureRegistryMap
protected final Map<String,SignatureDescriptor> signatureRegistryMap
-
-
Method Detail
-
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
public SignatureService.StatusWithBlob getSigningStatus(DocumentModel doc, DocumentModel user)
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
protected int getSigningStatus(Blob pdfBlob, DocumentModel user)
-
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
public SignatureLayout 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
protected String getSigningReason() throws SignException
- 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
public List<X509Certificate> getCertificates(DocumentModel doc)
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
protected List<X509Certificate> getCertificates(Blob pdfBlob) throws SignException
- Throws:
SignException
-
getCertificates
protected List<X509Certificate> getCertificates(com.lowagie.text.pdf.PdfReader pdfReader) throws SignException
- Throws:
SignException
-
-