From 3d982813b34f6f230baf4a467cdc37ec92a77595 Mon Sep 17 00:00:00 2001 From: netconomy Date: Fri, 17 Aug 2007 06:10:56 +0000 Subject: Performance git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@167 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../wag/egov/egiz/pdf/BinarySignatureHolder.java | 165 ++++++++++++--------- 1 file changed, 98 insertions(+), 67 deletions(-) (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignatureHolder.java') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignatureHolder.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignatureHolder.java index 1f522ff..8d42370 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignatureHolder.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/BinarySignatureHolder.java @@ -19,6 +19,10 @@ package at.knowcenter.wag.egov.egiz.pdf; import java.io.Serializable; +import at.gv.egiz.pdfas.impl.input.ByteArrayPdfDataSourceImpl; +import at.gv.egiz.pdfas.framework.input.DataSource; +import at.gv.egiz.pdfas.framework.input.PdfDataSource; + import at.knowcenter.wag.egov.egiz.sig.SignatureObject; /** @@ -44,48 +48,58 @@ public class BinarySignatureHolder implements Serializable, SignatureHolder */ private static final long serialVersionUID = -7208103904479272760L; - /** - * The whole pdf this holder was extracted from. - */ - private byte[] signed_pdf = null; - - /** - * The number of bytes that give the signed document. - */ - private int signed_pdf_length = -1; - - /** - * The signed text of this object. - * - *

- * This is the value that will be signed by the Connector. - *

- */ - private String signed_text = null; +// /** +// * The whole pdf this holder was extracted from. +// */ +// private byte[] signed_pdf = null; + + private PdfDataSource pdfDataSource = null; + +// /** +// * The number of bytes that give the signed document. +// */ +// private int signed_pdf_length = -1; + +// /** +// * The signed text of this object. +// * +// *

+// * This is the value that will be signed by the Connector. +// *

+// */ +// private String signed_text = null; /** * The signature object. */ private SignatureObject signature_object = null; - /** - * Constructor that takes the pdf and the SignatureObject as parameters. - * - * @param pdf - * The pdf data. - * @param length - * The length (number of bytes) of the pdf data to be used for being - * converted into "signed text". - * @param so - * The signed signature object. - */ - public BinarySignatureHolder(final byte[] pdf, final int length, SignatureObject so) +// /** +// * Constructor that takes the pdf and the SignatureObject as parameters. +// * +// * @param pdf +// * The pdf data. +// * @param length +// * The length (number of bytes) of the pdf data to be used for being +// * converted into "signed text". +// * @param so +// * The signed signature object. +// */ +// public BinarySignatureHolder(final byte[] pdf, final int length, SignatureObject so) +// { +//// this.signed_pdf = pdf; +// this.pdfDataSource = new ByteArrayPdfDataSourceImpl(pdf); +// // streaming byte array +// this.signed_pdf_length = length; +// this.signature_object = so; +// +//// this.signed_text = null; +// } + + public BinarySignatureHolder(PdfDataSource pdf, SignatureObject so) { - this.signed_pdf = pdf; - this.signed_pdf_length = length; + this.pdfDataSource = pdf; this.signature_object = so; - - this.signed_text = null; } /** @@ -93,11 +107,12 @@ public class BinarySignatureHolder implements Serializable, SignatureHolder */ public String getSignedText() { - if (this.signed_text == null) - { - computeSignedText(); - } - return this.signed_text; + throw new RuntimeException("BinarySignatureHolder must not return text."); +// if (this.signed_text == null) +// { +// computeSignedText(); +// } +// return this.signed_text; } /** @@ -107,40 +122,56 @@ public class BinarySignatureHolder implements Serializable, SignatureHolder { return this.signature_object; } - + /** - * Computes or recomputes the signed text from the underlying binary data. - * - *

- * This usually encodes the binary data of given length in Base64. - *

- * - *

- * This is usually called automatically when the signed text is first - * requested. - *

+ * @see at.knowcenter.wag.egov.egiz.pdf.SignatureHolder#getDataSource() */ - protected void computeSignedText() + public DataSource getDataSource() { - this.signed_text = BinarySignature.retrieveSignableTextFromData(this.signed_pdf, this.signed_pdf_length); + return getSignedPdf(); } - - /** - * Returns the signed_pdf. - * @return Returns the signed_pdf. - */ - public byte[] getSignedPdf() + + + + // TODO obsolete funtction - remove; +// /** +// * Computes or recomputes the signed text from the underlying binary data. +// * +// *

+// * This usually encodes the binary data of given length in Base64. +// *

+// * +// *

+// * This is usually called automatically when the signed text is first +// * requested. +// *

+// */ +// protected void computeSignedText() +// { +// this.signed_text = BinarySignature.retrieveSignableTextFromData(this.signed_pdf, this.signed_pdf_length); +// } + +// /** +// * Returns the signed_pdf. +// * @return Returns the signed_pdf. +// */ +// public byte[] getSignedPdf() +// { +// return this.signed_pdf; +// } + + public PdfDataSource getSignedPdf () { - return this.signed_pdf; + return this.pdfDataSource; } - /** - * Returns the signed_pdf_length. - * @return Returns the signed_pdf_length. - */ - public int getSignedPdfLength() - { - return this.signed_pdf_length; - } +// /** +// * Returns the signed_pdf_length. +// * @return Returns the signed_pdf_length. +// */ +// public int getSignedPdfLength() +// { +// return this.signed_pdf_length; +// } } -- cgit v1.2.3