aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv
diff options
context:
space:
mode:
authorferbas <ferbas@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2009-12-10 14:23:21 +0000
committerferbas <ferbas@7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c>2009-12-10 14:23:21 +0000
commit8ba10b6fa16c78ec3a8661d7b050320971495405 (patch)
treea8c37cc68bdab41f0387f0b83a4c76e697552ea0 /src/main/java/at/gv
parent3c227f61c5e7bd5b9adceaa0d62e0c9862f7868b (diff)
downloadpdf-as-3-8ba10b6fa16c78ec3a8661d7b050320971495405.tar.gz
pdf-as-3-8ba10b6fa16c78ec3a8661d7b050320971495405.tar.bz2
pdf-as-3-8ba10b6fa16c78ec3a8661d7b050320971495405.zip
improved nonObjectExtraction. Use per signature basis
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@506 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c
Diffstat (limited to 'src/main/java/at/gv')
-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
9 files changed, 90 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;
}