From f7fcf33ac95f498238e5e79059e2aaf05f659fd6 Mon Sep 17 00:00:00 2001 From: ferbas Date: Mon, 2 Nov 2009 09:21:12 +0000 Subject: dynamic algorithm support, compatibility mode git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@380 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../mocca/LocRefDetachedMOCCAConnector.java | 2 +- .../egov/egiz/sig/connectors/mocca/MOCCAHelper.java | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'src/main/java/at/knowcenter/wag/egov') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/LocRefDetachedMOCCAConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/LocRefDetachedMOCCAConnector.java index a16dbf8..4b91328 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/LocRefDetachedMOCCAConnector.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/LocRefDetachedMOCCAConnector.java @@ -146,7 +146,7 @@ public class LocRefDetachedMOCCAConnector implements Connector, LocalConnector { BKUHelper.checkResponseForError(response_string); // SignSignatureObject so = MOCCAHelper.parseCreateXMLResponse(response_string, new DetachedMOCIdFormatter()); - SignSignatureObject so = sigLayout.parseCreateXMLSignatureResponse(response_string); + SignSignatureObject so = sigLayout.parseCreateXMLSignatureResponse(response_string, this.environment); so.response_properties = response_properties; log.debug("analyzeSignResponse finished."); return so; diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/MOCCAHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/MOCCAHelper.java index 1a68eca..6f4bc65 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/MOCCAHelper.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/mocca/MOCCAHelper.java @@ -13,12 +13,16 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import at.gv.egiz.pdfas.algorithmSuite.AlgorithmMapper; +import at.gv.egiz.pdfas.algorithmSuite.AlgorithmSuiteObject; import at.gv.egiz.pdfas.algorithmSuite.AlgorithmSuiteUtil; import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException; import at.knowcenter.wag.egov.egiz.sig.SignatureObject; import at.knowcenter.wag.egov.egiz.sig.X509Cert; +import at.knowcenter.wag.egov.egiz.sig.connectors.ConnectorEnvironment; import at.knowcenter.wag.egov.egiz.sig.connectors.bku.BKUHelper; import at.knowcenter.wag.egov.egiz.sig.connectors.bku.SignSignatureObject; +import at.knowcenter.wag.egov.egiz.sig.connectors.moa.MOASoapWithAttachmentConnector.Environment; import at.knowcenter.wag.egov.egiz.sig.sigid.IdFormatter; import at.knowcenter.wag.egov.egiz.tools.CodingHelper; @@ -50,7 +54,7 @@ public final class MOCCAHelper { * @see CodingHelper * @see X509Cert */ - public final static SignSignatureObject parseCreateXMLResponse(String xmlResponse, IdFormatter id_formatter) throws ConnectorException { + public final static SignSignatureObject parseCreateXMLResponse(String xmlResponse, IdFormatter id_formatter, ConnectorEnvironment environment) throws ConnectorException { if (log.isDebugEnabled()) { log.debug("xmlResponse = " + xmlResponse); @@ -137,13 +141,26 @@ public final class MOCCAHelper { log.debug("ser number matches = " + cert.getSerialNumber().toString().equals(ser_num)); } + SignSignatureObject so = new SignSignatureObject(); + // extract Signature Id's String[] ids = extractIds(xmlResponse); // dferbas String algs = AlgorithmSuiteUtil.extractAlgorithmSuiteString(xmlResponse); + + AlgorithmSuiteObject suite = new AlgorithmSuiteObject(algs, false); + so.sigAlgorithm = AlgorithmMapper.getUri(suite.getSignatureMethod()); + + String defaultCertAlg = environment.getDefaultAlgForCert(cert); + + if (AlgorithmSuiteUtil.isDefaultCertAlg(algs, defaultCertAlg)) { + // do not embed default alg + algs = null; + } + String final_ids = id_formatter.formatIds(ids, algs); - SignSignatureObject so = new SignSignatureObject(); + so.date = sig_tim; so.issuer = iss_nam; so.signatureValue = sig_val; -- cgit v1.2.3