From 7404b3f95c03d9c872d32e9fff73a394081a80ff Mon Sep 17 00:00:00 2001 From: netconomy Date: Fri, 25 Jan 2008 14:26:54 +0000 Subject: =?UTF-8?q?RHID=20und=20VTime=20f=C3=BCr=20EnvelopingBase64MOAConn?= =?UTF-8?q?ector?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@249 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../gv/egiz/pdfas/framework/ConnectorFactory.java | 3 +- .../egov/egiz/sig/connectors/ConnectorChooser.java | 13 +++-- .../bku/EnvelopedBase64BKUConnector.java | 62 +++++++++++----------- .../moa/EnvelopingBase64MOAConnector.java | 20 ++++++- .../default.moa.verify.request.enveloping.xml | 2 + 5 files changed, 62 insertions(+), 38 deletions(-) diff --git a/src/main/java/at/gv/egiz/pdfas/framework/ConnectorFactory.java b/src/main/java/at/gv/egiz/pdfas/framework/ConnectorFactory.java index 99d692e..a430518 100644 --- a/src/main/java/at/gv/egiz/pdfas/framework/ConnectorFactory.java +++ b/src/main/java/at/gv/egiz/pdfas/framework/ConnectorFactory.java @@ -9,7 +9,6 @@ import at.knowcenter.wag.egov.egiz.sig.connectors.Connector; import at.knowcenter.wag.egov.egiz.sig.connectors.bku.EnvelopedBase64BKUConnector; import at.knowcenter.wag.egov.egiz.sig.connectors.bku.MultipartDetachedBKUConnector; import at.knowcenter.wag.egov.egiz.sig.connectors.bku.OldEnvelopingBase64BKUConnector; -import at.knowcenter.wag.egov.egiz.sig.connectors.moa.DetachedLocRefMOAConnector; import at.knowcenter.wag.egov.egiz.sig.connectors.moa.EnvelopingBase64MOAConnector; import at.knowcenter.wag.egov.egiz.sig.connectors.moa.MOASoapWithAttachmentConnector; @@ -60,7 +59,7 @@ public class ConnectorFactory if (connectorId.equals(ENVELOPING_BASE64_MOA_CONNECTOR)) { // TODO Hier wird NICHT der neue Connector verwendet - return new EnvelopingBase64MOAConnector(connectorParameters.getProfileId()); + return new EnvelopingBase64MOAConnector(connectorParameters); // return new MOASoapWithAttachmentConnector(profile); } diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/ConnectorChooser.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/ConnectorChooser.java index cbdee42..e991e04 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/ConnectorChooser.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/ConnectorChooser.java @@ -14,7 +14,6 @@ import at.knowcenter.wag.egov.egiz.sig.connectors.bku.EnvelopedBase64BKUConnecto import at.knowcenter.wag.egov.egiz.sig.connectors.bku.LocRefDetachedBKUConnector; import at.knowcenter.wag.egov.egiz.sig.connectors.bku.MultipartDetachedBKUConnector; import at.knowcenter.wag.egov.egiz.sig.connectors.bku.OldEnvelopingBase64BKUConnector; -import at.knowcenter.wag.egov.egiz.sig.connectors.moa.DetachedLocRefMOAConnector; import at.knowcenter.wag.egov.egiz.sig.connectors.moa.EnvelopingBase64MOAConnector; import at.knowcenter.wag.egov.egiz.sig.connectors.moa.MOASoapWithAttachmentConnector; import at.knowcenter.wag.egov.egiz.sig.sigid.HotfixIdFormatter; @@ -178,7 +177,9 @@ public final class ConnectorChooser { log.debug("sig_kz is null or sig_kz version is 1.0.0 -> choosing Base64 connector."); - return new EnvelopingBase64MOAConnector(profile); + ConnectorParameters cp = new ConnectorParameters(); + cp.setProfileId(profile); + return new EnvelopingBase64MOAConnector(cp); } if (sig_kz.getVersion().equals(SignatorFactory.VERSION_1_1_0)) @@ -270,7 +271,9 @@ public final class ConnectorChooser { log.debug("sig_app is MOA ==> EnvelopingBase64MOAConnector"); //$NON-NLS-1$ - return new EnvelopingBase64MOAConnector(profile); + ConnectorParameters cp = new ConnectorParameters(); + cp.setProfileId(profile); + return new EnvelopingBase64MOAConnector(cp); } throw new ConnectorException(310, "Unknown sig_app '" + sig_app + "'."); //$NON-NLS-1$ //$NON-NLS-2$ @@ -289,7 +292,9 @@ public final class ConnectorChooser { log.debug("sig_app is MOA ==> EnvelopedBase64MOAConnector"); //$NON-NLS-1$ - return new EnvelopingBase64MOAConnector(profile); + ConnectorParameters cp = new ConnectorParameters(); + cp.setProfileId(profile); + return new EnvelopingBase64MOAConnector(cp); } throw new ConnectorException(310, "Unknown sig_app '" + sig_app + "'."); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/EnvelopedBase64BKUConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/EnvelopedBase64BKUConnector.java index 82ec9bd..742a9a8 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/EnvelopedBase64BKUConnector.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/EnvelopedBase64BKUConnector.java @@ -11,6 +11,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import at.gv.egiz.pdfas.exceptions.ErrorCode; +import at.gv.egiz.pdfas.framework.ConnectorParameters; import at.knowcenter.wag.egov.egiz.cfg.SettingsReader; import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException; import at.knowcenter.wag.egov.egiz.exceptions.SettingsException; @@ -24,7 +25,6 @@ import at.knowcenter.wag.egov.egiz.sig.connectors.moa.EnvelopingBase64MOAConnect import at.knowcenter.wag.egov.egiz.sig.sigid.HotfixIdFormatter; import at.knowcenter.wag.egov.egiz.sig.sigkz.SigKZIDHelper; import at.knowcenter.wag.egov.egiz.tools.CodingHelper; -import at.knowcenter.wag.egov.egiz.tools.DebugHelper; import at.knowcenter.wag.egov.egiz.tools.FileHelper; /** @@ -111,34 +111,34 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector return signature_response; } - /** - * This emthod extracts id-values from a text. The id is given by the name. - * - * @param text - * the id-value that should extract from - * @param name - * the id-key - * @return the value of the given key in the text - */ - private String extractId(String text, String name) - { - String id = null; - int start_idx = text.indexOf(name) + name.length(); - int end_idx = text.indexOf("\"", start_idx); - - // TODO hotfix! - final int quot_end_idx = end_idx; - final int squot_end_idx = text.indexOf("'", start_idx); - end_idx = Math.min(quot_end_idx, squot_end_idx); - // TODO hotfix end! - - id = text.substring(start_idx, end_idx); - if (log.isDebugEnabled()) - { - log.debug("extract id:" + name + id); - } - return id; - } +// /** +// * This emthod extracts id-values from a text. The id is given by the name. +// * +// * @param text +// * the id-value that should extract from +// * @param name +// * the id-key +// * @return the value of the given key in the text +// */ +// private String extractId(String text, String name) +// { +// String id = null; +// int start_idx = text.indexOf(name) + name.length(); +// int end_idx = text.indexOf("\"", start_idx); +// +// // TODO hotfix! +// final int quot_end_idx = end_idx; +// final int squot_end_idx = text.indexOf("'", start_idx); +// end_idx = Math.min(quot_end_idx, squot_end_idx); +// // TODO hotfix end! +// +// id = text.substring(start_idx, end_idx); +// if (log.isDebugEnabled()) +// { +// log.debug("extract id:" + name + id); +// } +// return id; +// } /** * Prepares the XML content the holds the actual signature data. @@ -301,7 +301,9 @@ public class EnvelopedBase64BKUConnector implements Connector, LocalConnector if (SigKZIDHelper.isMOASigned(so)) { log.debug("The signature is MOA signed -> getting XML content from Base64MOA connector."); - EnvelopingBase64MOAConnector moa_conn = new EnvelopingBase64MOAConnector(this.environment.getProfile()); + ConnectorParameters cp = new ConnectorParameters(); + cp.setProfileId(this.environment.getProfile()); + EnvelopingBase64MOAConnector moa_conn = new EnvelopingBase64MOAConnector(cp); xml_content = moa_conn.prepareXMLContent(data, so); } else diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java index c8a8717..7d58d79 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/moa/EnvelopingBase64MOAConnector.java @@ -9,6 +9,7 @@ import java.util.Properties; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import at.gv.egiz.pdfas.framework.ConnectorParameters; import at.knowcenter.wag.egov.egiz.cfg.SettingsReader; import at.knowcenter.wag.egov.egiz.exceptions.ConnectorException; import at.knowcenter.wag.egov.egiz.exceptions.SettingsException; @@ -42,6 +43,8 @@ public class EnvelopingBase64MOAConnector implements Connector * other configurable elements. */ protected Environment environment = null; + + protected ConnectorParameters params = null; /** * Constructor that builds the configuration environment for this connector @@ -57,9 +60,10 @@ public class EnvelopingBase64MOAConnector implements Connector * @throws ConnectorException * f.e. */ - public EnvelopingBase64MOAConnector(String profile) throws ConnectorException + public EnvelopingBase64MOAConnector(ConnectorParameters connectorParameters) throws ConnectorException { - this.environment = new Environment(profile); + this.params = connectorParameters; + this.environment = new Environment(connectorParameters.getProfileId()); } /** @@ -181,6 +185,18 @@ public class EnvelopingBase64MOAConnector implements Connector String verify_request_xml = verify_request_template.replaceFirst(TemplateReplaces.XML_CONTENT_REPLACE, xml_content); verify_request_xml = verify_request_xml.replaceFirst(TemplateReplaces.TRUST_PROFILE_ID_REPLACE, this.environment.getVerifyTrustProfileId()); + String returnHashInputDataElement = ""; + if (this.params.isReturnHashInputData()) + { + returnHashInputDataElement = MOASoapWithAttachmentConnector.RETURN_HASH_INPUT_DATA; + } + verify_request_xml = verify_request_xml.replaceFirst(TemplateReplaces.RETURN_HASH_INPUT_DATA_REPLACE, returnHashInputDataElement); + + verify_request_xml = verify_request_xml.replaceFirst(TemplateReplaces.DATE_TIME_REPLACE, BKUHelper.formDateTimeElement(this.params.getVerificationTime())); + + + log.debug("\r\n\r\n" + verify_request_xml + "\r\n\r\n"); + return verify_request_xml; } diff --git a/work/templates/default.moa.verify.request.enveloping.xml b/work/templates/default.moa.verify.request.enveloping.xml index 04c6863..81e581f 100644 --- a/work/templates/default.moa.verify.request.enveloping.xml +++ b/work/templates/default.moa.verify.request.enveloping.xml @@ -1,10 +1,12 @@ +DateTimeReplace XMLContentReplace /dsig:Signature +ReturnHashInputDataReplace TrustProfileIDReplace \ No newline at end of file -- cgit v1.2.3