From 56f8680bd81892ec7cfe4e346f98ecfe23651caf Mon Sep 17 00:00:00 2001 From: pdanner Date: Mon, 29 Nov 2010 14:32:04 +0000 Subject: improved prepareVerifyRequest to disable "default verify" git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@640 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../sig/connectors/bku/DetachedBKUConnector.java | 51 ++++++++++++---------- 1 file changed, 29 insertions(+), 22 deletions(-) (limited to 'src/main/java/at/knowcenter/wag/egov/egiz') diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java index c55e727..dcb758d 100644 --- a/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java +++ b/src/main/java/at/knowcenter/wag/egov/egiz/sig/connectors/bku/DetachedBKUConnector.java @@ -324,7 +324,7 @@ public class DetachedBKUConnector implements Connector, LocalConnector String verify_request_template = this.environment.getVerifyRequestTemplate(); String xml_content = null; - + if (dsigData != null && dsigData.getXmlDsig() != null) { xml_content = dsigData.getXmlDsig(); @@ -333,6 +333,8 @@ public class DetachedBKUConnector implements Connector, LocalConnector { xml_content = chooseAndCreateXMLDsig(data, so); } + + String verify_request_xml = verify_request_template.replaceFirst(TemplateReplaces.XML_CONTENT_REPLACE, xml_content); verify_request_xml = verify_request_xml.replaceFirst(TemplateReplaces.LOC_REF_CONTENT_REPLACE, this.environment.getLocRefContent()); @@ -340,37 +342,42 @@ public class DetachedBKUConnector implements Connector, LocalConnector return verify_request_xml; } - - private String chooseAndCreateXMLDsig(SignatureData data, SignSignatureObject so) throws ConnectorException { - // MOA + + private String chooseAndCreateXMLDsig(SignatureData data, SignSignatureObject so) throws ConnectorException { + // MOA if (SigKZIDHelper.isMOASigned(so)) { log.debug("The signature is MOA signed -> getting XML content from DetachedLocRefMOA connector."); DetachedLocRefMOAConnector moa_conn = new DetachedLocRefMOAConnector(this.environment.getProfile(), "loc ref not needed here"); return moa_conn.prepareXMLContent(data, so); - // MOCCA - } else if (SigKZIDHelper.isMOCCASigned(so)) { - log.debug("MOCCA signature detected."); - String algorithmId = SigKZIDHelper.parseAlgorithmId(so.id); - log.debug("Algorithm = " + algorithmId); - LocRefDetachedMOCCAConnector mocca_connector = new LocRefDetachedMOCCAConnector(this.params, "not needed here", algorithmId); - return mocca_connector.prepareXMLContent(data, so); - // ATRUST - } else if (SigKZIDHelper.isATrustSigned(so)) { - log.debug("ATrust signature detected"); - MOASoapWithAttachmentConnector moaConn = new MOASoapWithAttachmentConnector(this.params); - moaConn.reInitVerifyTemplate(MOASoapWithAttachmentConnector.ATRUST_VERIFY_TEMPLATE_KEY); - return moaConn.prepareXMLContent(data, so); - } + + // MOCCA + } else if (SigKZIDHelper.isMOCCASigned(so)) { + log.debug("MOCCA signature detected."); + String algorithmId = SigKZIDHelper.parseAlgorithmId(so.id); + log.debug("Algorithm = " + algorithmId); + LocRefDetachedMOCCAConnector mocca_connector = new LocRefDetachedMOCCAConnector(this.params, "not needed here", algorithmId); + return mocca_connector.prepareXMLContent(data, so); + + // ATRUST + } else if (SigKZIDHelper.isATrustSigned(so)) { + log.debug("ATrust signature detected"); + MOASoapWithAttachmentConnector moaConn = new MOASoapWithAttachmentConnector(this.params); + moaConn.reInitVerifyTemplate(MOASoapWithAttachmentConnector.ATRUST_VERIFY_TEMPLATE_KEY); + return moaConn.prepareXMLContent(data, so); + } // TD - else - { + else if (SigKZIDHelper.isBKUSigned(so)) { log.debug("TD signature signature detected."); return prepareXMLContent(data, so); + } + // unknown + else { + throw new ConnectorException(ErrorCode.UNSUPPORTED_SIGNATURE_METHOD, "unsupported signature, get a new pdf-as version. " + so.id + ", " +so.kz); } - } + } -/** + /** * Prepares the XML content the holds the actual signature data. * *

-- cgit v1.2.3