/**
*
* In prepareSign, the document text is extracted and normalized. *
** In finishSign, the signed SignatureObject is transformed into a Signature * block, which is then written as an Incremental Update. *
* * @author wprinz */ public class DetachedfTextualSignator_1_0_0 implements Signator { /** * The Mime Type. */ public static final String MIME_TYPE = "text/xml"; /** * The Pdf-AS ID of this Signator. */ public static final PdfASID MY_ID = new PdfASID(SignatorFactory.VENDOR, SignatorFactory.TYPE_DETACHED_TEXTUAL, SignatorFactory.VERSION_1_0_0); /** * Default constructor. */ public DetachedfTextualSignator_1_0_0() { // Default constructor. } /** ** The parameter has_SIG_ID is not used by this Signator because it doesn't * pre-format the signature block. *
* * @see at.knowcenter.wag.egov.egiz.framework.Signator#prepareSign(byte[], * String, TablePos, boolean) */ public IncrementalUpdateInformation prepareSign(byte[] pdf, String signature_type, TablePos pos, boolean has_SIG_ID) throws PresentableException { IncrementalUpdateInformation iui = new IncrementalUpdateInformation(); iui.original_document = pdf; iui.signature_type = signature_type; iui.pos = pos; iui.document_text = PdfAS.extractNormalizedTextTextual(pdf); // logger_.debug("signed_text = " + document_text); return iui; } /** * @see at.knowcenter.wag.egov.egiz.framework.Signator#finishSign(at.knowcenter.wag.egov.egiz.pdf.IncrementalUpdateInformation) */ public SignResult finishSign(IncrementalUpdateInformation iui) throws PresentableException { try { String response = iui.signed_signature_object.getRawSignatureResponse(); byte[] response_bytes = response.getBytes("UTF-8"); SignResult sign_result = new SignResult(MIME_TYPE, response_bytes); return sign_result; } catch (UnsupportedEncodingException e) { e.printStackTrace(); throw new PDFDocumentException(300, e); } } }