aboutsummaryrefslogtreecommitdiff
path: root/pdf-as-lib
diff options
context:
space:
mode:
authorAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-30 17:25:31 +0100
committerAndreas Fitzek <andreas.fitzek@iaik.tugraz.at>2014-10-30 17:25:31 +0100
commitd82c9837a3f7c250ed116487ab874b6825562e1f (patch)
tree559065142b1483eff007223aeca134a9e386649c /pdf-as-lib
parentfb3344c1e4d4ac8e8a6aa5605d052cee8cd4c3b1 (diff)
downloadpdf-as-4-d82c9837a3f7c250ed116487ab874b6825562e1f.tar.gz
pdf-as-4-d82c9837a3f7c250ed116487ab874b6825562e1f.tar.bz2
pdf-as-4-d82c9837a3f7c250ed116487ab874b6825562e1f.zip
added Option to keep invalid signatures
Diffstat (limited to 'pdf-as-lib')
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java2
-rw-r--r--pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnectorSLWrapper.java14
2 files changed, 15 insertions, 1 deletions
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java
index 03e72ecc..24af4ad8 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/lib/api/IConfigurationConstants.java
@@ -83,6 +83,8 @@ public interface IConfigurationConstants {
*/
public static final String MOA_SIGN_URL = "moa.sign.url";
+ public static final String KEEP_INVALID_SIGNATURE = "report.invalidSign";
+
public static final String MOC_SIGN_URL = "moc.sign.url";
public static final String MOBILE_SIGN_URL = "mobile.sign.url";
diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnectorSLWrapper.java b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnectorSLWrapper.java
index 49a450af..0b6b1fff 100644
--- a/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnectorSLWrapper.java
+++ b/pdf-as-lib/src/main/java/at/gv/egiz/sl/util/ISignatureConnectorSLWrapper.java
@@ -28,6 +28,7 @@ import iaik.x509.X509Certificate;
import java.security.cert.CertificateException;
import java.util.Iterator;
+import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -36,7 +37,9 @@ import at.gv.egiz.pdfas.common.exceptions.PDFASError;
import at.gv.egiz.pdfas.common.exceptions.PdfAsErrorCarrier;
import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
import at.gv.egiz.pdfas.common.exceptions.PdfAsSignatureException;
+import at.gv.egiz.pdfas.common.utils.SettingsUtils;
import at.gv.egiz.pdfas.common.utils.StreamUtils;
+import at.gv.egiz.pdfas.lib.api.IConfigurationConstants;
import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
import at.gv.egiz.pdfas.lib.api.verify.VerifyResult;
import at.gv.egiz.pdfas.lib.impl.status.RequestedSignature;
@@ -109,11 +112,20 @@ public class ISignatureConnectorSLWrapper implements ISignatureConnector {
break;
}
}
-
+
VerifyResult verifyResult;
try {
verifyResult = SignatureUtils.verifySignature(
response.getCMSSignature(), input);
+ if(SettingsUtils.getBooleanValue(requestedSignature.getStatus().getSettings(),
+ IConfigurationConstants.KEEP_INVALID_SIGNATURE, false)) {
+ Base64 b64 = new Base64();
+ requestedSignature
+ .getStatus()
+ .getMetaInformations()
+ .put(ErrorConstants.STATUS_INFO_INVALIDSIG,
+ b64.encodeToString(response.getCMSSignature()));
+ }
} catch (PDFASError e) {
throw new PdfAsErrorCarrier(e);
}