aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/IncrementalUpdateInformation.java
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/IncrementalUpdateInformation.java')
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/IncrementalUpdateInformation.java252
1 files changed, 252 insertions, 0 deletions
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/IncrementalUpdateInformation.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/IncrementalUpdateInformation.java
new file mode 100644
index 0000000..3714684
--- /dev/null
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/pdf/IncrementalUpdateInformation.java
@@ -0,0 +1,252 @@
+/**
+ * <copyright> Copyright 2006 by Know-Center, Graz, Austria </copyright>
+ * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a
+ * joint initiative of the Federal Chancellery Austria and Graz University of
+ * Technology.
+ *
+ * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
+ * the European Commission - subsequent versions of the EUPL (the "Licence");
+ * You may not use this work except in compliance with the Licence.
+ * You may obtain a copy of the Licence at:
+ * http://www.osor.eu/eupl/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the Licence is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the Licence for the specific language governing permissions and
+ * limitations under the Licence.
+ *
+ * This product combines work with different licenses. See the "NOTICE" text
+ * file for details on the various modules and licenses.
+ * The "NOTICE" text file is part of the distribution. Any derivative works
+ * that you distribute must include a readable copy of the "NOTICE" text file.
+ *
+ * $Id: IncrementalUpdateInformation.java,v 1.2 2006/10/31 08:09:33 wprinz Exp $
+ */
+package at.knowcenter.wag.egov.egiz.pdf;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo;
+import at.gv.egiz.pdfas.api.timestamp.TimeStamper;
+import at.gv.egiz.pdfas.framework.input.PdfDataSource;
+import at.gv.egiz.pdfas.utils.PdfAUtil;
+import at.knowcenter.wag.egov.egiz.sig.SignatureData;
+import at.knowcenter.wag.egov.egiz.sig.connectors.bku.SignSignatureObject;
+
+import com.lowagie.text.pdf.PdfReader;
+
+/**
+ * This parameter object contains all useful inforamtion the binary incremental
+ * update methods need to create and replace a binary singature block.
+ *
+ * <p>
+ * This class is basically used to transport information about the document from
+ * the prepareSign to the finishSign of the Signator. In future, this could be
+ * extended and encapsulated to task proprietary IUI instances. E.g. a
+ * BinarySignatorIUI, a TextualSignatorIUI, both implementing the core IUI
+ * interface, but encapsulating Binary or Textual specialities.
+ * </p>
+ *
+ * @author wprinz
+ */
+public class IncrementalUpdateInformation implements Serializable
+{
+ public static final Logger log = Logger.getLogger(IncrementalUpdateInformation.class);
+
+ /**
+ * SVUID.
+ */
+ private static final long serialVersionUID = -5904526956127108035L;
+
+ /**
+ * The original PDF document.
+ */
+ //public byte[] original_document = null;
+ public PdfDataSource original_document = null;
+
+ /**
+ * The Singature type to be created.
+ */
+ public String signature_type = null;
+
+ /**
+ * The signed pdf document.
+ *
+ * <p>
+ * This is the original document plus the incremental update block.
+ * </p>
+ */
+ public byte[] signed_pdf = null;
+ // this is only valid during prepare
+
+ // holds the variable iui data for bin sigs.
+ public byte [] sign_iui_block = null;
+
+ /**
+ * The start index of this incremental update block.
+ */
+ int start_index = -1;
+
+ /**
+ * The indirect reference of the egiz dict.
+ */
+ // PdfIndirectReference egiz_dict_ir = null;
+ public int egiz_dict_ir_number;
+
+ public int egiz_dict_ir_generation;
+
+ /**
+ * The List of ReplaceInfo objects specifying the byte ranges where the
+ * variable data has to be fille in.
+ */
+ public List replaces = null;
+
+ /**
+ * The List of StringInfo objects specifying the byte ranges that should
+ * be/were signed.
+ */
+ public List byte_ranges = null;
+
+ /**
+ * The indirect reference of the signature x-object.
+ */
+ // public PdfIndirectReference temp_ir;
+ public int temp_ir_number;
+
+ public int temp_ir_generation;
+
+ /**
+ * The start index of the content stream of the signature x-object.
+ */
+ public int content_stream_start = -1;
+
+ /**
+ * The length of the content stream of the signature x-object.
+ */
+ public int content_stream_length = -1;
+
+// /**
+// * The document text for signing.
+// */
+// public String document_text;
+ /**
+ * The data to be signed or verified.
+ *
+ * <p>
+ * For text signature this is the document text.
+ * For binary signature this is the PDF document.
+ * </p>
+ */
+ public SignatureData signature_data = null;
+
+ /**
+ * The SignatureObject containing the variable values after the document text
+ * has been signed.
+ * <p>
+ * These values have to be filled in.
+ * </p>
+ */
+ public SignSignatureObject signed_signature_object;
+
+ /**
+ * The start of the /encodings array.
+ */
+ public int enc_start = -1;
+
+ /**
+ * The length of the /encodings array.
+ */
+ public int enc_length = -1;
+
+ /**
+ * The start of the first /Cert
+ */
+ public int cert_start = -1;
+
+ /**
+ * The length of the /cert placeholder.
+ */
+ public int cert_length = -1;
+
+ /**
+ * The length of the /TimeStamp placeholder.
+ */
+ public int timestamp_length = -1;
+
+ /**
+ * The start of the first /Timestamp
+ */
+ public int timestamp_start = -1;
+
+ /**
+ * The list of strings of the KZ.
+ */
+ public List kz_list;
+
+ /**
+ * The table position.
+ */
+ public TablePos pos;
+
+ /**
+ * For signing: the profile.
+ */
+ public String signProfile;
+
+ /**
+ * The actual position where the table was written.
+ */
+ public ActualTablePos actualTablePos;
+
+ /**
+ * The field definitions of invisible fields, which data should be stored in /Data.
+ */
+ public List invisible_field_definitions;
+
+ /**
+ * The invisible KZ String, if KZ is invisible.
+ */
+ public String invisibleKZString = null;
+
+ /**
+ * List {@link NonTextObjectInfo} of non text objects if available (text signature only).
+ *
+ */
+ public List nonTextObjectInfos;
+
+
+ /**
+ * The timestamper if any
+ */
+ public TimeStamper timeStamper;
+
+ // dferbas
+
+ public String getPdfVersion() {
+ byte[] pdf_data = this.original_document.getAsByteArray();
+ PdfReader reader;
+ String pdfVersion = null;
+ try {
+ reader = new PdfReader(pdf_data);
+ // is.close();
+
+ byte[] metaData = reader.getMetadata();
+ if (metaData != null) {
+ pdfVersion = PdfAUtil.findPdfAVersion(new String(metaData));
+ }
+ if (pdfVersion == null) {
+ pdfVersion = "PDF 1." + reader.getPdfVersion();
+ }
+
+ reader.close();
+ } catch (IOException e) {
+ log.error(e.getMessage(), e);
+ }
+ return pdfVersion;
+ }
+}