diff options
author | tknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2013-01-09 15:41:29 +0000 |
---|---|---|
committer | tknall <tknall@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c> | 2013-01-09 15:41:29 +0000 |
commit | 535a04fa05f739ec16dd81666e3b0f82dfbd442d (patch) | |
tree | 0804f301c1a9ceb303a8441b7b29244fc8eb7ff0 /pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework | |
parent | 1efaf6fd5619dfa95c9d7e8c71eda4c2ffba4998 (diff) | |
download | pdf-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 'pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework')
24 files changed, 1660 insertions, 0 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/ConnectorFactory.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/ConnectorFactory.java new file mode 100644 index 0000000..c9b6238 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/ConnectorFactory.java @@ -0,0 +1,107 @@ +/**
+ * <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.gv.egiz.pdfas.framework;
+
+import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException;
+import at.knowcenter.wag.egov.egiz.exceptions.ConnectorFactoryException;
+import at.knowcenter.wag.egov.egiz.sig.connectors.Connector;
+import at.knowcenter.wag.egov.egiz.sig.connectors.bku.EnvelopedBase64BKUConnector;
+import at.knowcenter.wag.egov.egiz.sig.connectors.bku.MultipartDetachedBKUConnector;
+import at.knowcenter.wag.egov.egiz.sig.connectors.bku.OldEnvelopingBase64BKUConnector;
+import at.knowcenter.wag.egov.egiz.sig.connectors.moa.EnvelopingBase64MOAConnector;
+import at.knowcenter.wag.egov.egiz.sig.connectors.moa.MOASoapWithAttachmentConnector;
+
+/**
+ * @author wprinz
+ */
+public class ConnectorFactory
+{
+ // TODO the functionality of the connector should be split into template
+ // handling and the actualy hardware access
+
+ public static String DETACHED_MULTIPART_BKU_CONNECTOR = "DetachedMultipartBKUConnector";
+
+ public static String ENVELOPING_BASE64_BKU_CONNECTOR = "EnvelopingBase64BKUConnector";
+
+ public static String OLD_ENVELOPING_BASE64_BKU_CONNECTOR = "OldEnvelopingBase64BKUConnector";
+
+ public static String DETACHED_LOCREF_MOA_CONNECTOR = "DetachedLocRefMOAConnector";
+
+ public static String ENVELOPING_BASE64_MOA_CONNECTOR = "EnvelopingBase64MOAConnector";
+
+
+
+ public static Connector createConnector (String connectorId, ConnectorParameters connectorParameters) throws ConnectorFactoryException, ConnectorException
+ {
+ if (connectorId.equals(DETACHED_MULTIPART_BKU_CONNECTOR))
+ {
+ return new MultipartDetachedBKUConnector(connectorParameters);
+ }
+
+ if (connectorId.equals(ENVELOPING_BASE64_BKU_CONNECTOR))
+ {
+ return new EnvelopedBase64BKUConnector(connectorParameters.getProfileId());
+ }
+
+ if (connectorId.equals(OLD_ENVELOPING_BASE64_BKU_CONNECTOR))
+ {
+ return new OldEnvelopingBase64BKUConnector(connectorParameters.getProfileId());
+ }
+
+ if (connectorId.equals(DETACHED_LOCREF_MOA_CONNECTOR))
+ {
+// TODO Hier wird der neue Connector verwendet
+// return new DetachedLocRefMOAConnector(profile, locRef);
+ return new MOASoapWithAttachmentConnector(connectorParameters);
+ }
+
+ if (connectorId.equals(ENVELOPING_BASE64_MOA_CONNECTOR))
+ {
+// TODO Hier wird NICHT der neue Connector verwendet
+ return new EnvelopingBase64MOAConnector(connectorParameters);
+// return new MOASoapWithAttachmentConnector(profile);
+ }
+
+ throw new ConnectorFactoryException("The connector Id " + connectorId + " couldn't be found by the ConnectorFactory.");
+ }
+
+ public static boolean isMOA (String connectorId)
+ {
+ if (connectorId.equals(DETACHED_LOCREF_MOA_CONNECTOR) || connectorId.equals(ENVELOPING_BASE64_MOA_CONNECTOR))
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+// public static Connector createConnectorForCommandline (String connectorId) throws ConnectorFactoryException
+// {
+// }
+//
+// public static Connector createConnectorForCommandline (String connectorId) throws ConnectorFactoryException
+// {
+// }
+
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/ConnectorParameters.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/ConnectorParameters.java new file mode 100644 index 0000000..a0b7ceb --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/ConnectorParameters.java @@ -0,0 +1,118 @@ +/**
+ * <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.gv.egiz.pdfas.framework;
+
+import java.util.Date;
+
+/**
+ * Parameters passed to the constructor of the Connector.
+ *
+ * <p>
+ * Each Connector must have a constructor accepting this parameter class as an
+ * argument.
+ * </p>
+ *
+ * @author wprinz
+ */
+public class ConnectorParameters {
+ /**
+ * The profile Id to get the connector parameters from.
+ *
+ * <p>
+ * The there are no explicit parameters for the connector in the profile, the
+ * default parameters are used.
+ * </p>
+ */
+ protected String profileId = null;
+
+ /**
+ * The signature key identifier to be used or null if it should be read from
+ * the profile.
+ *
+ * <p>
+ * Currently this is only used by MOA connectors and identifies the MOA key
+ * group to be used when signing. If null, the MOA connector reads the key
+ * from the profile.
+ * </p>
+ */
+ protected String signatureKeyIdentifier = null;
+
+ /**
+ * Tells, if the connector should ask the device to return the hash input
+ * data.
+ *
+ * <p>
+ * Note that not all connectors support to return the hash input data - so
+ * there is no guarantee that the hash value will actually be returned.
+ * </p>
+ */
+ protected boolean returnHashInputData = false;
+
+ /**
+ * Allows to specify an explicit time of verification.
+ *
+ * <p>
+ * If null, the device's default behaviour determines the time of
+ * verification, which is usually the current time.
+ * </p>
+ * <p>
+ * The time of verification usually influences the certificate check. E.g.
+ * the certificate may not be valid at the time of verification.
+ * </p>
+ */
+ protected Date verificationTime = null;
+
+ public String getProfileId() {
+ return this.profileId;
+ }
+
+ public void setProfileId(String profileId) {
+ this.profileId = profileId;
+ }
+
+ public String getSignatureKeyIdentifier() {
+ return this.signatureKeyIdentifier;
+ }
+
+ public void setSignatureKeyIdentifier(String signatureKeyIdentifier) {
+ this.signatureKeyIdentifier = signatureKeyIdentifier;
+ }
+
+ public boolean isReturnHashInputData() {
+ return this.returnHashInputData;
+ }
+
+ public void setReturnHashInputData(boolean returnHashInputData) {
+ this.returnHashInputData = returnHashInputData;
+ }
+
+ public Date getVerificationTime() {
+ return this.verificationTime;
+ }
+
+ public void setVerificationTime(Date verificationTime) {
+ this.verificationTime = verificationTime;
+ }
+
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/DataManager.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/DataManager.java new file mode 100644 index 0000000..4f0641a --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/DataManager.java @@ -0,0 +1,55 @@ +/**
+ * <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.gv.egiz.pdfas.framework;
+
+/**
+ * The DataManager is a mediator for all components that need to allocate large
+ * data elements.
+ *
+ * <p>
+ * The DataManager uses a certain DataStrategy to perform the actual tasks. The
+ * strategy may be different in different environments. E.g. The commandline may
+ * implement a strategy to keep all data in memory, whereas the web might
+ * implement one that puts as many data onto the disk as possible to save
+ * memory.
+ * </p>
+ *
+ * @author wprinz
+ *
+ */
+public class DataManager
+{
+ protected static DataStrategy dataStrategy = null;
+
+ public static void initialize(DataStrategy ds)
+ {
+ dataStrategy = ds;
+ }
+
+ public static DataStrategy getDataStrategy()
+ {
+ return dataStrategy;
+ }
+
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/DataSourceHolder.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/DataSourceHolder.java new file mode 100644 index 0000000..355da37 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/DataSourceHolder.java @@ -0,0 +1,45 @@ +/**
+ * <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.gv.egiz.pdfas.framework;
+
+import at.gv.egiz.pdfas.framework.input.DataSource;
+
+public class DataSourceHolder {
+ private DataSource dataSource;
+
+ public DataSourceHolder(DataSource dataSource) {
+ this.dataSource = dataSource;
+ }
+
+ public DataSource getDataSource() {
+ return dataSource;
+ }
+
+ public void setDataSource(DataSource dataSource) {
+ this.dataSource = dataSource;
+ }
+
+
+
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/DataStrategy.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/DataStrategy.java new file mode 100644 index 0000000..659ba1d --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/DataStrategy.java @@ -0,0 +1,57 @@ +/**
+ * <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.gv.egiz.pdfas.framework;
+
+import java.io.InputStream;
+
+import at.gv.egiz.pdfas.framework.input.DataSource;
+import at.gv.egiz.pdfas.framework.input.PdfDataSource;
+import at.gv.egiz.pdfas.framework.input.TextDataSource;
+import at.gv.egiz.pdfas.framework.output.DataSink;
+
+/**
+ * Factory for creating DataSources.
+ *
+ * @author wprinz
+ */
+public interface DataStrategy
+{
+
+ public TextDataSource createTextDataSource (String text);
+
+ public PdfDataSource createPdfDataSource (InputStream is);
+
+ public PdfDataSource createPdfDataSource (DataSource other, int length);
+
+ /**
+ * @deprecated - use streaming.
+ * @param pdf
+ * @return
+ */
+ public PdfDataSource createPdfDataSource (byte [] pdf);
+
+ public void destroyDataSource (DataSource dataSource);
+
+ public DataSink createDataSink ();
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/SignatorFactory.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/SignatorFactory.java new file mode 100644 index 0000000..891551c --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/SignatorFactory.java @@ -0,0 +1,131 @@ +/**
+ * <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.gv.egiz.pdfas.framework;
+
+import at.knowcenter.wag.egov.egiz.PdfASID;
+import at.knowcenter.wag.egov.egiz.exceptions.SignatorFactoryException;
+import at.gv.egiz.pdfas.impl.signator.binary.BinarySignator_1_0_0;
+import at.gv.egiz.pdfas.impl.signator.binary.BinarySignator_1_1_0;
+import at.gv.egiz.pdfas.impl.signator.detached.DetachedTextualSignator_1_0_0;
+import at.gv.egiz.pdfas.impl.signator.textual.TextualSignator_1_0_0;
+import at.gv.egiz.pdfas.impl.signator.textual.TextualSignator_1_1_0;
+import at.gv.egiz.pdfas.impl.signator.textual.TextualSignator_1_2_0;
+import at.gv.egiz.pdfas.framework.signator.Signator;
+
+/**
+ * @author wprinz
+ *
+ */
+public 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$
+
+ /**
+ * Detached Signator.
+ */
+ 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$
+
+
+ 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();
+ }
+ if (id.getVersion().equals(VERSION_1_2_0))
+ {
+ return new TextualSignator_1_2_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 DetachedTextualSignator_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$
+ }
+
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/SignatureHolderHelper.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/SignatureHolderHelper.java new file mode 100644 index 0000000..7aaa285 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/SignatureHolderHelper.java @@ -0,0 +1,57 @@ +/**
+ * <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.gv.egiz.pdfas.framework;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import at.knowcenter.wag.egov.egiz.pdf.EGIZDate;
+import at.knowcenter.wag.egov.egiz.pdf.SignatureHolder;
+
+public final class SignatureHolderHelper
+{
+
+ /**
+ * Sorts the List of SignatureHolders by date.
+ *
+ * @param signatureHolders
+ * The List of SignatureHolders.
+ */
+ public static void sortByDate(List signatureHolders)
+ {
+ Collections.sort(signatureHolders, new Comparator() {
+ public int compare(Object o1, Object o2)
+ {
+ SignatureHolder sh1 = (SignatureHolder) o1;
+ SignatureHolder sh2 = (SignatureHolder) o2;
+
+ EGIZDate date1 = EGIZDate.parseFromString(sh1.getSignatureObject().getSignationDate());
+ EGIZDate date2 = EGIZDate.parseFromString(sh2.getSignatureObject().getSignationDate());
+
+ return date1.compareTo(date2);
+ }
+ });
+ }
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/VerificatorFactory.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/VerificatorFactory.java new file mode 100644 index 0000000..2cc964b --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/VerificatorFactory.java @@ -0,0 +1,65 @@ +/**
+ * <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.gv.egiz.pdfas.framework;
+
+import at.gv.egiz.pdfas.exceptions.framework.VerificatorFactoryException;
+import at.gv.egiz.pdfas.framework.verificator.Verificator;
+import at.gv.egiz.pdfas.impl.verificator.binary.BinaryVerificator_1_0_0;
+import at.gv.egiz.pdfas.impl.verificator.binary.BinaryVerificator_1_1_0;
+import at.knowcenter.wag.egov.egiz.PdfASID;
+import at.knowcenter.wag.egov.egiz.framework.SignatorFactory;
+
+/**
+ * @author wprinz
+ *
+ */
+public class VerificatorFactory
+{
+
+ public static Verificator createVerificator(PdfASID kz) throws VerificatorFactoryException
+ {
+ if (kz.getType().equals(SignatorFactory.TYPE_BINARY))
+ {
+ return createBinaryVerificator(kz);
+ }
+
+ return null;
+ }
+
+ public static Verificator createBinaryVerificator(PdfASID kz) throws VerificatorFactoryException
+ {
+ assert kz.getType().equals(SignatorFactory.TYPE_BINARY);
+
+ if (kz.equals(BinaryVerificator_1_0_0.MY_ID))
+ {
+ return new BinaryVerificator_1_0_0();
+ }
+ if (kz.equals(BinaryVerificator_1_1_0.MY_ID))
+ {
+ return new BinaryVerificator_1_1_0();
+ }
+
+ throw new VerificatorFactoryException("kz is not a known binary signator " + kz);
+ }
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/config/SettingsHelper.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/config/SettingsHelper.java new file mode 100644 index 0000000..fc9860a --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/config/SettingsHelper.java @@ -0,0 +1,81 @@ +/**
+ * <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.gv.egiz.pdfas.framework.config;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.pdfas.framework.vfilter.VerificationFilterParameters;
+import at.gv.egiz.pdfas.impl.vfilter.VerificationFilterParametersImpl;
+import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
+import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
+
+/**
+ * Contains helpful Settings functions.
+ *
+ * @author wprinz
+ */
+public final class SettingsHelper
+{
+ /**
+ * The log.
+ */
+ private static final Log log = LogFactory.getLog(SettingsHelper.class);
+
+ public static VerificationFilterParameters readVerificationFilterParametersFromSettings() throws SettingsException
+ {
+ boolean binaryOnly = getFlag("binary_only");
+ boolean assumeOnlySB = getAssumeSB();
+ boolean checkOld = getFlag("check_old_textual_sigs");
+
+ VerificationFilterParameters vfp = new VerificationFilterParametersImpl(binaryOnly, assumeOnlySB, checkOld);
+ return vfp;
+ }
+
+ protected static boolean getFlag(String settingsKey) throws SettingsException
+ {
+ String flag = SettingsReader.getInstance().getSetting(settingsKey, "false");
+ boolean b = true;
+ if (flag.equals("false"))
+ {
+ b = false;
+ }
+ return b;
+ }
+
+ protected static boolean getAssumeSB() throws SettingsException
+ {
+ // backward compatibility for typo
+ String setting_with_typo = SettingsReader.getInstance().getSetting("assume_only_signauture_blocks", null);
+ if (setting_with_typo != null)
+ {
+ log.warn("You still have the typo in your configuration file. Please change 'assume_only_signauture_blocks' to 'assume_only_signature_blocks'. Thanks.");
+ boolean assumeOnlySB_typo = getFlag("assume_only_signauture_blocks");
+ return assumeOnlySB_typo;
+ }
+
+ boolean assumeOnlySB = getFlag("assume_only_signature_blocks");
+ return assumeOnlySB;
+ }
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/DataSource.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/DataSource.java new file mode 100644 index 0000000..f834622 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/DataSource.java @@ -0,0 +1,70 @@ +/**
+ * <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.gv.egiz.pdfas.framework.input;
+
+import java.io.InputStream;
+
+/**
+ * The input document data source.
+ *
+ * <p>
+ * Usually this is a PdfDataSource, but it may be a TextDataSource as well.
+ * </p>
+ *
+ * @author wprinz
+ *
+ */
+public interface DataSource
+{
+ /**
+ * Creates a new InputStream that allows to read out the document's binary
+ * data from the beginning.
+ *
+ * @return Returns the InputStream with the binary data.
+ */
+ public InputStream createInputStream();
+
+ /**
+ * Returns the length (number of bytes) of the stream.
+ *
+ * @return Returns the length (number of bytes) of the stream.
+ */
+ public int getLength();
+
+ /**
+ * Returns the data of this DataSource as a byte array.
+ *
+ * <p>
+ * Calling this method indicates that you need a byte array for random <strong>read</strong> access.
+ * The DataSource implementation should of course cache this byte array to avoid too much memory usage.
+ * </p>
+ * <p>
+ * Performance analysis has shown that the libraries internally convert the streams to byte arrays and
+ * that file system access is very slow.
+ * </p>
+ *
+ * @return
+ */
+ public byte [] getAsByteArray();
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/ExtractionStage.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/ExtractionStage.java new file mode 100644 index 0000000..19065b0 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/ExtractionStage.java @@ -0,0 +1,90 @@ +/**
+ * <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.gv.egiz.pdfas.framework.input;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import at.gv.egiz.pdfas.exceptions.ErrorCode;
+import at.gv.egiz.pdfas.exceptions.framework.VerificationFilterException;
+import at.gv.egiz.pdfas.framework.DataSourceHolder;
+import at.gv.egiz.pdfas.framework.vfilter.VerificationFilter;
+import at.gv.egiz.pdfas.framework.vfilter.VerificationFilterParameters;
+import at.gv.egiz.pdfas.impl.input.IncrementalUpdateParser;
+import at.gv.egiz.pdfas.impl.vfilter.VerificationFilterImpl;
+import at.knowcenter.wag.egov.egiz.exceptions.PDFDocumentException;
+import at.knowcenter.wag.egov.egiz.exceptions.PresentableException;
+
+/**
+ * Extracts all signatures from a given input DataSource.
+ *
+ * @author wprinz
+ */
+public class ExtractionStage
+{
+ /**
+ * The log.
+ */
+ private static final Log log = LogFactory.getLog(ExtractionStage.class);
+
+ public List extractSignatureHolders(final DataSourceHolder dataSource, VerificationFilterParameters parameters) throws PresentableException
+ {
+ if (dataSource.getDataSource() instanceof PdfDataSource)
+ {
+ PdfDataSource pdfDataSource = (PdfDataSource) dataSource.getDataSource();
+
+ PdfDataSourceHolder pdsh = new PdfDataSourceHolder(pdfDataSource);
+ List blocks = parsePdfIntoBlocks(pdsh);
+ dataSource.setDataSource(pdsh.getDataSource());
+ parameters.setBeenCorrected(pdsh.hasChanged());
+
+ VerificationFilter vf = new VerificationFilterImpl();
+ List signatures = vf.extractSignatureHolders(pdsh.getDataSource(), blocks, parameters);
+
+ return signatures;
+ }
+
+ if (dataSource.getDataSource() instanceof TextDataSource)
+ {
+ TextDataSource textDataSource = (TextDataSource) dataSource.getDataSource();
+
+ VerificationFilter vf = new VerificationFilterImpl();
+ List signatures = vf.extractSignaturHolders(textDataSource, parameters);
+
+ return signatures;
+ }
+
+ String msg = "The input DataSource is neither pdf nor text. class.name = " + dataSource.getClass().getName();
+ log.error(msg);
+ throw new VerificationFilterException(ErrorCode.DOCUMENT_CANNOT_BE_READ, msg);
+ }
+
+ protected List parsePdfIntoBlocks(PdfDataSourceHolder pdfDataSource) throws PDFDocumentException
+ {
+ List blocks = IncrementalUpdateParser.parsePdfIntoIUBlocks(pdfDataSource);
+ return blocks;
+ }
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/PdfDataSource.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/PdfDataSource.java new file mode 100644 index 0000000..ce3d658 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/PdfDataSource.java @@ -0,0 +1,41 @@ +/**
+ * <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.gv.egiz.pdfas.framework.input;
+
+
+/**
+ * Represents the binary data of a PDF document.
+ *
+ * <p>
+ * This interface allows Pdf data to be handled in an abstract way so that the
+ * storage (byta array, disk etc.) of pdf documents can be separated from the
+ * algorithms.
+ * </p>
+ *
+ * @author wprinz
+ */
+public interface PdfDataSource extends DataSource
+{
+ // jsut a marker interface
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/PdfDataSourceHolder.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/PdfDataSourceHolder.java new file mode 100644 index 0000000..14a4ff4 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/PdfDataSourceHolder.java @@ -0,0 +1,49 @@ +/**
+ * <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.gv.egiz.pdfas.framework.input;
+
+public class PdfDataSourceHolder {
+ private PdfDataSource dataSource;
+ private boolean hasChanged = false;
+
+ public PdfDataSourceHolder(PdfDataSource dataSource) {
+ this.dataSource = dataSource;
+ }
+
+ public PdfDataSource getDataSource() {
+ return dataSource;
+ }
+
+ public void setDataSource(PdfDataSource dataSource) {
+ this.dataSource = dataSource;
+ this.hasChanged = true;
+ }
+
+ public boolean hasChanged() {
+ return this.hasChanged;
+ }
+
+
+
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/TextDataSource.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/TextDataSource.java new file mode 100644 index 0000000..7623896 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/TextDataSource.java @@ -0,0 +1,39 @@ +/**
+ * <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.gv.egiz.pdfas.framework.input;
+
+/**
+ * Represents a free-text input text to be processed.
+ *
+ * @author wprinz
+ */
+public interface TextDataSource extends DataSource
+{
+ /**
+ * Returns the text to be processed.
+ * @return Returns the text to be processed.
+ */
+ public String getText();
+
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/correction/Corrector.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/correction/Corrector.java new file mode 100644 index 0000000..71f3ded --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/correction/Corrector.java @@ -0,0 +1,61 @@ +/**
+ * <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.gv.egiz.pdfas.framework.input.correction;
+
+import at.gv.egiz.pdfas.exceptions.framework.CorrectorException;
+import at.gv.egiz.pdfas.framework.input.PdfDataSource;
+
+/**
+ * Interface for PDF corretors.
+ *
+ * <p>
+ * Often PDF documents generated by various document to PDF converters have an
+ * invalid structure that upsets PDF-AS. The correction mechanism allows these
+ * documents to be corrected before being signed.
+ * </p>
+ * <p>
+ * A PDF corrector takes an incorrect PDF document and transforms it into a
+ * correct one.
+ * </p>
+ * <p>
+ * Note that correcting a document destroys all signatures in that document, so
+ * never correct an already signed document.
+ * </p>
+ *
+ * @author wprinz
+ */
+public interface Corrector
+{
+ /**
+ * Corrects the given PDF document to a form that PDF-AS can use.
+ *
+ * @param document
+ * The (incorrect) PDF document.
+ * @return Returns the corrected PDF document.
+ * @throws CorrectorException
+ * Exception thrown if the document couldn't be corrected.
+ */
+ public PdfDataSource correctDocument(PdfDataSource document) throws CorrectorException;
+
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/correction/CorrectorFactory.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/correction/CorrectorFactory.java new file mode 100644 index 0000000..8c954f7 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/input/correction/CorrectorFactory.java @@ -0,0 +1,63 @@ +/**
+ * <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.gv.egiz.pdfas.framework.input.correction;
+
+import at.gv.egiz.pdfas.impl.input.correction.ExternalCorrector;
+import at.gv.egiz.pdfas.impl.input.correction.InternalCorrector;
+import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
+import at.knowcenter.wag.egov.egiz.exceptions.SettingsException;
+
+/**
+ * Factory for creating Correctors.
+ *
+ * @author wprinz
+ */
+public class CorrectorFactory
+{
+ public static final String INTERNAL_CORRECTOR = "internal";
+
+ public static final String EXTERNAL_CORRECTOR = "external";
+
+ public static final String CORRECTOR_KEY = "corrector";
+
+ public static Corrector createCorrector(String id) throws SettingsException
+ {
+ if (id.equals(INTERNAL_CORRECTOR))
+ {
+ return new InternalCorrector();
+ }
+ if (id.equals(EXTERNAL_CORRECTOR))
+ {
+ return new ExternalCorrector();
+ }
+ throw new SettingsException("The connector id '" + id + "' is not a valid corrector id.");
+ }
+
+ public static Corrector createCorrector() throws SettingsException
+ {
+ String id = SettingsReader.getInstance().getSetting(CORRECTOR_KEY, INTERNAL_CORRECTOR);
+ return createCorrector(id);
+ }
+
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/output/DataSink.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/output/DataSink.java new file mode 100644 index 0000000..52959a9 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/output/DataSink.java @@ -0,0 +1,42 @@ +/**
+ * <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.gv.egiz.pdfas.framework.output;
+
+import java.io.OutputStream;
+
+/**
+ * Output document data sink.
+ *
+ * @author wprinz
+ */
+public interface DataSink
+{
+ public OutputStream createOutputStream(String mimeType);
+
+ public OutputStream createOutputStream(String mimeType, String characterEncoding);
+
+ public String getMimeType();
+
+ public String getCharacterEncoding();
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/sigdevice/SequentialSignatureDevice.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/sigdevice/SequentialSignatureDevice.java new file mode 100644 index 0000000..4edc435 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/sigdevice/SequentialSignatureDevice.java @@ -0,0 +1,45 @@ +/**
+ * <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.gv.egiz.pdfas.framework.sigdevice;
+
+/**
+ * A SignatureDevice that can be accessed in a sequential manner.
+ *
+ * <p>
+ * A sequential device handles all necessary steps in sequence. E.g. all the
+ * data is transformed into a http request and sent to a server. The server
+ * processes the request and answers. The response from the server is then
+ * analyzed and returned.
+ * </p>
+ *
+ * @author wprinz
+ */
+public interface SequentialSignatureDevice extends SignatureDevice
+{
+ // This is just a concept how it could be realized in future.
+ public void sign();
+
+ public void verify();
+
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/sigdevice/SignatureDevice.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/sigdevice/SignatureDevice.java new file mode 100644 index 0000000..eb7656a --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/sigdevice/SignatureDevice.java @@ -0,0 +1,36 @@ +/**
+ * <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.gv.egiz.pdfas.framework.sigdevice;
+
+/**
+ * Performs the task of passing the signature XML and data from the application
+ * to an external signature device and return the response in an form that the
+ * application can use.
+ *
+ * @author wprinz
+ */
+public interface SignatureDevice
+{
+ // Marker interface
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/signator/Signator.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/signator/Signator.java new file mode 100644 index 0000000..073af4d --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/signator/Signator.java @@ -0,0 +1,71 @@ +/**
+ * <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.gv.egiz.pdfas.framework.signator;
+
+import at.gv.egiz.pdfas.api.timestamp.TimeStamper;
+import at.gv.egiz.pdfas.exceptions.framework.SignatorException;
+import at.gv.egiz.pdfas.framework.input.PdfDataSource;
+import at.gv.egiz.pdfas.framework.output.DataSink;
+import at.knowcenter.wag.egov.egiz.PdfASID;
+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();
+
+ /**
+ * Suppies encoding for text extraction
+ * @return
+ */
+ public String getEncoding();
+
+ // dferbas no more has_SIG_ID
+
+ public SignatorInformation prepareSign(PdfDataSource pdfDataSource,
+ String profile, TablePos pos, TimeStamper timestamper) throws SignatorException;
+
+
+ public void finishSign(SignatorInformation signatorInformation, DataSink dataSink) throws SignatorException;
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/signator/SignatorInformation.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/signator/SignatorInformation.java new file mode 100644 index 0000000..f9efcbe --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/signator/SignatorInformation.java @@ -0,0 +1,99 @@ +/**
+ * <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.gv.egiz.pdfas.framework.signator;
+
+import java.util.List;
+
+import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo;
+import at.knowcenter.wag.egov.egiz.pdf.ActualTablePos;
+import at.knowcenter.wag.egov.egiz.sig.SignatureData;
+import at.knowcenter.wag.egov.egiz.sig.connectors.bku.SignSignatureObject;
+
+/**
+ * Encapsulates the Signator dependant information that needs to be passed from
+ * prepareSign to finishSign.
+ *
+ * <p>
+ * This supersedes the IncrementalUpdateInformation.
+ * </p>
+ *
+ * @author wprinz
+ */
+public interface SignatorInformation
+{
+ /**
+ * Returns the SignatureData to be signed.
+ * <p>
+ * This is passed on to the Connector and signature device for signing.
+ * </p>
+ *
+ * @return Returns the SignatureData to be signed.
+ */
+ public SignatureData getSignatureData();
+
+ /**
+ * Sets the SignSignatureObject with the signature data.
+ *
+ * <p>
+ * This is called by the framework to provide the finishSign with the
+ * signature data.
+ * </p>
+ *
+ * @param signSignatureObject
+ * The SignSignatureObject.
+ */
+ public void setSignSignatureObject(SignSignatureObject signSignatureObject);
+
+ /**
+ * Returns the SignSignatureObject.
+ *
+ * <p>
+ * After signation, this is used by the framework/API to get additional
+ * information about the signature.
+ * </p>
+ *
+ * @return Returns the SignSignatureObject.
+ */
+ public SignSignatureObject getSignSignatureObject();
+
+ /**
+ * Returns the position where the signature table was actually placed.
+ *
+ * @return Returns the position where the signature table was actually placed.
+ */
+ public ActualTablePos getActualTablePos();
+
+ /**
+ * Returns a list<{@link NonTextObjectInfo} of non textual objects in the pdf document.
+ * Only available for textual signatures. Show this to the user who signed the textual content only!
+ * @return List<{@link NonTextObjectInfo} or <tt>null</tt> of not available (binary signature)
+ */
+ public List getNonTextualObjects();
+
+ /**
+ * Set a list<{@link NonTextObjectInfo} of non textual objects in the pdf document.
+ * Only available for textual signatures. Show this to the user who signed the textual content only!
+ */
+ public void setNonTextualObjects(List nonTextObjects);
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/verificator/Verificator.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/verificator/Verificator.java new file mode 100644 index 0000000..78d6a2a --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/verificator/Verificator.java @@ -0,0 +1,61 @@ +/**
+ * <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.gv.egiz.pdfas.framework.verificator;
+
+import java.util.List;
+
+import at.gv.egiz.pdfas.framework.input.PdfDataSource;
+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.
+ *
+ * @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(PdfDataSource pdfDataSource, byte [] pdf, final FooterParseResult block,
+ int start_of_whole_block) throws PresentableException;
+
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/vfilter/VerificationFilter.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/vfilter/VerificationFilter.java new file mode 100644 index 0000000..58422d2 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/vfilter/VerificationFilter.java @@ -0,0 +1,72 @@ +/**
+ * <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.gv.egiz.pdfas.framework.vfilter;
+
+import java.util.List;
+
+import at.gv.egiz.pdfas.exceptions.framework.VerificationFilterException;
+import at.gv.egiz.pdfas.framework.input.PdfDataSource;
+import at.gv.egiz.pdfas.framework.input.TextDataSource;
+
+/**
+ * Extracts all signatures from a given PDF document or text.
+ *
+ * @see VerificationFilterParameters
+ *
+ * @author wprinz
+ */
+public interface VerificationFilter
+{
+
+ /**
+ * Extracts the signatures from the given PDF.
+ *
+ * @param pdf
+ * The PDF.
+ * @param blocks
+ * The List of Incremental Update blocks. Usually this comes from a
+ * preprocessing step.
+ * @param parameters
+ * The algorithm parameters.
+ * @return Returns a List of SignatureHolders containing the signatures. May
+ * be empty in case no signatures have been found.
+ * @throws VerificationFilterException
+ * Thrown if something goes wrong.
+ */
+ public List extractSignatureHolders(PdfDataSource pdf, List blocks, VerificationFilterParameters parameters) throws VerificationFilterException;
+
+ /**
+ * Extracts the text signatures from the given free-text.
+ *
+ * @param text
+ * The free-text.
+ * @param parameters
+ * The algorithm parameters.
+ * @return Returns a List of SignatureHolders containing the signatures. May
+ * be empty in case no signatures have been found.
+ * @throws VerificationFilterException
+ * Thrown if something goes wrong.
+ */
+ public List extractSignaturHolders(TextDataSource text, VerificationFilterParameters parameters) throws VerificationFilterException;
+}
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/vfilter/VerificationFilterParameters.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/vfilter/VerificationFilterParameters.java new file mode 100644 index 0000000..cf99086 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/vfilter/VerificationFilterParameters.java @@ -0,0 +1,105 @@ +/**
+ * <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.gv.egiz.pdfas.framework.vfilter;
+
+/**
+ * The parameters of the VerificationFilter algorithm.
+ *
+ * @author wprinz
+ */
+public interface VerificationFilterParameters
+{
+
+ /**
+ * Tells the VerificationFilter to extract binary signatures only.
+ *
+ * <p>
+ * Not scanning for textual signatures allows the algorithm to skip text
+ * extraction and signature extraction, which are both time and memory
+ * intensive processes.
+ * </p>
+ *
+ * @return Returns true if the VerificationFilter should extract binary
+ * signatures only.
+ */
+ public boolean extractBinarySignaturesOnly();
+
+ /**
+ * Tells the VerificationFilter to assume that there are only singatures (and
+ * their Incremental Update blocks) younger than the original document.
+ *
+ * <p>
+ * This is equivalent to saying that the document was not updated using an
+ * Incremental update block other than a signature after being singed. The
+ * incremental update blocks after the original document contain only
+ * signatures (either text or binary).
+ * </p>
+ * <p>
+ * This is equivalent to saying that there exists no Incremental Update block
+ * that would render a text signature before it invalid.
+ * </p>
+ * <p>
+ * Under this assumption, the process of finding all text signatures
+ * simplifies to one text extraction of the whole document and one signature
+ * extraction. This is of course a massive performance gain.
+ * </p>
+ * <p>
+ * Actually the algorithm performs a text extraction of the whole document not
+ * including trailing binary signature Incremental Update blocks. This means
+ * that if a the last n Incremental Update blocks of a document are binary,
+ * there is no use extract text from them.
+ * </p>
+ * <p>
+ * Note that if there are Incremental Update blocks with text after a
+ * signature thus this assumption does not hold the signatures older than this
+ * block will break.
+ * </p>
+ *
+ * @return Returns true if the Verification filter should assume that there
+ * are only signature blocks after the original document.
+ */
+ public boolean assumeOnlySignatureUpdateBlocks();
+
+ /**
+ * Tells the VerificationFilter so scan for old signatures in the rest text.
+ *
+ * <p>
+ * The rest text is the text of the oldest text signature or the original
+ * document text if there is no text signature.
+ * </p>
+ *
+ * @return Returns true if the VerificationFilter should scan for old text
+ * signatures in the rest text.
+ */
+ public boolean scanForOldSignatures();
+
+ /**
+ * Return value that tell if the document has been corrected before verification.
+ *
+ * @return
+ */
+ public boolean hasBeenCorrected();
+
+ public void setBeenCorrected(boolean corrected);
+}
|