aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeResult.java12
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/commons/SignatureInformation.java18
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResult.java15
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResults.java18
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java38
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/analyze/AnalyzeResultImpl.java43
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureInformationAdapter.java15
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultsImpl.java20
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/vfilter/VerificationFilterImpl.java10
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/pdf/TextualSignatureHolder.java26
10 files changed, 116 insertions, 99 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeResult.java b/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeResult.java
index c9dde9e..a1aabb4 100644
--- a/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeResult.java
+++ b/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeResult.java
@@ -30,17 +30,5 @@ public interface AnalyzeResult
public List getNoSignatures();
- /**
- * Returns non textual data from pdf provided that {@link AnalyzeParameters#setReturnNonTextualObjects(boolean)}
- * has been set {@code true}.
- * @return List of {@link NonTextObjectInfo}
- */
- public List getNonTextualObjects();
-
- /**
- * Returns <code>true</code> if non textual objects have been found, <code>false</code> if not.
- * @return <code>true</code> if non textual objects have been found, <code>false</code> if not.
- */
- public boolean hasNonTextualObjects();
}
diff --git a/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureInformation.java b/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureInformation.java
index 8eef6e8..3b05685 100644
--- a/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureInformation.java
+++ b/src/main/java/at/gv/egiz/pdfas/api/commons/SignatureInformation.java
@@ -19,7 +19,9 @@ package at.gv.egiz.pdfas.api.commons;
import java.security.cert.X509Certificate;
import java.util.Date;
+import java.util.List;
+import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo;
import at.gv.egiz.pdfas.api.io.DataSource;
/**
@@ -99,5 +101,21 @@ public interface SignatureInformation
* @return
*/
public String getTimeStampValue();
+
+ /**
+ * 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();
+
+ public void setNonTextualObjects(List nonTextualObjects);
+
+ /**
+ * Returns <code>true</code> if non textual objects have been found, <code>false</code> if not.
+ * @return <code>true</code> if non textual objects have been found, <code>false</code> if not.
+ */
+ public boolean hasNonTextualObjects();
+
} \ No newline at end of file
diff --git a/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResult.java b/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResult.java
index 34fbcd1..9455a2d 100644
--- a/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResult.java
+++ b/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResult.java
@@ -3,6 +3,7 @@ package at.gv.egiz.pdfas.api.verify;
import java.util.Date;
import java.util.List;
+import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo;
import at.gv.egiz.pdfas.api.commons.SignatureInformation;
/**
@@ -113,6 +114,20 @@ public interface VerifyResult extends SignatureInformation
* @see SignatureInformation#getSignedData()
*/
public String getHashInputData();
+
+ /**
+ * 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();
+
+
+ /**
+ * Returns <code>true</code> if non textual objects have been found, <code>false</code> if not.
+ * @return <code>true</code> if non textual objects have been found, <code>false</code> if not.
+ */
+ public boolean hasNonTextualObjects();
}
diff --git a/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResults.java b/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResults.java
index ef06880..d2f79b3 100644
--- a/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResults.java
+++ b/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResults.java
@@ -5,8 +5,6 @@ package at.gv.egiz.pdfas.api.verify;
import java.util.List;
-import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo;
-
/**
* The result of the verification of a document.
*
@@ -26,19 +24,5 @@ public interface VerifyResults
* signature.
*/
public List getResults();
-
- /**
- * 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();
-
-
- /**
- * Returns <code>true</code> if non textual objects have been found, <code>false</code> if not.
- * @return <code>true</code> if non textual objects have been found, <code>false</code> if not.
- */
- public boolean hasNonTextualObjects();
-
+
}
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
index f98b0f0..824416f 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java
@@ -31,6 +31,7 @@ import at.gv.egiz.pdfas.commandline.CommandlineConnectorChooser;
import at.gv.egiz.pdfas.exceptions.ErrorCode;
import at.gv.egiz.pdfas.framework.config.SettingsHelper;
import at.gv.egiz.pdfas.framework.input.ExtractionStage;
+import at.gv.egiz.pdfas.framework.input.PdfDataSource;
import at.gv.egiz.pdfas.framework.signator.SignatorInformation;
import at.gv.egiz.pdfas.framework.vfilter.VerificationFilterParameters;
import at.gv.egiz.pdfas.impl.api.analyze.AnalyzeResultImpl;
@@ -43,6 +44,7 @@ import at.gv.egiz.pdfas.impl.api.sign.ActualSignaturePositionAdapter;
import at.gv.egiz.pdfas.impl.api.sign.SignResultImpl;
import at.gv.egiz.pdfas.impl.api.verify.VerifyResultAdapter;
import at.gv.egiz.pdfas.impl.api.verify.VerifyResultsImpl;
+import at.gv.egiz.pdfas.impl.input.DelimitedPdfDataSource;
import at.gv.egiz.pdfas.impl.vfilter.VerificationFilterParametersImpl;
import at.gv.egiz.pdfas.utils.ConfigUtils;
import at.knowcenter.wag.egov.egiz.PdfAS;
@@ -52,11 +54,12 @@ 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.framework.SignatorFactory;
+import at.knowcenter.wag.egov.egiz.pdf.BinarySignatureHolder;
import at.knowcenter.wag.egov.egiz.pdf.NoSignatureHolder;
import at.knowcenter.wag.egov.egiz.pdf.ObjectExtractor;
import at.knowcenter.wag.egov.egiz.pdf.SignatureHolder;
import at.knowcenter.wag.egov.egiz.pdf.TablePos;
-import at.knowcenter.wag.egov.egiz.pdf.TextualSignature;
+import at.knowcenter.wag.egov.egiz.pdf.TextualSignatureHolder;
import at.knowcenter.wag.egov.egiz.sig.SignatureResponse;
import at.knowcenter.wag.egov.egiz.sig.SignatureTypeDefinition;
import at.knowcenter.wag.egov.egiz.sig.SignatureTypes;
@@ -378,17 +381,35 @@ public class PdfAsObject implements PdfAs
SignatureInformation si = new SignatureInformationAdapter(sh);
sigInfs.add(si);
+ if (analyzeParameters.isReturnNonTextualObjects()) {
+ si.setNonTextualObjects(doExtractNonTexualObjects(sh, (PdfDataSource) inputDataSource));
+ }
+
}
}
- List nonTextInfos = null;
- if (analyzeParameters.isReturnNonTextualObjects()) {
- nonTextInfos = ObjectExtractor.extractNonTextInfo(new PdfDataSourceAdapter(analyzeParameters.getDocument()));
- }
- return new AnalyzeResultImpl(sigInfs, noSigs, nonTextInfos);
+ return new AnalyzeResultImpl(sigInfs, noSigs);
}
- /**
+ private List doExtractNonTexualObjects(SignatureHolder sh, PdfDataSource pdfDataSource) {
+ if (sh == null) return null;
+ if (sh instanceof BinarySignatureHolder) {
+ BinarySignatureHolder bsh = (BinarySignatureHolder)sh;
+ return ObjectExtractor.extractNonTextInfo(bsh.getSignedPdf());
+ } else if (sh instanceof TextualSignatureHolder) {
+ TextualSignatureHolder tsh = (TextualSignatureHolder)sh;
+ if (tsh.getUiBlockEndPos() == 0) {
+ log.warn("uiblockendpos not available. Extract objects from final pdf document");
+ return ObjectExtractor.extractNonTextInfo(pdfDataSource);
+ }
+ DelimitedPdfDataSource dpds = new DelimitedPdfDataSource(pdfDataSource, tsh.getUiBlockEndPos());
+ return ObjectExtractor.extractNonTextInfo(dpds);
+ } else {
+ return null;
+ }
+ }
+
+/**
* @see at.gv.egiz.pdfas.api.PdfAs#verify(at.gv.egiz.pdfas.api.verify.VerifyAfterAnalysisParameters)
*/
public VerifyResults verify(VerifyAfterAnalysisParameters verifyAfterAnalysisParameters) throws PdfAsException
@@ -424,11 +445,12 @@ public class PdfAsObject implements PdfAs
SignatureHolder holder = (SignatureHolder) signature_holders.get(i);
VerifyResult vr = new VerifyResultAdapter(response, holder, verifyAfterAnalysisParameters.getVerificationTime());
+ vr.setNonTextualObjects( ((SignatureInformation) signatures.get(i)).getNonTextualObjects());
+
vrs.add(vr);
}
VerifyResultsImpl verifyResults = new VerifyResultsImpl(vrs);
- verifyResults.setNonTextualObjects(verifyAfterAnalysisParameters.getAnalyzeResult().getNonTextualObjects());
return verifyResults;
}
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/analyze/AnalyzeResultImpl.java b/src/main/java/at/gv/egiz/pdfas/impl/api/analyze/AnalyzeResultImpl.java
index a50b7a1..154d73d 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/api/analyze/AnalyzeResultImpl.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/api/analyze/AnalyzeResultImpl.java
@@ -5,9 +5,7 @@ package at.gv.egiz.pdfas.impl.api.analyze;
import java.util.List;
-import at.gv.egiz.pdfas.api.analyze.AnalyzeParameters;
import at.gv.egiz.pdfas.api.analyze.AnalyzeResult;
-import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo;
import at.gv.egiz.pdfas.api.exceptions.PdfAsException;
/**
@@ -25,23 +23,8 @@ public class AnalyzeResultImpl implements AnalyzeResult
/**
* The found non-signature update blocks.
*/
- protected List noSignatures = null;
+ protected List noSignatures = null;
- protected List nonTextualObjects = null;
-
-
- /**
- * Constructor.
- *
- * @param signatures
- * The found signatures.
- * @param noSignatures
- * The found non-signature update blocks.
- */
- public AnalyzeResultImpl(List signatures, List noSignatures)
- {
- this(signatures, noSignatures, null);
- }
/**
* Constructor.
@@ -50,9 +33,8 @@ public class AnalyzeResultImpl implements AnalyzeResult
* The found signatures.
* @param noSignatures
* The found non-signature update blocks.
- * @param nonTextInfos Non textual data from pdf provided that {@link AnalyzeParameters#setReturnNonTextualObjects(boolean)} was set.
*/
- public AnalyzeResultImpl(List signatures, List noSignatures, List nonTextInfos)
+ public AnalyzeResultImpl(List signatures, List noSignatures)
{
if (signatures == null)
{
@@ -60,8 +42,7 @@ public class AnalyzeResultImpl implements AnalyzeResult
}
this.signatures = signatures;
- this.noSignatures = noSignatures;
- this.nonTextualObjects = nonTextInfos;
+ this.noSignatures = noSignatures;
}
@@ -94,22 +75,4 @@ public class AnalyzeResultImpl implements AnalyzeResult
return this.noSignatures;
}
-
- /**
- * Returns non textual data from pdf provided that {@link AnalyzeParameters#setReturnNonTextualObjects(boolean)}
- * has been set {@code true}.
- * @return List of {@link NonTextObjectInfo}
- */
- public List getNonTextualObjects() {
- return this.nonTextualObjects;
- }
-
- /**
- * Returns <code>true</code> if non textual objects have been found, <code>false</code> if not.
- * @return <code>true</code> if non textual objects have been found, <code>false</code> if not.
- */
- public boolean hasNonTextualObjects() {
- return this.nonTextualObjects != null && !this.nonTextualObjects.isEmpty();
- }
-
}
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureInformationAdapter.java b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureInformationAdapter.java
index 3d4b560..4661d4e 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureInformationAdapter.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/api/commons/SignatureInformationAdapter.java
@@ -5,6 +5,7 @@ package at.gv.egiz.pdfas.impl.api.commons;
import java.security.cert.X509Certificate;
import java.util.Date;
+import java.util.List;
import at.gv.egiz.pdfas.api.commons.Constants;
import at.gv.egiz.pdfas.api.commons.SignatureInformation;
@@ -27,6 +28,8 @@ public class SignatureInformationAdapter implements SignatureInformation
protected SignatureHolder signatureHolder = null;
protected String timeStamp = null;
+
+ protected List nonTextualObjects = null;
/**
* Constructor.
@@ -94,5 +97,17 @@ public class SignatureInformationAdapter implements SignatureInformation
return this.timeStamp;
}
+ public List getNonTextualObjects() {
+ return this.nonTextualObjects;
+ }
+
+ public boolean hasNonTextualObjects() {
+ return this.nonTextualObjects != null && this.nonTextualObjects.size() > 0;
+ }
+
+ public void setNonTextualObjects(List nonTextualObjects) {
+ this.nonTextualObjects = nonTextualObjects;
+ }
+
}
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultsImpl.java b/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultsImpl.java
index 22d446a..22ab475 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultsImpl.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultsImpl.java
@@ -15,9 +15,7 @@ public class VerifyResultsImpl implements VerifyResults
/**
* The results.
*/
- protected List results = null;
-
- protected List nonTextualObjects = null;
+ protected List results = null;
/**
* Constructor.
@@ -38,21 +36,5 @@ public class VerifyResultsImpl implements VerifyResults
return this.results;
}
- public List getNonTextualObjects() {
- return this.nonTextualObjects;
- }
-
- public void setNonTextualObjects(List nonTextObjects) {
- this.nonTextualObjects = nonTextObjects;
-
- }
-
- /**
- * Returns <code>true</code> if non textual objects have been found, <code>false</code> if not.
- * @return <code>true</code> if non textual objects have been found, <code>false</code> if not.
- */
- public boolean hasNonTextualObjects() {
- return this.nonTextualObjects != null && !this.nonTextualObjects.isEmpty();
- }
}
diff --git a/src/main/java/at/gv/egiz/pdfas/impl/vfilter/VerificationFilterImpl.java b/src/main/java/at/gv/egiz/pdfas/impl/vfilter/VerificationFilterImpl.java
index e7724bc..acf6622 100644
--- a/src/main/java/at/gv/egiz/pdfas/impl/vfilter/VerificationFilterImpl.java
+++ b/src/main/java/at/gv/egiz/pdfas/impl/vfilter/VerificationFilterImpl.java
@@ -242,7 +242,7 @@ public class VerificationFilterImpl implements VerificationFilter
if (sao.oldSignature != null)
{
extractedSignatures.add(0, sao.oldSignature);
- }
+ }
}
else
{
@@ -666,7 +666,7 @@ public class VerificationFilterImpl implements VerificationFilter
//kz = new PdfASID("urn:pdfsigfilter:bka.gv.at:binaer:v1.1.0");
Verificator verificator = VerificatorFactory.createBinaryVerificator(kz);
- List binary_holders = verificator.parseBlock(pdf, data, fpr, prev_end);
+ List binary_holders = verificator.parseBlock(pdf, data, fpr, prev_end);
binarySignatures.addAll(binary_holders);
if(binary_holders.size() > 0) {
@@ -753,7 +753,9 @@ public class VerificationFilterImpl implements VerificationFilter
assert partition.isTextPartition();
int endOfDocument = VerificationFilterHelper.getEndOfPartition(partition);
- return extractSignatures(pdf, endOfDocument);
+ List extractedSigs = extractSignatures(pdf, endOfDocument);
+ TextualSignatureHolder.mulitSetUiBlockEndPos(extractedSigs, endOfDocument);
+ return extractedSigs;
}
protected SignaturesAndOld extractSignaturesFromPartitionAndOld(PdfDataSource pdf, Partition partition) throws VerificationFilterException
@@ -770,6 +772,8 @@ public class VerificationFilterImpl implements VerificationFilter
// log.debug("extracted text: " + extractedText);
SignaturesAndOld sao = extractSignaturesAndOld(extractedText);
+ TextualSignatureHolder.trySetUiBlockEndPos(sao.oldSignature, endOfDocument);
+ TextualSignatureHolder.mulitSetUiBlockEndPos(sao.newSignatures, endOfDocument);
return sao;
}
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TextualSignatureHolder.java b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TextualSignatureHolder.java
index 0971f90..8c7863d 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TextualSignatureHolder.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/pdf/TextualSignatureHolder.java
@@ -18,6 +18,8 @@
package at.knowcenter.wag.egov.egiz.pdf;
import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
import at.gv.egiz.pdfas.framework.input.DataSource;
import at.gv.egiz.pdfas.framework.input.TextDataSource;
@@ -53,6 +55,8 @@ public class TextualSignatureHolder implements Serializable, SignatureHolder
private SignatureObject signature_object = null;
private TextDataSource textDataSource = null;
+
+ private int uiBlockEndPos = 0;
public TextualSignatureHolder(String text, SignatureObject so)
{
@@ -114,6 +118,28 @@ public class TextualSignatureHolder implements Serializable, SignatureHolder
{
return this.textDataSource.getText();
}
+
+ public int getUiBlockEndPos() {
+ return this.uiBlockEndPos;
+ }
+
+ public void setUiBlockEndPos(int uiBlockEndPos) {
+ this.uiBlockEndPos = uiBlockEndPos;
+ }
+
+ public static void mulitSetUiBlockEndPos(List signatureHolders, int uiBlockEndPos) {
+ for (Iterator it = signatureHolders.iterator(); it.hasNext();) {
+ SignatureHolder sh = (SignatureHolder) it.next();
+ trySetUiBlockEndPos(sh, uiBlockEndPos);
+ }
+ }
+
+ public static void trySetUiBlockEndPos(SignatureHolder sh, int uiBlockEndPos ) {
+ if (sh != null && sh instanceof TextualSignatureHolder) {
+ ((TextualSignatureHolder)sh).setUiBlockEndPos(uiBlockEndPos);
+ }
+ }
+
}