From 45819f5a12b1942d5c942ec909e22536b16aa56c Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Wed, 1 Feb 2017 10:11:47 +0100 Subject: fix wrong result in VerifyPDFSignatureResponse --- .../moa/spss/api/xmlbind/ResponseBuilderUtils.java | 16 ++++++++++++++++ .../api/xmlbind/VerifyPDFSignatureResponseBuilder.java | 14 +++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'moaSig/moa-sig-lib/src/main') diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/ResponseBuilderUtils.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/ResponseBuilderUtils.java index fafbc16..91dc6b9 100644 --- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/ResponseBuilderUtils.java +++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/ResponseBuilderUtils.java @@ -68,6 +68,22 @@ public class ResponseBuilderUtils { private static final String DSIG_NS_URI = Constants.DSIG_NS_URI; private static final String XMLNS_NS_URI = Constants.XMLNS_NS_URI; + /** + * Add an DOM element with a specific name as child to a root element + * + * @param elementName Name of the DOM element + * @param response Full document with namespace information + * @param rootElement Root element + * @return new child DOM element + */ + public static Element addChildElement(String elementName, Document response, + Element rootElement) { + Element childElement = response.createElementNS(MOA_NS_URI, elementName); + rootElement.appendChild(childElement); + return childElement; + + } + /** * Create a response element with all the namespaces set. * diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyPDFSignatureResponseBuilder.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyPDFSignatureResponseBuilder.java index f58b68a..98b54a3 100644 --- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyPDFSignatureResponseBuilder.java +++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyPDFSignatureResponseBuilder.java @@ -48,7 +48,7 @@ public class VerifyPDFSignatureResponseBuilder { /** The XML document containing the response element. */ private Document responseDoc; /** The response VerifyCMSSignatureResponse DOM element. */ - private Element responseElem; + private Element responseRootElem; /** * Create a new VerifyCMSSignatureResponseBuilder: @@ -59,7 +59,7 @@ public class VerifyPDFSignatureResponseBuilder { public VerifyPDFSignatureResponseBuilder() throws MOASystemException { responseDoc = ResponseBuilderUtils.createResponse("VerifyPDFSignatureResponse"); - responseElem = responseDoc.getDocumentElement(); + responseRootElem = responseDoc.getDocumentElement(); } /** @@ -78,10 +78,13 @@ public class VerifyPDFSignatureResponseBuilder { Iterator iter; + for (iter = response.getResponseElements().iterator(); iter.hasNext();) { VerifyCMSSignatureResponseElement responseElement = - (VerifyCMSSignatureResponseElement) iter.next(); - addResponseElement(responseElement); + (VerifyCMSSignatureResponseElement) iter.next(); + Element signatureResult = ResponseBuilderUtils.addChildElement("SignatureResult", responseDoc, responseRootElem); + addResponseElement(responseElement, signatureResult); + } return responseDoc; @@ -91,9 +94,10 @@ public class VerifyPDFSignatureResponseBuilder { * Add an element to the response. * * @param responseElement The element to add to the response. + * @param signatureResult * @throws MOAApplicationException An error occurred adding the element. */ - private void addResponseElement(VerifyCMSSignatureResponseElement responseElement) + private void addResponseElement(VerifyCMSSignatureResponseElement responseElement, Element responseElem) throws MOAApplicationException { SignerInfo signerInfo = responseElement.getSignerInfo(); -- cgit v1.2.3