aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/knowcenter/wag/egov/egiz/framework
diff options
context:
space:
mode:
authortknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2013-01-09 15:41:29 +0000
committertknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2013-01-09 15:41:29 +0000
commit535a04fa05f739ec16dd81666e3b0f82dfbd442d (patch)
tree0804f301c1a9ceb303a8441b7b29244fc8eb7ff0 /src/main/java/at/knowcenter/wag/egov/egiz/framework
parent1efaf6fd5619dfa95c9d7e8c71eda4c2ffba4998 (diff)
downloadpdf-as-3-535a04fa05f739ec16dd81666e3b0f82dfbd442d.tar.gz
pdf-as-3-535a04fa05f739ec16dd81666e3b0f82dfbd442d.tar.bz2
pdf-as-3-535a04fa05f739ec16dd81666e3b0f82dfbd442d.zip
pdf-as-lib maven project files moved to pdf-as-lib
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/pdf-as/trunk@926 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/knowcenter/wag/egov/egiz/framework')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/FoundBlock.java230
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/FoundKey.java104
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/SignResult.java104
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/Signator.java93
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/SignatorFactory.java226
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/VerificationFilter.java569
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/Verificator.java62
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/BinarySignator_1_0_0.java285
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/BinarySignator_1_1_0.java83
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/DetachedSignator_1_0_0.java125
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/DetachedfTextualSignator_1_0_0.java133
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/TextualSignator_1_0_0.java136
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/TextualSignator_1_1_0.java53
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_0_0.java396
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_1_0.java44
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_1_0_0.java147
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_pdfasold.java106
17 files changed, 0 insertions, 2896 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/FoundBlock.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/FoundBlock.java
deleted file mode 100644
index 4076129..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/FoundBlock.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/**
- * <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: FoundBlock.java,v 1.2 2006/10/31 08:07:29 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.framework;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import at.knowcenter.wag.egov.egiz.sig.SignatureTypeDefinition;
-import at.knowcenter.wag.egov.egiz.sig.SignatureTypes;
-
-/**
- * Contains all the information about a found Block in text extracton.
- *
- * <p>
- * This is basically the ordered list of found captions.
- * </p>
- *
- * @author wprinz
- */
-public class FoundBlock
-{
- /**
- * The ordered list of found keys.
- */
- public List found_keys = null;
-
- /**
- * The end index of the block.
- */
- public int end_index = 0;
-
- /**
- * The type of the block.
- */
- public SignatureTypeDefinition std = null;
-
- /**
- * Returns the first key of this block.
- *
- * @return Returns the first key of this block.
- */
- public FoundKey getFirstKey()
- {
- return (FoundKey) this.found_keys.get(found_keys.size() - 1);
- }
-
- /**
- * Returns the last key of this block.
- *
- * @return Returns the last key of this block.
- */
- public FoundKey getLastKey()
- {
- return (FoundKey) this.found_keys.get(0);
- }
-
- /**
- * Returns the size of this block.
- *
- * <p>
- * Note that this doesn't give the exact size of the block, but rather a value
- * suirable for comparison.
- * </p>
- *
- * @return Returns the size of this block.
- */
- public int getSize()
- {
- int size = getLastKey().start_index - getFirstKey().start_index;
- return size;
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString()
- {
- return "FoundBlock: std=" + this.std.getType() + ", #=" + this.found_keys.size() + ", size = " + getSize();
- }
-
- /**
- * Tells, if this block is semantically equal to the other block.
- *
- * Two blocks are semantically equal, if all the required fields (except SIG_ID) have the
- * same captions in the same order.
- *
- * @param other_block
- * The other block.
- * @return Returns true, of this block is semantically equal to the other one,
- * false otherwise.
- */
- public boolean isSemanticallyEqual(FoundBlock other_block)
- {
- return this.std.isSemanticallyEqual(other_block.std);
-
-// List this_keys = filterOutNonRequiredFoundKeys(filterOutSIG_ID(this.found_keys));
-// List other_keys = filterOutNonRequiredFoundKeys(filterOutSIG_ID(other_block.found_keys));
-//
-// if (this_keys.size() != other_keys.size())
-// {
-// return false;
-// }
-//
-// for (int i = 0; i < this_keys.size(); i++)
-// {
-// FoundKey this_found_key = (FoundKey) this_keys.get(i);
-// FoundKey other_found_key = (FoundKey) other_keys.get(i);
-//
-// if (!this_found_key.isSemanticallyEqual(other_found_key))
-// {
-// return false;
-// }
-// }
-// return true;
- }
-
- /**
- * Filters out all non required keys from the List of found keys.
- *
- * @param found_keys The List of found keys.
- *
- * @return Returns the subset List which contains only the required keys.
- */
- protected static List filterOutNonRequiredFoundKeys (List found_keys)
- {
- List required_found_keys = new ArrayList(found_keys.size());
- for (int i = 0; i < found_keys.size(); i++)
- {
- FoundKey this_found_key = (FoundKey) found_keys.get(i);
-
- if (!SignatureTypes.isRequiredKey(this_found_key.key))
- {
- continue;
- }
-
- required_found_keys.add(this_found_key);
- }
- return required_found_keys;
- }
-
- /**
- * Filters out a SIG_ID found key.
- * @param found_keys The List of found keys.
- * @return Returns the subset List which contains all keys but the SIG_ID.
- */
- protected static List filterOutSIG_ID (List found_keys)
- {
- List nonsigid_found_keys = new ArrayList(found_keys.size());
- for (int i = 0; i < found_keys.size(); i++)
- {
- FoundKey this_found_key = (FoundKey) found_keys.get(i);
-
- if (this_found_key.key.equals(SignatureTypes.SIG_ID))
- {
- continue;
- }
-
- nonsigid_found_keys.add(this_found_key);
- }
- return nonsigid_found_keys;
- }
-
- /**
- * Tells, if this block is strictly semantically equal to the other block.
- *
- * Two blocks are strictly semantically equal, if they contain the same keys with the
- * same captions in the same order.
- *
- * @param other_block
- * The other block.
- * @return Returns true, of this block is semantically equal to the other one,
- * false otherwise.
- */
- public boolean isStrictlySemanticallyEqual(FoundBlock other_block)
- {
- if (this.found_keys.size() != other_block.found_keys.size())
- {
- return false;
- }
-
- for (int i = 0; i < this.found_keys.size(); i++)
- {
- FoundKey this_found_key = (FoundKey) this.found_keys.get(i);
- FoundKey other_found_key = (FoundKey) other_block.found_keys.get(i);
-
- if (!this_found_key.isSemanticallyEqual(other_found_key))
- {
- return false;
- }
- }
- return true;
- }
-
-
- public FoundKey getDateFoundKey ()
- {
- for (int i = 0; i < this.found_keys.size(); i++)
- {
- FoundKey found_key = (FoundKey) this.found_keys.get(i);
- if (found_key.key.equals(SignatureTypes.SIG_DATE))
- {
- return found_key;
- }
- }
- throw new RuntimeException("There is no SIG_DATE in the list of found_keys. This must not happen.");
- }
-}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/FoundKey.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/FoundKey.java
deleted file mode 100644
index b8e9609..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/FoundKey.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * <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: FoundKey.java,v 1.1 2006/08/25 17:07:21 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.framework;
-
-/**
- * Holds the information of one found key.
- * @author wprinz
- */
-public class FoundKey
-{
- /**
- * The type of the key.
- */
- public String key = null;
-
- /**
- * The caption of the key.
- */
- public String caption = null;
-
- /**
- * The start index of the caption in the text.
- */
- public int start_index = -1;
-
- /**
- *
- * @param key The type of the key.
- * @param caption The caption of the key.
- * @param start_index The start index of the caption in the text.
- */
- public FoundKey(String key, String caption, int start_index)
- {
- this.key = key;
- this.caption = caption;
- this.start_index = start_index;
- }
-
- /**
- * Returns the key.
- * @return Returns the key.
- */
- public String getKey()
- {
- return this.key;
- }
-
- /**
- * Returns the start_index.
- * @return Returns the start_index.
- */
- public int getStartIndex()
- {
- return this.start_index;
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString()
- {
- return this.key + "(" + this.caption + ")@" + this.start_index;
- }
-
- /**
- * Tells, if this FoundKey is semantically equal to the other FoundKey.
- *
- * <p>
- * Two FoundKeys are semantically equal if their key and caption are the same.
- * </p>
- *
- * @param other_found_key
- * The other FoundKey.
- * @return Returns true if the two keys are semantically equal.
- */
- public boolean isSemanticallyEqual(FoundKey other_found_key)
- {
- return this.key.equals(other_found_key.key) && this.caption.equals(other_found_key.caption);
- }
-
-}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/SignResult.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/SignResult.java
deleted file mode 100644
index 5471d86..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/SignResult.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * <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: SignResult.java,v 1.1 2006/08/25 17:07:21 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.framework;
-
-import java.io.Serializable;
-
-/**
- * This class holds the signed document, which is given by the mime type and the
- * binary data.
- *
- * @author wprinz
- */
-public class SignResult implements Serializable
-{
- /**
- * SVUID.
- */
- private static final long serialVersionUID = -6664489317508509973L;
-
- /**
- * The mime type of the data specifying the type of the document.
- */
- protected String mime_type = null;
-
- /**
- * The binary data of the document.
- */
- protected byte[] data = null;
-
- /**
- * Constructor.
- *
- * @param document_mime_type
- * The mime type of the data specifying the type of the document.
- * @param document_data
- * The binary data of the document.
- */
- public SignResult(String document_mime_type, byte[] document_data)
- {
- if (document_mime_type == null || document_mime_type.length() == 0)
- {
- throw new IllegalArgumentException("Please provide a valid Mime Type for the SignResult. " + document_mime_type);
- }
- if (document_data == null)
- {
- throw new IllegalArgumentException("Please provide document data. " + document_data);
- }
-
- this.mime_type = document_mime_type;
- this.data = document_data;
- }
-
- /**
- * Returns the binary data.
- *
- * @return Returns the binary data.
- */
- public byte[] getData()
- {
- return this.data;
- }
-
- /**
- * Returns the mime type.
- *
- * @return Returns the mime type.
- */
- public String getMimeType()
- {
- return this.mime_type;
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString()
- {
- return "SignResult:" + this.mime_type + "," + this.data.length;
- }
-
-}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/Signator.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/Signator.java
deleted file mode 100644
index 88a6ea1..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/Signator.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * <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: Signator.java,v 1.1 2006/08/25 17:07:21 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.framework;
-
-import at.gv.egiz.pdfas.framework.input.PdfDataSource;
-import at.knowcenter.wag.egov.egiz.PdfASID;
-import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
-import at.knowcenter.wag.egov.egiz.exceptions.PresentableException;
-import at.knowcenter.wag.egov.egiz.pdf.IncrementalUpdateInformation;
-import at.knowcenter.wag.egov.egiz.pdf.TablePos;
-
-/**
- * The basic interface for signator algorithms.
- *
- * @author wprinz
- */
-public interface Signator
-{
- /**
- * Returns the PdfASID of this Connector.
- *
- * <p>
- * This should always return the MY_ID static field of the connector. Dont't
- * forget to override this.
- * </p>
- * <p>
- * Within connector code always use this method so that code reuse through
- * derivation can take place correctly.
- * </p>
- *
- * @return Returns the PdfASID of this Connector.
- */
- public PdfASID getMyId();
-
- /**
- * This is called before the data is sent to the connector.
- *
- * @param pdf
- * The PDF document to be signed.
- * @param signature_type
- * The type/profile of the signature to apply.
- * @param pos
- * The table position. If null, the position is read from the
- * profile, if this is null too, the position is computed.
- * @param has_SIG_ID
- * Tells the algorithm, id a SIG_ID field will be required after
- * signing. Algorithms with fixed formatted signature blocks need to
- * know this.
- * @return Returns the IncrementalUpdateInformation.
- * @throws PresentableException
- * Forwarded exception.
- */
- public IncrementalUpdateInformation prepareSign(PdfDataSource pdfDataSource,
- String signature_type, TablePos pos, boolean has_SIG_ID) throws PresentableException;
-
- /**
- * This is called after the data has been signed by the connector.
- *
- * <p>
- * Replaces all the left out placeholders with their values retrieved from the
- * signation process.
- * </p>
- *
- * @param iui
- * The IncrementalUpdateInformation.
- * @throws PDFDocumentException
- * Forwarded exception.
- */
- public SignResult finishSign(IncrementalUpdateInformation iui) throws PresentableException;
-}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/SignatorFactory.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/SignatorFactory.java
deleted file mode 100644
index ccb414d..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/SignatorFactory.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/**
- * <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: SignatorFactory.java,v 1.2 2006/08/30 14:02:35 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.framework;
-
-import at.gv.egiz.pdfas.impl.signator.textual.TextualSignator_1_2_0;
-import at.knowcenter.wag.egov.egiz.PdfASID;
-import at.knowcenter.wag.egov.egiz.exceptions.SignatorFactoryException;
-import at.knowcenter.wag.egov.egiz.framework.signators.BinarySignator_1_0_0;
-import at.knowcenter.wag.egov.egiz.framework.signators.BinarySignator_1_1_0;
-import at.knowcenter.wag.egov.egiz.framework.signators.DetachedSignator_1_0_0;
-import at.knowcenter.wag.egov.egiz.framework.signators.DetachedfTextualSignator_1_0_0;
-import at.knowcenter.wag.egov.egiz.framework.signators.TextualSignator_1_0_0;
-import at.knowcenter.wag.egov.egiz.framework.signators.TextualSignator_1_1_0;
-
-/**
- * This factory creates instances of Signator classes corresponding to the given
- * PdfAS Algorithm IDs.
- *
- * @author wprinz
- */
-public abstract class SignatorFactory
-{
- /**
- * The Vendor.
- */
- public static final String VENDOR = "bka.gv.at"; //$NON-NLS-1$
-
- /**
- * The binary Signator algorithm.
- */
- public static final String TYPE_BINARY = "binaer"; //$NON-NLS-1$
-
- /**
- * The textual Signator algorithm.
- */
- public static final String TYPE_TEXTUAL = "text"; //$NON-NLS-1$
-
- /**
- * This signator is only for testing the framework.
- */
- public static final String TYPE_TEST = "testalgo"; //$NON-NLS-1$
-
- /**
- * This signator is only for testing the framework.
- */
- public static final String TYPE_DETACHED_TEXTUAL = "detachedtext"; //$NON-NLS-1$
-
- /**
- * This application's current algorithm versions.
- */
- public static final String VERSION_1_0_0 = "v1.0.0"; //$NON-NLS-1$
-
- /**
- * This application's current algorithm versions.
- */
- public static final String VERSION_1_1_0 = "v1.1.0"; //$NON-NLS-1$
-
- /**
- * This application's current algorithm versions.
- */
- public static final String VERSION_1_2_0 = "v1.2.0"; //$NON-NLS-1$
-
-
- /**
- * The most recent binary algorithm this application provides.
- */
- public static final PdfASID MOST_RECENT_BINARY_SIGNATOR_ID = BinarySignator_1_1_0.MY_ID;
-
- /**
- * The most recent textual algorithm this application provides.
- */
- public static final PdfASID MOST_RECENT_TEXTUAL_SIGNATOR_ID = TextualSignator_1_2_0.MY_ID;
-
- /**
- * The most recent test algorithm this application provides.
- */
- public static final PdfASID MOST_RECENT_DETACHED_SIGNATOR_ID = DetachedfTextualSignator_1_0_0.MY_ID;
-
- /**
- * The most recent test algorithm this application provides.
- */
- public static final PdfASID MOST_RECENT_DETACHEDTEXT_SIGNATOR_ID = DetachedfTextualSignator_1_0_0.MY_ID;
-
-
- /**
- * Creates a Signator for the given ID.
- *
- * @param id
- * The ID of the Signator to be created.
- * @return Returns the created Signator object.
- * @throws SignatorFactoryException
- * Thrown, if there is no appropriate Signator for the given ID.
- */
- public static Signator createSignator(PdfASID id) throws SignatorFactoryException
- {
- if (!id.getVendor().equals(VENDOR))
- {
- throw new SignatorFactoryException("The vendor '" + id.getVendor() + "' is unrecognized by this SignatorFactory. (id='" + id + "')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- if (id.getType().equals(TYPE_BINARY))
- {
- if (id.getVersion().equals(VERSION_1_0_0))
- {
- return new BinarySignator_1_0_0();
- }
- if (id.getVersion().equals(VERSION_1_1_0))
- {
- return new BinarySignator_1_1_0();
- }
-
- throw new SignatorFactoryException("The version '" + id.getVersion() + "' of type '" + id.getType() + "' is not supported by this SignatorFactory. (id='" + id + "')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- if (id.getType().equals(TYPE_TEXTUAL))
- {
- if (id.getVersion().equals(VERSION_1_0_0))
- {
- return new TextualSignator_1_0_0();
- }
- if (id.getVersion().equals(VERSION_1_1_0))
- {
- return new TextualSignator_1_1_0();
- }
-
- throw new SignatorFactoryException("The version '" + id.getVersion() + "' of type '" + id.getType() + "' is not supported by this SignatorFactory. (id='" + id + "')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- if (id.getType().equals(TYPE_TEST))
- {
- if (id.getVersion().equals(VERSION_1_0_0))
- {
- return new DetachedSignator_1_0_0();
- }
-
- throw new SignatorFactoryException("The version '" + id.getVersion() + "' of type '" + id.getType() + "' is not supported by this SignatorFactory. (id='" + id + "')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- if (id.getType().equals(TYPE_DETACHED_TEXTUAL))
- {
- if (id.getVersion().equals(VERSION_1_0_0))
- {
- return new DetachedfTextualSignator_1_0_0();
- }
-
- throw new SignatorFactoryException("The version '" + id.getVersion() + "' of type '" + id.getType() + "' is not supported by this SignatorFactory. (id='" + id + "')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- throw new SignatorFactoryException("The type '" + id.getType() + "' is not supported by this SignatorFactory. (id='" + id + "')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- /**
- * Creates the most recent signator the application provides for the given
- * type.
- *
- * @param signator_type
- * The type of the signator to be created (see the type field of
- * PdfASID).
- * @return Returns the created Signator instance.
- * @throws SignatorFactoryException
- * Thrown, if the type is unknown.
- */
- public static Signator createMostRecentSignator(String signator_type) throws SignatorFactoryException
- {
- PdfASID id = null;
- if (signator_type.equals(TYPE_BINARY))
- {
- id = MOST_RECENT_BINARY_SIGNATOR_ID;
- }
- if (signator_type.equals(TYPE_TEXTUAL))
- {
- id = MOST_RECENT_TEXTUAL_SIGNATOR_ID;
- }
- if (signator_type.equals(TYPE_TEST))
- {
- id = MOST_RECENT_TEXTUAL_SIGNATOR_ID;
- }
-
- if (id == null)
- {
- throw new SignatorFactoryException("The type '" + signator_type + "' is not supported by this SignatorFactory."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- return createSignator(id);
- }
-
- /**
- * Returns the list of available Signator algorithms of this application.
- *
- * <p>
- * Use createMostRecentSignator to create the most recent signator for the
- * type.
- * </p>
- *
- * @return Returns the list of available Signator algorithms of this
- * application.
- */
- public static String[] getAvailableTyes()
- {
- String[] types = new String[] { TYPE_BINARY, TYPE_TEXTUAL, TYPE_TEST };
- return types;
- }
-}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/VerificationFilter.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/VerificationFilter.java
deleted file mode 100644
index 0bab96f..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/VerificationFilter.java
+++ /dev/null
@@ -1,569 +0,0 @@
-/**
- * <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: VerificationFilter.java,v 1.5 2006/10/31 08:07:20 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.framework;
-
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.log4j.Logger;
-
-import at.gv.egiz.pdfas.exceptions.ErrorCode;
-import at.gv.egiz.pdfas.impl.vfilter.VerificationFilterImpl;
-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.cfg.SettingsReader;
-import at.knowcenter.wag.egov.egiz.exceptions.InvalidIDException;
-import at.knowcenter.wag.egov.egiz.exceptions.NormalizeException;
-import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
-import at.knowcenter.wag.egov.egiz.exceptions.PresentableException;
-import at.knowcenter.wag.egov.egiz.exceptions.SignatureException;
-import at.knowcenter.wag.egov.egiz.exceptions.SignatureTypesException;
-import at.knowcenter.wag.egov.egiz.framework.verificators.BinaryVerificator_1_0_0;
-import at.knowcenter.wag.egov.egiz.framework.verificators.TextualVerificator_1_0_0;
-import at.knowcenter.wag.egov.egiz.pdf.AbsoluteTextSignature;
-import at.knowcenter.wag.egov.egiz.pdf.BinarySignature;
-import at.knowcenter.wag.egov.egiz.pdf.Placeholder;
-import at.knowcenter.wag.egov.egiz.pdf.SignatureHolder;
-import at.knowcenter.wag.egov.egiz.pdf.StringInfo;
-import at.knowcenter.wag.egov.egiz.pdf.TextualSignatureHolder;
-import at.knowcenter.wag.exactparser.ParseDocument;
-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.NumberParseResult;
-import at.knowcenter.wag.exactparser.parsing.results.ObjectParseResult;
-
-
-/**
- * This filter transforms an arbitrary input pdf into an ordered List of
- * SignatureHolders for verification.
- *
- * <p>
- * The pdf document is parsed and the signature blocks (textual, binary, etc.)
- * are extracted as verifyable SignatureHolder objects in the order they appear
- * in the document.
- * </p>
- *
- * @deprecated use the new at.gv.egiz.framework instead
- *
- * @author wprinz
- * @author amavriqi
- */
-public class VerificationFilter
-{
- public static final byte[] EGIZ_DICT_NAME = { 'E', 'G', 'I', 'Z', 'S', 'i',
- 'g', 'D', 'i', 'c', 't' };
-
- public static final byte[] EGIZ_KZ_NAME = { 'I', 'D' };
-
- //tzefferer: flag for accepting post-sign modifications
- public static final String ALLOW_POST_SIGN_MODIFICATIONS = "allow_post_sign_modifications";
-
- /**
- * The logger definition.
- */
- private static final Logger logger_ = ConfigLogger.getLogger(VerificationFilter.class);
-
- /**
- * Default constructor.
- */
- public VerificationFilter()
- {
- // empty block.
- }
-
- /**
- * Extracts the List of SignatureHolders from the given PDF document.
- *
- * @param pdf
- * The PDF document.
- * @return Returns the ordered List of SignatureHolder objects (the first
- * signature will be at index 0) extracted from the document or an
- * empty list, if none could be found.
- * @throws PresentableException
- */
- public List extractSignaturesFromPdf(final byte[] pdf) throws PresentableException
- {
- return extractSignaturesFromPdf(pdf, false);
- }
-
- //@deprecated
- public List extractSignaturesFromPdf(final byte[] pdf, boolean ignorePostSignModificationsRestriction) throws PresentableException
- {
-
- // tzefferer: get allow_post_sign_modifications property from property file
- SettingsReader settings = SettingsReader.getInstance();
- String allow_post_sign_mods = settings.getSetting(ALLOW_POST_SIGN_MODIFICATIONS, "false");
- boolean supressException = "true".equalsIgnoreCase(settings.getSetting(VerificationFilterImpl.SUPRESS_EXCEPTION_WHEN_LAST_UIBLOCK_IS_NO_SIGNATURE, "false"));
-
- List holders = new ArrayList();
-
- List blocks = null;
- try
- {
- blocks = ParseDocument.parseDocument(pdf);
- }
- catch (Exception e)
- {
- logger_.debug("Error while parsing Document.", e);
- throw new PDFDocumentException(201, e);
- }
-
-// for (int i = 0; i < blocks.size(); i++)
-// {
-// FooterParseResult bpr = (FooterParseResult) blocks.get(i);
-// // logger_.debug("block[" + i + "] from " + bpr.start_index + " to
-// // " + bpr.next_index);
-// }
-
- unrollLinearization(blocks);
-
- boolean signature_block_detected = false;
-
- for (int i = 0; i < blocks.size(); i++)
- {
- boolean current_block_contains_signature = false;
- FooterParseResult bpr = (FooterParseResult) blocks.get(i);
-
- int prev_end = 0;
- if (i > 0)
- {
- FooterParseResult prev_bpr = (FooterParseResult) blocks.get(i - 1);
- prev_end = prev_bpr.next_index;
- }
-
- // logger_.debug("block from " + prev_end + " to " +
- // bpr.next_index);
-
- if (containsEGIZDict(pdf, bpr))
- {
- logger_.debug("Parsing Binary Sig:");
-
- PdfASID kz = extractKZFromEGIZBlock(pdf, bpr);
-
- if (!kz.toString().equals(BinaryVerificator_1_0_0.MY_ID.toString()))
- {
- logger_.debug("Warning: Binary Kennzeichnung not recognized:" + kz.toString());
- }
-
- Verificator verificator = new BinaryVerificator_1_0_0();
- List binary_holders = verificator.parseBlock(pdf, bpr, prev_end);
-
- holders.addAll(binary_holders);
-
- // tzefferer: check if signatures have been detected in current block
- if(binary_holders.size() > 0)
- {
- signature_block_detected = true;
- current_block_contains_signature = true;
- }
-
- logger_.debug(":Parsing Binary Sig END - holders.size = " + holders.size());
- }
- else
- {
- // TODO: make better - already deprecated
- //amavriqi: skip checking for old sigs becouse of performance issues
- String old_text_sigs = SettingsReader.getInstance().getSetting("check_old_textual_sigs", "false");
-
- //amavriqi: if old textual signatures not checked for then
- // no need to check Incremental Block 0
- if(old_text_sigs.equalsIgnoreCase("false") && (prev_end == 0))
- {
- continue;
- }
- logger_.debug("Extracting text for: " + prev_end + " to " + bpr.next_index);
-
- Verificator verificator = new TextualVerificator_1_0_0();
- List text_holders = verificator.parseBlock(pdf, bpr, prev_end);
- logger_.debug("text_holders = " + text_holders.size());
-
- // tzefferer: check if signatures have been detected in current block
- if(text_holders.size() > 0)
- {
- signature_block_detected = true;
- current_block_contains_signature = true;
- }
-
- // TODO: make better - already deprecated
- //amavriqi: only if old textual signatures are checked for
- if(old_text_sigs.equalsIgnoreCase("true")){
- if (prev_end == 0)
- {
- String rest_text = null;
- if (!text_holders.isEmpty())
- {
- TextualSignatureHolder first_holder = (TextualSignatureHolder) text_holders.get(0);
- rest_text = first_holder.getSignedText();
- }
- else
- {
- //a.m.
- logger_.debug("Incemental block" + prev_end + " and there are " + text_holders.size() + " text holders");
- logger_.debug("Checking for older textual Signatures");
- logger_.debug("Extracting text to " + bpr.next_index);
- rest_text = PdfAS.extractNormalizedTextTextual(pdf, bpr.next_index);
- }
-
- List old_holders = PdfAS.extractSignatureHoldersTextual(rest_text, true);
-
- logger_.debug("Found old holders = " + old_holders.size());
- if (!old_holders.isEmpty())
- {
- // there must be only one old holder.
- holders.add(0, old_holders.get(0));
- }
- }
- }
- if (!text_holders.isEmpty())
- {
- List actual_text_holders = throwOutBinHolders(text_holders);
- holders.addAll(actual_text_holders);
- }
-
- logger_.debug(":Extracting tex END - holders.size = " + holders.size());
- }
-
- // tzefferer: check if illegal modifications have been performed on the document after performing a signation
- if (!("true".equalsIgnoreCase(allow_post_sign_mods)) && !ignorePostSignModificationsRestriction)
- {
- if (signature_block_detected && !current_block_contains_signature)
- {
- if (!supressException) {
- throw new PDFDocumentException(ErrorCode.MODIFIED_AFTER_SIGNATION, "Das Dokument wurde nach erfolgter Signierung verändert.");
- }
-
- }
- }
- }
-
- for (int i = 0; i < holders.size(); i++)
- {
- SignatureHolder holder = (SignatureHolder) holders.get(i);
-
- PdfASID kz = holder.getSignatureObject().getKZ();
- if (kz != null)
- {
- checkKZ(kz);
- }
- }
-
- return holders;
- }
-
- /**
- * Checks, if the given KZ is recognized by this application or logs a warning if it isn't.
- * @param kz The Kennzeichnung.
- */
- protected void checkKZ (PdfASID kz)
- {
- if (!kz.getVendor().equals(SignatorFactory.VENDOR))
- {
- logger_.warn("The vendor " + kz.getVendor() + " isn't known by this application.");
- }
- if (!kz.getVersion().equals(SignatorFactory.VERSION_1_0_0))
- {
- logger_.warn("The version " + kz.getVersion() + " istn't supported by this application. This might cause problems.");
- }
- }
-
- /**
- * Throws out SignatureHolders with a binary KZ.
- *
- * @param text_holders
- * The List of SignatureHolder objects.
- * @return Returns the List of SignatureHolder objects, where no object has
- * binary KZ.
- */
- private List throwOutBinHolders(List text_holders)
- {
- List actual_text_holders = new ArrayList();
- for (int i = 0; i < text_holders.size(); i++)
- {
- SignatureHolder sh = (SignatureHolder) text_holders.get(i);
- PdfASID kz = null;
- try
- {
- kz = sh.getSignatureObject().getKZ();
- }
- catch (InvalidIDException e)
- {
- logger_.error(e.getMessage(), e);
- }
- if (kz != null && kz.getType().equals(SignatorFactory.TYPE_BINARY))
- {
- logger_.info("Throwing out binary signature: " + kz);
- continue;
- }
- actual_text_holders.add(sh);
- }
- return actual_text_holders;
- }
-
- /**
- * Removes the linearization footer from the list of update blocks.
- *
- * @param blocks
- * The list of FooterParseResult objects in \prev order.
- */
- protected void unrollLinearization(List blocks)
- {
- int linearization_index = -1;
- for (int i = 0; i < blocks.size(); i++)
- {
- FooterParseResult bpr = (FooterParseResult) blocks.get(i);
-
- if (bpr.sxpr.xref_index == 0)
- {
- if (linearization_index >= 0)
- {
- throw new RuntimeException("There is more than one linearization block! index = " + i);
- }
- linearization_index = i;
- }
- }
-
- if (linearization_index >= 0)
- {
- // logger_.debug("The document is linearized - unrolling
- // linearization block " + linearization_index);
- blocks.remove(linearization_index);
- }
- }
-
- /**
- * Extracts the List of SignatureHolders from the given plain text document.
- *
- * <p>
- * Note that this can only extract text signatures.
- * </p>
- *
- * @param raw_text
- * The plain text document.
- * @return Returns the ordered List of SignatureHolder objects (the first
- * signature will be at index 0) extracted from the document or an
- * empty list, if none could be found.
- * @throws SignatureException
- * @throws PDFDocumentException
- * @throws SignatureTypesException
- * @throws NormalizeException
- */
- public List extractSignaturesFromPlainText(final String raw_text) throws PDFDocumentException, SignatureException, SignatureTypesException, NormalizeException
- {
- String normalized_text = PdfAS.normalizeText(raw_text);
-
- //List text_holders = PdfAS.extractSignatureHoldersTextual(normalized_text, false);
- List text_holders = AbsoluteTextSignature.extractSignatureHoldersFromText(normalized_text);
-
- String rest_text = normalized_text;
- if (!text_holders.isEmpty())
- {
- TextualSignatureHolder holder = (TextualSignatureHolder) text_holders.get(0);
- rest_text = holder.getSignedText();
- }
-
- List old_holders = PdfAS.extractSignatureHoldersTextual(rest_text, true);
- if (!old_holders.isEmpty())
- {
- text_holders.addAll(0, old_holders);
- }
-
- List actual_text_holders = throwOutBinHolders(text_holders);
-
- return actual_text_holders;
- }
-
- /**
- * Tells, if the given incremental update block contains a binary signature.
- *
- * <p>
- * According to definition, if a block is a binary block, it must/cannot
- * contain other signatures than this one.
- * </p>
- *
- * @param block
- * The incremental update block.
- * @return Returns true, if this block is a binary signature block, false
- * otherwise.
- */
- protected boolean containsEGIZDict(final byte[] pdf,
- final FooterParseResult block)
- {
- int dict_index = PDFUtils.indexOfName(pdf, block.tpr.dpr.names, EGIZ_DICT_NAME);
- if (dict_index <= 0)
- {
- return false;
- }
-
- return true;
- }
-
- /**
- * Extracts the PDF AS ID of the egiz block.
- *
- * @param pdf
- * The pdf.
- * @param block
- * The IU block.
- * @return Returns the extracted PDF AS ID.
- * @throws PDFDocumentException
- * Forwarded exception.
- * @throws InvalidIDException
- * Forwarded exception.
- */
- protected PdfASID extractKZFromEGIZBlock(final byte[] pdf,
- final FooterParseResult block) throws PDFDocumentException, InvalidIDException
- {
- int egiz_index = PDFUtils.indexOfName(pdf, block.tpr.dpr.names, VerificationFilter.EGIZ_DICT_NAME);
- if (egiz_index < 0)
- {
- throw new PDFDocumentException(301, "egiz_index = " + egiz_index);
- }
-
- IndirectObjectReferenceParseResult egiz_dict_iorpr = (IndirectObjectReferenceParseResult) block.tpr.dpr.values.get(egiz_index);
- // logger_.debug("egiz_dict_ir = " + egiz_dict_iorpr.ior.object_number
- // + " " + egiz_dict_iorpr.ior.generation_number);
-
- IndirectObjectReference ior = egiz_dict_iorpr.ior;
-
- final int egiz_dict_offset = PDFUtils.getObjectOffsetFromXRefByIndirectObjectReference(block.xpr, ior);
- // logger_.debug("egiz_dict_offset = " + egiz_dict_offset);
-
- ObjectParseResult obj = PDFUtils.parseObject(pdf, egiz_dict_offset);
- DictionaryParseResult egiz_dict = (DictionaryParseResult) obj.object;
-
- int kz_index = PDFUtils.indexOfName(pdf, egiz_dict.names, EGIZ_KZ_NAME);
- if (kz_index < 0)
- {
- throw new PDFDocumentException(301, "kz_index = " + kz_index);
- }
- ArrayParseResult kz_apr = (ArrayParseResult) egiz_dict.values.get(kz_index);
-
- String kz_string = restoreKZ(pdf, kz_apr);
- PdfASID kz = new PdfASID(kz_string);
-
- return kz;
- }
-
- /**
- * Restores the Kennzeichnung String from an Array.
- *
- * @param pdf
- * The PDF.
- * @param kz_apr
- * The Array, as parsed from the EGIZ Dict.
- * @return Returns the restored KZ.
- * @throws PDFDocumentException
- * Forwarded exception.
- */
- public static String restoreKZ(byte[] pdf, ArrayParseResult kz_apr) throws PDFDocumentException
- {
- try
- {
- List partition = new ArrayList();
-
- for (int i = 0; i < kz_apr.elements.size() / 2; i++)
- {
- NumberParseResult start_npr = (NumberParseResult) kz_apr.elements.get(i * 2);
- NumberParseResult length_npr = (NumberParseResult) kz_apr.elements.get(i * 2 + 1);
-
- StringInfo si = new StringInfo();
- si.string_start = start_npr.number;
- si.string_length = length_npr.number;
-
- partition.add(si);
- }
-
- String KZ = Placeholder.reconstructStringFromPartition(pdf, partition, BinarySignature.ENCODING_WIN);
- return KZ;
- }
- catch (IOException e1)
- {
- throw new PDFDocumentException(ErrorCode.DOCUMENT_CANNOT_BE_READ, e1);
- }
- }
-
-
- protected static void printFoundHolders (String list_caption, List found_holders, PrintStream writer)
- {
- writer.println("------------------------------------");
- writer.println(list_caption + ": #=" + found_holders.size());
-
- for (int i = 0; i < found_holders.size(); i++)
- {
- SignatureHolder holder = (SignatureHolder) found_holders.get(i);
- String kz = "invalid";
- try
- {
- PdfASID kz_id = holder.getSignatureObject().getKZ();
- if (kz_id == null)
- {
- kz = "old signature";
- }
- else
- {
- kz = kz_id.toString();
- }
- }
- catch (InvalidIDException e)
- {
- logger_.error(e.getMessage(), e);
- }
- writer.println(" holder[" + i + "]: " + holder.getSignatureObject().getSignationType() + ", KZ=" + kz);
- }
-
- writer.println(":" + list_caption);
- writer.println("------------------------------------");
-
- }
-
- // TODO old code - remove
-// public static void main(String[] args) throws IOException, PresentableException
-// {
-// SettingsReader.initializeForCommandLine();
-//
-// File in = new File(args[0]);
-// FileInputStream fis = new FileInputStream(in);
-// byte[] pdf = new byte[(int) in.length()];
-// fis.read(pdf);
-// fis.close();
-//
-// String text = PdfAS.extractNormalizedTextTextual(pdf, pdf.length);;
-//
-// VerificationFilter vf = new VerificationFilter();
-// //List found = vf.extractSignaturesFromPdf(pdf);
-//
-// List found = vf.extractSignaturesFromPlainText(text);
-//
-// printFoundHolders("Final Holders", found, System.out);
-// }
-}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/Verificator.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/Verificator.java
deleted file mode 100644
index 5a8228e..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/Verificator.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/**
- * <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: Verificator.java,v 1.1 2006/08/25 17:07:21 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.framework;
-
-import java.util.List;
-
-import at.knowcenter.wag.egov.egiz.exceptions.PresentableException;
-import at.knowcenter.wag.exactparser.parsing.results.FooterParseResult;
-
-
-/**
- * Given an Incremental Update Block and the corresponding PDF, a verificator
- * extracts all Signatures of its type and returns them as valitatable
- * SignatureHolders.
- *
- * @deprecated replaced by the one in framework
- *
- * @author wprinz
- */
-public interface Verificator
-{
- /**
- * Parses the given document/Block for signatures of this type.
- *
- * @param pdf
- * The whole pdf document. A Verificator must only access the
- * document up to its given block (block.next_index) and must not
- * modify any byte in the pdf array.
- * @param block
- * The incremental update block.
- * @param start_of_whole_block
- * The start of the incremental update block (the end of the previous
- * block) - If 0, this is the first block (the original Document).
- * @return Returns the List of SignatureHolder objects found for this block.
- */
- public List parseBlock(final byte[] pdf, final FooterParseResult block,
- int start_of_whole_block) throws PresentableException;
-
-}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/BinarySignator_1_0_0.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/BinarySignator_1_0_0.java
deleted file mode 100644
index 46245d2..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/BinarySignator_1_0_0.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/**
- * <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: BinarySignator_1_0_0.java,v 1.1 2006/08/25 17:07:35 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.framework.signators;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import at.gv.egiz.pdfas.framework.input.DataSource;
-import at.gv.egiz.pdfas.framework.input.PdfDataSource;
-import at.gv.egiz.pdfas.impl.input.CompoundPdfDataSourceImpl;
-import at.gv.egiz.pdfas.impl.signator.IncrementalUpdateHelper;
-import at.knowcenter.wag.egov.egiz.PdfAS;
-import at.knowcenter.wag.egov.egiz.PdfASID;
-import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
-import at.knowcenter.wag.egov.egiz.exceptions.PresentableException;
-import at.knowcenter.wag.egov.egiz.framework.SignResult;
-import at.knowcenter.wag.egov.egiz.framework.Signator;
-import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
-import at.knowcenter.wag.egov.egiz.pdf.BinarySignature;
-import at.knowcenter.wag.egov.egiz.pdf.IncrementalUpdateInformation;
-import at.knowcenter.wag.egov.egiz.pdf.PositioningInstruction;
-import at.knowcenter.wag.egov.egiz.pdf.ReplaceInfo;
-import at.knowcenter.wag.egov.egiz.pdf.StringInfo;
-import at.knowcenter.wag.egov.egiz.pdf.TablePos;
-import at.knowcenter.wag.egov.egiz.sig.SignatureData;
-import at.knowcenter.wag.egov.egiz.sig.SignatureDataImpl;
-import at.knowcenter.wag.egov.egiz.sig.SignatureFieldDefinition;
-import at.knowcenter.wag.egov.egiz.sig.SignatureObject;
-import at.knowcenter.wag.egov.egiz.sig.SignatureTypes;
-import at.knowcenter.wag.exactparser.ByteArrayUtils;
-
-import com.lowagie.text.pdf.PdfPTable;
-
-/**
- * Signs the document binary.
- *
- * <p>
- * In prepareSign, an Incremental Update is created that contains the Signature
- * block and the egiz dictionary. For formatting the layout, variable values are
- * filled with placeholders. After the layout has been fixed, all variable
- * fields (all holes in the byte ranges) are replaced with 0. This document is
- * then base64 encoded and signed.
- * </p>
- * <p>
- * In finishSign, the variable fields (values, /Cert) are replaced with the
- * values according to the encoding.
- * </p>
- *
- * @deprecated moved to new-framework
- *
- * @author wprinz
- */
-public class BinarySignator_1_0_0 implements Signator
-{
- /**
- * The Pdf-AS ID of this Signator.
- */
- public static final PdfASID MY_ID = new PdfASID(SignatorFactory.VENDOR, SignatorFactory.TYPE_BINARY, SignatorFactory.VERSION_1_0_0);
-
- /**
- * @see at.knowcenter.wag.egov.egiz.framework.Signator#getMyId()
- */
- public PdfASID getMyId()
- {
- return MY_ID;
- }
-
- /**
- * Default constructor.
- */
- public BinarySignator_1_0_0()
- {
- // Default constructor.
- }
-
- /**
- * @see at.knowcenter.wag.egov.egiz.framework.Signator#prepareSign(byte[],
- * String, TablePos, boolean)
- */
- public IncrementalUpdateInformation prepareSign(PdfDataSource pdf, String signature_type, TablePos pos, boolean has_SIG_ID) throws PresentableException
- {
- try
- {
- SignatureObject signature_object = PdfAS.createSignatureObjectFromType(signature_type);
- signature_object.fillValues((char) BinarySignature.LAYOUT_PLACEHOLDER, has_SIG_ID, false);
-
- signature_object.setKZ(getMyId());
-
- PdfPTable pdf_table = PdfAS.createPdfPTableFromSignatureObject(signature_object);
-
- PositioningInstruction pi = PdfAS.determineTablePositioning(pos, signature_type, pdf, pdf_table);
-
- List all_field_definitions = signature_object.getSignatureTypeDefinition().getFieldDefinitions();
- List variable_field_definitions = new ArrayList();
- for (int i = 0; i < all_field_definitions.size(); i++)
- {
- SignatureFieldDefinition sfd = (SignatureFieldDefinition) all_field_definitions.get(i);
- if (sfd.placeholder_length > 0)
- {
- if (sfd.field_name.equals(SignatureTypes.SIG_ID) && has_SIG_ID == false)
- {
- continue;
- }
- variable_field_definitions.add(sfd);
- }
- }
-
- //check if signature block is invisible, and if so and if also signature block is positioned
- //on a new page, prevent pdf-as to do that, because why should make a new page just for an invisible block
- //added by rpiazzi
- if (signature_object.getSignatureTypeDefinition().getInvisibleFieldDefinitions().size()==SignatureTypes.REQUIRED_SIG_KEYS.length) {
- if (pi.isMakeNewPage()) {
- int pageNumber = pi.getPage();
- pi = new PositioningInstruction(false, pageNumber-1, 0, 0);
- }
- }
- //end added
-
- IncrementalUpdateInformation iui = IncrementalUpdateHelper.writeIncrementalUpdate(pdf, pdf_table, signature_type, pi, variable_field_definitions, all_field_definitions, null, null, null);
-
- String temp_string = iui.temp_ir_number + " " + iui.temp_ir_generation + " obj"; //$NON-NLS-1$//$NON-NLS-2$
- byte[] temp_bytes = temp_string.getBytes("US-ASCII"); //$NON-NLS-1$
- int temp_start = ByteArrayUtils.lastIndexOf(iui.signed_pdf, temp_bytes);
- byte[] stream_bytes = new byte[] { '>', '>', 's', 't', 'r', 'e', 'a', 'm', 0x0A };
- int stream_start = ByteArrayUtils.indexOf(iui.signed_pdf, temp_start, stream_bytes);
- iui.content_stream_start = stream_start + stream_bytes.length;
-
- // update the stream indices
- Iterator it = iui.replaces.iterator();
- while (it.hasNext())
- {
- ReplaceInfo ri = (ReplaceInfo) it.next();
-
- Iterator sit = ri.replaces.iterator();
- while (sit.hasNext())
- {
- StringInfo si = (StringInfo) sit.next();
- si.string_start += iui.content_stream_start;
- }
- }
- // update KZ list indices:
- it = iui.kz_list.iterator();
- while (it.hasNext())
- {
- StringInfo si = (StringInfo) it.next();
- si.string_start += iui.content_stream_start;
- }
-
- BinarySignature.markByteRanges(iui);
-
- // byte [] old_signed_pdf = iui.signed_pdf;
- iui.signed_pdf = BinarySignature.prepareDataToSign(iui.signed_pdf, iui.byte_ranges);
-
- reduceToIUBlock(iui);
-
- iui.signature_data = formSignatureData(iui);
-
- return iui;
-
- }
- catch (UnsupportedEncodingException e)
- {
- e.printStackTrace();
- throw new PDFDocumentException(201, e);
- }
- }
-
- /**
- * @see at.knowcenter.wag.egov.egiz.framework.Signator#finishSign(at.knowcenter.wag.egov.egiz.pdf.IncrementalUpdateInformation)
- */
- public SignResult finishSign(IncrementalUpdateInformation iui) throws PresentableException
- {
- restoreSignedPdf(iui);
-
- // PdfAS.prefixID(iui.signed_signature_object, PdfAS.BINARY_ID);
- fillReplacesWithValues(iui);
-
- BinarySignature.replaceCertificate(iui);
- BinarySignature.replacePlaceholders(iui);
-
- SignResult sign_result = new SignResult(PdfAS.PDF_MIME_TYPE, iui.signed_pdf);
- return sign_result;
- }
-
- /**
- * Reads the signature values from the signed signature object and fills the
- * corresponding value in the Replaces array.
- *
- * @param iui
- * The IncrementalUpdateInformation.
- */
- protected void fillReplacesWithValues(IncrementalUpdateInformation iui)
- {
- Iterator it = iui.replaces.iterator();
- while (it.hasNext())
- {
- ReplaceInfo ri = (ReplaceInfo) it.next();
-
- ri.value = iui.signed_signature_object.retrieveStringValue(ri.sfd.field_name);
- }
- }
-
- protected void reduceToIUBlock(IncrementalUpdateInformation iui)
- {
- byte[] iu_block = new byte[iui.signed_pdf.length - iui.original_document.getLength()];
- System.arraycopy(iui.signed_pdf, iui.original_document.getLength(), iu_block, 0, iu_block.length);
-
- iui.signed_pdf = null;
- iui.sign_iui_block = iu_block;
- }
-
- protected void restoreSignedPdf(IncrementalUpdateInformation iui)
- {
- iui.signed_pdf = new byte[iui.original_document.getLength() + iui.sign_iui_block.length];
-
- try
- {
- InputStream is = iui.original_document.createInputStream();
- is.read(iui.signed_pdf, 0, iui.original_document.getLength());
- is.close();
- }
- catch (IOException e)
- {
- throw new RuntimeException(e);
- }
-
- System.arraycopy(iui.sign_iui_block, 0, iui.signed_pdf, iui.original_document.getLength(), iui.sign_iui_block.length);
- }
-
- /**
- * Forms the SignatureData to be used for signing.
- *
- * @param iui
- * The IncrementalUpdateInformation.
- * @return Returns the SignatureData to be used for signing.
- */
- protected SignatureData formSignatureData(IncrementalUpdateInformation iui)
- {
- // String document_text =
- // BinarySignature.retrieveSignableTextFromData(iui.signed_pdf,
- // iui.signed_pdf.length); // signed_pdf.length);
- //
- // byte[] data;
- // try
- // {
- // data = document_text.getBytes("UTF-8"); //$NON-NLS-1$
- // }
- // catch (UnsupportedEncodingException e)
- // {
- // throw new RuntimeException("Very strange: UTF-8 character encoding not
- // supported.", e); //$NON-NLS-1$
- // }
- DataSource ds = new CompoundPdfDataSourceImpl(iui.original_document, iui.sign_iui_block);
- SignatureData signature_data = new SignatureDataImpl(ds, PdfAS.PDF_MIME_TYPE);
-
- return signature_data;
- }
-}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/BinarySignator_1_1_0.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/BinarySignator_1_1_0.java
deleted file mode 100644
index 2cb99c2..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/BinarySignator_1_1_0.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/**
- * <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: BinarySignator_1_0_0.java,v 1.1 2006/08/25 17:07:35 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.framework.signators;
-
-import java.io.ByteArrayInputStream;
-
-import at.gv.egiz.pdfas.impl.input.ByteArrayPdfDataSourceImpl;
-import at.gv.egiz.pdfas.impl.input.CompoundPdfDataSourceImpl;
-import at.gv.egiz.pdfas.framework.input.DataSource;
-
-import at.knowcenter.wag.egov.egiz.PdfAS;
-import at.knowcenter.wag.egov.egiz.PdfASID;
-import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
-import at.knowcenter.wag.egov.egiz.pdf.IncrementalUpdateInformation;
-import at.knowcenter.wag.egov.egiz.sig.SignatureData;
-import at.knowcenter.wag.egov.egiz.sig.SignatureDataImpl;
-
-/**
- * Signs the document binary.
- *
- * <p>
- * This just differs from version 1.0.0 in the fact that the signature data is
- * the actual binary PDF instead of a Base64 encoding.
- * </p>
- *
- * @see BinarySignator_1_0_0
- *
- * @deprecated moved to nc-framework
- *
- * @author wprinz
- */
-public class BinarySignator_1_1_0 extends BinarySignator_1_0_0
-{
- /**
- * The Pdf-AS ID of this Signator.
- */
- 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.Signator#getMyId()
- */
- public PdfASID getMyId()
- {
- return MY_ID;
- }
-
- /**
- * Overrides the SignatureData generation of the BinarySignator 1.0.0 so that
- * the SignatureData is the actual binary PDF instead of a Base64 encoding.
- *
- * @see at.knowcenter.wag.egov.egiz.framework.signators.BinarySignator_1_0_0#formSignatureData(at.knowcenter.wag.egov.egiz.pdf.IncrementalUpdateInformation)
- */
- protected SignatureData formSignatureData(IncrementalUpdateInformation iui)
- {
- DataSource ds = new CompoundPdfDataSourceImpl(iui.original_document, iui.sign_iui_block);
- SignatureData signature_data = new SignatureDataImpl(ds, PdfAS.PDF_MIME_TYPE);
-
- return signature_data;
- }
-}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/DetachedSignator_1_0_0.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/DetachedSignator_1_0_0.java
deleted file mode 100644
index 9ffeefe..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/DetachedSignator_1_0_0.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/**
- * <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: DetachedSignator_1_0_0.java,v 1.1 2006/08/30 14:02:35 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.framework.signators;
-
-import java.io.UnsupportedEncodingException;
-
-import at.gv.egiz.pdfas.framework.input.DataSource;
-import at.gv.egiz.pdfas.framework.input.PdfDataSource;
-import at.gv.egiz.pdfas.impl.input.TextDataSourceImpl;
-import at.knowcenter.wag.egov.egiz.PdfAS;
-import at.knowcenter.wag.egov.egiz.PdfASID;
-import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
-import at.knowcenter.wag.egov.egiz.exceptions.PresentableException;
-import at.knowcenter.wag.egov.egiz.framework.SignResult;
-import at.knowcenter.wag.egov.egiz.framework.Signator;
-import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
-import at.knowcenter.wag.egov.egiz.pdf.IncrementalUpdateInformation;
-import at.knowcenter.wag.egov.egiz.pdf.TablePos;
-import at.knowcenter.wag.egov.egiz.sig.SignatureDataImpl;
-import at.knowcenter.wag.egov.egiz.sig.connectors.bku.BKUPostConnection;
-
-/**
- * This signator is just for testing purposes.
- *
- * <p>
- * It doesn't modify the original document, but simply returns the XML signature
- * response as the signed document.
- * </p>
- *
- * @author wprinz
- */
-public class DetachedSignator_1_0_0 implements Signator
-{
- /**
- * The Pdf-AS ID of this Signator.
- */
- public static final PdfASID MY_ID = new PdfASID(SignatorFactory.VENDOR, SignatorFactory.TYPE_TEST, SignatorFactory.VERSION_1_0_0);
-
- /**
- * @see at.knowcenter.wag.egov.egiz.framework.Signator#getMyId()
- */
- public PdfASID getMyId()
- {
- return MY_ID;
- }
-
- /**
- * The Mime Type.
- */
- public static final String MIME_TYPE = "text/xml"; //$NON-NLS-1$
-
- /**
- * Default constructor.
- */
- public DetachedSignator_1_0_0()
- {
- // Default constructor.
- }
-
- /**
- * @see at.knowcenter.wag.egov.egiz.framework.Signator#prepareSign(byte[],
- * String, TablePos, boolean)
- */
- public IncrementalUpdateInformation prepareSign(PdfDataSource 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;
-
- String document_text = PdfAS.extractNormalizedTextTextual(pdf);
- iui.nonTextObjectInfos = PdfAS.extractNonTextualObjects(pdf);
- // logger_.debug("signed_text = " + document_text);
-
- DataSource ds = new TextDataSourceImpl(document_text);
- iui.signature_data = new SignatureDataImpl(ds, MIME_TYPE, "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
-
- 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.response_properties.getProperty(BKUPostConnection.RESPONSE_STRING_KEY);
- byte[] response_bytes = response.getBytes("UTF-8"); //$NON-NLS-1$
-
- SignResult sign_result = new SignResult(MIME_TYPE, response_bytes);
- return sign_result;
- }
- catch (UnsupportedEncodingException e)
- {
- e.printStackTrace();
- throw new PDFDocumentException(300, e);
- }
- }
-
-}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/DetachedfTextualSignator_1_0_0.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/DetachedfTextualSignator_1_0_0.java
deleted file mode 100644
index 1559246..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/DetachedfTextualSignator_1_0_0.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/**
- * <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: TextualSignator_1_0_0.java,v 1.3 2006/10/31 08:07:50 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.framework.signators;
-
-import java.io.UnsupportedEncodingException;
-
-import at.gv.egiz.pdfas.framework.input.DataSource;
-import at.gv.egiz.pdfas.framework.input.PdfDataSource;
-import at.gv.egiz.pdfas.impl.input.TextDataSourceImpl;
-import at.knowcenter.wag.egov.egiz.PdfAS;
-import at.knowcenter.wag.egov.egiz.PdfASID;
-import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
-import at.knowcenter.wag.egov.egiz.exceptions.PresentableException;
-import at.knowcenter.wag.egov.egiz.framework.SignResult;
-import at.knowcenter.wag.egov.egiz.framework.Signator;
-import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
-import at.knowcenter.wag.egov.egiz.pdf.IncrementalUpdateInformation;
-import at.knowcenter.wag.egov.egiz.pdf.TablePos;
-import at.knowcenter.wag.egov.egiz.sig.SignatureDataImpl;
-import at.knowcenter.wag.egov.egiz.sig.connectors.bku.BKUPostConnection;
-
-/**
- * Signs a document textually.
- *
- * <p>
- * In prepareSign, the document text is extracted and normalized.
- * </p>
- * <p>
- * In finishSign, the signed SignatureObject is transformed into a Signature
- * block, which is then written as an Incremental Update.
- * </p>
- *
- * @author wprinz
- */
-public class DetachedfTextualSignator_1_0_0 implements Signator
-{
- /**
- * The Mime Type.
- */
- public static final String MIME_TYPE = "text/xml"; //$NON-NLS-1$
-
- /**
- * 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);
-
- /**
- * @see at.knowcenter.wag.egov.egiz.framework.Signator#getMyId()
- */
- public PdfASID getMyId()
- {
- return MY_ID;
- }
-
- /**
- * Default constructor.
- */
- public DetachedfTextualSignator_1_0_0()
- {
- // Default constructor.
- }
-
- /**
- * <p>
- * The parameter has_SIG_ID is not used by this Signator because it doesn't
- * pre-format the signature block.
- * </p>
- *
- * @see at.knowcenter.wag.egov.egiz.framework.Signator#prepareSign(byte[],
- * String, TablePos, boolean)
- */
- public IncrementalUpdateInformation prepareSign(PdfDataSource 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;
-
- String document_text = PdfAS.extractNormalizedTextTextual(pdf, "cp1252");
- iui.nonTextObjectInfos = PdfAS.extractNonTextualObjects(pdf);
- // logger_.debug("signed_text = " + document_text);
-
- DataSource ds = new TextDataSourceImpl(document_text);
- iui.signature_data = new SignatureDataImpl(ds, MIME_TYPE, "UTF-8"); //$NON-NLS-1$ //$NON-NLS-2$
-
- 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.response_properties.getProperty(BKUPostConnection.RESPONSE_STRING_KEY);
- byte[] response_bytes = response.getBytes("UTF-8"); //$NON-NLS-1$
-
- SignResult sign_result = new SignResult(MIME_TYPE, response_bytes);
- return sign_result;
- }
- catch (UnsupportedEncodingException e)
- {
- e.printStackTrace();
- throw new PDFDocumentException(300, e);
- }
- }
-
-}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/TextualSignator_1_0_0.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/TextualSignator_1_0_0.java
deleted file mode 100644
index ff92cd1..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/TextualSignator_1_0_0.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * <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: TextualSignator_1_0_0.java,v 1.3 2006/10/31 08:07:50 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.framework.signators;
-
-import java.util.ArrayList;
-
-import at.gv.egiz.pdfas.framework.input.DataSource;
-import at.gv.egiz.pdfas.framework.input.PdfDataSource;
-import at.gv.egiz.pdfas.impl.input.TextDataSourceImpl;
-import at.gv.egiz.pdfas.impl.signator.IncrementalUpdateHelper;
-import at.knowcenter.wag.egov.egiz.PdfAS;
-import at.knowcenter.wag.egov.egiz.PdfASID;
-import at.knowcenter.wag.egov.egiz.exceptions.PresentableException;
-import at.knowcenter.wag.egov.egiz.framework.SignResult;
-import at.knowcenter.wag.egov.egiz.framework.Signator;
-import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
-import at.knowcenter.wag.egov.egiz.pdf.IncrementalUpdateInformation;
-import at.knowcenter.wag.egov.egiz.pdf.PositioningInstruction;
-import at.knowcenter.wag.egov.egiz.pdf.TablePos;
-import at.knowcenter.wag.egov.egiz.pdf.TextualSignature;
-import at.knowcenter.wag.egov.egiz.sig.SignatureDataImpl;
-import at.knowcenter.wag.egov.egiz.sig.SignatureObject;
-import at.knowcenter.wag.egov.egiz.sig.signatureobject.SignatureObjectHelper;
-
-import com.lowagie.text.pdf.PdfPTable;
-
-/**
- * Signs a document textually.
- *
- * <p>
- * In prepareSign, the document text is extracted and normalized.
- * </p>
- * <p>
- * In finishSign, the signed SignatureObject is transformed into a Signature
- * block, which is then written as an Incremental Update.
- * </p>
- *
- * @deprecated moved to new-framework
- *
- * @author wprinz
- */
-public class TextualSignator_1_0_0 implements Signator
-{
- /**
- * The Pdf-AS ID of this Signator.
- */
- public static final PdfASID MY_ID = new PdfASID(SignatorFactory.VENDOR, SignatorFactory.TYPE_TEXTUAL, SignatorFactory.VERSION_1_0_0);
-
- /**
- * @see at.knowcenter.wag.egov.egiz.framework.Signator#getMyId()
- */
- public PdfASID getMyId()
- {
- return MY_ID;
- }
-
- /**
- * Default constructor.
- */
- public TextualSignator_1_0_0()
- {
- // Default constructor.
- }
-
- /**
- * <p>
- * The parameter has_SIG_ID is not used by this Signator because it doesn't
- * pre-format the signature block.
- * </p>
- *
- * @see at.knowcenter.wag.egov.egiz.framework.Signator#prepareSign(byte[],
- * String, TablePos, boolean)
- */
- public IncrementalUpdateInformation prepareSign(PdfDataSource 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;
-
- String document_text = PdfAS.extractNormalizedTextTextual(pdf);
- iui.nonTextObjectInfos = PdfAS.extractNonTextualObjects(pdf);
- // logger_.debug("signed_text = " + document_text);
-
- DataSource ds = new TextDataSourceImpl(document_text);
- iui.signature_data = new SignatureDataImpl(ds, "text/plain", "UTF-8");
-
- 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
- {
- // PdfAS.prefixID(iui.signed_signature_object, PdfAS.TEXT_ID);
-
- iui.signed_signature_object.kz = getMyId().toString();
-
- SignatureObject so = SignatureObjectHelper.convertSignSignatureObjectToSignatureObject(iui.signed_signature_object, iui.signature_type);
-
- PdfPTable pdf_table = PdfAS.createPdfPTableFromSignatureObject(so);
-
- PositioningInstruction pi = PdfAS.determineTablePositioning(iui.pos, iui.signature_type, iui.original_document, pdf_table);
-
- IncrementalUpdateInformation signed_iui = IncrementalUpdateHelper.writeIncrementalUpdate(iui.original_document, pdf_table, iui.signature_type, pi, null, null, null, null, null);
-
- SignResult sign_result = new SignResult(PdfAS.PDF_MIME_TYPE, signed_iui.signed_pdf);
- return sign_result;
- }
-
-}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/TextualSignator_1_1_0.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/TextualSignator_1_1_0.java
deleted file mode 100644
index 42a5856..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/signators/TextualSignator_1_1_0.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * <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: TextualSignator_1_0_0.java,v 1.3 2006/10/31 08:07:50 wprinz Exp $
- */
-package at.knowcenter.wag.egov.egiz.framework.signators;
-
-import at.knowcenter.wag.egov.egiz.PdfASID;
-import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
-
-/**
- * Signs a document textually.
- *
- * @see TextualSignator_1_0_0
- *
- * @author wprinz
- */
-public class TextualSignator_1_1_0 extends TextualSignator_1_0_0
-{
- /**
- * The Pdf-AS ID of this Signator.
- */
- public static final PdfASID MY_ID = new PdfASID(SignatorFactory.VENDOR, SignatorFactory.TYPE_TEXTUAL, SignatorFactory.VERSION_1_1_0);
-
- /**
- * @see at.knowcenter.wag.egov.egiz.framework.Signator#getMyId()
- */
- public PdfASID getMyId()
- {
- return MY_ID;
- }
-
-}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_0_0.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_0_0.java
deleted file mode 100644
index 1ec1568..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_0_0.java
+++ /dev/null
@@ -1,396 +0,0 @@
-/**
- * <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/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_1_0.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_1_0.java
deleted file mode 100644
index c1d94c1..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/BinaryVerificator_1_1_0.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * <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/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_1_0_0.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_1_0_0.java
deleted file mode 100644
index 58302be..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_1_0_0.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/**
- * <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/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_pdfasold.java b/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_pdfasold.java
deleted file mode 100644
index 98940d6..0000000
--- a/src/main/java/at/knowcenter/wag/egov/egiz/framework/verificators/TextualVerificator_pdfasold.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/**
- * <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;
- }
-
-}