aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv/egiz/pdfas
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv/egiz/pdfas')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeParameters.java16
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeResult.java14
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/verify/VerifyParameters.java12
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResults.java10
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/PdfAsObject.java19
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/analyze/AnalyzeResultImpl.java37
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultsImpl.java9
7 files changed, 102 insertions, 15 deletions
diff --git a/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeParameters.java b/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeParameters.java
index 0ab854c..b0ad28b 100644
--- a/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeParameters.java
+++ b/src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeParameters.java
@@ -33,6 +33,8 @@ public class AnalyzeParameters
*/
protected String verifyMode = Constants.VERIFY_MODE_FULL_CONSERVATIVE;
+ protected boolean returnNonTextualObjects = false;
+
/**
* @return the document
*/
@@ -65,5 +67,19 @@ public class AnalyzeParameters
this.verifyMode = verifyMode;
}
+ public boolean isReturnNonTextualObjects() {
+ return this.returnNonTextualObjects;
+ }
+
+ /**
+ * Tells if non text object of the signed pdf should be extracted and returned.
+ * One should show this to the user, especially in case of textual signature.
+ * Defaults to <tt>false</tt>
+ *
+ * @param returnNonTextualObjects
+ */
+ public void setReturnNonTextualObjects(boolean returnNonTextualObjects) {
+ this.returnNonTextualObjects = returnNonTextualObjects;
+ }
}
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 d063b76..c9dde9e 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
@@ -29,4 +29,18 @@ public interface AnalyzeResult
public List getSignatures() throws PdfAsException;
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/verify/VerifyParameters.java b/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyParameters.java
index 4f60bea..793764b 100644
--- a/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyParameters.java
+++ b/src/main/java/at/gv/egiz/pdfas/api/verify/VerifyParameters.java
@@ -78,7 +78,7 @@ public class VerifyParameters
*/
protected boolean returnHashInputData = false;
- protected boolean returnNonTextObjects = false;
+ protected boolean returnNonTextualObjects = false;
/**
* @return the document
@@ -182,8 +182,8 @@ public class VerifyParameters
this.returnHashInputData = returnHashInputData;
}
- public boolean isReturnNonTextObjects() {
- return this.returnNonTextObjects;
+ public boolean isReturnNonTextualObjects() {
+ return this.returnNonTextualObjects;
}
/**
@@ -191,10 +191,10 @@ public class VerifyParameters
* One should show this to the user, especially in case of textual signature.
* Defaults to <tt>false</tt>
*
- * @param returnNonTextObjects
+ * @param returnNonTextualObjects
*/
- public void setReturnNonTextObjects(boolean returnNonTextObjects) {
- this.returnNonTextObjects = returnNonTextObjects;
+ public void setReturnNonTextualObjects(boolean returnNonTextualObjects) {
+ this.returnNonTextualObjects = returnNonTextualObjects;
}
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 b30c451..ef06880 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
@@ -28,11 +28,17 @@ public interface VerifyResults
public List getResults();
/**
- * Returns a list<{@link NonTextObjectInfo} of non textual objects in the pdf document.
+ * 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 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();
+
}
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 df72a65..f98b0f0 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
@@ -53,8 +53,10 @@ 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.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.sig.SignatureResponse;
import at.knowcenter.wag.egov.egiz.sig.SignatureTypeDefinition;
import at.knowcenter.wag.egov.egiz.sig.SignatureTypes;
@@ -280,10 +282,6 @@ public class PdfAsObject implements PdfAs
fillVerifyAfterAnalysisParametersWithVerifyParameters(vaap, verifyParameters);
VerifyResults res = verify(vaap);
- if (verifyParameters.isReturnNonTextObjects()) {
- res.setNonTextualObjects(PdfAS.extractNonTextualObjects(new PdfDataSourceAdapter(verifyParameters.getDocument())));
- }
-
return res;
}
@@ -302,6 +300,7 @@ public class PdfAsObject implements PdfAs
{
ap.setDocument(vp.getDocument());
ap.setVerifyMode(vp.getVerifyMode());
+ ap.setReturnNonTextualObjects(vp.isReturnNonTextualObjects());
}
/**
@@ -381,8 +380,12 @@ public class PdfAsObject implements PdfAs
sigInfs.add(si);
}
}
+ List nonTextInfos = null;
+ if (analyzeParameters.isReturnNonTextualObjects()) {
+ nonTextInfos = ObjectExtractor.extractNonTextInfo(new PdfDataSourceAdapter(analyzeParameters.getDocument()));
+ }
- return new AnalyzeResultImpl(sigInfs, noSigs);
+ return new AnalyzeResultImpl(sigInfs, noSigs, nonTextInfos);
}
/**
@@ -423,8 +426,10 @@ public class PdfAsObject implements PdfAs
VerifyResult vr = new VerifyResultAdapter(response, holder, verifyAfterAnalysisParameters.getVerificationTime());
vrs.add(vr);
}
-
- return new VerifyResultsImpl(vrs);
+
+ 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 7b1dffa..a50b7a1 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,7 +5,9 @@ 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,6 +27,8 @@ public class AnalyzeResultImpl implements AnalyzeResult
*/
protected List noSignatures = null;
+ protected List nonTextualObjects = null;
+
/**
* Constructor.
@@ -36,6 +40,20 @@ public class AnalyzeResultImpl implements AnalyzeResult
*/
public AnalyzeResultImpl(List signatures, List noSignatures)
{
+ this(signatures, noSignatures, null);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param signatures
+ * 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)
+ {
if (signatures == null)
{
throw new IllegalArgumentException("The list of found signatures must not be null.");
@@ -43,6 +61,7 @@ public class AnalyzeResultImpl implements AnalyzeResult
this.signatures = signatures;
this.noSignatures = noSignatures;
+ this.nonTextualObjects = nonTextInfos;
}
@@ -74,5 +93,23 @@ 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/verify/VerifyResultsImpl.java b/src/main/java/at/gv/egiz/pdfas/impl/api/verify/VerifyResultsImpl.java
index c5e6713..22d446a 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
@@ -46,4 +46,13 @@ public class VerifyResultsImpl implements VerifyResults
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();
+ }
+
}