aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/gv
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/gv')
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/analyze/AnalyzeResult.java2
-rw-r--r--src/main/java/at/gv/egiz/pdfas/api/verify/VerifyResult.java2
-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.java31
-rw-r--r--src/main/java/at/gv/egiz/pdfas/impl/vfilter/VerificationFilterImpl.java38
5 files changed, 75 insertions, 17 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 098f309..d063b76 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
@@ -27,4 +27,6 @@ public interface AnalyzeResult
* @see SignatureInformation
*/
public List getSignatures() throws PdfAsException;
+
+ public List getNoSignatures();
}
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 be5a88f..e830f51 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
@@ -84,7 +84,7 @@ public interface VerifyResult extends SignatureInformation
* </p>
* <p>
* Note that the HashInputData does not necessarily have to be exactly the
- * same as the signed date return by the
+ * same as the signed data return by the
* {@link SignatureInformation#getSignedData()} method.
* </p>
*
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 3b5d0a6..704f9fd 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
@@ -45,6 +45,7 @@ import at.knowcenter.wag.egov.egiz.cfg.SettingsReader;
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.SignatureHolder;
import at.knowcenter.wag.egov.egiz.pdf.TablePos;
import at.knowcenter.wag.egov.egiz.sig.SignatureResponse;
@@ -268,16 +269,24 @@ public class PdfAsObject implements PdfAs
ExtractionStage es = new ExtractionStage();
List signature_holders = es.extractSignatureHolders(inputDataSource, parameters);
- List sigInfs = new ArrayList(signature_holders.size());
+// List sigInfs = new ArrayList(signature_holders.size());
+ List sigInfs = new ArrayList();
+ List noSigs = new ArrayList();
Iterator it = signature_holders.iterator();
while (it.hasNext())
{
SignatureHolder sh = (SignatureHolder)it.next();
- SignatureInformation si = new SignatureInformationAdapter(sh);
- sigInfs.add(si);
+
+ if(sh instanceof NoSignatureHolder) {
+ noSigs.add(sh);
+ } else {
+
+ SignatureInformation si = new SignatureInformationAdapter(sh);
+ sigInfs.add(si);
+ }
}
- return new AnalyzeResultImpl(sigInfs);
+ return new AnalyzeResultImpl(sigInfs, noSigs);
}
/**
@@ -308,7 +317,7 @@ public class PdfAsObject implements PdfAs
{
SignatureResponse response = (SignatureResponse) results.get(i);
SignatureHolder holder = (SignatureHolder) signature_holders.get(i);
-
+
VerifyResult vr = new VerifyResultAdapter(response, holder, verifyAfterAnalysisParameters.getVerificationTime());
vrs.add(vr);
}
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 87a14f0..7b1dffa 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
@@ -19,6 +19,32 @@ public class AnalyzeResultImpl implements AnalyzeResult
* The found signatures.
*/
protected List signatures = null;
+
+ /**
+ * The found non-signature update blocks.
+ */
+ protected List noSignatures = null;
+
+
+ /**
+ * Constructor.
+ *
+ * @param signatures
+ * The found signatures.
+ * @param noSignatures
+ * The found non-signature update blocks.
+ */
+ public AnalyzeResultImpl(List signatures, List noSignatures)
+ {
+ if (signatures == null)
+ {
+ throw new IllegalArgumentException("The list of found signatures must not be null.");
+ }
+
+ this.signatures = signatures;
+ this.noSignatures = noSignatures;
+ }
+
/**
* Constructor.
@@ -44,4 +70,9 @@ public class AnalyzeResultImpl implements AnalyzeResult
return this.signatures;
}
+ public List getNoSignatures() {
+
+ return this.noSignatures;
+ }
+
}
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 2aa5c28..81b0364 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
@@ -37,6 +37,7 @@ import at.knowcenter.wag.egov.egiz.exceptions.SignatureException;
import at.knowcenter.wag.egov.egiz.exceptions.SignatureTypesException;
import at.knowcenter.wag.egov.egiz.pdf.AbsoluteTextSignature;
import at.knowcenter.wag.egov.egiz.pdf.EGIZDate;
+import at.knowcenter.wag.egov.egiz.pdf.NoSignatureHolder;
import at.knowcenter.wag.egov.egiz.pdf.SignatureHolder;
import at.knowcenter.wag.egov.egiz.pdf.TextualSignatureHolder;
import at.knowcenter.wag.exactparser.parsing.results.FooterParseResult;
@@ -280,10 +281,13 @@ public class VerificationFilterImpl implements VerificationFilter
String check_doc = settings.getSetting(CHECK_DOCUMENT, "false");
// flags for determination of illegal incremental update
- int sigs_found = 0;
- int sigs_found_prev = 0;
+ int sigsFound = 0;
+ int sigsFoundPrev = 0;
+ boolean lastBlockWasModified = false;
List partitionResults = new ArrayList(partitions.size());
+ List nshList = new ArrayList();
+
for (int i = 0; i < partitions.size(); i++)
{
Partition p = (Partition) partitions.get(i);
@@ -307,8 +311,8 @@ public class VerificationFilterImpl implements VerificationFilter
partitionResult = extractSignaturesFromPartition(pdf, tp);
}
- sigs_found_prev = sigs_found;
- sigs_found = partitionResult.size();
+ sigsFoundPrev = sigsFound;
+ sigsFound = partitionResult.size();
partitionResults.add(partitionResult);
} else {
// should be binary partition
@@ -316,19 +320,28 @@ public class VerificationFilterImpl implements VerificationFilter
BinaryPartition binpart = (BinaryPartition)p;
// add number (n) of found binary signatures - if there is a subsequent textual partition,
// at least n+1 sigs have to be found (note: sig-blocks of binary signatures are also extracted and detected)
- sigs_found = sigs_found + binpart.blocks.size();
+ sigsFound = sigsFound + binpart.blocks.size();
}
}
- // throw an Exception if there were already signatures, but current block does not contain any signatures
- if((check_doc.equalsIgnoreCase("true"))&& ((sigs_found_prev > 0) && !(sigs_found > sigs_found_prev)) ) {
- log.error("Illegal document modification!");
- throw new VerificationFilterException(ErrorCode.MODIFIED_AFTER_SIGNATION, "The document has been modified after being signed.");
+ // add NoSignatureHolder object if there were already signatures, but current block does not contain any signatures
+ if((check_doc.equalsIgnoreCase("true"))&& ((sigsFoundPrev > 0) && !(sigsFound > sigsFoundPrev)) ) {
+
+ nshList.add(new NoSignatureHolder(sigsFound));
+
+ lastBlockWasModified = true;
+ } else {
+ lastBlockWasModified = false;
}
}
+ // throw an exception if the last update block does not contain a signature and signatures have been found in this document
+ if(lastBlockWasModified) {
+ throw new VerificationFilterException(ErrorCode.MODIFIED_AFTER_SIGNATION, "The document has been modified after being signed.");
+ }
+
List extractedSignatures = new ArrayList();
Iterator it = partitionResults.iterator();
List prevPartitionResult = null;
@@ -355,12 +368,15 @@ public class VerificationFilterImpl implements VerificationFilter
}
List signatureHolderChain = intermingleSignatures(binarySignatures, extractedSignatures);
-
+
if (oldSignature != null)
{
signatureHolderChain.add(0, oldSignature);
}
-
+
+ // add the created NoSignatureHolders
+ signatureHolderChain.addAll(nshList);
+
return signatureHolderChain;
}