From 71af11797a51acf6ecdfc7832af4b5eb6a3c2621 Mon Sep 17 00:00:00 2001 From: pdanner Date: Thu, 9 Dec 2010 10:57:31 +0000 Subject: added suppress_validate_exceptions parameter git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@695 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../java/at/knowcenter/wag/egov/egiz/PdfAS.java | 46 +++++++++++++--------- 1 file changed, 28 insertions(+), 18 deletions(-) (limited to 'src/main/java/at/knowcenter/wag/egov') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java index 6a19b42..6d5e399 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/PdfAS.java @@ -32,7 +32,6 @@ import org.apache.commons.logging.LogFactory; import at.gv.egiz.pdfas.api.analyze.NonTextObjectInfo; import at.gv.egiz.pdfas.api.commons.DynamicSignatureProfileImpl; -import at.gv.egiz.pdfas.api.exceptions.PdfAsException; import at.gv.egiz.pdfas.api.commons.SignatureInformation; import at.gv.egiz.pdfas.api.timestamp.TimeStamper; import at.gv.egiz.pdfas.api.xmldsig.ExtendedSignatureInformation; @@ -914,14 +913,33 @@ public abstract class PdfAS cp.setVerificationTime(verificationTime); Connector c = at.gv.egiz.pdfas.framework.ConnectorFactory.createConnector(connectorId, cp); - SignatureResponse res = null; - try { - return c.doVerify(sd, so, dsig); - } catch (PdfAsException e) { - res = new SignatureResponse(); - res.setVerificationImpossibleEx(e); - } - return res; + return executeVerify(dsig, so, sd, c); + } + + private static SignatureResponse executeVerify(XMLDsigData dsig, SignSignatureObject so, + SignatureData sd, Connector c) throws ConnectorException { + SignatureResponse res = null; + try { + return c.doVerify(sd, so, dsig); + } catch (ConnectorException e) { + if (suppressVerifyException()) { + res = new SignatureResponse(); + res.setVerificationImpossibleEx(e); + } else { + throw e; + } + } + return res; + } + + private static boolean suppressVerifyException() { + String propKey = "suppress_validate_exceptions"; + try { + return SettingsReader.getInstance().getSetting(propKey).equalsIgnoreCase("true"); + } catch (Exception e) { + log.debug("'" + propKey + "' property not found, using default value 'false'"); + return false; + } } public static SignatureResponse verifyWeb(SignatureHolder signature_holder, String connector, String loc_ref) throws NormalizeException, PDFDocumentException, SignatureException, ConnectorException @@ -960,15 +978,7 @@ public abstract class PdfAS String profile = so_to_be_verified.getSignatureTypeDefinition().getType(); Connector c = ConnectorChooser.chooseWebConnectorForVerify(connector, so_to_be_verified.getKZ(), so.id, profile, loc_ref); - SignatureResponse res = null; - try { - return c.doVerify(sd, so, null); - } catch (PdfAsException e) { - res = new SignatureResponse(); - res.setVerificationImpossibleEx(e); - } - - return res; + return executeVerify(null, so, sd, c); } -- cgit v1.2.3