aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators
diff options
context:
space:
mode:
Diffstat (limited to 'pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators')
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_0_0.java396
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_1_0.java44
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_1_0_0.java147
-rw-r--r--pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_pdfasold.java106
4 files changed, 693 insertions, 0 deletions
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_0_0.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_0_0.java
new file mode 100644
index 0000000..1ec1568
--- /dev/null
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_0_0.java
@@ -0,0 +1,396 @@
+/**
+ * <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: BinaryVerificator_1_0_0.java,v 1.3 2006/10/11 08:03:22 wprinz Exp $
+ */
+package at.knowcenter.wag.egov.egiz.framework.verificators;
+
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import at.gv.egiz.pdfas.exceptions.ErrorCode;
+import at.gv.egiz.pdfas.framework.input.PdfDataSource;
+import at.gv.egiz.pdfas.impl.input.ByteArrayPdfDataSourceImpl;
+import at.gv.egiz.pdfas.impl.vfilter.helper.VerificationFilterBinaryHelper;
+
+import org.apache.log4j.Logger;
+
+import at.knowcenter.wag.egov.egiz.PdfASID;
+import at.knowcenter.wag.egov.egiz.cfg.ConfigLogger;
+import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
+import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
+import at.knowcenter.wag.egov.egiz.exceptions.PresentableException;
+import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
+import at.knowcenter.wag.egov.egiz.framework.VerificationFilter;
+import at.knowcenter.wag.egov.egiz.framework.Verificator;
+import at.knowcenter.wag.egov.egiz.pdf.BinaryBlockInfo;
+import at.knowcenter.wag.egov.egiz.pdf.BinarySignature;
+import at.knowcenter.wag.egov.egiz.pdf.BinarySignatureHolder;
+import at.knowcenter.wag.egov.egiz.pdf.Placeholder;
+import at.knowcenter.wag.egov.egiz.pdf.ReplaceInfo;
+import at.knowcenter.wag.egov.egiz.pdf.StringInfo;
+import at.knowcenter.wag.egov.egiz.sig.SignatureObject;
+import at.knowcenter.wag.egov.egiz.sig.SignatureTypes;
+import at.knowcenter.wag.exactparser.parsing.IndirectObjectReference;
+import at.knowcenter.wag.exactparser.parsing.PDFUtils;
+import at.knowcenter.wag.exactparser.parsing.results.ArrayParseResult;
+import at.knowcenter.wag.exactparser.parsing.results.DictionaryParseResult;
+import at.knowcenter.wag.exactparser.parsing.results.FooterParseResult;
+import at.knowcenter.wag.exactparser.parsing.results.IndirectObjectReferenceParseResult;
+import at.knowcenter.wag.exactparser.parsing.results.LiteralStringParseResult;
+import at.knowcenter.wag.exactparser.parsing.results.NameParseResult;
+import at.knowcenter.wag.exactparser.parsing.results.NumberParseResult;
+import at.knowcenter.wag.exactparser.parsing.results.ObjectParseResult;
+import at.knowcenter.wag.exactparser.parsing.results.ParseResult;
+
+/**
+ * The BinaryVerificator parses the EGIT Dictionary and extracts the signature
+ * holder from it.
+ *
+ * @deprecated moved to the new framework
+ *
+ * @author wprinz
+ */
+public class BinaryVerificator_1_0_0 implements Verificator
+{
+ /**
+ * The Pdf-AS ID of this Verificator.
+ */
+ public static final PdfASID MY_ID = new PdfASID(SignatorFactory.VENDOR, SignatorFactory.TYPE_BINARY, SignatorFactory.VERSION_1_0_0);
+
+ /**
+ * Use this to override the MY_ID field.
+ *
+ * @return Returns the Id of this Verificator.
+ */
+ protected PdfASID getMyId()
+ {
+ return MY_ID;
+ }
+
+ /**
+ * The /ODS key in the EGIZ Dict.
+ */
+ public static final byte[] EGIZ_ODS_NAME = new byte[] { 'O', 'D', 'S' };
+
+ /**
+ * The /ID key in the EGIZ Dict.
+ */
+ public static final byte[] EGIZ_KZ_NAME = VerificationFilter.EGIZ_KZ_NAME;
+
+ /**
+ * The /ByteRange key in the EGIZ Dict.
+ */
+ public static final byte[] EGIZ_BYTE_RANGE_NAME = new byte[] { 'B', 'y', 't', 'e', 'R', 'a', 'n', 'g', 'e' };
+
+ /**
+ * The /replaces key in the EGIZ Dict.
+ */
+ public static final byte[] EGIZ_REPLACES_NAME = new byte[] { 'r', 'e', 'p', 'l', 'a', 'c', 'e', 's' };
+
+ /**
+ * The /encodings key in the EGIZ Dict.
+ */
+ public static final byte[] EGIZ_ENCODINGS_NAME = new byte[] { 'e', 'n', 'c', 'o', 'd', 'i', 'n', 'g', 's' };
+
+ /**
+ * The /Cert key in the EGIZ Dict.
+ */
+ public static final byte[] EGIZ_CERT_NAME = new byte[] { 'C', 'e', 'r', 't' };
+
+ /**
+ * The logger definition.
+ */
+ private static final Logger logger_ = ConfigLogger.getLogger(BinaryVerificator_1_0_0.class);
+
+ /**
+ * Default constructor.
+ */
+ public BinaryVerificator_1_0_0()
+ {
+ // Default constructor.
+ }
+
+ /**
+ * @see at.knowcenter.wag.egov.egiz.framework.Verificator#parseBlock(byte[],
+ * at.knowcenter.wag.exactparser.parsing.results.FooterParseResult, int)
+ */
+ public List parseBlock(byte[] pdf, FooterParseResult block, int start_of_whole_block) throws PresentableException
+ {
+ int egiz_index = PDFUtils.indexOfName(pdf, block.tpr.dpr.names, VerificationFilter.EGIZ_DICT_NAME);
+ if (egiz_index < 0)
+ {
+ throw new PDFDocumentException(ErrorCode.COULDNT_VERIFY, "egiz_index = " + egiz_index);
+ }
+
+ IndirectObjectReferenceParseResult egiz_dict_iorpr = (IndirectObjectReferenceParseResult) block.tpr.dpr.values.get(egiz_index);
+
+ IndirectObjectReference ior = egiz_dict_iorpr.ior;
+
+ final int egiz_dict_offset = PDFUtils.getObjectOffsetFromXRefByIndirectObjectReference(block.xpr, ior);
+
+ ObjectParseResult obj = PDFUtils.parseObject(pdf, egiz_dict_offset);
+ DictionaryParseResult egiz_dict = (DictionaryParseResult) obj.object;
+
+ NumberParseResult ods_npr = (NumberParseResult) getRequiredValueOfKey(pdf, egiz_dict, EGIZ_ODS_NAME);
+
+ ArrayParseResult kz_apr = (ArrayParseResult) getRequiredValueOfKey(pdf, egiz_dict, EGIZ_KZ_NAME);
+ PdfASID kz = null;
+// String kz_string = VerificationFilter.restoreKZ(pdf, kz_apr);
+ String kz_string = VerificationFilterBinaryHelper.restoreKZ(pdf, kz_apr);
+ kz = new PdfASID(kz_string);
+ if (!kz_string.equals(getMyId().toString()))
+ {
+ logger_.warn("Warning: Kennzeichnung not recognized:" + kz_string);
+ }
+
+ ArrayParseResult byte_ranges_apr = (ArrayParseResult) getRequiredValueOfKey(pdf, egiz_dict, EGIZ_BYTE_RANGE_NAME);
+
+ ArrayParseResult replaces_apr = (ArrayParseResult) getRequiredValueOfKey(pdf, egiz_dict, EGIZ_REPLACES_NAME);
+
+ ArrayParseResult encodings_apr = (ArrayParseResult) getRequiredValueOfKey(pdf, egiz_dict, EGIZ_ENCODINGS_NAME);
+
+ ArrayParseResult cert_apr = (ArrayParseResult) getValueOfKey(pdf, egiz_dict, EGIZ_CERT_NAME);
+ byte[] cert = null;
+ if (cert_apr != null && !cert_apr.elements.isEmpty())
+ {
+ LiteralStringParseResult lspr = (LiteralStringParseResult) cert_apr.elements.get(0);
+ int str_length = lspr.content_end_index - lspr.content_start_index;
+ byte[] encoded = new byte[str_length];
+ System.arraycopy(pdf, lspr.content_start_index, encoded, 0, encoded.length);
+
+ cert = Placeholder.unescapePDFString(encoded);
+ }
+
+ int num_byte_ranges = byte_ranges_apr.elements.size() / 2;
+ List byte_ranges = new ArrayList();
+ for (int i = 0; i < num_byte_ranges; i++)
+ {
+ NumberParseResult start_npr = (NumberParseResult) byte_ranges_apr.elements.get(2 * i);
+ NumberParseResult length_npr = (NumberParseResult) byte_ranges_apr.elements.get(2 * i + 1);
+
+ StringInfo si = new StringInfo();
+ si.string_start = start_npr.number;
+ si.string_length = length_npr.number;
+ byte_ranges.add(si);
+ }
+
+ StringInfo sis[] = new StringInfo[num_byte_ranges - 1];
+ for (int i = 0; i < num_byte_ranges - 1; i++)
+ {
+ StringInfo prev = (StringInfo) byte_ranges.get(i);
+ StringInfo next = (StringInfo) byte_ranges.get(i + 1);
+
+ StringInfo hole = new StringInfo();
+ hole.string_start = prev.string_start + prev.string_length;
+ hole.string_length = next.string_start - hole.string_start;
+
+ sis[i] = hole;
+ }
+
+ int n = replaces_apr.elements.size();
+ byte[][] brevs = new byte[n][];
+ for (int i = 0; i < n; i++)
+ {
+ NameParseResult lspr = (NameParseResult) replaces_apr.elements.get(i);
+
+ byte[] brev = new byte[3];
+ System.arraycopy(pdf, lspr.name_start_index, brev, 0, brev.length);
+
+ brevs[i] = brev; // SignatureTypes.convertBrevToType(brev);
+ }
+
+ n = encodings_apr.elements.size();
+ byte[][] encodings = new byte[n][];
+ for (int i = 0; i < n; i++)
+ {
+ NameParseResult lspr = (NameParseResult) encodings_apr.elements.get(i);
+
+ byte[] enc = new byte[3];
+ System.arraycopy(pdf, lspr.name_start_index, enc, 0, enc.length);
+ encodings[i] = enc;
+ }
+
+ BinaryBlockInfo bbi = new BinaryBlockInfo();
+ bbi.replaces = BinarySignature.reconstructReplaces(pdf, brevs, sis, encodings);
+ bbi.signed_size = ods_npr.number;
+
+ // BinaryBlockInfo bbi = BinarySignature.retrieveEgizDictInformation(pdf,
+ // ior.object_number, ior.generation_number, egiz_dict_offset);
+
+ // byte[] original_pdf = BinarySignature.restoreEgizDictInformation(pdf,
+ // bbi);
+
+ byte[] signed_pdf = BinarySignature.prepareDataToSign(pdf, byte_ranges);
+ // String signed_text =
+ // BinarySignature.retrieveSignableTextFromData(signed_pdf,
+ // signed_pdf.length); // has been moved into the BinarySignatureHolder
+
+ SignatureObject signature_object = new SignatureObject();
+ String default_type = SettingsReader.getInstance().getValueFromKey(SignatureTypes.DEFAULT_TYPE);
+ signature_object.setSigType(default_type);
+ signature_object.initByType();
+
+ signature_object.setKZ(kz);
+
+ if (cert != null)
+ {
+ try
+ {
+ // ByteArrayInputStream bais = new ByteArrayInputStream(cert);
+ // CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ // X509Certificate certificate = (X509Certificate)
+ // cf.generateCertificate(bais);
+
+ // trim zero bytes. - the base 64 cert must not have zero bytes.
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ for (int i = 0; i < cert.length; i++)
+ {
+ if (cert[i] != 0)
+ {
+ baos.write(cert[i]);
+ }
+ }
+ byte[] b64 = baos.toByteArray();
+
+ signature_object.storeNewCertificateInLocalStore(b64);
+ }
+ catch (Exception e)
+ {
+ logger_.error(e.getMessage(), e);
+ }
+
+ }
+
+ Iterator rit = bbi.replaces.iterator();
+ while (rit.hasNext())
+ {
+ ReplaceInfo ri = (ReplaceInfo) rit.next();
+
+ String type = SignatureTypes.convertBrevToType(ri.brev);
+
+ // signature_object.setSigValue(ri.type, ri.value);
+ if (type.equals(SignatureTypes.SIG_DATE))
+ {
+ signature_object.setSignationDate(ri.value);
+ continue;
+ }
+
+ if (type.equals(SignatureTypes.SIG_ISSUER))
+ {
+ signature_object.setSignationIssuer(ri.value);
+ continue;
+ }
+
+ if (type.equals(SignatureTypes.SIG_VALUE))
+ {
+ signature_object.setSignationValue(ri.value);
+ continue;
+ }
+
+ if (type.equals(SignatureTypes.SIG_NUMBER))
+ {
+ signature_object.setSignationSerialNumber(ri.value);
+ continue;
+ }
+
+ if (type.equals(SignatureTypes.SIG_ID))
+ {
+ signature_object.setSignationIDs(ri.value);
+ continue;
+ }
+ }
+
+ // FIXME This blows up the session !!!!!
+ PdfDataSource ds = new ByteArrayPdfDataSourceImpl(signed_pdf, signed_pdf.length);
+ BinarySignatureHolder signature_holder = new BinarySignatureHolder(ds, signature_object);
+
+ List holders = new ArrayList();
+ holders.add(signature_holder);
+ return holders;
+ }
+
+ /**
+ * Retrieves the value of the key from the dictionary.
+ *
+ * @param pdf
+ * The PDF.
+ * @param egiz_dict
+ * The dictionary.
+ * @param name
+ * The name of the key.
+ * @return Returns the value of the key. An exception is thrown if the key
+ * doesn't exist.
+ * @throws PDFDocumentException
+ * Thrown, if the key doesn't exist in the dictionary.
+ */
+ protected ParseResult getRequiredValueOfKey(byte[] pdf, DictionaryParseResult egiz_dict, byte[] name) throws PDFDocumentException
+ {
+ final int index = PDFUtils.indexOfName(pdf, egiz_dict.names, name);
+ checkIndex(index);
+ ParseResult value = (ParseResult) egiz_dict.values.get(index);
+ return value;
+ }
+
+ /**
+ * Throws an excaption, if the index is lower than 0.
+ *
+ * @param name_index
+ * The index.
+ * @throws PDFDocumentException
+ * Thrown, if the index is lower than 0.
+ */
+ protected void checkIndex(int name_index) throws PDFDocumentException
+ {
+ if (name_index < 0)
+ {
+ throw new PDFDocumentException(ErrorCode.COULDNT_VERIFY, "The name wasn't found in the egiz dict.");
+ }
+ }
+
+ /**
+ * Retrieves the value of the key from the dictionary.
+ *
+ * @param pdf
+ * The PDF.
+ * @param egiz_dict
+ * The dictionary.
+ * @param name
+ * The name of the key.
+ * @return Returns the key's value, or null if the dictionary didn't contain
+ * that key.
+ */
+ protected ParseResult getValueOfKey(byte[] pdf, DictionaryParseResult egiz_dict, byte[] name)
+ {
+ final int index = PDFUtils.indexOfName(pdf, egiz_dict.names, name);
+ if (index < 0)
+ {
+ return null;
+ }
+ ParseResult value = (ParseResult) egiz_dict.values.get(index);
+ return value;
+ }
+
+}
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_1_0.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_1_0.java
new file mode 100644
index 0000000..c1d94c1
--- /dev/null
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_1_0.java
@@ -0,0 +1,44 @@
+/**
+ * <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.
+ */
+package at.knowcenter.wag.egov.egiz.framework.verificators;
+
+import at.knowcenter.wag.egov.egiz.PdfASID;
+import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
+
+/**
+ * @author wprinz
+ *
+ */
+public class BinaryVerificator_1_1_0 extends BinaryVerificator_1_0_0
+{
+ public static final PdfASID MY_ID = new PdfASID(SignatorFactory.VENDOR, SignatorFactory.TYPE_BINARY, SignatorFactory.VERSION_1_1_0);
+
+ /**
+ * @see at.knowcenter.wag.egov.egiz.framework.verificators.BinaryVerificator_1_0_0#getMyId()
+ */
+ protected PdfASID getMyId()
+ {
+ return MY_ID;
+ }
+}
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_1_0_0.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_1_0_0.java
new file mode 100644
index 0000000..58302be
--- /dev/null
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_1_0_0.java
@@ -0,0 +1,147 @@
+/**
+ * <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: TextualVerificator_1_0_0.java,v 1.5 2006/11/28 07:45:09 wprinz Exp $
+ */
+package at.knowcenter.wag.egov.egiz.framework.verificators;
+
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import at.knowcenter.wag.egov.egiz.PdfAS;
+import at.knowcenter.wag.egov.egiz.PdfASID;
+import at.knowcenter.wag.egov.egiz.cfg.ConfigLogger;
+import at.knowcenter.wag.egov.egiz.exceptions.PresentableException;
+import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
+import at.knowcenter.wag.egov.egiz.framework.Verificator;
+import at.knowcenter.wag.egov.egiz.pdf.AbsoluteTextSignature;
+import at.knowcenter.wag.egov.egiz.pdf.SignatureHolder;
+import at.knowcenter.wag.exactparser.parsing.results.FooterParseResult;
+
+
+/**
+ * The textual verificator.
+ *
+ * <p>
+ * All holders of the document so far including the block itself are extracted.
+ * If at least one has been found it is checked that this one doesn't belong to
+ * a previous block.
+ * </p>
+ * <p>
+ * Note that the KZ is not explicitely checked here, so this algorithm will find
+ * all blocks.
+ * </p>
+ * <p>
+ * Note that it will not find old style blocks as they don't have the SIG_KZ.
+ * </p>
+ *
+ * @deprecated moved to the new framework
+ *
+ * @author wprinz
+ */
+public class TextualVerificator_1_0_0 implements Verificator
+{
+ /**
+ * The Pdf-AS ID of this Verificator.
+ */
+ public static final PdfASID MY_ID = new PdfASID(SignatorFactory.VENDOR, SignatorFactory.TYPE_TEXTUAL, SignatorFactory.VERSION_1_0_0);
+
+ /**
+ * The logger definition.
+ */
+ private static final Logger logger_ = ConfigLogger.getLogger(TextualVerificator_1_0_0.class);
+
+ /**
+ * Default constructor.
+ */
+ public TextualVerificator_1_0_0()
+ {
+ // Default constructor.
+ }
+
+ /**
+ * @see at.knowcenter.wag.egov.egiz.framework.Verificator#parseBlock(byte[],
+ * at.knowcenter.wag.exactparser.parsing.results.FooterParseResult, int)
+ */
+ public List parseBlock(byte[] pdf, FooterParseResult block,
+ int start_of_whole_block) throws PresentableException
+ {
+ String block_text = PdfAS.extractNormalizedTextTextual(pdf, block.next_index);
+
+ logger_.debug("Scanning block:");
+ //List signature_holders = PdfAS.extractSignatureHoldersTextual(block_text, false);
+ List signature_holders = AbsoluteTextSignature.extractSignatureHoldersFromText(block_text);
+ logger_.debug(": end of Scanning block");
+
+ // logger_.debug("signature_holders = " + signature_holders.size());
+
+ if (signature_holders.isEmpty())
+ {
+ return signature_holders;
+ }
+
+ List text_holder_candidates = null;
+ if (start_of_whole_block > 0)
+ {
+ text_holder_candidates = new ArrayList();
+
+ String prev_text = PdfAS.extractNormalizedTextTextual(pdf, start_of_whole_block);
+
+ logger_.debug("Scanning prev block:");
+ //List prev_signature_holders = PdfAS.extractSignatureHoldersTextual(prev_text, false);
+ List prev_signature_holders = AbsoluteTextSignature.extractSignatureHoldersFromText(prev_text);
+ logger_.debug(": end of Scanning prev block");
+
+ // logger_.debug("prev_signature_holders = " +
+ // prev_signature_holders.size());
+
+ for (int i = prev_signature_holders.size(); i < signature_holders.size(); i++)
+ {
+ SignatureHolder holder = (SignatureHolder) signature_holders.get(i);
+ text_holder_candidates.add(holder);
+ }
+ }
+ else
+ {
+ logger_.debug("there is no prev - so all found signatures are possible candidates.");
+ text_holder_candidates = signature_holders;
+ }
+
+ List text_holders = new ArrayList();
+ for (int i = 0; i < text_holder_candidates.size(); i++)
+ {
+ SignatureHolder holder = (SignatureHolder) text_holder_candidates.get(i);
+ if (!holder.getSignatureObject().isTextual())
+ {
+ logger_.debug("Skipping found signature block because it's not textual.");
+ continue;
+ }
+ text_holders.add(holder);
+ }
+
+ return text_holders;
+ }
+}
diff --git a/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_pdfasold.java b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_pdfasold.java
new file mode 100644
index 0000000..98940d6
--- /dev/null
+++ b/pdf-as-lib/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_pdfasold.java
@@ -0,0 +1,106 @@
+/**
+ * <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: TextualVerificator_pdfasold.java,v 1.3 2006/10/11 08:03:22 wprinz Exp $
+ */
+package at.knowcenter.wag.egov.egiz.framework.verificators;
+
+import java.io.ByteArrayInputStream;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import at.knowcenter.wag.egov.egiz.PdfAS;
+import at.knowcenter.wag.egov.egiz.cfg.ConfigLogger;
+import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
+import at.knowcenter.wag.egov.egiz.exceptions.PresentableException;
+import at.knowcenter.wag.egov.egiz.framework.Verificator;
+import at.knowcenter.wag.exactparser.parsing.results.FooterParseResult;
+
+
+/**
+ * This Verificator extracts a PDF-AS old signature from the original document.
+ *
+ * @author wprinz
+ */
+public class TextualVerificator_pdfasold implements Verificator
+{
+ /**
+ * The logger definition.
+ */
+ private static final Logger logger_ = ConfigLogger.getLogger(TextualVerificator_1_0_0.class);
+
+ /**
+ * Default Constructor.
+ */
+ public TextualVerificator_pdfasold()
+ {
+ // Default Constructor.
+ }
+
+ /**
+ * @see at.knowcenter.wag.egov.egiz.framework.Verificator#parseBlock(byte[], at.knowcenter.wag.exactparser.parsing.results.FooterParseResult, int)
+ */
+ public List parseBlock(byte[] pdf, FooterParseResult block,
+ int start_of_whole_block) throws PresentableException
+ {
+ if (start_of_whole_block != 0)
+ {
+ throw new PDFDocumentException(201, "The PDF-AS-old Verificator can only be applied on original documents.");
+ }
+
+ String normalized_text = PdfAS.extractNormalizedTextTextual(pdf, block.next_index);
+
+ logger_.debug("Scanning block:");
+ List signature_holders = PdfAS.extractSignatureHoldersTextual(normalized_text, true);
+ logger_.debug(": end of Scanning block");
+
+
+// List signature_holders = new ArrayList();
+//
+// SignatureTypes sig_types = SignatureTypes.getInstance();
+// List signatureTypes_ = sig_types.getSignatureTypeDefinitions();
+//
+// boolean can_separate = true;
+// int endIndex = normalized_text.length();
+// String signed_text = normalized_text;
+//
+// SignatureBlock sig_block = new SignatureBlock(signatureTypes_);
+// can_separate = sig_block.separateBlockFromRawText(signed_text, true);
+// if (can_separate)
+// {
+// endIndex = sig_block.getStartIndex();
+// signed_text = signed_text.substring(0, endIndex);
+//
+// SignatureObject sig_object = sig_block.getSignatureObject();
+//
+// SignatureHolder holder = new SignatureHolder();
+// holder.signed_text = signed_text;
+// holder.signature_object = sig_object;
+// signature_holders.add(0, holder);
+// }
+
+ return signature_holders;
+ }
+
+}