From 578ad0d6bc408edf9e6c875156054374f5fd8337 Mon Sep 17 00:00:00 2001
From: Thomas <>
Date: Mon, 22 Mar 2021 18:40:26 +0100
Subject: change to EGIZ codestyle
---
.../xmlbind/CreateCMSSignatureRequestParser.java | 214 ++++---
.../xmlbind/CreateCMSSignatureResponseBuilder.java | 113 ++--
.../xmlbind/CreateXMLSignatureRequestParser.java | 243 ++++----
.../xmlbind/CreateXMLSignatureResponseBuilder.java | 82 +--
.../moa/spss/api/xmlbind/ProfileParser.java | 246 ++++-----
.../moa/spss/api/xmlbind/RequestParserUtils.java | 310 ++++++-----
.../moa/spss/api/xmlbind/ResponseBuilderUtils.java | 601 ++++++++++----------
.../moa/spss/api/xmlbind/TransformParser.java | 149 +++--
.../xmlbind/VerifyCMSSignatureRequestParser.java | 216 ++++----
.../xmlbind/VerifyCMSSignatureResponseBuilder.java | 164 +++---
.../xmlbind/VerifyPDFSignatureResponseBuilder.java | 184 +++----
.../xmlbind/VerifyXMLSignatureRequestParser.java | 440 ++++++++-------
.../xmlbind/VerifyXMLSignatureResponseBuilder.java | 612 ++++++++++-----------
13 files changed, 1770 insertions(+), 1804 deletions(-)
(limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind')
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateCMSSignatureRequestParser.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateCMSSignatureRequestParser.java
index a4c4d29..579fb51 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateCMSSignatureRequestParser.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateCMSSignatureRequestParser.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.api.xmlbind;
import java.io.InputStream;
@@ -49,7 +48,7 @@ import at.gv.egovernment.moaspss.util.XPathUtils;
/**
* A parser to parse CreateCMSSignatureRequest
DOM trees into
* CreateCMSSignatureRequest
API objects.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
@@ -60,12 +59,12 @@ public class CreateCMSSignatureRequestParser {
//
private static final String MOA = Constants.MOA_PREFIX + ":";
private static final String KEY_IDENTIFIER_XPATH =
- "/" + MOA + "CreateCMSSignatureRequest/" + MOA + "KeyIdentifier";
+ "/" + MOA + "CreateCMSSignatureRequest/" + MOA + "KeyIdentifier";
private static final String SINGLE_SIGNATURE_INFO_XPATH =
- "/" + MOA + "CreateCMSSignatureRequest/" + MOA + "SingleSignatureInfo";
+ "/" + MOA + "CreateCMSSignatureRequest/" + MOA + "SingleSignatureInfo";
private static final String DATA_OBJECT_INFO_XPATH = MOA + "DataObjectInfo";
private static final String DATA_OBJECT_XPATH = MOA + "DataObject";
-
+
private static final String SL_CONFORM_ATTR_NAME = "SecurityLayerConformity";
private static final String IS_PADES_SIGNATURE_ATTR_NAME = "PAdESConformity";
@@ -74,11 +73,9 @@ public class CreateCMSSignatureRequestParser {
private static final String BASE64_CONTENT_XPATH = MOA + "Base64Content";
private static final String EXCLUDEBYTERANGE_FROM_XPATH = MOA + "ExcludedByteRange/" + MOA + "From";
private static final String EXCLUDEBYTERANGE_TO_XPATH = MOA + "ExcludedByteRange/" + MOA + "To";
-
-
/** The factory to create API objects. */
- private SPSSFactory factory;
+ private final SPSSFactory factory;
/**
* Create a new CreateCMSSignatureRequestParser
.
@@ -88,44 +85,43 @@ public class CreateCMSSignatureRequestParser {
}
/**
- * Parse a CreateCMSSignatureRequest
DOM element, as defined
- * by the MOA schema.
- *
+ * Parse a CreateCMSSignatureRequest
DOM element, as defined by the
+ * MOA schema.
+ *
* @param requestElem The CreateCMSSignatureRequest
to parse. The
- * request must have been successfully parsed against the schema for this
- * method to succeed.
- * @return A CreateCMSSignatureRequest
API object containing
- * the data from the DOM element.
+ * request must have been successfully parsed against the
+ * schema for this method to succeed.
+ * @return A CreateCMSSignatureRequest
API object containing the
+ * data from the DOM element.
* @throws MOAApplicationException An error occurred parsing the request.
*/
public CreateCMSSignatureRequest parse(Element requestElem)
- throws MOAApplicationException {
+ throws MOAApplicationException {
- List singleSignatureInfos = parseSingleSignatureInfos(requestElem);
- String keyIdentifier =
- XPathUtils.getElementValue(requestElem, KEY_IDENTIFIER_XPATH, null);
+ final List singleSignatureInfos = parseSingleSignatureInfos(requestElem);
+ final String keyIdentifier =
+ XPathUtils.getElementValue(requestElem, KEY_IDENTIFIER_XPATH, null);
return factory.createCreateCMSSignatureRequest(
- keyIdentifier,
- singleSignatureInfos);
+ keyIdentifier,
+ singleSignatureInfos);
}
/**
- * Parse all SingleSignatureInfo
elements of the
+ * Parse all SingleSignatureInfo
elements of the
* CreateCMSSignatureRequest
.
- *
+ *
* @param requestElem The CreateCMSSignatureRequest
to parse.
- * @return A List
of SingleSignatureInfo
API
- * objects.
- * @throws MOAApplicationException An error occurred parsing on of the
- * SingleSignatureInfo
elements.
+ * @return A List
of SingleSignatureInfo
API objects.
+ * @throws MOAApplicationException An error occurred parsing on of the
+ * SingleSignatureInfo
elements.
*/
private List parseSingleSignatureInfos(Element requestElem)
- throws MOAApplicationException {
+ throws MOAApplicationException {
- List singleSignatureInfos = new ArrayList();
- NodeIterator sigInfoElems =
- XPathUtils.selectNodeIterator(requestElem, SINGLE_SIGNATURE_INFO_XPATH);
+ final List singleSignatureInfos = new ArrayList();
+ final NodeIterator sigInfoElems =
+ XPathUtils.selectNodeIterator(requestElem, SINGLE_SIGNATURE_INFO_XPATH);
Element sigInfoElem;
while ((sigInfoElem = (Element) sigInfoElems.nextNode()) != null) {
@@ -137,132 +133,130 @@ public class CreateCMSSignatureRequestParser {
/**
* Parse a SingleSignatureInfo
DOM element.
- *
- * @param sigInfoElem The SingleSignatureInfo
DOM element to
- * parse.
- * @return A SingleSignatureInfo
API object containing the
- * information of sigInfoElem
.
- * @throws MOAApplicationException An error occurred parsing the
- * SingleSignatureInfo
.
+ *
+ * @param sigInfoElem The SingleSignatureInfo
DOM element to parse.
+ * @return A SingleSignatureInfo
API object containing the
+ * information of sigInfoElem
.
+ * @throws MOAApplicationException An error occurred parsing the
+ * SingleSignatureInfo
.
*/
private SingleSignatureInfo parseSingleSignatureInfo(Element sigInfoElem)
- throws MOAApplicationException {
+ throws MOAApplicationException {
- DataObjectInfo dataObjectInfo = parseDataObjectInfo(sigInfoElem);
+ final DataObjectInfo dataObjectInfo = parseDataObjectInfo(sigInfoElem);
boolean securityLayerConform;
boolean isPAdESSignature = false;
if (sigInfoElem.hasAttribute(SL_CONFORM_ATTR_NAME)) {
securityLayerConform =
- BoolUtils.valueOf(sigInfoElem.getAttribute(SL_CONFORM_ATTR_NAME));
+ BoolUtils.valueOf(sigInfoElem.getAttribute(SL_CONFORM_ATTR_NAME));
} else {
securityLayerConform = true;
}
if (sigInfoElem.hasAttribute(IS_PADES_SIGNATURE_ATTR_NAME)) {
- isPAdESSignature = BoolUtils.valueOf(sigInfoElem.getAttribute(IS_PADES_SIGNATURE_ATTR_NAME));
+ isPAdESSignature = BoolUtils.valueOf(sigInfoElem.getAttribute(IS_PADES_SIGNATURE_ATTR_NAME));
}
-
+
return factory.createSingleSignatureInfoCMS(
- dataObjectInfo,
- securityLayerConform,
- isPAdESSignature);
+ dataObjectInfo,
+ securityLayerConform,
+ isPAdESSignature);
}
/**
* Parse the DataObjectInfo
DOM elements contained in the given
* SingleSignatureInfo
DOM element.
- *
- * @param sigInfoElem The SingleSignatureInfo
DOM element
- * whose DataObjectInfo
s to parse.
+ *
+ * @param sigInfoElem The SingleSignatureInfo
DOM element whose
+ * DataObjectInfo
s to parse.
* @return A List
of DataObjectInfo
API objects
- * containing the data from the DataObjectInfo
DOM elements.
+ * containing the data from the DataObjectInfo
DOM
+ * elements.
* @throws MOAApplicationException An error occurred parsing one of the
- * DataObjectInfo
s.
+ * DataObjectInfo
s.
*/
private DataObjectInfo parseDataObjectInfo(Element sigInfoElem)
- throws MOAApplicationException {
-
- Element dataObjInfoElem = (Element)XPathUtils.selectSingleNode(sigInfoElem, DATA_OBJECT_INFO_XPATH);
-
- String structure = dataObjInfoElem.getAttribute("Structure");
- Element dataObjectElem =
- (Element) XPathUtils.selectSingleNode(dataObjInfoElem, DATA_OBJECT_XPATH);
-
- CMSDataObject dataObject = parseDataObject(dataObjectElem);
-
- return factory.createDataObjectInfo(
- structure,
- dataObject);
-
- }
-
-
+ throws MOAApplicationException {
+
+ final Element dataObjInfoElem = (Element) XPathUtils.selectSingleNode(sigInfoElem,
+ DATA_OBJECT_INFO_XPATH);
+
+ final String structure = dataObjInfoElem.getAttribute("Structure");
+ final Element dataObjectElem =
+ (Element) XPathUtils.selectSingleNode(dataObjInfoElem, DATA_OBJECT_XPATH);
-
+ final CMSDataObject dataObject = parseDataObject(dataObjectElem);
+
+ return factory.createDataObjectInfo(
+ structure,
+ dataObject);
+
+ }
/**
- * Parse a the DataObject
DOM element contained in a given
+ * Parse a the DataObject
DOM element contained in a given
* CreateCMSSignatureRequest
DOM element.
- *
- * @param requestElem The DataObject DOM element of the VerifyCMSSignatureRequest
- * to parse.
- * @return The CMSDataObject
API object containing the data
- * from the DataObject
DOM element.
+ *
+ * @param requestElem The DataObject DOM element of the
+ * VerifyCMSSignatureRequest
to parse.
+ * @return The CMSDataObject
API object containing the data from
+ * the DataObject
DOM element.
*/
private CMSDataObject parseDataObject(Element dataObjectElem) {
if (dataObjectElem != null) {
- Element metaInfoElem = (Element) XPathUtils.selectSingleNode(dataObjectElem, META_INFO_XPATH);
+ final Element metaInfoElem = (Element) XPathUtils.selectSingleNode(dataObjectElem, META_INFO_XPATH);
MetaInfo metaInfo = null;
- Element contentElem = (Element) XPathUtils.selectSingleNode(dataObjectElem, CONTENT_XPATH);
- CMSContent content = parseContent(contentElem);
+ final Element contentElem = (Element) XPathUtils.selectSingleNode(dataObjectElem, CONTENT_XPATH);
+ final CMSContent content = parseContent(contentElem);
if (metaInfoElem != null) {
metaInfo = RequestParserUtils.parseMetaInfo(metaInfoElem);
}
- String excludeByteRangeFromStr = XPathUtils.getElementValue(dataObjectElem, EXCLUDEBYTERANGE_FROM_XPATH, null);
- String excludeByteRangeToStr = XPathUtils.getElementValue(dataObjectElem, EXCLUDEBYTERANGE_TO_XPATH, null);
-
+ final String excludeByteRangeFromStr = XPathUtils.getElementValue(dataObjectElem,
+ EXCLUDEBYTERANGE_FROM_XPATH, null);
+ final String excludeByteRangeToStr = XPathUtils.getElementValue(dataObjectElem,
+ EXCLUDEBYTERANGE_TO_XPATH, null);
+
BigDecimal excludeByteRangeFrom = null;
BigDecimal excludeByteRangeTo = null;
-
- if (excludeByteRangeFromStr != null)
- excludeByteRangeFrom = new BigDecimal(excludeByteRangeFromStr);
- if (excludeByteRangeToStr != null)
- excludeByteRangeTo = new BigDecimal(excludeByteRangeToStr);
-
+
+ if (excludeByteRangeFromStr != null) {
+ excludeByteRangeFrom = new BigDecimal(excludeByteRangeFromStr);
+ }
+ if (excludeByteRangeToStr != null) {
+ excludeByteRangeTo = new BigDecimal(excludeByteRangeToStr);
+ }
+
return factory.createCMSDataObject(metaInfo, content, excludeByteRangeFrom, excludeByteRangeTo);
- }
- else {
+ } else {
return null;
}
}
-
-
- /**
- * Parse the content contained in a CMSContentBaseType
kind of
- * DOM element.
- *
- * @param contentElem The CMSContentBaseType
kind of element to
- * parse.
- * @return A CMSDataObject
API object containing the data
- * from the given DOM element.
- */
- private CMSContent parseContent(Element contentElem) {
- Element base64ContentElem =
+ /**
+ * Parse the content contained in a CMSContentBaseType
kind of DOM
+ * element.
+ *
+ * @param contentElem The CMSContentBaseType
kind of element to
+ * parse.
+ * @return A CMSDataObject
API object containing the data from the
+ * given DOM element.
+ */
+ private CMSContent parseContent(Element contentElem) {
+ final Element base64ContentElem =
(Element) XPathUtils.selectSingleNode(contentElem, BASE64_CONTENT_XPATH);
- if (base64ContentElem != null) {
- String base64Str = DOMUtils.getText(base64ContentElem);
- InputStream binaryContent = Base64Utils.decodeToStream(base64Str, true);
- return factory.createCMSContent(binaryContent);
- } else {
- return factory.createCMSContent(
+ if (base64ContentElem != null) {
+ final String base64Str = DOMUtils.getText(base64ContentElem);
+ final InputStream binaryContent = Base64Utils.decodeToStream(base64Str, true);
+ return factory.createCMSContent(binaryContent);
+ } else {
+ return factory.createCMSContent(
contentElem.getAttribute("Reference"));
- }
- }
+ }
+ }
}
\ No newline at end of file
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateCMSSignatureResponseBuilder.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateCMSSignatureResponseBuilder.java
index 7ce0871..12b408b 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateCMSSignatureResponseBuilder.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateCMSSignatureResponseBuilder.java
@@ -21,14 +21,10 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.api.xmlbind;
-import java.io.IOException;
import java.util.Iterator;
-import javax.xml.transform.TransformerException;
-
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -37,76 +33,71 @@ import at.gv.egovernment.moa.spss.api.cmssign.CMSSignatureResponse;
import at.gv.egovernment.moa.spss.api.cmssign.CreateCMSSignatureResponse;
import at.gv.egovernment.moa.spss.api.cmssign.CreateCMSSignatureResponseElement;
import at.gv.egovernment.moa.spss.api.xmlsign.ErrorResponse;
-import at.gv.egovernment.moa.spss.api.xmlsign.SignatureEnvironmentResponse;
import at.gv.egovernment.moaspss.util.Constants;
-import at.gv.egovernment.moaspss.util.DOMUtils;
/**
- * Convert a CreateCMSSignatureResponse
API object into its
- * XML representation, according to the MOA XML schema.
- *
+ * Convert a CreateCMSSignatureResponse
API object into its XML
+ * representation, according to the MOA XML schema.
+ *
* @version $Id$
*/
public class CreateCMSSignatureResponseBuilder {
private static final String MOA_NS_URI = Constants.MOA_NS_URI;
/** The XML document containing the response element. */
- private Document responseDoc;
+ private final Document responseDoc;
/** The response CreateCMSSignatureResponse
DOM element. */
- private Element responseElem;
+ private final Element responseElem;
/**
* Create a new CreateCMSSignatureResponseBuilder
:
- *
- * @throws MOASystemException An error occurred setting up the resulting
- * XML document.
+ *
+ * @throws MOASystemException An error occurred setting up the resulting XML
+ * document.
*/
public CreateCMSSignatureResponseBuilder() throws MOASystemException {
responseDoc =
- ResponseBuilderUtils.createResponse("CreateCMSSignatureResponse");
+ ResponseBuilderUtils.createResponse("CreateCMSSignatureResponse");
responseElem = responseDoc.getDocumentElement();
}
/**
- * Build a document containing a CreateCMSSignatureResponse
- * DOM element being the XML representation of the given
+ * Build a document containing a CreateCMSSignatureResponse
DOM
+ * element being the XML representation of the given
* CreateCMSSignatureResponse
API object.
- *
- * @param response The CreateCMSSignatureResponse
to convert
- * to XML.
- * @return A document containing the CreateCMSSignatureResponse
- * DOM element.
+ *
+ * @param response The CreateCMSSignatureResponse
to convert to
+ * XML.
+ * @return A document containing the CreateCMSSignatureResponse
DOM
+ * element.
*/
public Document build(CreateCMSSignatureResponse response) {
Iterator iter;
-
-
-
for (iter = response.getResponseElements().iterator(); iter.hasNext();) {
-
- Object responseObj = iter.next();
-
- if (responseObj instanceof ErrorResponse) {
- ErrorResponse errorResponse = (ErrorResponse) responseObj;
- addErrorResponse(errorResponse);
-
- } else if (responseObj instanceof CreateCMSSignatureResponseElement) {
- CMSSignatureResponse cmsSignatureResponse = (CMSSignatureResponse) responseObj;
- addCMSSignature(cmsSignatureResponse);
-
- }
-
+
+ final Object responseObj = iter.next();
+
+ if (responseObj instanceof ErrorResponse) {
+ final ErrorResponse errorResponse = (ErrorResponse) responseObj;
+ addErrorResponse(errorResponse);
+
+ } else if (responseObj instanceof CreateCMSSignatureResponseElement) {
+ final CMSSignatureResponse cmsSignatureResponse = (CMSSignatureResponse) responseObj;
+ addCMSSignature(cmsSignatureResponse);
+
+ }
+
// CreateCMSSignatureResponseElement responseElement =
// (CreateCMSSignatureResponseElement) iter.next();
-//
+//
// switch (responseElement.getResponseType()) {
// case CreateCMSSignatureResponseElement.CMS_SIGNATURE :
-//
+//
// break;
//
// case CreateCMSSignatureResponseElement.ERROR_RESPONSE :
-//
+//
// break;
// }
@@ -115,37 +106,35 @@ public class CreateCMSSignatureResponseBuilder {
return responseDoc;
}
-
-
/**
* Add a CMSSignature
element to the response.
- *
+ *
* @param cmsSignatureResponse The content to put under the
- * CMSSignature
element.
+ * CMSSignature
element.
*/
private void addCMSSignature(CMSSignatureResponse cmsSignatureResponse) {
- String base64Value = cmsSignatureResponse.getCMSSignature();
-
- Element cmsSignature = responseDoc.createElementNS(MOA_NS_URI, "CMSSignature");
- cmsSignature.setTextContent(base64Value);
-
- responseElem.appendChild(cmsSignature);
-
-}
-
+ final String base64Value = cmsSignatureResponse.getCMSSignature();
+
+ final Element cmsSignature = responseDoc.createElementNS(MOA_NS_URI, "CMSSignature");
+ cmsSignature.setTextContent(base64Value);
+
+ responseElem.appendChild(cmsSignature);
+
+ }
+
/**
* Add a ErrorResponse
element to the response.
- *
+ *
* @param errorResponse The API object containing the information to put into
- * the ErrorResponse
DOM element.
+ * the ErrorResponse
DOM element.
*/
private void addErrorResponse(ErrorResponse errorResponse) {
- Element errorElem =
- responseDoc.createElementNS(MOA_NS_URI, "ErrorResponse");
- Element errorCodeElem =
- responseDoc.createElementNS(MOA_NS_URI, "ErrorCode");
- Element infoElem = responseDoc.createElementNS(MOA_NS_URI, "Info");
- String errorCodeStr = Integer.toString(errorResponse.getErrorCode());
+ final Element errorElem =
+ responseDoc.createElementNS(MOA_NS_URI, "ErrorResponse");
+ final Element errorCodeElem =
+ responseDoc.createElementNS(MOA_NS_URI, "ErrorCode");
+ final Element infoElem = responseDoc.createElementNS(MOA_NS_URI, "Info");
+ final String errorCodeStr = Integer.toString(errorResponse.getErrorCode());
errorCodeElem.appendChild(responseDoc.createTextNode(errorCodeStr));
errorElem.appendChild(errorCodeElem);
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java
index d677f88..8898aaf 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.api.xmlbind;
import java.util.ArrayList;
@@ -47,7 +46,7 @@ import at.gv.egovernment.moaspss.util.XPathUtils;
/**
* A parser to parse CreateXMLSignatureRequest
DOM trees into
* CreateXMLSignatureRequest
API objects.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
@@ -58,25 +57,25 @@ public class CreateXMLSignatureRequestParser {
//
private static final String MOA = Constants.MOA_PREFIX + ":";
private static final String KEY_IDENTIFIER_XPATH =
- "/" + MOA + "CreateXMLSignatureRequest/" + MOA + "KeyIdentifier";
+ "/" + MOA + "CreateXMLSignatureRequest/" + MOA + "KeyIdentifier";
private static final String SINGLE_SIGNATURE_INFO_XPATH =
- "/" + MOA + "CreateXMLSignatureRequest/" + MOA + "SingleSignatureInfo";
+ "/" + MOA + "CreateXMLSignatureRequest/" + MOA + "SingleSignatureInfo";
private static final String DATA_OBJECT_INFO_XPATH = MOA + "DataObjectInfo";
private static final String DATA_OBJECT_XPATH = MOA + "DataObject";
private static final String CREATE_SIGNATURE_INFO_XPATH =
- MOA + "CreateSignatureInfo";
+ MOA + "CreateSignatureInfo";
private static final String CREATE_TRANSFORMS_INFO_PROFILE_XPATH =
- (MOA + "CreateTransformsInfoProfile | ")
- + (MOA + "CreateTransformsInfoProfileID");
+ MOA + "CreateTransformsInfoProfile | "
+ + MOA + "CreateTransformsInfoProfileID";
private static final String CREATE_SIGNATURE_ENVIRONMENT_XPATH =
- MOA + "CreateSignatureEnvironment";
+ MOA + "CreateSignatureEnvironment";
private static final String CREATE_SIGNATURE_ENVIRONMENT_PROFILE_XPATH =
- (MOA + "CreateSignatureEnvironmentProfile | ")
- + (MOA + "CreateSignatureEnvironmentProfileID");
+ MOA + "CreateSignatureEnvironmentProfile | "
+ + MOA + "CreateSignatureEnvironmentProfileID";
private static final String SL_CONFORM_ATTR_NAME = "SecurityLayerConformity";
-
+
/** The factory to create API objects. */
- private SPSSFactory factory;
+ private final SPSSFactory factory;
/**
* Create a new CreateXMLSignatureRequestParser
.
@@ -86,44 +85,43 @@ public class CreateXMLSignatureRequestParser {
}
/**
- * Parse a CreateXMLSignatureRequest
DOM element, as defined
- * by the MOA schema.
- *
+ * Parse a CreateXMLSignatureRequest
DOM element, as defined by the
+ * MOA schema.
+ *
* @param requestElem The CreateXMLSignatureRequest
to parse. The
- * request must have been successfully parsed against the schema for this
- * method to succeed.
- * @return A CreateXMLSignatureRequest
API object containing
- * the data from the DOM element.
+ * request must have been successfully parsed against the
+ * schema for this method to succeed.
+ * @return A CreateXMLSignatureRequest
API object containing the
+ * data from the DOM element.
* @throws MOAApplicationException An error occurred parsing the request.
*/
public CreateXMLSignatureRequest parse(Element requestElem)
- throws MOAApplicationException {
+ throws MOAApplicationException {
- List singleSignatureInfos = parseSingleSignatureInfos(requestElem);
- String keyIdentifier =
- XPathUtils.getElementValue(requestElem, KEY_IDENTIFIER_XPATH, null);
+ final List singleSignatureInfos = parseSingleSignatureInfos(requestElem);
+ final String keyIdentifier =
+ XPathUtils.getElementValue(requestElem, KEY_IDENTIFIER_XPATH, null);
return factory.createCreateXMLSignatureRequest(
- keyIdentifier,
- singleSignatureInfos);
+ keyIdentifier,
+ singleSignatureInfos);
}
/**
- * Parse all SingleSignatureInfo
elements of the
+ * Parse all SingleSignatureInfo
elements of the
* CreateXMLSignatureRequest
.
- *
+ *
* @param requestElem The CreateXMLSignatureRequest
to parse.
- * @return A List
of SingleSignatureInfo
API
- * objects.
- * @throws MOAApplicationException An error occurred parsing on of the
- * SingleSignatureInfo
elements.
+ * @return A List
of SingleSignatureInfo
API objects.
+ * @throws MOAApplicationException An error occurred parsing on of the
+ * SingleSignatureInfo
elements.
*/
private List parseSingleSignatureInfos(Element requestElem)
- throws MOAApplicationException {
+ throws MOAApplicationException {
- List singleSignatureInfos = new ArrayList();
- NodeIterator sigInfoElems =
- XPathUtils.selectNodeIterator(requestElem, SINGLE_SIGNATURE_INFO_XPATH);
+ final List singleSignatureInfos = new ArrayList();
+ final NodeIterator sigInfoElems =
+ XPathUtils.selectNodeIterator(requestElem, SINGLE_SIGNATURE_INFO_XPATH);
Element sigInfoElem;
while ((sigInfoElem = (Element) sigInfoElems.nextNode()) != null) {
@@ -135,52 +133,52 @@ public class CreateXMLSignatureRequestParser {
/**
* Parse a SingleSignatureInfo
DOM element.
- *
- * @param sigInfoElem The SingleSignatureInfo
DOM element to
- * parse.
- * @return A SingleSignatureInfo
API object containing the
- * information of sigInfoElem
.
- * @throws MOAApplicationException An error occurred parsing the
- * SingleSignatureInfo
.
+ *
+ * @param sigInfoElem The SingleSignatureInfo
DOM element to parse.
+ * @return A SingleSignatureInfo
API object containing the
+ * information of sigInfoElem
.
+ * @throws MOAApplicationException An error occurred parsing the
+ * SingleSignatureInfo
.
*/
private SingleSignatureInfo parseSingleSignatureInfo(Element sigInfoElem)
- throws MOAApplicationException {
+ throws MOAApplicationException {
- List dataObjectInfos = parseDataObjectInfos(sigInfoElem);
- CreateSignatureInfo createSignatureInfo =
- parseCreateSignatureInfo(sigInfoElem);
+ final List dataObjectInfos = parseDataObjectInfos(sigInfoElem);
+ final CreateSignatureInfo createSignatureInfo =
+ parseCreateSignatureInfo(sigInfoElem);
boolean securityLayerConform;
if (sigInfoElem.hasAttribute(SL_CONFORM_ATTR_NAME)) {
securityLayerConform =
- BoolUtils.valueOf(sigInfoElem.getAttribute(SL_CONFORM_ATTR_NAME));
+ BoolUtils.valueOf(sigInfoElem.getAttribute(SL_CONFORM_ATTR_NAME));
} else {
securityLayerConform = true;
}
return factory.createSingleSignatureInfo(
- dataObjectInfos,
- createSignatureInfo,
- securityLayerConform);
+ dataObjectInfos,
+ createSignatureInfo,
+ securityLayerConform);
}
/**
* Parse the DataObjectInfo
DOM elements contained in the given
* SingleSignatureInfo
DOM element.
- *
- * @param sigInfoElem The SingleSignatureInfo
DOM element
- * whose DataObjectInfo
s to parse.
+ *
+ * @param sigInfoElem The SingleSignatureInfo
DOM element whose
+ * DataObjectInfo
s to parse.
* @return A List
of DataObjectInfo
API objects
- * containing the data from the DataObjectInfo
DOM elements.
+ * containing the data from the DataObjectInfo
DOM
+ * elements.
* @throws MOAApplicationException An error occurred parsing one of the
- * DataObjectInfo
s.
+ * DataObjectInfo
s.
*/
private List parseDataObjectInfos(Element sigInfoElem)
- throws MOAApplicationException {
+ throws MOAApplicationException {
- List dataObjectInfos = new ArrayList();
- NodeIterator dataObjInfoElems =
- XPathUtils.selectNodeIterator(sigInfoElem, DATA_OBJECT_INFO_XPATH);
+ final List dataObjectInfos = new ArrayList();
+ final NodeIterator dataObjInfoElems =
+ XPathUtils.selectNodeIterator(sigInfoElem, DATA_OBJECT_INFO_XPATH);
Element dataObjInfoElem;
while ((dataObjInfoElem = (Element) dataObjInfoElems.nextNode()) != null) {
@@ -191,91 +189,91 @@ public class CreateXMLSignatureRequestParser {
/**
* Parse a DataObjectInfo
DOM element.
- *
- * @param dataObjInfoElem The DataObjectInfo
DOM element to
- * parse.
- * @return A DataObjectInfo
API element containing the data
- * from dataObjInfoElem
.
+ *
+ * @param dataObjInfoElem The DataObjectInfo
DOM element to parse.
+ * @return A DataObjectInfo
API element containing the data from
+ * dataObjInfoElem
.
* @throws MOAApplicationException An error occurred parsing the
- * DataObjectInfo
.
+ * DataObjectInfo
.
*/
private DataObjectInfo parseDataObjectInfo(Element dataObjInfoElem)
- throws MOAApplicationException {
-
- String structure = dataObjInfoElem.getAttribute("Structure");
- Element dataObjectElem =
- (Element) XPathUtils.selectSingleNode(dataObjInfoElem, DATA_OBJECT_XPATH);
- Content dataObject = RequestParserUtils.parseContent(dataObjectElem);
- CreateTransformsInfoProfile createTransformsInfoProfile =
- parseCreateTransformsInfoProfile(dataObjInfoElem);
+ throws MOAApplicationException {
+
+ final String structure = dataObjInfoElem.getAttribute("Structure");
+ final Element dataObjectElem =
+ (Element) XPathUtils.selectSingleNode(dataObjInfoElem, DATA_OBJECT_XPATH);
+ final Content dataObject = RequestParserUtils.parseContent(dataObjectElem);
+ final CreateTransformsInfoProfile createTransformsInfoProfile =
+ parseCreateTransformsInfoProfile(dataObjInfoElem);
boolean childOfManifest;
if (dataObjInfoElem.hasAttribute("ChildOfManifest")) {
childOfManifest =
- BoolUtils.valueOf(dataObjInfoElem.getAttribute("ChildOfManifest"));
+ BoolUtils.valueOf(dataObjInfoElem.getAttribute("ChildOfManifest"));
} else {
childOfManifest = false;
}
return factory.createDataObjectInfo(
- structure,
- childOfManifest,
- dataObject,
- createTransformsInfoProfile);
+ structure,
+ childOfManifest,
+ dataObject,
+ createTransformsInfoProfile);
}
/**
* Parse a CreateTransformsInfoProfile
DOM element.
- *
- * @param dataObjInfoElem The DataObjectInfo
DOM element
- * containing the CreateTransformsInfoProfile
.
+ *
+ * @param dataObjInfoElem The DataObjectInfo
DOM element containing
+ * the CreateTransformsInfoProfile
.
* @return The CreateTransformsInfoProfile
API object containing
- * the profile found in dataObjInfoElem
.
- * @throws MOAApplicationException An error occurred parsing the
- * CreateTransformsInfoProfile
.
+ * the profile found in dataObjInfoElem
.
+ * @throws MOAApplicationException An error occurred parsing the
+ * CreateTransformsInfoProfile
.
*/
private CreateTransformsInfoProfile parseCreateTransformsInfoProfile(Element dataObjInfoElem)
- throws MOAApplicationException {
+ throws MOAApplicationException {
- Element profileElem =
- (Element) XPathUtils.selectSingleNode(
- dataObjInfoElem,
- CREATE_TRANSFORMS_INFO_PROFILE_XPATH);
+ final Element profileElem =
+ (Element) XPathUtils.selectSingleNode(
+ dataObjInfoElem,
+ CREATE_TRANSFORMS_INFO_PROFILE_XPATH);
if ("CreateTransformsInfoProfile".equals(profileElem.getLocalName())) {
- ProfileParser profileParser = new ProfileParser();
+ final ProfileParser profileParser = new ProfileParser();
return profileParser.parseCreateTransformsInfoProfile(profileElem);
} else {
- String profileID = DOMUtils.getText(profileElem);
+ final String profileID = DOMUtils.getText(profileElem);
return factory.createCreateTransformsInfoProfile(profileID);
}
}
/**
- * Parse the CreateSignatureInfo
DOM element contained in
- * a SingleSignatureInfo
.
- *
+ * Parse the CreateSignatureInfo
DOM element contained in a
+ * SingleSignatureInfo
.
+ *
* @param sigInfoElem The SingleSignatureInfo
DOM element
- * containing the CreateSignatureInfo
to be parsed.
- * @return A CreateSignatureInfo
API object containing the
- * data from the CreateSignatureInfo
DOM element, or
- * null
, if none was found.
+ * containing the CreateSignatureInfo
to be
+ * parsed.
+ * @return A CreateSignatureInfo
API object containing the data
+ * from the CreateSignatureInfo
DOM element, or
+ * null
, if none was found.
*/
private CreateSignatureInfo parseCreateSignatureInfo(Element sigInfoElem) {
- Element createInfoElem =
- (Element) XPathUtils.selectSingleNode(
- sigInfoElem,
- CREATE_SIGNATURE_INFO_XPATH);
+ final Element createInfoElem =
+ (Element) XPathUtils.selectSingleNode(
+ sigInfoElem,
+ CREATE_SIGNATURE_INFO_XPATH);
if (createInfoElem != null) {
- Element environmentElem =
- (Element) XPathUtils.selectSingleNode(
- createInfoElem,
- CREATE_SIGNATURE_ENVIRONMENT_XPATH);
- Content environment = RequestParserUtils.parseContent(environmentElem);
- CreateSignatureEnvironmentProfile environmentProfile =
- parseCreateSignatureEnvironmentProfile(createInfoElem);
+ final Element environmentElem =
+ (Element) XPathUtils.selectSingleNode(
+ createInfoElem,
+ CREATE_SIGNATURE_ENVIRONMENT_XPATH);
+ final Content environment = RequestParserUtils.parseContent(environmentElem);
+ final CreateSignatureEnvironmentProfile environmentProfile =
+ parseCreateSignatureEnvironmentProfile(createInfoElem);
return factory.createCreateSignatureInfo(environment, environmentProfile);
} else {
@@ -284,26 +282,25 @@ public class CreateXMLSignatureRequestParser {
}
/**
- * Parse the CreateSignatureEnvironmentProfile
contained in
- * the given CreateSignatureInfo
DOM element.
- *
- * @param createInfoElem CreateSignatureInfo
DOM element to
- * parse.
- * @return The CreateSignatureEnvironmentProfile
contained
- * in the given CreateSignatureInfo
DOM element..
+ * Parse the CreateSignatureEnvironmentProfile
contained in the
+ * given CreateSignatureInfo
DOM element.
+ *
+ * @param createInfoElem CreateSignatureInfo
DOM element to parse.
+ * @return The CreateSignatureEnvironmentProfile
contained in the
+ * given CreateSignatureInfo
DOM element..
*/
private CreateSignatureEnvironmentProfile parseCreateSignatureEnvironmentProfile(Element createInfoElem) {
- Element profileElem =
- (Element) XPathUtils.selectSingleNode(
- createInfoElem,
- CREATE_SIGNATURE_ENVIRONMENT_PROFILE_XPATH);
+ final Element profileElem =
+ (Element) XPathUtils.selectSingleNode(
+ createInfoElem,
+ CREATE_SIGNATURE_ENVIRONMENT_PROFILE_XPATH);
if ("CreateSignatureEnvironmentProfile"
- .equals(profileElem.getLocalName())) {
- ProfileParser profileParser = new ProfileParser();
+ .equals(profileElem.getLocalName())) {
+ final ProfileParser profileParser = new ProfileParser();
return profileParser.parseCreateSignatureEnvironmentProfile(profileElem);
} else {
- String profileID = DOMUtils.getText(profileElem);
+ final String profileID = DOMUtils.getText(profileElem);
return factory.createCreateSignatureEnvironmentProfile(profileID);
}
}
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureResponseBuilder.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureResponseBuilder.java
index 3c93fce..d6af889 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureResponseBuilder.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureResponseBuilder.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.api.xmlbind;
import java.util.Iterator;
@@ -38,9 +37,9 @@ import at.gv.egovernment.moa.spss.api.xmlsign.SignatureEnvironmentResponse;
import at.gv.egovernment.moaspss.util.Constants;
/**
- * Convert a CreateXMLSignatureResponse
API object into its
- * XML representation, according to the MOA XML schema.
- *
+ * Convert a CreateXMLSignatureResponse
API object into its XML
+ * representation, according to the MOA XML schema.
+ *
* @author Patrick Peck
* @version $Id$
*/
@@ -48,48 +47,48 @@ public class CreateXMLSignatureResponseBuilder {
private static final String MOA_NS_URI = Constants.MOA_NS_URI;
/** The XML document containing the response element. */
- private Document responseDoc;
+ private final Document responseDoc;
/** The response CreateXMLSignatureResponse
DOM element. */
- private Element responseElem;
+ private final Element responseElem;
/**
* Create a new CreateXMLSignatureResponseBuilder
:
- *
- * @throws MOASystemException An error occurred setting up the resulting
- * XML document.
+ *
+ * @throws MOASystemException An error occurred setting up the resulting XML
+ * document.
*/
public CreateXMLSignatureResponseBuilder() throws MOASystemException {
responseDoc =
- ResponseBuilderUtils.createResponse("CreateXMLSignatureResponse");
+ ResponseBuilderUtils.createResponse("CreateXMLSignatureResponse");
responseElem = responseDoc.getDocumentElement();
}
/**
- * Build a document containing a CreateXMLSignatureResponse
- * DOM element being the XML representation of the given
+ * Build a document containing a CreateXMLSignatureResponse
DOM
+ * element being the XML representation of the given
* CreateXMLSignatureResponse
API object.
- *
- * @param response The CreateXMLSignatureResponse
to convert
- * to XML.
- * @return A document containing the CreateXMLSignatureResponse
- * DOM element.
+ *
+ * @param response The CreateXMLSignatureResponse
to convert to
+ * XML.
+ * @return A document containing the CreateXMLSignatureResponse
DOM
+ * element.
*/
public Document build(CreateXMLSignatureResponse response) {
Iterator iter;
for (iter = response.getResponseElements().iterator(); iter.hasNext();) {
- CreateXMLSignatureResponseElement responseElement =
- (CreateXMLSignatureResponseElement) iter.next();
+ final CreateXMLSignatureResponseElement responseElement =
+ (CreateXMLSignatureResponseElement) iter.next();
switch (responseElement.getResponseType()) {
- case CreateXMLSignatureResponseElement.SIGNATURE_ENVIRONMENT_RESPONSE :
- SignatureEnvironmentResponse envResponse =
- (SignatureEnvironmentResponse) responseElement;
+ case CreateXMLSignatureResponseElement.SIGNATURE_ENVIRONMENT_RESPONSE:
+ final SignatureEnvironmentResponse envResponse =
+ (SignatureEnvironmentResponse) responseElement;
addSignatureEnvironment(envResponse);
break;
- case CreateXMLSignatureResponseElement.ERROR_RESPONSE :
- ErrorResponse errorResponse = (ErrorResponse) responseElement;
+ case CreateXMLSignatureResponseElement.ERROR_RESPONSE:
+ final ErrorResponse errorResponse = (ErrorResponse) responseElement;
addErrorResponse(errorResponse);
break;
}
@@ -101,35 +100,36 @@ public class CreateXMLSignatureResponseBuilder {
/**
* Add a SignatureEnvironment
element to the response.
- *
+ *
* @param envResponse The content to put under the
- * SignatureEnvironment
element. This should either be a
- * dsig:Signature
element (in case of a detached signature) or
- * the signature environment containing the signature (in case of
- * an enveloping signature).
+ * SignatureEnvironment
element. This should
+ * either be a dsig:Signature
element (in case
+ * of a detached signature) or the signature environment
+ * containing the signature (in case of an enveloping
+ * signature).
*/
private void addSignatureEnvironment(SignatureEnvironmentResponse envResponse) {
- Element content = envResponse.getSignatureEnvironment();
- Node importedSignature = responseDoc.importNode(content, true);
- Element signatureEnvironment =
- responseDoc.createElementNS(MOA_NS_URI, "SignatureEnvironment");
+ final Element content = envResponse.getSignatureEnvironment();
+ final Node importedSignature = responseDoc.importNode(content, true);
+ final Element signatureEnvironment =
+ responseDoc.createElementNS(MOA_NS_URI, "SignatureEnvironment");
signatureEnvironment.appendChild(importedSignature);
responseElem.appendChild(signatureEnvironment);
}
/**
* Add a ErrorResponse
element to the response.
- *
+ *
* @param errorResponse The API object containing the information to put into
- * the ErrorResponse
DOM element.
+ * the ErrorResponse
DOM element.
*/
private void addErrorResponse(ErrorResponse errorResponse) {
- Element errorElem =
- responseDoc.createElementNS(MOA_NS_URI, "ErrorResponse");
- Element errorCodeElem =
- responseDoc.createElementNS(MOA_NS_URI, "ErrorCode");
- Element infoElem = responseDoc.createElementNS(MOA_NS_URI, "Info");
- String errorCodeStr = Integer.toString(errorResponse.getErrorCode());
+ final Element errorElem =
+ responseDoc.createElementNS(MOA_NS_URI, "ErrorResponse");
+ final Element errorCodeElem =
+ responseDoc.createElementNS(MOA_NS_URI, "ErrorCode");
+ final Element infoElem = responseDoc.createElementNS(MOA_NS_URI, "Info");
+ final String errorCodeStr = Integer.toString(errorResponse.getErrorCode());
errorCodeElem.appendChild(responseDoc.createTextNode(errorCodeStr));
errorElem.appendChild(errorCodeElem);
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/ProfileParser.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/ProfileParser.java
index 6b34922..b8cb361 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/ProfileParser.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/ProfileParser.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.api.xmlbind;
import java.io.IOException;
@@ -52,85 +51,86 @@ import at.gv.egovernment.moaspss.util.XPathUtils;
/**
* Parse the various profile elements contained in the MOA web service requests
* and given as separate files in the MOA configuration.
- *
+ *
* The profiles parsed must be schema valid according to the MOA XML schema.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class ProfileParser {
-
+
//
// XPath expressions to select parts of the profiles
//
private static final String MOA = Constants.MOA_PREFIX + ":";
private static final String DSIG = Constants.DSIG_PREFIX + ":";
private static final String CREATE_TRANSFORMS_XPATH =
- MOA + "CreateTransformsInfo/" + DSIG + "Transforms";
+ MOA + "CreateTransformsInfo/" + DSIG + "Transforms";
private static final String FINAL_DATA_META_INFO_XPATH =
- MOA + "CreateTransformsInfo/" + MOA + "FinalDataMetaInfo";
+ MOA + "CreateTransformsInfo/" + MOA + "FinalDataMetaInfo";
private static final String CREATE_SIGNATURE_LOCATION_XPATH =
- MOA + "CreateSignatureLocation";
+ MOA + "CreateSignatureLocation";
private static final String SUPPLEMENT_XPATH = MOA + "Supplement";
private static final String VERIFY_TRANSFORMS_XPATH = DSIG + "Transforms";
private static final String TRANSFORM_PARAMETER_XPATH =
- MOA + "TransformParameter";
+ MOA + "TransformParameter";
private static final String TRANSFORM_PARAMETER_CONTENT_XPATH =
- MOA + "Base64Content | " + MOA + "Hash";
+ MOA + "Base64Content | " + MOA + "Hash";
private static final String DIGEST_METHOD_XPATH = DSIG + "DigestMethod";
private static final String DIGEST_VALUE_XPATH = DSIG + "DigestValue";
/** The factory used to create API objects. */
- private SPSSFactory factory = SPSSFactory.getInstance();
+ private final SPSSFactory factory = SPSSFactory.getInstance();
/**
* Parse a CreateTransformsInfoProfile
DOM element.
- *
- * @param profileElem The CreateTransformsInfoProfile
element
- * to parse.
+ *
+ * @param profileElem The CreateTransformsInfoProfile
element to
+ * parse.
* @return The CreateTransformsInfoProfile
API object containing
- * the data from the profileElem
.
- * @throws MOAApplicationException An error occurred parsing the DOM element.
+ * the data from the profileElem
.
+ * @throws MOAApplicationException An error occurred parsing the DOM element.
*/
public CreateTransformsInfoProfile parseCreateTransformsInfoProfile(Element profileElem)
- throws MOAApplicationException {
- CreateTransformsInfo createTransformsInfo =
- parseCreateTransformsInfo(profileElem);
- List supplements = parseSupplements(profileElem);
+ throws MOAApplicationException {
+ final CreateTransformsInfo createTransformsInfo =
+ parseCreateTransformsInfo(profileElem);
+ final List supplements = parseSupplements(profileElem);
return factory.createCreateTransformsInfoProfile(
- createTransformsInfo,
- supplements);
+ createTransformsInfo,
+ supplements);
}
/**
- * Parse the CreateTransformsInfo
DOM element contained in a
+ * Parse the CreateTransformsInfo
DOM element contained in a
* CreateTransformsInfoProfile
.
- *
- * @param profileElem The CreateTransformsInfoProfile
DOM
- * element containing the CreateTransformsInfo
.
- * @return The CreateTransformsInfo
API object containinig the
- * data from the CreateTransformsInfo
DOM element.
+ *
+ * @param profileElem The CreateTransformsInfoProfile
DOM element
+ * containing the CreateTransformsInfo
.
+ * @return The CreateTransformsInfo
API object containinig the data
+ * from the CreateTransformsInfo
DOM element.
* @throws MOAApplicationException An error occurred parsing the
- * CreateTransformsInfo
DOM element.
+ * CreateTransformsInfo
DOM
+ * element.
*/
private CreateTransformsInfo parseCreateTransformsInfo(Element profileElem)
- throws MOAApplicationException {
+ throws MOAApplicationException {
- Element transformsElem =
- (Element) XPathUtils.selectSingleNode(
- profileElem,
- CREATE_TRANSFORMS_XPATH);
- Element metaInfoElem =
- (Element) XPathUtils.selectSingleNode(
- profileElem,
- FINAL_DATA_META_INFO_XPATH);
+ final Element transformsElem =
+ (Element) XPathUtils.selectSingleNode(
+ profileElem,
+ CREATE_TRANSFORMS_XPATH);
+ final Element metaInfoElem =
+ (Element) XPathUtils.selectSingleNode(
+ profileElem,
+ FINAL_DATA_META_INFO_XPATH);
MetaInfo finalDataMetaInfo;
List transforms;
- // parse the dsig:Transforms
+ // parse the dsig:Transforms
if (transformsElem != null) {
- TransformParser transformsParser = new TransformParser();
+ final TransformParser transformsParser = new TransformParser();
transforms = transformsParser.parseTransforms(transformsElem);
} else {
transforms = null;
@@ -144,65 +144,66 @@ public class ProfileParser {
/**
* Parse a CreateSignatureEnvironmentProfile
DOM element.
- *
- * @param profileElem The CreateSignatureEnvironmentProfile
- * DOM element to parse.
+ *
+ * @param profileElem The CreateSignatureEnvironmentProfile
DOM
+ * element to parse.
* @return The CreateSignatureEnvironmentProfile
API object
- * containing the data from the profileElem
.
+ * containing the data from the profileElem
.
*/
public CreateSignatureEnvironmentProfile parseCreateSignatureEnvironmentProfile(Element profileElem) {
- CreateSignatureLocation createSignatureLocation =
- parseCreateSignatureLocation(profileElem);
- List supplements = parseSupplements(profileElem);
+ final CreateSignatureLocation createSignatureLocation =
+ parseCreateSignatureLocation(profileElem);
+ final List supplements = parseSupplements(profileElem);
return factory.createCreateSignatureEnvironmentProfile(
- createSignatureLocation,
- supplements);
+ createSignatureLocation,
+ supplements);
}
/**
- * Parse a CreateSignatureLocation
DOM element contained in
- * a CreateSignatureEnvironmentProfile
.
- *
+ * Parse a CreateSignatureLocation
DOM element contained in a
+ * CreateSignatureEnvironmentProfile
.
+ *
* @param profileElem The CreateSignatureEnvironmentProfile
DOM
- * element containing the CreateSignatureLocation
.
- * @return The CreateSignatureLocation
API object containing
- * the data from the CreateSignatureLocation
DOM element.
+ * element containing the
+ * CreateSignatureLocation
.
+ * @return The CreateSignatureLocation
API object containing the
+ * data from the CreateSignatureLocation
DOM element.
*/
private CreateSignatureLocation parseCreateSignatureLocation(Element profileElem) {
- Element locationElem =
- (Element) XPathUtils.selectSingleNode(
- profileElem,
- CREATE_SIGNATURE_LOCATION_XPATH);
- String xPathExpression = DOMUtils.getText(locationElem);
- Map namespaceDeclarations = DOMUtils.getNamespaceDeclarations(locationElem);
- String indexStr = locationElem.getAttribute("Index");
- int index = Integer.parseInt(indexStr);
+ final Element locationElem =
+ (Element) XPathUtils.selectSingleNode(
+ profileElem,
+ CREATE_SIGNATURE_LOCATION_XPATH);
+ final String xPathExpression = DOMUtils.getText(locationElem);
+ final Map namespaceDeclarations = DOMUtils.getNamespaceDeclarations(locationElem);
+ final String indexStr = locationElem.getAttribute("Index");
+ final int index = Integer.parseInt(indexStr);
return factory.createCreateSignatureLocation(
- xPathExpression,
- index,
- namespaceDeclarations);
+ xPathExpression,
+ index,
+ namespaceDeclarations);
}
/**
- * Parse all Supplement
DOM elements contained in a given
- * parent DOM element.
- *
+ * Parse all Supplement
DOM elements contained in a given parent
+ * DOM element.
+ *
* @param supplementsParentElem The DOM element being the parent of the
- * Supplement
s.
- * @return A List
of Supplement
API objects
- * containing the data from the Supplement
DOM elements.
+ * Supplement
s.
+ * @return A List
of Supplement
API objects containing
+ * the data from the Supplement
DOM elements.
*/
private List parseSupplements(Element supplementsParentElem) {
- List supplements = new ArrayList();
- NodeIterator supplementElems =
- XPathUtils.selectNodeIterator(supplementsParentElem, SUPPLEMENT_XPATH);
+ final List supplements = new ArrayList();
+ final NodeIterator supplementElems =
+ XPathUtils.selectNodeIterator(supplementsParentElem, SUPPLEMENT_XPATH);
Element supplementElem;
while ((supplementElem = (Element) supplementElems.nextNode()) != null) {
- XMLDataObjectAssociation supplement =
- RequestParserUtils.parseXMLDataObjectAssociation(supplementElem);
+ final XMLDataObjectAssociation supplement =
+ RequestParserUtils.parseXMLDataObjectAssociation(supplementElem);
supplements.add(supplement);
}
return supplements;
@@ -210,44 +211,44 @@ public class ProfileParser {
/**
* Parse a SupplementProfile
DOM element.
- *
+ *
* @param profileElem The SupplementProfile
DOM element to parse.
- * @return The SupplementProfile
API object containing the
- * data from the SupplementProfile
DOM element.
+ * @return The SupplementProfile
API object containing the data
+ * from the SupplementProfile
DOM element.
*/
public SupplementProfile parseSupplementProfile(Element profileElem) {
- XMLDataObjectAssociation supplementProfile =
- RequestParserUtils.parseXMLDataObjectAssociation(profileElem);
+ final XMLDataObjectAssociation supplementProfile =
+ RequestParserUtils.parseXMLDataObjectAssociation(profileElem);
return factory.createSupplementProfile(supplementProfile);
}
/**
- * Parse a VerifyTransformsInfoProfile
DOM element.
- *
- * @param profileElem The VerifyTransformsInfoProfile
DOM
- * element to parse.
- * @return A VerifyTransformsInfoProfile
API object containing
- * the information from the VerifyTransformsInfoProfile
DOM
- * element.
+ * Parse a VerifyTransformsInfoProfile
DOM element.
+ *
+ * @param profileElem The VerifyTransformsInfoProfile
DOM element
+ * to parse.
+ * @return A VerifyTransformsInfoProfile
API object containing the
+ * information from the VerifyTransformsInfoProfile
DOM
+ * element.
* @throws MOAApplicationException An error occurred parsing the
- * VerifyTransformsInfoProfile
.
+ * VerifyTransformsInfoProfile
.
*/
public VerifyTransformsInfoProfile parseVerifyTransformsInfoProfile(Element profileElem)
- throws MOAApplicationException {
- Element transformsElem =
- (Element) XPathUtils.selectSingleNode(
- profileElem,
- VERIFY_TRANSFORMS_XPATH);
+ throws MOAApplicationException {
+ final Element transformsElem =
+ (Element) XPathUtils.selectSingleNode(
+ profileElem,
+ VERIFY_TRANSFORMS_XPATH);
List transforms = null;
- NodeIterator paramElems =
- XPathUtils.selectNodeIterator(profileElem, TRANSFORM_PARAMETER_XPATH);
+ final NodeIterator paramElems =
+ XPathUtils.selectNodeIterator(profileElem, TRANSFORM_PARAMETER_XPATH);
Element paramElem;
- List transformParameters = new ArrayList();
+ final List transformParameters = new ArrayList();
// parse the dsig:Transforms
if (transformsElem != null) {
- TransformParser transformsParser = new TransformParser();
+ final TransformParser transformsParser = new TransformParser();
transforms = transformsParser.parseTransforms(transformsElem);
}
@@ -257,51 +258,50 @@ public class ProfileParser {
}
return factory.createVerifyTransformsInfoProfile(
- transforms,
- transformParameters);
+ transforms,
+ transformParameters);
}
/**
* Parse a TransformParameter
DOM element.
- *
- * @param paramElem The TransformParameter
DOM element to
- * parse.
+ *
+ * @param paramElem The TransformParameter
DOM element to parse.
* @return The TransformParameter
API object containing the
- * information from the TransformParameter
DOM element.
+ * information from the TransformParameter
DOM element.
* @throws MOAApplicationException An error occurred parsing the
- * TransformParameter
DOM element.
+ * TransformParameter
DOM element.
*/
- private TransformParameter parseTransformParameter(Element paramElem)
- throws MOAApplicationException {
- String uri = paramElem.getAttribute("URI");
- Element contentElem =
- (Element) XPathUtils.selectSingleNode(
- paramElem,
- TRANSFORM_PARAMETER_CONTENT_XPATH);
+ private TransformParameter parseTransformParameter(Element paramElem)
+ throws MOAApplicationException {
+ final String uri = paramElem.getAttribute("URI");
+ final Element contentElem =
+ (Element) XPathUtils.selectSingleNode(
+ paramElem,
+ TRANSFORM_PARAMETER_CONTENT_XPATH);
if (contentElem == null) {
return factory.createTransformParameter(uri);
} else if ("Base64Content".equals(contentElem.getLocalName())) {
- String base64Str = DOMUtils.getText(contentElem);
- InputStream binaryContent = Base64Utils.decodeToStream(base64Str, true);
+ final String base64Str = DOMUtils.getText(contentElem);
+ final InputStream binaryContent = Base64Utils.decodeToStream(base64Str, true);
return factory.createTransformParameter(uri, binaryContent);
} else { // "Hash".equals(contentElem.getLocalName())
- String digestMethodStr =
- XPathUtils.getElementValue(contentElem, DIGEST_METHOD_XPATH, "");
- String digestValueStr =
- XPathUtils.getElementValue(contentElem, DIGEST_VALUE_XPATH, "");
+ final String digestMethodStr =
+ XPathUtils.getElementValue(contentElem, DIGEST_METHOD_XPATH, "");
+ final String digestValueStr =
+ XPathUtils.getElementValue(contentElem, DIGEST_VALUE_XPATH, "");
byte[] digestValue = null;
try {
digestValue = Base64Utils.decode(digestValueStr, true);
- } catch (IOException e) {
- throw new MOAApplicationException("2270", null);
+ } catch (final IOException e) {
+ throw new MOAApplicationException("2270", null);
}
return factory.createTransformParameter(
- uri,
- digestMethodStr,
- digestValue);
+ uri,
+ digestMethodStr,
+ digestValue);
}
}
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/RequestParserUtils.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/RequestParserUtils.java
index 99a64d9..173ecbf 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/RequestParserUtils.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/RequestParserUtils.java
@@ -42,165 +42,163 @@ import at.gv.egovernment.moaspss.util.XPathUtils;
/**
* Utility methods for parsing XML requests definied in the MOA XML schema.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class RequestParserUtils {
- //
- // XPath expressions for parsing parts of a request
- //
- private static final String MOA = Constants.MOA_PREFIX + ":";
- private static final String REFERENCE_ATTR_NAME = "Reference";
- private static final String MIME_TYPE_XPATH = MOA + "MimeType";
- private static final String DESCRIPTION_XPATH = MOA + "Description";
- private static final String TYPE_XPATH = MOA + "Type";
- private static final String XML_ASSOC_CONTENT_XPATH = MOA + "Content";
- private static final String CONTENT_XPATH = MOA + "Base64Content | " + MOA + "XMLContent |" + MOA + "LocRefContent";
- private static final String ANY_OTHER_XPATH = "*[namespace-uri() != \"" + Constants.MOA_NS_URI + "\"]";
-
- /**
- * Parse a XMLDataObjectAssociationType
kind of DOM element.
- *
- * @param assocElem
- * The XMLDataObjectAssociationType
kind of DOM
- * elmeent to parse.
- * @return The XMLDataObjectAssociation
API object containing
- * the data from the XMLDataObjectAssociationType
DOM
- * element.
- */
- public static XMLDataObjectAssociation parseXMLDataObjectAssociation(Element assocElem) {
- SPSSFactory factory = SPSSFactory.getInstance();
- MetaInfo metaInfo = parseMetaInfo(assocElem);
- Element contentElem = (Element) XPathUtils.selectSingleNode(assocElem, XML_ASSOC_CONTENT_XPATH);
- Content content = parseContent(contentElem);
-
- return factory.createXMLDataObjectAssociation(metaInfo, content);
- }
-
- /**
- * Parse a MetaInfoType
kind of DOM element.
- *
- * @param metaInfoElem
- * The MetaInfoType
kind of DOM element.
- * @return The MetaInfo
API object containing the data from the
- * metaInfoElem
.
- */
- public static MetaInfo parseMetaInfo(Element metaInfoElem) {
- SPSSFactory factory = SPSSFactory.getInstance();
- String mimeType = XPathUtils.getElementValue(metaInfoElem, MIME_TYPE_XPATH, null);
- String description = XPathUtils.getElementValue(metaInfoElem, DESCRIPTION_XPATH, null);
- NodeList anyOther = XPathUtils.selectNodeList(metaInfoElem, ANY_OTHER_XPATH);
- String type = XPathUtils.getElementValue(metaInfoElem, TYPE_XPATH, null);
-
- return factory.createMetaInfo(mimeType, description, anyOther, type);
- }
-
- /**
- * Parse a ContentOptionalRefType
or
- * ContentRequiredRefType
kind of DOM element.
- *
- * @param contentParentElem
- * The DOM element being the parent of the content element.
- * @return The Content
API object containing the data from the
- * given DOM element.
- */
- public static Content parseContent(Element contentParentElem) {
- SPSSFactory factory = SPSSFactory.getInstance();
- String referenceURI = contentParentElem.hasAttribute(REFERENCE_ATTR_NAME)
- ? contentParentElem.getAttribute(REFERENCE_ATTR_NAME) : null;
- Element contentElem = (Element) XPathUtils.selectSingleNode(contentParentElem, CONTENT_XPATH);
-
- if (contentElem == null) {
- return factory.createContent(referenceURI);
- }
-
- if ("Base64Content".equals(contentElem.getLocalName())) {
- String base64String = DOMUtils.getText(contentElem);
- return factory.createContent(Base64Utils.decodeToStream(base64String, true), referenceURI);
- } else if ("LocRefContent".equals(contentElem.getLocalName())) {
- String locationReferenceURI = DOMUtils.getText(contentElem);
- return factory.createContent(locationReferenceURI, referenceURI);
- } else { // "XMLContent".equals(contentElem.getLocalName())
- return factory.createContent(contentElem.getChildNodes(), referenceURI);
- }
- }
-
- /**
- * Get the signing time from a Verfiy(CMS|XML)SignatureRequest.
- *
- * @param requestElem
- * A Verify(CMS|XML)SignatureRequest
DOM element.
- * @param dateTimeXPath
- * The XPath to lookup the DateTime
element within
- * the request.
- * @return Date The date and time corresponding to the DateTime
- * element in the request. If no DateTime
element
- * exists in the request, null
is returned.
- * @throws MOAApplicationException
- * An error occurred during a parsing the DateTime
- * element or creating the return value.
- */
- public static Date parseDateTime(Element requestElem, String dateTimeXPath) throws MOAApplicationException {
-
- Element dateTimeElem;
- String dateTimeText;
-
- // select the DateTime element
- dateTimeElem = (Element) XPathUtils.selectSingleNode(requestElem, dateTimeXPath);
-
- // parse a date from the element value
- if (dateTimeElem != null) {
- dateTimeText = DOMUtils.getText(dateTimeElem);
- try {
- return DateTimeUtils.parseDateTime(dateTimeText);
- } catch (ParseException e) {
- throw new MOAApplicationException("1104", new Object[] { dateTimeText });
- }
- } else {
- return null;
- }
- }
-
- /**
- * Get the signing time from a Verfiy(CMS|XML)SignatureRequest.
- *
- * @param requestElem
- * A Verify(CMS|XML)SignatureRequest
DOM element.
- * @param dateTimeXPath
- * The XPath to lookup the DateTime
element within
- * the request.
- * @return Date The date and time corresponding to the DateTime
- * element in the request. If no DateTime
element
- * exists in the request, null
is returned.
- * @throws MOAApplicationException
- * An error occurred during a parsing the DateTime
- * element or creating the return value.
- */
- public static boolean parseExtendedValidation(Element requestElem, String extendedValidationXPath,
- boolean defaultValue) throws MOAApplicationException {
-
- Element dateTimeElem;
- String dateTimeText;
-
- // select the DateTime element
- dateTimeElem = (Element) XPathUtils.selectSingleNode(requestElem, extendedValidationXPath);
-
- // parse a date from the element value
- if (dateTimeElem != null) {
- dateTimeText = DOMUtils.getText(dateTimeElem);
- String xsdBoolean = dateTimeText.trim();
- if ("".equals(xsdBoolean))
- return defaultValue;
- if("true".equalsIgnoreCase(xsdBoolean) ||
- "1".equalsIgnoreCase(xsdBoolean)) {
- return true;
- } else {
- return false;
- }
- } else {
- return defaultValue;
- }
- }
+ //
+ // XPath expressions for parsing parts of a request
+ //
+ private static final String MOA = Constants.MOA_PREFIX + ":";
+ private static final String REFERENCE_ATTR_NAME = "Reference";
+ private static final String MIME_TYPE_XPATH = MOA + "MimeType";
+ private static final String DESCRIPTION_XPATH = MOA + "Description";
+ private static final String TYPE_XPATH = MOA + "Type";
+ private static final String XML_ASSOC_CONTENT_XPATH = MOA + "Content";
+ private static final String CONTENT_XPATH = MOA + "Base64Content | " + MOA + "XMLContent |" + MOA
+ + "LocRefContent";
+ private static final String ANY_OTHER_XPATH = "*[namespace-uri() != \"" + Constants.MOA_NS_URI + "\"]";
+
+ /**
+ * Parse a XMLDataObjectAssociationType
kind of DOM element.
+ *
+ * @param assocElem The XMLDataObjectAssociationType
kind of DOM
+ * elmeent to parse.
+ * @return The XMLDataObjectAssociation
API object containing the
+ * data from the XMLDataObjectAssociationType
DOM element.
+ */
+ public static XMLDataObjectAssociation parseXMLDataObjectAssociation(Element assocElem) {
+ final SPSSFactory factory = SPSSFactory.getInstance();
+ final MetaInfo metaInfo = parseMetaInfo(assocElem);
+ final Element contentElem = (Element) XPathUtils.selectSingleNode(assocElem, XML_ASSOC_CONTENT_XPATH);
+ final Content content = parseContent(contentElem);
+
+ return factory.createXMLDataObjectAssociation(metaInfo, content);
+ }
+
+ /**
+ * Parse a MetaInfoType
kind of DOM element.
+ *
+ * @param metaInfoElem The MetaInfoType
kind of DOM element.
+ * @return The MetaInfo
API object containing the data from the
+ * metaInfoElem
.
+ */
+ public static MetaInfo parseMetaInfo(Element metaInfoElem) {
+ final SPSSFactory factory = SPSSFactory.getInstance();
+ final String mimeType = XPathUtils.getElementValue(metaInfoElem, MIME_TYPE_XPATH, null);
+ final String description = XPathUtils.getElementValue(metaInfoElem, DESCRIPTION_XPATH, null);
+ final NodeList anyOther = XPathUtils.selectNodeList(metaInfoElem, ANY_OTHER_XPATH);
+ final String type = XPathUtils.getElementValue(metaInfoElem, TYPE_XPATH, null);
+
+ return factory.createMetaInfo(mimeType, description, anyOther, type);
+ }
+
+ /**
+ * Parse a ContentOptionalRefType
or
+ * ContentRequiredRefType
kind of DOM element.
+ *
+ * @param contentParentElem The DOM element being the parent of the content
+ * element.
+ * @return The Content
API object containing the data from the
+ * given DOM element.
+ */
+ public static Content parseContent(Element contentParentElem) {
+ final SPSSFactory factory = SPSSFactory.getInstance();
+ final String referenceURI = contentParentElem.hasAttribute(REFERENCE_ATTR_NAME)
+ ? contentParentElem.getAttribute(REFERENCE_ATTR_NAME)
+ : null;
+ final Element contentElem = (Element) XPathUtils.selectSingleNode(contentParentElem, CONTENT_XPATH);
+
+ if (contentElem == null) {
+ return factory.createContent(referenceURI);
+ }
+
+ if ("Base64Content".equals(contentElem.getLocalName())) {
+ final String base64String = DOMUtils.getText(contentElem);
+ return factory.createContent(Base64Utils.decodeToStream(base64String, true), referenceURI);
+ } else if ("LocRefContent".equals(contentElem.getLocalName())) {
+ final String locationReferenceURI = DOMUtils.getText(contentElem);
+ return factory.createContent(locationReferenceURI, referenceURI);
+ } else { // "XMLContent".equals(contentElem.getLocalName())
+ return factory.createContent(contentElem.getChildNodes(), referenceURI);
+ }
+ }
+
+ /**
+ * Get the signing time from a Verfiy(CMS|XML)SignatureRequest.
+ *
+ * @param requestElem A Verify(CMS|XML)SignatureRequest
DOM
+ * element.
+ * @param dateTimeXPath The XPath to lookup the DateTime
element
+ * within the request.
+ * @return Date The date and time corresponding to the DateTime
+ * element in the request. If no DateTime
element exists in
+ * the request, null
is returned.
+ * @throws MOAApplicationException An error occurred during a parsing the
+ * DateTime
element or creating the
+ * return value.
+ */
+ public static Date parseDateTime(Element requestElem, String dateTimeXPath) throws MOAApplicationException {
+
+ Element dateTimeElem;
+ String dateTimeText;
+
+ // select the DateTime element
+ dateTimeElem = (Element) XPathUtils.selectSingleNode(requestElem, dateTimeXPath);
+
+ // parse a date from the element value
+ if (dateTimeElem != null) {
+ dateTimeText = DOMUtils.getText(dateTimeElem);
+ try {
+ return DateTimeUtils.parseDateTime(dateTimeText);
+ } catch (final ParseException e) {
+ throw new MOAApplicationException("1104", new Object[] { dateTimeText });
+ }
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Get the signing time from a Verfiy(CMS|XML)SignatureRequest.
+ *
+ * @param requestElem A Verify(CMS|XML)SignatureRequest
DOM
+ * element.
+ * @param dateTimeXPath The XPath to lookup the DateTime
element
+ * within the request.
+ * @return Date The date and time corresponding to the DateTime
+ * element in the request. If no DateTime
element exists in
+ * the request, null
is returned.
+ * @throws MOAApplicationException An error occurred during a parsing the
+ * DateTime
element or creating the
+ * return value.
+ */
+ public static boolean parseExtendedValidation(Element requestElem, String extendedValidationXPath,
+ boolean defaultValue) throws MOAApplicationException {
+
+ Element dateTimeElem;
+ String dateTimeText;
+
+ // select the DateTime element
+ dateTimeElem = (Element) XPathUtils.selectSingleNode(requestElem, extendedValidationXPath);
+
+ // parse a date from the element value
+ if (dateTimeElem != null) {
+ dateTimeText = DOMUtils.getText(dateTimeElem);
+ final String xsdBoolean = dateTimeText.trim();
+ if ("".equals(xsdBoolean)) {
+ return defaultValue;
+ }
+ if ("true".equalsIgnoreCase(xsdBoolean) ||
+ "1".equalsIgnoreCase(xsdBoolean)) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return defaultValue;
+ }
+ }
}
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 a7113fd..dff1fcc 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
@@ -21,16 +21,14 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.api.xmlbind;
import java.io.IOException;
import java.security.cert.CertificateEncodingException;
import java.security.cert.X509Certificate;
-import java.text.SimpleDateFormat;
+import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
-import java.util.Calendar;
import java.util.TimeZone;
import javax.xml.bind.DatatypeConverter;
@@ -44,8 +42,6 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import iaik.utils.RFC2253NameParser;
-import iaik.utils.RFC2253NameParserException;
import at.gv.egovernment.moa.spss.MOAApplicationException;
import at.gv.egovernment.moa.spss.MOASystemException;
import at.gv.egovernment.moa.spss.api.common.ExtendedCertificateCheckResult;
@@ -53,10 +49,12 @@ import at.gv.egovernment.moa.spss.api.common.TslInfos;
import at.gv.egovernment.moaspss.util.Base64Utils;
import at.gv.egovernment.moaspss.util.Constants;
import at.gv.egovernment.moaspss.util.MiscUtil;
+import iaik.utils.RFC2253NameParser;
+import iaik.utils.RFC2253NameParserException;
/**
* Utility methods used by the verious ResponseBuilder
classes.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
@@ -71,35 +69,35 @@ public class ResponseBuilderUtils {
/**
* 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 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;
-
+ Element rootElement) {
+ final Element childElement = response.createElementNS(MOA_NS_URI, elementName);
+ rootElement.appendChild(childElement);
+ return childElement;
+
}
-
+
/**
* Create a response element with all the namespaces set.
- *
+ *
* @param responseName The name of the response root element.
* @return A DOM document containing the response root element and predefined
- * MOA, DSIG and XML namespace declarations.
+ * MOA, DSIG and XML namespace declarations.
* @throws MOASystemException An error building the response document.
*/
public static Document createResponse(String responseName)
- throws MOASystemException {
+ throws MOASystemException {
try {
- DocumentBuilder docBuilder =
- DocumentBuilderFactory.newInstance().newDocumentBuilder();
- DOMImplementation impl = docBuilder.getDOMImplementation();
+ final DocumentBuilder docBuilder =
+ DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ final DOMImplementation impl = docBuilder.getDOMImplementation();
Document response;
Element root;
String attrValue;
@@ -113,159 +111,170 @@ public class ResponseBuilderUtils {
root.setAttributeNS(XMLNS_NS_URI, attrValue, DSIG_NS_URI);
return response;
- } catch (ParserConfigurationException e) {
+ } catch (final ParserConfigurationException e) {
throw new MOASystemException("2200", null, e);
}
}
/**
* Add a SignerInfo
element to the response.
- *
- * @param response The response document, in order to create new elements in
- * it.
- * @param root The root element into which the SignerInfo
element
- * will be inserted.
- * @param cert The signer certificate to add.
- * @param isQualified Indicates, whether cert
is a qualified
- * certificate.
- * @param isPublicAuthority Indicates, whether cert
is
- * certificate owned by a public authority.
+ *
+ * @param response The response document, in order to create new
+ * elements in it.
+ * @param root The root element into which the
+ * SignerInfo
element will be inserted.
+ * @param cert The signer certificate to add.
+ * @param isQualified Indicates, whether cert
is a qualified
+ * certificate.
+ * @param isPublicAuthority Indicates, whether cert
is certificate
+ * owned by a public authority.
* @param publicAuthorityID Information about the public authority owning
- * cert
. Must not be null
, if
- * isPublicAuthority ! = null
.
+ * cert
. Must not be null
, if
+ * isPublicAuthority ! = null
.
* @throws MOAApplicationException An error occurred reading data from the
- * certificate.
+ * certificate.
*/
public static void addSignerInfo(
- Document response,
- Element root,
- X509Certificate cert,
- boolean isQualified,
- String qcSource,
- boolean isPublicAuthority,
- String publicAuthorityID,
- boolean isSSCD,
- String sscdSource,
- String issuerCountryCode,
- TslInfos tslInfos)
- throws MOAApplicationException {
-
- Element signerInfoElem = response.createElementNS(MOA_NS_URI, "SignerInfo");
- Element x509DataElem =
- response.createElementNS(DSIG_NS_URI, DSIG + "X509Data");
- Element x509IssuerSerialElem =
- response.createElementNS(DSIG_NS_URI, DSIG + "X509IssuerSerial");
- Element x509IssuerElem =
- response.createElementNS(DSIG_NS_URI, DSIG + "X509IssuerName");
- String issuer = cert.getIssuerDN().getName();
- Element x509SerialNumberElem =
- response.createElementNS(DSIG_NS_URI, DSIG + "X509SerialNumber");
- String serialNumber = cert.getSerialNumber().toString();
- Element x509SubjectNameElem =
- response.createElementNS(DSIG_NS_URI, DSIG + "X509SubjectName");
- Element x509CertificateElem =
- response.createElementNS(DSIG_NS_URI, DSIG + "X509Certificate");
- Element qualifiedCertificateElem =
- isQualified
- ? response.createElementNS(MOA_NS_URI, "QualifiedCertificate")
- : null;
- Element sscdElem =
- isSSCD
- ? response.createElementNS(MOA_NS_URI, "SecureSignatureCreationDevice")
- : null;
+ Document response,
+ Element root,
+ X509Certificate cert,
+ boolean isQualified,
+ String qcSource,
+ boolean isPublicAuthority,
+ String publicAuthorityID,
+ boolean isSSCD,
+ String sscdSource,
+ String issuerCountryCode,
+ TslInfos tslInfos)
+ throws MOAApplicationException {
+
+ final Element signerInfoElem = response.createElementNS(MOA_NS_URI, "SignerInfo");
+ final Element x509DataElem =
+ response.createElementNS(DSIG_NS_URI, DSIG + "X509Data");
+ final Element x509IssuerSerialElem =
+ response.createElementNS(DSIG_NS_URI, DSIG + "X509IssuerSerial");
+ final Element x509IssuerElem =
+ response.createElementNS(DSIG_NS_URI, DSIG + "X509IssuerName");
+ final String issuer = cert.getIssuerDN().getName();
+ final Element x509SerialNumberElem =
+ response.createElementNS(DSIG_NS_URI, DSIG + "X509SerialNumber");
+ final String serialNumber = cert.getSerialNumber().toString();
+ final Element x509SubjectNameElem =
+ response.createElementNS(DSIG_NS_URI, DSIG + "X509SubjectName");
+ final Element x509CertificateElem =
+ response.createElementNS(DSIG_NS_URI, DSIG + "X509Certificate");
+ final Element qualifiedCertificateElem =
+ isQualified
+ ? response.createElementNS(MOA_NS_URI, "QualifiedCertificate")
+ : null;
+ final Element sscdElem =
+ isSSCD
+ ? response.createElementNS(MOA_NS_URI, "SecureSignatureCreationDevice")
+ : null;
Element issuerCountryCodeElem = null;
if (issuerCountryCode != null) {
- issuerCountryCodeElem = response.createElementNS(MOA_NS_URI, "IssuerCountryCode");
- issuerCountryCodeElem.setTextContent(issuerCountryCode);
+ issuerCountryCodeElem = response.createElementNS(MOA_NS_URI, "IssuerCountryCode");
+ issuerCountryCodeElem.setTextContent(issuerCountryCode);
}
-
- //add TSL infos
+
+ // add TSL infos
Element tslInfoElement = null;
if (tslInfos != null) {
- tslInfoElement = response.createElementNS(MOA_NS_URI, "TSLInformation");
-
- //append TSL issuer country-code
- if (MiscUtil.isNotEmpty(tslInfos.getTslIssuerCountry())); {
- Element tslIssuerCountryCodeElem = response.createElementNS(MOA_NS_URI, "TSLIssuerCountryCode");
- tslIssuerCountryCodeElem.setTextContent(tslInfos.getTslIssuerCountry());
- tslInfoElement.appendChild(tslIssuerCountryCodeElem);
-
- }
-
- //append Service-Type Status
- if (MiscUtil.isNotEmpty(tslInfos.getServiceTypeStatus())); {
- Element tslServiceInfo = response.createElementNS(MOA_NS_URI, "ServiceTypeStatus");
- tslServiceInfo.setTextContent(tslInfos.getServiceTypeStatus());
- tslInfoElement.appendChild(tslServiceInfo);
-
- }
-
- //append Service-Type Identifier
- if (MiscUtil.isNotEmpty(tslInfos.getServiceTypeIdentifier())); {
- Element tslServiceInfo = response.createElementNS(MOA_NS_URI, "ServiceTypeIdentifier");
- tslServiceInfo.setTextContent(tslInfos.getServiceTypeIdentifier());
- tslInfoElement.appendChild(tslServiceInfo);
-
- }
-
- //append qualifiers
- if (tslInfos.getQualifiers() != null && tslInfos.getQualifiers().size() > 0) {
- Element tslQualifiers = response.createElementNS(MOA_NS_URI, "Qualifiers");
-
- for (String el : tslInfos.getQualifiers()) {
- Element tslQualifier = response.createElementNS(MOA_NS_URI, "Qualifier");
- tslQualifier.setTextContent(el);
- tslQualifiers.appendChild(tslQualifier);
-
- }
-
- tslInfoElement.appendChild(tslQualifiers);
-
- }
-
- //append additional service information
- if (tslInfos.getAdditionalServiceInformation() != null
- && tslInfos.getAdditionalServiceInformation().size() > 0) {
- Element tslAdditionalServiceInformations = response.createElementNS(MOA_NS_URI, "AdditionalServiceInformations");
-
- for (String el : tslInfos.getAdditionalServiceInformation()) {
- Element tslAdditionalServiceInformation = response.createElementNS(MOA_NS_URI, "AdditionalServiceInformation");
- tslAdditionalServiceInformation.setTextContent(el);
- tslAdditionalServiceInformations.appendChild(tslAdditionalServiceInformation);
-
- }
- tslInfoElement.appendChild(tslAdditionalServiceInformations);
-
- }
+ tslInfoElement = response.createElementNS(MOA_NS_URI, "TSLInformation");
+
+ // append TSL issuer country-code
+ if (MiscUtil.isNotEmpty(tslInfos.getTslIssuerCountry())) {
+ ;
+ }
+ {
+ final Element tslIssuerCountryCodeElem = response.createElementNS(MOA_NS_URI, "TSLIssuerCountryCode");
+ tslIssuerCountryCodeElem.setTextContent(tslInfos.getTslIssuerCountry());
+ tslInfoElement.appendChild(tslIssuerCountryCodeElem);
+
+ }
+
+ // append Service-Type Status
+ if (MiscUtil.isNotEmpty(tslInfos.getServiceTypeStatus())) {
+ ;
+ }
+ {
+ final Element tslServiceInfo = response.createElementNS(MOA_NS_URI, "ServiceTypeStatus");
+ tslServiceInfo.setTextContent(tslInfos.getServiceTypeStatus());
+ tslInfoElement.appendChild(tslServiceInfo);
+
+ }
+
+ // append Service-Type Identifier
+ if (MiscUtil.isNotEmpty(tslInfos.getServiceTypeIdentifier())) {
+ ;
+ }
+ {
+ final Element tslServiceInfo = response.createElementNS(MOA_NS_URI, "ServiceTypeIdentifier");
+ tslServiceInfo.setTextContent(tslInfos.getServiceTypeIdentifier());
+ tslInfoElement.appendChild(tslServiceInfo);
+
+ }
+
+ // append qualifiers
+ if (tslInfos.getQualifiers() != null && tslInfos.getQualifiers().size() > 0) {
+ final Element tslQualifiers = response.createElementNS(MOA_NS_URI, "Qualifiers");
+
+ for (final String el : tslInfos.getQualifiers()) {
+ final Element tslQualifier = response.createElementNS(MOA_NS_URI, "Qualifier");
+ tslQualifier.setTextContent(el);
+ tslQualifiers.appendChild(tslQualifier);
+
+ }
+
+ tslInfoElement.appendChild(tslQualifiers);
+
+ }
+
+ // append additional service information
+ if (tslInfos.getAdditionalServiceInformation() != null
+ && tslInfos.getAdditionalServiceInformation().size() > 0) {
+ final Element tslAdditionalServiceInformations = response.createElementNS(MOA_NS_URI,
+ "AdditionalServiceInformations");
+
+ for (final String el : tslInfos.getAdditionalServiceInformation()) {
+ final Element tslAdditionalServiceInformation = response.createElementNS(MOA_NS_URI,
+ "AdditionalServiceInformation");
+ tslAdditionalServiceInformation.setTextContent(el);
+ tslAdditionalServiceInformations.appendChild(tslAdditionalServiceInformation);
+
+ }
+ tslInfoElement.appendChild(tslAdditionalServiceInformations);
+
+ }
}
-
- Element publicAuthorityElem =
- isPublicAuthority
- ? response.createElementNS(MOA_NS_URI, "PublicAuthority")
- : null;
- Element codeElem =
- publicAuthorityID != null
- ? response.createElementNS(MOA_NS_URI, "Code")
- : null;
+
+ final Element publicAuthorityElem =
+ isPublicAuthority
+ ? response.createElementNS(MOA_NS_URI, "PublicAuthority")
+ : null;
+ final Element codeElem =
+ publicAuthorityID != null
+ ? response.createElementNS(MOA_NS_URI, "Code")
+ : null;
// fill in text
x509IssuerElem.appendChild(response.createTextNode(issuer));
x509SerialNumberElem.appendChild(response.createTextNode(serialNumber));
try {
- RFC2253NameParser parser =
- new RFC2253NameParser(cert.getSubjectDN().getName());
- String subjectRfc2253 = parser.parse().getRFC2253String();
+ final RFC2253NameParser parser =
+ new RFC2253NameParser(cert.getSubjectDN().getName());
+ final String subjectRfc2253 = parser.parse().getRFC2253String();
x509SubjectNameElem.appendChild(response.createTextNode(subjectRfc2253));
- } catch (RFC2253NameParserException e) {
+ } catch (final RFC2253NameParserException e) {
x509SubjectNameElem.appendChild(
- response.createTextNode(cert.getSubjectDN().getName()));
+ response.createTextNode(cert.getSubjectDN().getName()));
}
try {
x509CertificateElem.appendChild(
- response.createTextNode(Base64Utils.encode(cert.getEncoded())));
- } catch (CertificateEncodingException e) {
+ response.createTextNode(Base64Utils.encode(cert.getEncoded())));
+ } catch (final CertificateEncodingException e) {
throw new MOAApplicationException("2245", null, e);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new MOAApplicationException("2245", null, e);
}
@@ -276,10 +285,11 @@ public class ResponseBuilderUtils {
x509DataElem.appendChild(x509IssuerSerialElem);
x509DataElem.appendChild(x509CertificateElem);
if (isQualified) {
- if (qcSource.compareToIgnoreCase("TSL") == 0)
- qualifiedCertificateElem.setAttributeNS(MOA_NS_URI, "Source", qcSource);
-
- x509DataElem.appendChild(qualifiedCertificateElem);
+ if (qcSource.compareToIgnoreCase("TSL") == 0) {
+ qualifiedCertificateElem.setAttributeNS(MOA_NS_URI, "Source", qcSource);
+ }
+
+ x509DataElem.appendChild(qualifiedCertificateElem);
}
if (isPublicAuthority) {
x509DataElem.appendChild(publicAuthorityElem);
@@ -289,16 +299,18 @@ public class ResponseBuilderUtils {
}
}
if (isSSCD) {
- sscdElem.setAttributeNS(MOA_NS_URI, "Source", sscdSource);
- x509DataElem.appendChild(sscdElem);
- }
- if (issuerCountryCodeElem != null)
- x509DataElem.appendChild(issuerCountryCodeElem);
-
- //add TSL infos to X509Date if TSL infos exists
- if (tslInfoElement != null)
- x509DataElem.appendChild(tslInfoElement);
-
+ sscdElem.setAttributeNS(MOA_NS_URI, "Source", sscdSource);
+ x509DataElem.appendChild(sscdElem);
+ }
+ if (issuerCountryCodeElem != null) {
+ x509DataElem.appendChild(issuerCountryCodeElem);
+ }
+
+ // add TSL infos to X509Date if TSL infos exists
+ if (tslInfoElement != null) {
+ x509DataElem.appendChild(tslInfoElement);
+ }
+
signerInfoElem.appendChild(x509DataElem);
root.appendChild(signerInfoElem);
}
@@ -306,24 +318,24 @@ public class ResponseBuilderUtils {
/**
* Add an element containing Code
and Info
* subelements.
- *
- * @param response The response document, in order to create new elements in
- * it.
- * @param root The root element into which to insert the newly created
- * element.
+ *
+ * @param response The response document, in order to create new elements in
+ * it.
+ * @param root The root element into which to insert the newly created
+ * element.
* @param elementName The name of the newly created element.
- * @param code The content of the Code
subelement.
- * @param info The content of the Info
subelement.
+ * @param code The content of the Code
subelement.
+ * @param info The content of the Info
subelement.
*/
public static void addCodeInfoElement(
- Document response,
- Element root,
- String elementName,
- int code,
- NodeList info) {
-
- Element codeInfoElem = response.createElementNS(MOA_NS_URI, elementName);
- Element codeElem = response.createElementNS(MOA_NS_URI, "Code");
+ Document response,
+ Element root,
+ String elementName,
+ int code,
+ NodeList info) {
+
+ final Element codeInfoElem = response.createElementNS(MOA_NS_URI, elementName);
+ final Element codeElem = response.createElementNS(MOA_NS_URI, "Code");
Element infoElem;
int i;
@@ -339,34 +351,34 @@ public class ResponseBuilderUtils {
}
root.appendChild(codeInfoElem);
}
-
+
/**
* Add an element containing Code
and Info
* subelements.
- *
- * @param response The response document, in order to create new elements in
- * it.
- * @param root The root element into which to insert the newly created
- * element.
+ *
+ * @param response The response document, in order to create new elements in
+ * it.
+ * @param root The root element into which to insert the newly created
+ * element.
* @param elementName The name of the newly created element.
- * @param code The content of the Code
subelement.
- * @param info The content of the Info
subelement.
+ * @param code The content of the Code
subelement.
+ * @param info The content of the Info
subelement.
*/
public static void addCodeInfoElement(
- Document response,
- Element root,
- String elementName,
- int code,
- String info) {
-
- Element codeInfoElem = response.createElementNS(MOA_NS_URI, elementName);
- Element codeElem = response.createElementNS(MOA_NS_URI, "Code");
+ Document response,
+ Element root,
+ String elementName,
+ int code,
+ String info) {
+
+ final Element codeInfoElem = response.createElementNS(MOA_NS_URI, elementName);
+ final Element codeElem = response.createElementNS(MOA_NS_URI, "Code");
Element infoElem;
- int i;
+ final int i;
codeElem.appendChild(response.createTextNode(Integer.toString(code)));
codeInfoElem.appendChild(codeElem);
-
+
if (info != null) {
infoElem = response.createElementNS(MOA_NS_URI, "Info");
infoElem.appendChild(response.createTextNode(info));
@@ -376,137 +388,138 @@ public class ResponseBuilderUtils {
}
public static void addSigningTime(Document response,
- Element root,
- Date signingTime) {
- if(signingTime != null) {
- Element extElem = response.createElementNS(MOA_NS_URI, "SigningTime");
- TimeZone tz = TimeZone.getTimeZone("UTC");
- Calendar calendar = new GregorianCalendar();
+ Element root,
+ Date signingTime) {
+ if (signingTime != null) {
+ final Element extElem = response.createElementNS(MOA_NS_URI, "SigningTime");
+ final TimeZone tz = TimeZone.getTimeZone("UTC");
+ final Calendar calendar = new GregorianCalendar();
calendar.setTimeZone(tz);
calendar.setTime(signingTime);
- String date = DatatypeConverter.printDateTime(calendar);
+ final String date = DatatypeConverter.printDateTime(calendar);
extElem.appendChild(response.createTextNode(date));
root.appendChild(extElem);
}
}
public static void addSignatureAlgorithm(Document response,
- Element root,
- String algorithm) {
- if(algorithm != null) {
- Element extElem = response.createElementNS(MOA_NS_URI, "SignatureAlgorithm");
- extElem.appendChild(response.createTextNode(algorithm));
- root.appendChild(extElem);
- }
+ Element root,
+ String algorithm) {
+ if (algorithm != null) {
+ final Element extElem = response.createElementNS(MOA_NS_URI, "SignatureAlgorithm");
+ extElem.appendChild(response.createTextNode(algorithm));
+ root.appendChild(extElem);
+ }
}
-
+
public static void addSignatureCoversFullPDF(Document response,
- Element root,
- Boolean coversFull) {
- if( coversFull != null) {
- Element extElem = response.createElementNS(MOA_NS_URI, "SignatureCoversFullPDF");
- extElem.appendChild(response.createTextNode(String.valueOf(coversFull)));
- root.appendChild(extElem);
- }
+ Element root,
+ Boolean coversFull) {
+ if (coversFull != null) {
+ final Element extElem = response.createElementNS(MOA_NS_URI, "SignatureCoversFullPDF");
+ extElem.appendChild(response.createTextNode(String.valueOf(coversFull)));
+ root.appendChild(extElem);
+ }
}
-
+
public static void addSignatureByteRange(Document response,
- Element root,
- int[] byteRange) {
- if(byteRange != null) {
- String byteRangeTextual = StringUtils.EMPTY;
- for (int el : byteRange)
- byteRangeTextual += "," + String.valueOf(el);
-
- Element extElem = response.createElementNS(MOA_NS_URI, "SignatureByteRange");
- extElem.appendChild(response.createTextNode(byteRangeTextual.substring(1)));
- root.appendChild(extElem);
- }
+ Element root,
+ int[] byteRange) {
+ if (byteRange != null) {
+ String byteRangeTextual = StringUtils.EMPTY;
+ for (final int el : byteRange) {
+ byteRangeTextual += "," + String.valueOf(el);
+ }
+
+ final Element extElem = response.createElementNS(MOA_NS_URI, "SignatureByteRange");
+ extElem.appendChild(response.createTextNode(byteRangeTextual.substring(1)));
+ root.appendChild(extElem);
+ }
}
-
+
public static Element createAndAddChildElement(Document response, Element root, String name) {
- Element element = response.createElementNS(MOA_NS_URI, name);
- root.appendChild(element);
- return element;
-
+ final Element element = response.createElementNS(MOA_NS_URI, name);
+ root.appendChild(element);
+ return element;
+
}
-
+
public static void addHashAlgorithm(Document response,
- Element root,
- String algorithm) {
- if(algorithm != null) {
- Element extElem = response.createElementNS(MOA_NS_URI, "HashAlgorithm");
- extElem.appendChild(response.createTextNode(algorithm));
- root.appendChild(extElem);
- }
-}
-
+ Element root,
+ String algorithm) {
+ if (algorithm != null) {
+ final Element extElem = response.createElementNS(MOA_NS_URI, "HashAlgorithm");
+ extElem.appendChild(response.createTextNode(algorithm));
+ root.appendChild(extElem);
+ }
+ }
+
public static void addExtendendResult(Document response,
- Element root,
- ExtendedCertificateCheckResult result) {
- Element extElem = response.createElementNS(MOA_NS_URI, "ExtendedCertificateCheck");
-
- Element extMajorElem = response.createElementNS(MOA_NS_URI, "Major");
-
- Element codeMajorCodeElem = response.createElementNS(MOA_NS_URI, "Code");
- Element codeMajorNameElem = response.createElementNS(MOA_NS_URI, "Name");
- codeMajorCodeElem.appendChild(response.createTextNode(Integer.toString(
- result.getMajorCode())));
- codeMajorNameElem.appendChild(response.createTextNode(result.getMajorInfo()));
-
- extMajorElem.appendChild(codeMajorCodeElem);
- extMajorElem.appendChild(codeMajorNameElem);
-
- extElem.appendChild(extMajorElem);
-
- if(result.getMinorCode() >= 0) {
- Element extMinorElem = response.createElementNS(MOA_NS_URI, "Minor");
- Element codeMinorCodeElem = response.createElementNS(MOA_NS_URI, "Code");
- Element codeMinorNameElem = response.createElementNS(MOA_NS_URI, "Name");
- codeMinorCodeElem.appendChild(response.createTextNode(Integer.toString(
- result.getMinorCode())));
- codeMinorNameElem.appendChild(response.createTextNode(result.getMinorInfo()));
-
- extMinorElem.appendChild(codeMinorCodeElem);
- extMinorElem.appendChild(codeMinorNameElem);
-
- extElem.appendChild(extMinorElem);
- }
-
- root.appendChild(extElem);
+ Element root,
+ ExtendedCertificateCheckResult result) {
+ final Element extElem = response.createElementNS(MOA_NS_URI, "ExtendedCertificateCheck");
+
+ final Element extMajorElem = response.createElementNS(MOA_NS_URI, "Major");
+
+ final Element codeMajorCodeElem = response.createElementNS(MOA_NS_URI, "Code");
+ final Element codeMajorNameElem = response.createElementNS(MOA_NS_URI, "Name");
+ codeMajorCodeElem.appendChild(response.createTextNode(Integer.toString(
+ result.getMajorCode())));
+ codeMajorNameElem.appendChild(response.createTextNode(result.getMajorInfo()));
+
+ extMajorElem.appendChild(codeMajorCodeElem);
+ extMajorElem.appendChild(codeMajorNameElem);
+
+ extElem.appendChild(extMajorElem);
+
+ if (result.getMinorCode() >= 0) {
+ final Element extMinorElem = response.createElementNS(MOA_NS_URI, "Minor");
+ final Element codeMinorCodeElem = response.createElementNS(MOA_NS_URI, "Code");
+ final Element codeMinorNameElem = response.createElementNS(MOA_NS_URI, "Name");
+ codeMinorCodeElem.appendChild(response.createTextNode(Integer.toString(
+ result.getMinorCode())));
+ codeMinorNameElem.appendChild(response.createTextNode(result.getMinorInfo()));
+
+ extMinorElem.appendChild(codeMinorCodeElem);
+ extMinorElem.appendChild(codeMinorNameElem);
+
+ extElem.appendChild(extMinorElem);
+ }
+
+ root.appendChild(extElem);
}
-
+
/**
* Add an element containing Code
and Info
* subelements.
- *
- * @param response The response document, in order to create new elements in
- * it.
- * @param root The root element into which to insert the newly created
- * element.
+ *
+ * @param response The response document, in order to create new elements in
+ * it.
+ * @param root The root element into which to insert the newly created
+ * element.
* @param elementName The name of the newly created element.
- * @param code The content of the Code
subelement.
- * @param info The content of the Info
subelement.
+ * @param code The content of the Code
subelement.
+ * @param info The content of the Info
subelement.
*/
public static void addFormCheckElement(
- Document response,
- Element root,
- String elementName,
- int code,
- String name) {
-
- Element codeInfoElem = response.createElementNS(MOA_NS_URI, elementName);
- Element codeElem = response.createElementNS(MOA_NS_URI, "Code");
+ Document response,
+ Element root,
+ String elementName,
+ int code,
+ String name) {
+
+ final Element codeInfoElem = response.createElementNS(MOA_NS_URI, elementName);
+ final Element codeElem = response.createElementNS(MOA_NS_URI, "Code");
Element infoElem;
-
+
codeElem.appendChild(response.createTextNode(Integer.toString(code)));
codeInfoElem.appendChild(codeElem);
-
+
infoElem = response.createElementNS(MOA_NS_URI, "Name");
infoElem.appendChild(response.createTextNode(name));
codeInfoElem.appendChild(infoElem);
-
+
root.appendChild(codeInfoElem);
}
-
+
}
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/TransformParser.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/TransformParser.java
index 6dc4803..7a246d6 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/TransformParser.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/TransformParser.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.api.xmlbind;
import java.util.ArrayList;
@@ -48,9 +47,9 @@ import at.gv.egovernment.moaspss.util.DOMUtils;
import at.gv.egovernment.moaspss.util.XPathUtils;
/**
- * A parser to parse XMLDsig Transform
DOM elements into their
- * MOA SPSS API representation.
- *
+ * A parser to parse XMLDsig Transform
DOM elements into their MOA
+ * SPSS API representation.
+ *
* @author Patrick Peck
* @version $Id$
*/
@@ -60,39 +59,38 @@ public class TransformParser {
//
private static final String DSIG = Constants.DSIG_PREFIX + ":";
private static final String DSIG_FILTER2 =
- Constants.DSIG_FILTER2_PREFIX + ":";
+ Constants.DSIG_FILTER2_PREFIX + ":";
private static final String XSLT = Constants.XSLT_PREFIX + ":";
private static final String EC = Constants.DSIG_EC_PREFIX + ":";
private static final String TRANSFORM_XPATH = DSIG + "Transform";
private static final String XPATH_XPATH = DSIG + "XPath";
private static final String XSLT_ELEMENT_XPATH = XSLT + "stylesheet";
private static final String XPATH2_XPATH =
- (DSIG_FILTER2 + "XPath[@Filter=\"intersect\"] | ")
- + (DSIG_FILTER2 + "XPath[@Filter=\"subtract\"] | ")
- + (DSIG_FILTER2 + "XPath[@Filter=\"union\"]");
+ DSIG_FILTER2 + "XPath[@Filter=\"intersect\"] | "
+ + DSIG_FILTER2 + "XPath[@Filter=\"subtract\"] | "
+ + DSIG_FILTER2 + "XPath[@Filter=\"union\"]";
private static final String INCLUSIVE_NAMESPACES_XPATH =
- EC + "InclusiveNamespaces";
+ EC + "InclusiveNamespaces";
/**
* The SPSSFactory
to use for creating new API objects.
*/
- private SPSSFactory factory = SPSSFactory.getInstance();
+ private final SPSSFactory factory = SPSSFactory.getInstance();
/**
* Parse an XMLDsig Transforms
DOM element.
- *
+ *
* @param transformsElem The Transforms
DOM element to parse.
- * @return A List
of Transform
API objects
- * containing the data from the individual Transform
DOM
- * elements.
- * @throws MOAApplicationException An error occurred parsing the
- * Transforms
DOM element.
+ * @return A List
of Transform
API objects containing
+ * the data from the individual Transform
DOM elements.
+ * @throws MOAApplicationException An error occurred parsing the
+ * Transforms
DOM element.
*/
public List parseTransforms(Element transformsElem)
- throws MOAApplicationException {
- List transforms = new ArrayList();
- NodeIterator transformElems =
- XPathUtils.selectNodeIterator(transformsElem, TRANSFORM_XPATH);
+ throws MOAApplicationException {
+ final List transforms = new ArrayList();
+ final NodeIterator transformElems =
+ XPathUtils.selectNodeIterator(transformsElem, TRANSFORM_XPATH);
Element transformElem;
Transform transform;
@@ -106,34 +104,31 @@ public class TransformParser {
/**
* Parse an XMLDsig Transform
DOM element.
- *
+ *
* @param transformElem Transform
DOM element to parse.
- * @return The Transform
API object containing the data
- * from the Transform
DOM element.
- * @throws MOAApplicationException An error occurred parsing the
- * Transform
DOM element.
+ * @return The Transform
API object containing the data from the
+ * Transform
DOM element.
+ * @throws MOAApplicationException An error occurred parsing the
+ * Transform
DOM element.
*/
public Transform parseTransform(Element transformElem)
- throws MOAApplicationException {
+ throws MOAApplicationException {
- String algorithmUri = transformElem.getAttribute("Algorithm");
+ final String algorithmUri = transformElem.getAttribute("Algorithm");
if (CanonicalizationTransform.CANONICAL_XML.equals(algorithmUri)
- || CanonicalizationTransform.CANONICAL_XML_WITH_COMMENTS.equals(
- algorithmUri)) {
+ || CanonicalizationTransform.CANONICAL_XML_WITH_COMMENTS.equals(
+ algorithmUri)) {
return factory.createCanonicalizationTransform(algorithmUri);
- } else if (
- ExclusiveCanonicalizationTransform.EXCLUSIVE_CANONICAL_XML.equals(
+ } else if (ExclusiveCanonicalizationTransform.EXCLUSIVE_CANONICAL_XML.equals(
algorithmUri)
- || ExclusiveCanonicalizationTransform
- .EXCLUSIVE_CANONICAL_XML_WITH_COMMENTS
- .equals(
- algorithmUri)) {
+ || ExclusiveCanonicalizationTransform.EXCLUSIVE_CANONICAL_XML_WITH_COMMENTS
+ .equals(
+ algorithmUri)) {
return parseExclusiveC14nTransform(algorithmUri, transformElem);
} else if (Base64Transform.BASE64_DECODING.equals(algorithmUri)) {
return factory.createBase64Transform();
- } else if (
- EnvelopedSignatureTransform.ENVELOPED_SIGNATURE.equals(algorithmUri)) {
+ } else if (EnvelopedSignatureTransform.ENVELOPED_SIGNATURE.equals(algorithmUri)) {
return factory.createEnvelopedSignatureTransform();
} else if (XPathTransform.XPATH.equals(algorithmUri)) {
return parseXPathTransform(transformElem);
@@ -148,49 +143,47 @@ public class TransformParser {
/**
* Parse an exclusive canonicalization type of transform.
- *
- * @param algorithmUri The algorithm URI of the canonicalization algorithm.
+ *
+ * @param algorithmUri The algorithm URI of the canonicalization algorithm.
* @param transformElem The Transform
DOM element to parse.
* @return An ExclusiveCanonicalizationTransform
API object
- * containing the data from the transformElem
.
+ * containing the data from the transformElem
.
*/
private Transform parseExclusiveC14nTransform(
- String algorithmUri,
- Element transformElem)
- {
+ String algorithmUri,
+ Element transformElem) {
- Element inclusiveNamespacesElem =
- (Element) XPathUtils.selectSingleNode(
- transformElem,
- INCLUSIVE_NAMESPACES_XPATH);
+ final Element inclusiveNamespacesElem =
+ (Element) XPathUtils.selectSingleNode(
+ transformElem,
+ INCLUSIVE_NAMESPACES_XPATH);
- List inclusiveNamespaces = new ArrayList();
- if (inclusiveNamespacesElem != null)
- {
- StringTokenizer tokenizer = new StringTokenizer(inclusiveNamespacesElem.getAttribute("PrefixList"));
- while (tokenizer.hasMoreTokens())
- {
+ final List inclusiveNamespaces = new ArrayList();
+ if (inclusiveNamespacesElem != null) {
+ final StringTokenizer tokenizer = new StringTokenizer(inclusiveNamespacesElem.getAttribute(
+ "PrefixList"));
+ while (tokenizer.hasMoreTokens()) {
inclusiveNamespaces.add(tokenizer.nextToken());
}
}
return factory.createExclusiveCanonicalizationTransform(
- algorithmUri,
- inclusiveNamespaces);
+ algorithmUri,
+ inclusiveNamespaces);
}
/**
* Parse an XPath
type of Transform
.
- *
+ *
* @param transformElem The Transform
DOM element to parse.
* @return The Transform
API object representation of the
- * Transform
DOM element.
- * @throws MOAApplicationException An error occurred parsing the
- * Transform
DOM element.
+ * Transform
DOM element.
+ * @throws MOAApplicationException An error occurred parsing the
+ * Transform
DOM element.
*/
private Transform parseXPathTransform(Element transformElem)
- throws MOAApplicationException {
- Element xPathElem =
- (Element) XPathUtils.selectSingleNode(transformElem, XPATH_XPATH);
+ throws MOAApplicationException {
+ final Element xPathElem =
+ (Element) XPathUtils.selectSingleNode(transformElem, XPATH_XPATH);
Map nsDecls;
if (xPathElem == null) {
@@ -205,22 +198,22 @@ public class TransformParser {
/**
* Parse an XPathFilter2
type of Transform
.
- *
+ *
* @param transformElem The Transform
DOM element to parse.
* @return The Transform
API object representation of the
- * Transform
DOM element.
- * @throws MOAApplicationException An error occurred parsing the
- * Transform
DOM element.
+ * Transform
DOM element.
+ * @throws MOAApplicationException An error occurred parsing the
+ * Transform
DOM element.
*/
private Transform parseXPathFilter2Transform(Element transformElem)
- throws MOAApplicationException {
- List filters = new ArrayList();
- NodeIterator iter =
- XPathUtils.selectNodeIterator(transformElem, XPATH2_XPATH);
+ throws MOAApplicationException {
+ final List filters = new ArrayList();
+ final NodeIterator iter =
+ XPathUtils.selectNodeIterator(transformElem, XPATH2_XPATH);
Element filterElem;
while ((filterElem = (Element) iter.nextNode()) != null) {
- String filterAttr = filterElem.getAttribute("Filter");
+ final String filterAttr = filterElem.getAttribute("Filter");
String filterType;
String expression;
Map nsDecls;
@@ -247,17 +240,17 @@ public class TransformParser {
/**
* Parse an XSLT
type of Transform
.
- *
+ *
* @param transformElem The Transform
DOM element to parse.
* @return The Transform
API object representation of the
- * Transform
DOM element.
- * @throws MOAApplicationException An error occurred parsing the
- * Transform
DOM element.
+ * Transform
DOM element.
+ * @throws MOAApplicationException An error occurred parsing the
+ * Transform
DOM element.
*/
private Transform parseXSLTTransform(Element transformElem)
- throws MOAApplicationException {
- Element xsltElem =
- (Element) XPathUtils.selectSingleNode(transformElem, XSLT_ELEMENT_XPATH);
+ throws MOAApplicationException {
+ final Element xsltElem =
+ (Element) XPathUtils.selectSingleNode(transformElem, XSLT_ELEMENT_XPATH);
if (xsltElem == null) {
throw new MOAApplicationException("2215", null);
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParser.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParser.java
index cb07b34..bcab978 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParser.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureRequestParser.java
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.api.xmlbind;
import java.io.InputStream;
@@ -39,7 +38,6 @@ import at.gv.egovernment.moa.spss.api.cmsverify.CMSContent;
import at.gv.egovernment.moa.spss.api.cmsverify.CMSDataObject;
import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureRequest;
import at.gv.egovernment.moa.spss.api.common.MetaInfo;
-import at.gv.egovernment.moaspss.logging.Logger;
import at.gv.egovernment.moaspss.util.Base64Utils;
import at.gv.egovernment.moaspss.util.CollectionUtils;
import at.gv.egovernment.moaspss.util.Constants;
@@ -49,7 +47,7 @@ import at.gv.egovernment.moaspss.util.XPathUtils;
/**
* A parser to parse VerifyCMSSignatureRequest
DOM trees into
* VerifyCMSSignatureRequest
API objects.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
@@ -63,7 +61,7 @@ public class VerifyCMSSignatureRequestParser {
private static final String EXTENDED_VALIDATION_XPATH = MOA + "ExtendedValidation";
private static final String CMS_SIGNATURE_XPATH = MOA + "CMSSignature";
private static final String PDF_SIGNATURE_XPATH = MOA + "PDFSignature";
-
+
private static final String TRUST_PROFILE_ID_XPATH = MOA + "TrustProfileID";
private static final String DATA_OBJECT_XPATH = MOA + "DataObject";
private static final String META_INFO_XPATH = MOA + "MetaInfo";
@@ -72,110 +70,109 @@ public class VerifyCMSSignatureRequestParser {
private static final String EXCLUDEBYTERANGE_FROM_XPATH = MOA + "ExcludedByteRange/" + MOA + "From";
private static final String EXCLUDEBYTERANGE_TO_XPATH = MOA + "ExcludedByteRange/" + MOA + "To";
-
/** The SPSSFactory
for creating new API objects. */
- private SPSSFactory factory = SPSSFactory.getInstance();
+ private final SPSSFactory factory = SPSSFactory.getInstance();
/**
- * Parse a VerifyCMSSignatureRequest
DOM element, as defined
- * by the MOA schema.
- *
+ * Parse a VerifyCMSSignatureRequest
DOM element, as defined by the
+ * MOA schema.
+ *
* @param requestElem The VerifyCMSSignatureRequest
to parse. The
- * request must have been successfully parsed against the schema for this
- * method to succeed.
- * @return A VerifyCMSSignatureRequest
API objects containing
- * the data from the DOM element.
+ * request must have been successfully parsed against the
+ * schema for this method to succeed.
+ * @return A VerifyCMSSignatureRequest
API objects containing the
+ * data from the DOM element.
* @throws MOAApplicationException An error occurred parsing the request.
*/
public VerifyCMSSignatureRequest parsePDF(Element requestElem)
- throws MOAApplicationException {
-
- int[] signatories = parseSignatories(requestElem);
- Date dateTime =
- RequestParserUtils.parseDateTime(requestElem, DATE_TIME_XPATH);
- boolean extendedValidation =
- RequestParserUtils.parseExtendedValidation(requestElem, EXTENDED_VALIDATION_XPATH, false);
-
- String cmsSignatureStr =
- XPathUtils.getElementValue(requestElem, PDF_SIGNATURE_XPATH, "");
- CMSDataObject dataObject = parseDataObject(requestElem);
- String trustProfileID =
- XPathUtils.getElementValue(requestElem, TRUST_PROFILE_ID_XPATH, null);
- //Logger.info("CMSSignature: " + cmsSignatureStr);
- InputStream cmsSignature =
- Base64Utils.decodeToStream(cmsSignatureStr, true);
+ throws MOAApplicationException {
+
+ final int[] signatories = parseSignatories(requestElem);
+ final Date dateTime =
+ RequestParserUtils.parseDateTime(requestElem, DATE_TIME_XPATH);
+ final boolean extendedValidation =
+ RequestParserUtils.parseExtendedValidation(requestElem, EXTENDED_VALIDATION_XPATH, false);
+
+ final String cmsSignatureStr =
+ XPathUtils.getElementValue(requestElem, PDF_SIGNATURE_XPATH, "");
+ final CMSDataObject dataObject = parseDataObject(requestElem);
+ final String trustProfileID =
+ XPathUtils.getElementValue(requestElem, TRUST_PROFILE_ID_XPATH, null);
+ // Logger.info("CMSSignature: " + cmsSignatureStr);
+ final InputStream cmsSignature =
+ Base64Utils.decodeToStream(cmsSignatureStr, true);
return factory.createVerifyCMSSignatureRequest(
- signatories,
- dateTime,
- cmsSignature,
- dataObject,
- trustProfileID,
- true,
- extendedValidation);
+ signatories,
+ dateTime,
+ cmsSignature,
+ dataObject,
+ trustProfileID,
+ true,
+ extendedValidation);
}
-
+
/**
- * Parse a VerifyCMSSignatureRequest
DOM element, as defined
- * by the MOA schema.
- *
+ * Parse a VerifyCMSSignatureRequest
DOM element, as defined by the
+ * MOA schema.
+ *
* @param requestElem The VerifyCMSSignatureRequest
to parse. The
- * request must have been successfully parsed against the schema for this
- * method to succeed.
- * @return A VerifyCMSSignatureRequest
API objects containing
- * the data from the DOM element.
+ * request must have been successfully parsed against the
+ * schema for this method to succeed.
+ * @return A VerifyCMSSignatureRequest
API objects containing the
+ * data from the DOM element.
* @throws MOAApplicationException An error occurred parsing the request.
*/
public VerifyCMSSignatureRequest parse(Element requestElem)
- throws MOAApplicationException {
-
- int[] signatories = parseSignatories(requestElem);
- Date dateTime =
- RequestParserUtils.parseDateTime(requestElem, DATE_TIME_XPATH);
- boolean extendedValidation =
- RequestParserUtils.parseExtendedValidation(requestElem, EXTENDED_VALIDATION_XPATH, false);
-
- String cmsSignatureStr =
- XPathUtils.getElementValue(requestElem, CMS_SIGNATURE_XPATH, "");
- CMSDataObject dataObject = parseDataObject(requestElem);
- String trustProfileID =
- XPathUtils.getElementValue(requestElem, TRUST_PROFILE_ID_XPATH, null);
- InputStream cmsSignature =
- Base64Utils.decodeToStream(cmsSignatureStr, true);
+ throws MOAApplicationException {
+
+ final int[] signatories = parseSignatories(requestElem);
+ final Date dateTime =
+ RequestParserUtils.parseDateTime(requestElem, DATE_TIME_XPATH);
+ final boolean extendedValidation =
+ RequestParserUtils.parseExtendedValidation(requestElem, EXTENDED_VALIDATION_XPATH, false);
+
+ final String cmsSignatureStr =
+ XPathUtils.getElementValue(requestElem, CMS_SIGNATURE_XPATH, "");
+ final CMSDataObject dataObject = parseDataObject(requestElem);
+ final String trustProfileID =
+ XPathUtils.getElementValue(requestElem, TRUST_PROFILE_ID_XPATH, null);
+ final InputStream cmsSignature =
+ Base64Utils.decodeToStream(cmsSignatureStr, true);
return factory.createVerifyCMSSignatureRequest(
- signatories,
- dateTime,
- cmsSignature,
- dataObject,
- trustProfileID,
- false,
- extendedValidation);
+ signatories,
+ dateTime,
+ cmsSignature,
+ dataObject,
+ trustProfileID,
+ false,
+ extendedValidation);
}
/**
- * Parse the Signatories
attribute contained in the
+ * Parse the Signatories
attribute contained in the
* VerifyCMSSignatureRequest
DOM element.
- *
+ *
* @param requestElem The VerifyCMSSignatureRequest
DOM element.
- * @return The signatories contained in the given
- * VerifyCMSSignatureRequest
DOM element.
+ * @return The signatories contained in the given
+ * VerifyCMSSignatureRequest
DOM element.
*/
private int[] parseSignatories(Element requestElem) {
- String signatoriesStr = requestElem.getAttribute("Signatories");
+ final String signatoriesStr = requestElem.getAttribute("Signatories");
if ("all".equals(signatoriesStr)) {
return VerifyCMSSignatureRequest.ALL_SIGNATORIES;
} else {
- StringTokenizer tokenizer = new StringTokenizer(signatoriesStr);
- List signatoriesList = new ArrayList();
+ final StringTokenizer tokenizer = new StringTokenizer(signatoriesStr);
+ final List signatoriesList = new ArrayList();
int[] signatories;
// put the signatories into a List
while (tokenizer.hasMoreTokens()) {
try {
signatoriesList.add(new Integer(tokenizer.nextToken()));
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
// this cannot occur if the request has been validated
}
}
@@ -188,44 +185,47 @@ public class VerifyCMSSignatureRequestParser {
}
/**
- * Parse a the DataObject
DOM element contained in a given
+ * Parse a the DataObject
DOM element contained in a given
* VerifyCMSSignatureRequest
DOM element.
- *
- * @param requestElem The VerifyCMSSignatureRequest
DOM element
- * to parse.
- * @return The CMSDataObject
API object containing the data
- * from the DataObject
DOM element.
+ *
+ * @param requestElem The VerifyCMSSignatureRequest
DOM element to
+ * parse.
+ * @return The CMSDataObject
API object containing the data from
+ * the DataObject
DOM element.
*/
private CMSDataObject parseDataObject(Element requestElem) {
- Element dataObjectElem =
- (Element) XPathUtils.selectSingleNode(requestElem, DATA_OBJECT_XPATH);
+ final Element dataObjectElem =
+ (Element) XPathUtils.selectSingleNode(requestElem, DATA_OBJECT_XPATH);
if (dataObjectElem != null) {
- Element metaInfoElem =
- (Element) XPathUtils.selectSingleNode(dataObjectElem, META_INFO_XPATH);
+ final Element metaInfoElem =
+ (Element) XPathUtils.selectSingleNode(dataObjectElem, META_INFO_XPATH);
MetaInfo metaInfo = null;
- Element contentElem =
- (Element) XPathUtils.selectSingleNode(dataObjectElem, CONTENT_XPATH);
- CMSContent content = parseContent(contentElem);
+ final Element contentElem =
+ (Element) XPathUtils.selectSingleNode(dataObjectElem, CONTENT_XPATH);
+ final CMSContent content = parseContent(contentElem);
if (metaInfoElem != null) {
metaInfo = RequestParserUtils.parseMetaInfo(metaInfoElem);
}
- String excludeByteRangeFromStr = XPathUtils.getElementValue(dataObjectElem, EXCLUDEBYTERANGE_FROM_XPATH, null);
- String excludeByteRangeToStr = XPathUtils.getElementValue(dataObjectElem, EXCLUDEBYTERANGE_TO_XPATH, null);
-
+ final String excludeByteRangeFromStr = XPathUtils.getElementValue(dataObjectElem,
+ EXCLUDEBYTERANGE_FROM_XPATH, null);
+ final String excludeByteRangeToStr = XPathUtils.getElementValue(dataObjectElem,
+ EXCLUDEBYTERANGE_TO_XPATH, null);
+
BigDecimal excludeByteRangeFrom = null;
BigDecimal excludeByteRangeTo = null;
-
- if (excludeByteRangeFromStr != null)
- excludeByteRangeFrom = new BigDecimal(excludeByteRangeFromStr);
- if (excludeByteRangeToStr != null)
- excludeByteRangeTo = new BigDecimal(excludeByteRangeToStr);
+
+ if (excludeByteRangeFromStr != null) {
+ excludeByteRangeFrom = new BigDecimal(excludeByteRangeFromStr);
+ }
+ if (excludeByteRangeToStr != null) {
+ excludeByteRangeTo = new BigDecimal(excludeByteRangeToStr);
+ }
return factory.createCMSDataObject(metaInfo, content, excludeByteRangeFrom, excludeByteRangeTo);
-
-
+
} else {
return null;
}
@@ -233,25 +233,25 @@ public class VerifyCMSSignatureRequestParser {
}
/**
- * Parse the content contained in a CMSContentBaseType
kind of
- * DOM element.
- *
+ * Parse the content contained in a CMSContentBaseType
kind of DOM
+ * element.
+ *
* @param contentElem The CMSContentBaseType
kind of element to
- * parse.
- * @return A CMSDataObject
API object containing the data
- * from the given DOM element.
+ * parse.
+ * @return A CMSDataObject
API object containing the data from the
+ * given DOM element.
*/
private CMSContent parseContent(Element contentElem) {
- Element base64ContentElem =
- (Element) XPathUtils.selectSingleNode(contentElem, BASE64_CONTENT_XPATH);
+ final Element base64ContentElem =
+ (Element) XPathUtils.selectSingleNode(contentElem, BASE64_CONTENT_XPATH);
if (base64ContentElem != null) {
- String base64Str = DOMUtils.getText(base64ContentElem);
- InputStream binaryContent = Base64Utils.decodeToStream(base64Str, true);
+ final String base64Str = DOMUtils.getText(base64ContentElem);
+ final InputStream binaryContent = Base64Utils.decodeToStream(base64Str, true);
return factory.createCMSContent(binaryContent);
} else {
return factory.createCMSContent(
- contentElem.getAttribute("Reference"));
+ contentElem.getAttribute("Reference"));
}
}
}
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureResponseBuilder.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureResponseBuilder.java
index de39948..265d0f3 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureResponseBuilder.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyCMSSignatureResponseBuilder.java
@@ -21,13 +21,10 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.api.xmlbind;
import java.util.Iterator;
-import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse;
-import at.gv.egovernment.moaspss.util.Constants;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -38,137 +35,138 @@ import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponseElemen
import at.gv.egovernment.moa.spss.api.common.CheckResult;
import at.gv.egovernment.moa.spss.api.common.SignerInfo;
import at.gv.egovernment.moa.spss.api.xmlverify.AdESFormResults;
+import at.gv.egovernment.moaspss.util.Constants;
/**
- * Convert a VerifyCMSSignatureResponse
API object into its
- * XML representation, according to the MOA XML schema.
- *
+ * Convert a VerifyCMSSignatureResponse
API object into its XML
+ * representation, according to the MOA XML schema.
+ *
* @author Patrick Peck
* @version $Id$
*/
public class VerifyCMSSignatureResponseBuilder {
/** The XML document containing the response element. */
- private Document responseDoc;
+ private final Document responseDoc;
/** The response VerifyCMSSignatureResponse
DOM element. */
- private Element responseElem;
+ private final Element responseElem;
private boolean includeSigningTime = false;
/**
* Create a new VerifyCMSSignatureResponseBuilder
:
- *
- * @throws MOASystemException An error occurred setting up the resulting
- * XML document.
+ *
+ * @throws MOASystemException An error occurred setting up the resulting XML
+ * document.
*/
public VerifyCMSSignatureResponseBuilder() throws MOASystemException {
responseDoc =
- ResponseBuilderUtils.createResponse("VerifyCMSSignatureResponse");
+ ResponseBuilderUtils.createResponse("VerifyCMSSignatureResponse");
responseElem = responseDoc.getDocumentElement();
}
- public VerifyCMSSignatureResponseBuilder(Document responseDoc, String name, boolean includeSigningTime) throws MOASystemException {
- this.responseDoc = responseDoc;
- responseElem = responseDoc.createElementNS(Constants.MOA_NS_URI, name);
- this.includeSigningTime = includeSigningTime;
- }
+ public VerifyCMSSignatureResponseBuilder(Document responseDoc, String name, boolean includeSigningTime)
+ throws MOASystemException {
+ this.responseDoc = responseDoc;
+ responseElem = responseDoc.createElementNS(Constants.MOA_NS_URI, name);
+ this.includeSigningTime = includeSigningTime;
+ }
+
+ public Element buildElement(VerifyCMSSignatureResponse response) throws MOAApplicationException {
+ this.build(response);
+ return responseElem;
+ }
- public Element buildElement(VerifyCMSSignatureResponse response) throws MOAApplicationException {
- this.build(response);
- return responseElem;
- }
-
/**
- * Build a document containing a VerifyCMSSignatureResponse
- * DOM element being the XML representation of the given
+ * Build a document containing a VerifyCMSSignatureResponse
DOM
+ * element being the XML representation of the given
* VerifyCMSSignatureResponse
API object.
- *
- * @param response The VerifyCMSSignatureResponse
to convert
- * to XML.
- * @return A document containing the VerifyCMSSignatureResponse
- * DOM element.
+ *
+ * @param response The VerifyCMSSignatureResponse
to convert to
+ * XML.
+ * @return A document containing the VerifyCMSSignatureResponse
DOM
+ * element.
* @throws MOAApplicationException An error occurred building the response.
*/
public Document build(VerifyCMSSignatureResponse response)
- throws MOAApplicationException {
+ throws MOAApplicationException {
Iterator iter;
for (iter = response.getResponseElements().iterator(); iter.hasNext();) {
- VerifyCMSSignatureResponseElement responseElement =
- (VerifyCMSSignatureResponseElement) iter.next();
+ final VerifyCMSSignatureResponseElement responseElement =
+ (VerifyCMSSignatureResponseElement) iter.next();
addResponseElement(responseElement);
}
-
+
return responseDoc;
}
/**
* Add an element to the response.
- *
+ *
* @param responseElement The element to add to the response.
* @throws MOAApplicationException An error occurred adding the element.
*/
private void addResponseElement(VerifyCMSSignatureResponseElement responseElement)
- throws MOAApplicationException {
+ throws MOAApplicationException {
+
+ final SignerInfo signerInfo = responseElement.getSignerInfo();
+ final CheckResult signatureCheck = responseElement.getSignatureCheck();
+ final CheckResult certCheck = responseElement.getCertificateCheck();
- SignerInfo signerInfo = responseElement.getSignerInfo();
- CheckResult signatureCheck = responseElement.getSignatureCheck();
- CheckResult certCheck = responseElement.getCertificateCheck();
-
ResponseBuilderUtils.addSignerInfo(
- responseDoc,
- responseElem,
- signerInfo.getSignerCertificate(),
- signerInfo.isQualifiedCertificate(),
- signerInfo.getQCSource(),
- signerInfo.isPublicAuthority(),
- signerInfo.getPublicAuhtorityID(),
- signerInfo.isSSCD(),
- signerInfo.getSSCDSource(),
- signerInfo.getIssuerCountryCode(),
- signerInfo.getTslInfos());
-
- if(this.includeSigningTime) {
+ responseDoc,
+ responseElem,
+ signerInfo.getSignerCertificate(),
+ signerInfo.isQualifiedCertificate(),
+ signerInfo.getQCSource(),
+ signerInfo.isPublicAuthority(),
+ signerInfo.getPublicAuhtorityID(),
+ signerInfo.isSSCD(),
+ signerInfo.getSSCDSource(),
+ signerInfo.getIssuerCountryCode(),
+ signerInfo.getTslInfos());
+
+ if (this.includeSigningTime) {
ResponseBuilderUtils.addSigningTime(responseDoc,
- responseElem, signerInfo.getSigningTime());
+ responseElem, signerInfo.getSigningTime());
}
ResponseBuilderUtils.addSignatureAlgorithm(responseDoc,
- responseElem,
- responseElement.getSignatureAlgorithm());
-
-
+ responseElem,
+ responseElement.getSignatureAlgorithm());
+
ResponseBuilderUtils.addCodeInfoElement(
- responseDoc,
- responseElem,
- "SignatureCheck",
- signatureCheck.getCode(),
- signatureCheck.getInfo());
+ responseDoc,
+ responseElem,
+ "SignatureCheck",
+ signatureCheck.getCode(),
+ signatureCheck.getInfo());
ResponseBuilderUtils.addCodeInfoElement(
- responseDoc,
- responseElem,
- "CertificateCheck",
- certCheck.getCode(),
- certCheck.getInfo());
-
+ responseDoc,
+ responseElem,
+ "CertificateCheck",
+ certCheck.getCode(),
+ certCheck.getInfo());
if (responseElement.getAdESFormResults() != null) {
- Iterator formIterator = responseElement.getAdESFormResults().iterator();
-
- while (formIterator.hasNext()) {
- AdESFormResults adESFormResult = (AdESFormResults) formIterator.next();
- // add the CertificateCheck
- ResponseBuilderUtils.addFormCheckElement(responseDoc, responseElem, "FormCheckResult",
- adESFormResult.getCode().intValue(), adESFormResult.getName());
-
- }
- }
-
- if(responseElement.getExtendedCertificateCheck() != null) {
- ResponseBuilderUtils.addExtendendResult(responseDoc, responseElem, responseElement.getExtendedCertificateCheck());
- }
-
+ final Iterator formIterator = responseElement.getAdESFormResults().iterator();
+
+ while (formIterator.hasNext()) {
+ final AdESFormResults adESFormResult = (AdESFormResults) formIterator.next();
+ // add the CertificateCheck
+ ResponseBuilderUtils.addFormCheckElement(responseDoc, responseElem, "FormCheckResult",
+ adESFormResult.getCode().intValue(), adESFormResult.getName());
+
+ }
+ }
+
+ if (responseElement.getExtendedCertificateCheck() != null) {
+ ResponseBuilderUtils.addExtendendResult(responseDoc, responseElem, responseElement
+ .getExtendedCertificateCheck());
+ }
+
}
}
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 499f514..b9b7d26 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
@@ -21,7 +21,6 @@
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
-
package at.gv.egovernment.moa.spss.api.xmlbind;
import java.util.Iterator;
@@ -39,145 +38,144 @@ import at.gv.egovernment.moa.spss.api.xmlverify.AdESFormResults;
import at.gv.egovernment.moaspss.logging.Logger;
/**
- * Convert a VerifyCMSSignatureResponse
API object into its
- * XML representation, according to the MOA XML schema.
- *
+ * Convert a VerifyCMSSignatureResponse
API object into its XML
+ * representation, according to the MOA XML schema.
+ *
* @author Patrick Peck
* @version $Id$
*/
public class VerifyPDFSignatureResponseBuilder {
/** The XML document containing the response element. */
- private Document responseDoc;
+ private final Document responseDoc;
/** The response VerifyCMSSignatureResponse
DOM element. */
- private Element responseRootElem;
+ private final Element responseRootElem;
/**
* Create a new VerifyCMSSignatureResponseBuilder
:
- *
- * @throws MOASystemException An error occurred setting up the resulting
- * XML document.
+ *
+ * @throws MOASystemException An error occurred setting up the resulting XML
+ * document.
*/
public VerifyPDFSignatureResponseBuilder() throws MOASystemException {
responseDoc =
- ResponseBuilderUtils.createResponse("VerifyPDFSignatureResponse");
+ ResponseBuilderUtils.createResponse("VerifyPDFSignatureResponse");
responseRootElem = responseDoc.getDocumentElement();
}
-
+
/**
- * Build a document containing a VerifyCMSSignatureResponse
- * DOM element being the XML representation of the given
+ * Build a document containing a VerifyCMSSignatureResponse
DOM
+ * element being the XML representation of the given
* VerifyCMSSignatureResponse
API object.
- *
- * @param response The VerifyCMSSignatureResponse
to convert
- * to XML.
- * @return A document containing the VerifyCMSSignatureResponse
- * DOM element.
+ *
+ * @param response The VerifyCMSSignatureResponse
to convert to
+ * XML.
+ * @return A document containing the VerifyCMSSignatureResponse
DOM
+ * element.
* @throws MOAApplicationException An error occurred building the response.
*/
public Document build(VerifyCMSSignatureResponse response)
- throws MOAApplicationException {
+ throws MOAApplicationException {
Iterator iter;
-
for (iter = response.getResponseElements().iterator(); iter.hasNext();) {
- VerifyCMSSignatureResponseElement responseElement =
- (VerifyCMSSignatureResponseElement) iter.next();
- Element signatureResult = ResponseBuilderUtils.addChildElement("SignatureResult", responseDoc, responseRootElem);
+ final VerifyCMSSignatureResponseElement responseElement =
+ (VerifyCMSSignatureResponseElement) iter.next();
+ final Element signatureResult = ResponseBuilderUtils.addChildElement("SignatureResult", responseDoc,
+ responseRootElem);
addResponseElement(responseElement, signatureResult);
-
+
}
-
+
return responseDoc;
}
/**
* Add an element to the response.
- *
+ *
* @param responseElement The element to add to the response.
- * @param signatureResult
+ * @param signatureResult
* @throws MOAApplicationException An error occurred adding the element.
*/
private void addResponseElement(VerifyCMSSignatureResponseElement responseElement, Element responseElem)
- throws MOAApplicationException {
+ throws MOAApplicationException {
+
+ final SignerInfo signerInfo = responseElement.getSignerInfo();
+ final CheckResult signatureCheck = responseElement.getSignatureCheck();
+ final CheckResult certCheck = responseElement.getCertificateCheck();
- SignerInfo signerInfo = responseElement.getSignerInfo();
- CheckResult signatureCheck = responseElement.getSignatureCheck();
- CheckResult certCheck = responseElement.getCertificateCheck();
-
if (signerInfo != null) {
- ResponseBuilderUtils.addSignerInfo(
- responseDoc,
- responseElem,
- signerInfo.getSignerCertificate(),
- signerInfo.isQualifiedCertificate(),
- signerInfo.getQCSource(),
- signerInfo.isPublicAuthority(),
- signerInfo.getPublicAuhtorityID(),
- signerInfo.isSSCD(),
- signerInfo.getSSCDSource(),
- signerInfo.getIssuerCountryCode(),
- signerInfo.getTslInfos());
-
- ResponseBuilderUtils.addSigningTime(responseDoc,
- responseElem,
- signerInfo.getSigningTime());
-
-
+ ResponseBuilderUtils.addSignerInfo(
+ responseDoc,
+ responseElem,
+ signerInfo.getSignerCertificate(),
+ signerInfo.isQualifiedCertificate(),
+ signerInfo.getQCSource(),
+ signerInfo.isPublicAuthority(),
+ signerInfo.getPublicAuhtorityID(),
+ signerInfo.isSSCD(),
+ signerInfo.getSSCDSource(),
+ signerInfo.getIssuerCountryCode(),
+ signerInfo.getTslInfos());
+
+ ResponseBuilderUtils.addSigningTime(responseDoc,
+ responseElem,
+ signerInfo.getSigningTime());
+
} else {
- Logger.info("Find signature result with no 'SignerInfo'. Maybe a signature verification Failed");
-
+ Logger.info("Find signature result with no 'SignerInfo'. Maybe a signature verification Failed");
+
}
ResponseBuilderUtils.addSignatureAlgorithm(responseDoc,
- responseElem,
- responseElement.getSignatureAlgorithm());
-
+ responseElem,
+ responseElement.getSignatureAlgorithm());
+
ResponseBuilderUtils.addCodeInfoElement(
- responseDoc,
- responseElem,
- "SignatureCheck",
- signatureCheck.getCode(),
- signatureCheck.getInfo());
+ responseDoc,
+ responseElem,
+ "SignatureCheck",
+ signatureCheck.getCode(),
+ signatureCheck.getInfo());
ResponseBuilderUtils.addCodeInfoElement(
- responseDoc,
- responseElem,
- "CertificateCheck",
- certCheck.getCode(),
- certCheck.getInfo());
-
+ responseDoc,
+ responseElem,
+ "CertificateCheck",
+ certCheck.getCode(),
+ certCheck.getInfo());
if (responseElement.getAdESFormResults() != null) {
- Iterator formIterator = responseElement.getAdESFormResults().iterator();
-
- while (formIterator.hasNext()) {
- AdESFormResults adESFormResult = (AdESFormResults) formIterator.next();
- // add the CertificateCheck
- ResponseBuilderUtils.addFormCheckElement(responseDoc, responseElem, "FormCheckResult",
- adESFormResult.getCode().intValue(), adESFormResult.getName());
-
- }
- }
-
- if(responseElement.getExtendedCertificateCheck() != null) {
- ResponseBuilderUtils.addExtendendResult(responseDoc, responseElem, responseElement.getExtendedCertificateCheck());
- }
-
-
- //add additional PDF signature properteis
- if (responseElement.getCoversFullDocument() != null ||
- responseElement.getByteRangeOfSignature() != null) {
- Element pdfSigProps = ResponseBuilderUtils.createAndAddChildElement(responseDoc, responseElem, "SignatureProperties");
- ResponseBuilderUtils.addSignatureCoversFullPDF(responseDoc,
- pdfSigProps,
- responseElement.getCoversFullDocument());
- ResponseBuilderUtils.addSignatureByteRange(responseDoc,
- pdfSigProps,
- responseElement.getByteRangeOfSignature());
+ final Iterator formIterator = responseElement.getAdESFormResults().iterator();
+
+ while (formIterator.hasNext()) {
+ final AdESFormResults adESFormResult = (AdESFormResults) formIterator.next();
+ // add the CertificateCheck
+ ResponseBuilderUtils.addFormCheckElement(responseDoc, responseElem, "FormCheckResult",
+ adESFormResult.getCode().intValue(), adESFormResult.getName());
+
+ }
+ }
+
+ if (responseElement.getExtendedCertificateCheck() != null) {
+ ResponseBuilderUtils.addExtendendResult(responseDoc, responseElem, responseElement
+ .getExtendedCertificateCheck());
+ }
+
+ // add additional PDF signature properteis
+ if (responseElement.getCoversFullDocument() != null ||
+ responseElement.getByteRangeOfSignature() != null) {
+ final Element pdfSigProps = ResponseBuilderUtils.createAndAddChildElement(responseDoc, responseElem,
+ "SignatureProperties");
+ ResponseBuilderUtils.addSignatureCoversFullPDF(responseDoc,
+ pdfSigProps,
+ responseElement.getCoversFullDocument());
+ ResponseBuilderUtils.addSignatureByteRange(responseDoc,
+ pdfSigProps,
+ responseElement.getByteRangeOfSignature());
}
-
+
}
}
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParser.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParser.java
index f1bb1d7..1360c5f 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParser.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureRequestParser.java
@@ -51,236 +51,230 @@ import at.gv.egovernment.moaspss.util.XPathUtils;
*/
public class VerifyXMLSignatureRequestParser {
- //
- // XPath expressions for parsing parts of the request
- //
- private static final String MOA = Constants.MOA_PREFIX + ":";
- private static final String DATE_TIME_XPATH = MOA + "DateTime";
- private static final String EXTENDED_VALIDATION_XPATH = MOA + "ExtendedValidation";
- private static final String RETURN_HASH_INPUT_DATA_XPATH = MOA + "ReturnHashInputData";
- private static final String TRUST_PROFILE_ID_XPATH = MOA + "TrustProfileID";
- private static final String VERIFY_SIGNATURE_ENVIRONMENT_XPATH = MOA + "VerifySignatureInfo/" + MOA
- + "VerifySignatureEnvironment";
- private static final String VERIFY_SIGNATURE_LOCATION_XPATH = MOA + "VerifySignatureInfo/" + MOA
- + "VerifySignatureLocation";
- private static final String SUPPLEMENT_PROFILE_XPATH = MOA + "SupplementProfile | " + MOA + "SupplementProfileID";
- private static final String SIGNATURE_MANIFEST_CHECK_PARAMS_XPATH = MOA + "SignatureManifestCheckParams";
- private static final String VERIFY_TRANSFORMS_INFO_PROFILE_XPATH = (MOA + "VerifyTransformsInfoProfile | ")
- + (MOA + "VerifyTransformsInfoProfileID");
- private static final String REFERENCE_INFO_XPATH = MOA + "ReferenceInfo";
-
- /** The SPSSFactory
for creating new API objects. */
- private SPSSFactory factory = SPSSFactory.getInstance();
-
- /**
- * Parse a VerifyXMLSignatureRequest
DOM element, as defined
- * by the MOA schema.
- *
+ //
+ // XPath expressions for parsing parts of the request
+ //
+ private static final String MOA = Constants.MOA_PREFIX + ":";
+ private static final String DATE_TIME_XPATH = MOA + "DateTime";
+ private static final String EXTENDED_VALIDATION_XPATH = MOA + "ExtendedValidation";
+ private static final String RETURN_HASH_INPUT_DATA_XPATH = MOA + "ReturnHashInputData";
+ private static final String TRUST_PROFILE_ID_XPATH = MOA + "TrustProfileID";
+ private static final String VERIFY_SIGNATURE_ENVIRONMENT_XPATH = MOA + "VerifySignatureInfo/" + MOA
+ + "VerifySignatureEnvironment";
+ private static final String VERIFY_SIGNATURE_LOCATION_XPATH = MOA + "VerifySignatureInfo/" + MOA
+ + "VerifySignatureLocation";
+ private static final String SUPPLEMENT_PROFILE_XPATH = MOA + "SupplementProfile | " + MOA
+ + "SupplementProfileID";
+ private static final String SIGNATURE_MANIFEST_CHECK_PARAMS_XPATH = MOA + "SignatureManifestCheckParams";
+ private static final String VERIFY_TRANSFORMS_INFO_PROFILE_XPATH = MOA + "VerifyTransformsInfoProfile | "
+ + MOA + "VerifyTransformsInfoProfileID";
+ private static final String REFERENCE_INFO_XPATH = MOA + "ReferenceInfo";
+
+ /** The SPSSFactory
for creating new API objects. */
+ private final SPSSFactory factory = SPSSFactory.getInstance();
+
+ /**
+ * Parse a VerifyXMLSignatureRequest
DOM element, as defined by the
+ * MOA schema.
+ *
* @param requestElem The VerifyXMLSignatureRequest
to parse. The
- * request must have been successfully parsed against the schema for this
- * method to succeed.
- * @return A VerifyXMLSignatureRequest
API object containing
- * the data from the DOM element.
+ * request must have been successfully parsed against the
+ * schema for this method to succeed.
+ * @return A VerifyXMLSignatureRequest
API object containing the
+ * data from the DOM element.
* @throws MOAApplicationException An error occurred parsing the request.
*/
public VerifyXMLSignatureRequest parse(Element requestElem)
- throws MOAApplicationException {
-
- Date dateTime =
- RequestParserUtils.parseDateTime(requestElem, DATE_TIME_XPATH);
-
- boolean extendedValidation =
- RequestParserUtils.parseExtendedValidation(requestElem, EXTENDED_VALIDATION_XPATH, false);
-
- VerifySignatureInfo verifySignatureInfo =
- parseVerifySignatureInfo(requestElem);
- List supplementProfiles = parseSupplementProfiles(requestElem);
- SignatureManifestCheckParams signatureManifestCheckParams =
- parseSignatureManifestCheckParams(requestElem);
- boolean returnHashInputData =
- XPathUtils.selectSingleNode(requestElem, RETURN_HASH_INPUT_DATA_XPATH)
- != null;
- String trustProfileID =
- XPathUtils.getElementValue(requestElem, TRUST_PROFILE_ID_XPATH, null);
+ throws MOAApplicationException {
+
+ final Date dateTime =
+ RequestParserUtils.parseDateTime(requestElem, DATE_TIME_XPATH);
+
+ final boolean extendedValidation =
+ RequestParserUtils.parseExtendedValidation(requestElem, EXTENDED_VALIDATION_XPATH, false);
+
+ final VerifySignatureInfo verifySignatureInfo =
+ parseVerifySignatureInfo(requestElem);
+ final List supplementProfiles = parseSupplementProfiles(requestElem);
+ final SignatureManifestCheckParams signatureManifestCheckParams =
+ parseSignatureManifestCheckParams(requestElem);
+ final boolean returnHashInputData =
+ XPathUtils.selectSingleNode(requestElem, RETURN_HASH_INPUT_DATA_XPATH) != null;
+ final String trustProfileID =
+ XPathUtils.getElementValue(requestElem, TRUST_PROFILE_ID_XPATH, null);
return factory.createVerifyXMLSignatureRequest(
- dateTime,
- verifySignatureInfo,
- supplementProfiles,
- signatureManifestCheckParams,
- returnHashInputData,
- trustProfileID,
- extendedValidation);
+ dateTime,
+ verifySignatureInfo,
+ supplementProfiles,
+ signatureManifestCheckParams,
+ returnHashInputData,
+ trustProfileID,
+ extendedValidation);
}
- /**
- * Parse the VerifySignatureInfo
DOM element contained in the
- * VerifyXMLSignatureRequest
DOM element.
- *
- * @param requestElem
- * The VerifyXMLSignatureRequest
DOM element
- * containing the VerifySignatureInfo
DOM element.
- * @return The VerifySignatureInfo
API object containing the
- * data from the DOM element.
- */
- private VerifySignatureInfo parseVerifySignatureInfo(Element requestElem) {
- Element verifySignatureEnvironmentElem = (Element) XPathUtils.selectSingleNode(requestElem,
- VERIFY_SIGNATURE_ENVIRONMENT_XPATH);
- Content verifySignatureEnvironment = RequestParserUtils.parseContent(verifySignatureEnvironmentElem);
- VerifySignatureLocation verifySignatureLocation = parseVerifySignatureLocation(requestElem);
-
- return factory.createVerifySignatureInfo(verifySignatureEnvironment, verifySignatureLocation);
- }
-
- /**
- * Parse the VerifySignatureLocation
DOM element contained in
- * the given VerifyXMLSignatureRequest
DOM element.
- *
- * @param requestElem
- * The VerifyXMLSignatureRequst
DOM element.
- * @return The VerifySignatureLocation
API object containing
- * the data from the DOM element.
- */
- private VerifySignatureLocation parseVerifySignatureLocation(Element requestElem) {
- Element locationElem = (Element) XPathUtils.selectSingleNode(requestElem, VERIFY_SIGNATURE_LOCATION_XPATH);
- String xPathExpression = DOMUtils.getText(locationElem);
- Map namespaceDeclarations = DOMUtils.getNamespaceDeclarations(locationElem);
-
- return factory.createVerifySignatureLocation(xPathExpression, namespaceDeclarations);
- }
-
- /**
- * Parse the supplement profiles contained in the given
- * VerifyXMLSignatureRequest
DOM element.
- *
- * @param requestElem
- * The VerifyXMLSignatureRequest
DOM element.
- * @return A List
of SupplementProfile
API objects
- * containing the data from the SupplementProfile
DOM
- * elements.
- */
- private List parseSupplementProfiles(Element requestElem) {
- List supplementProfiles = new ArrayList();
- NodeIterator profileElems = XPathUtils.selectNodeIterator(requestElem, SUPPLEMENT_PROFILE_XPATH);
- Element profileElem;
-
- while ((profileElem = (Element) profileElems.nextNode()) != null) {
- SupplementProfile profile;
-
- if ("SupplementProfile".equals(profileElem.getLocalName())) {
- ProfileParser profileParser = new ProfileParser();
- profile = profileParser.parseSupplementProfile(profileElem);
- } else {
- String profileID = DOMUtils.getText(profileElem);
- profile = factory.createSupplementProfile(profileID);
- }
- supplementProfiles.add(profile);
- }
- return supplementProfiles;
- }
-
- /**
- * Parse the SignatureManifestCheckParams
DOM element contained
- * in the given VerifyXMLSignatureRequest
DOM element.
- *
- * @param requestElem
- * The VerifyXMLSignatureRequest
DOM element.
- * @return The SignatureManifestCheckParams
API object
- * containing the data from the
- * SignatureManifestCheckParams
DOM element.
- * @throws MOAApplicationException
- * An error occurred parsing the
- * SignatureManifestCheckParams
DOM element.
- */
- private SignatureManifestCheckParams parseSignatureManifestCheckParams(Element requestElem)
- throws MOAApplicationException {
- Element paramsElem = (Element) XPathUtils.selectSingleNode(requestElem, SIGNATURE_MANIFEST_CHECK_PARAMS_XPATH);
-
- if (paramsElem != null) {
- String returnReferenceInputDataStr = paramsElem.getAttribute("ReturnReferenceInputData");
- boolean returnReferencInputData = BoolUtils.valueOf(returnReferenceInputDataStr);
- List referenceInfos = parseReferenceInfos(paramsElem);
-
- return factory.createSignatureManifestCheckParams(referenceInfos, returnReferencInputData);
- } else {
- return null;
- }
- }
-
- /**
- * Parse the ReferenceInfo
DOM elements contained in a
- * SignatureManifestCheckParams
DOM element.
- *
- * @param paramsElem
- * The SignatureManifestCheckParams
DOM element
- * containing the ReferenceInfo
DOM elements.
- * @return A List
of RefernceInfo
API objects
- * containing the data from the ReferenceInfo
DOM
- * elements.
- * @throws MOAApplicationException
- * An error occurred parsing the ReferenceInfo
DOM
- * elements.
- */
- private List parseReferenceInfos(Element paramsElem) throws MOAApplicationException {
-
- List referenceInfos = new ArrayList();
- NodeIterator refInfoElems = XPathUtils.selectNodeIterator(paramsElem, REFERENCE_INFO_XPATH);
- Element refInfoElem;
-
- while ((refInfoElem = (Element) refInfoElems.nextNode()) != null) {
- ReferenceInfo referenceInfo = parseReferenceInfo(refInfoElem);
-
- referenceInfos.add(referenceInfo);
- }
-
- return referenceInfos;
- }
-
- /**
- * Parse a ReferenceInfo
DOM element.
- *
- * @param refInfoElem
- * The ReferenceInfo
DOM element to parse.
- * @return The ReferenceInfo
API object containing the data
- * from the given ReferenceInfo
DOM element.
- * @throws MOAApplicationException
- * An error occurred parsing the ReferenceInfo
DOM
- * element.
- */
- private ReferenceInfo parseReferenceInfo(Element refInfoElem) throws MOAApplicationException {
- List profiles = parseVerifyTransformsInfoProfiles(refInfoElem);
- return factory.createReferenceInfo(profiles);
- }
-
- /**
- * Parse the VerifyTransformsInfoProfile
DOM elements contained
- * in a ReferenceInfo
DOM element.
- *
- * @param refInfoElem
- * ReferenceInfo
DOM element containing the
- * VerifyTransformsInfoProfile
DOM elements.
- * @return A List
of VerifyTransformsInfoProfile
- * API objects containing the profile data.
- * @throws MOAApplicationException
- * An error occurred building the
- * VerifyTransformsInfoProfile
s.
- */
- private List parseVerifyTransformsInfoProfiles(Element refInfoElem) throws MOAApplicationException {
-
- List profiles = new ArrayList();
- NodeIterator profileElems = XPathUtils.selectNodeIterator(refInfoElem, VERIFY_TRANSFORMS_INFO_PROFILE_XPATH);
- Element profileElem;
-
- while ((profileElem = (Element) profileElems.nextNode()) != null) {
- if ("VerifyTransformsInfoProfile".equals(profileElem.getLocalName())) {
- ProfileParser profileParser = new ProfileParser();
- profiles.add(profileParser.parseVerifyTransformsInfoProfile(profileElem));
- } else {
- String profileID = DOMUtils.getText(profileElem);
- profiles.add(factory.createVerifyTransformsInfoProfile(profileID));
- }
- }
- return profiles;
- }
+ /**
+ * Parse the VerifySignatureInfo
DOM element contained in the
+ * VerifyXMLSignatureRequest
DOM element.
+ *
+ * @param requestElem The VerifyXMLSignatureRequest
DOM element
+ * containing the VerifySignatureInfo
DOM
+ * element.
+ * @return The VerifySignatureInfo
API object containing the data
+ * from the DOM element.
+ */
+ private VerifySignatureInfo parseVerifySignatureInfo(Element requestElem) {
+ final Element verifySignatureEnvironmentElem = (Element) XPathUtils.selectSingleNode(requestElem,
+ VERIFY_SIGNATURE_ENVIRONMENT_XPATH);
+ final Content verifySignatureEnvironment = RequestParserUtils.parseContent(
+ verifySignatureEnvironmentElem);
+ final VerifySignatureLocation verifySignatureLocation = parseVerifySignatureLocation(requestElem);
+
+ return factory.createVerifySignatureInfo(verifySignatureEnvironment, verifySignatureLocation);
+ }
+
+ /**
+ * Parse the VerifySignatureLocation
DOM element contained in the
+ * given VerifyXMLSignatureRequest
DOM element.
+ *
+ * @param requestElem The VerifyXMLSignatureRequst
DOM element.
+ * @return The VerifySignatureLocation
API object containing the
+ * data from the DOM element.
+ */
+ private VerifySignatureLocation parseVerifySignatureLocation(Element requestElem) {
+ final Element locationElem = (Element) XPathUtils.selectSingleNode(requestElem,
+ VERIFY_SIGNATURE_LOCATION_XPATH);
+ final String xPathExpression = DOMUtils.getText(locationElem);
+ final Map namespaceDeclarations = DOMUtils.getNamespaceDeclarations(locationElem);
+
+ return factory.createVerifySignatureLocation(xPathExpression, namespaceDeclarations);
+ }
+
+ /**
+ * Parse the supplement profiles contained in the given
+ * VerifyXMLSignatureRequest
DOM element.
+ *
+ * @param requestElem The VerifyXMLSignatureRequest
DOM element.
+ * @return A List
of SupplementProfile
API objects
+ * containing the data from the SupplementProfile
DOM
+ * elements.
+ */
+ private List parseSupplementProfiles(Element requestElem) {
+ final List supplementProfiles = new ArrayList();
+ final NodeIterator profileElems = XPathUtils.selectNodeIterator(requestElem, SUPPLEMENT_PROFILE_XPATH);
+ Element profileElem;
+
+ while ((profileElem = (Element) profileElems.nextNode()) != null) {
+ SupplementProfile profile;
+
+ if ("SupplementProfile".equals(profileElem.getLocalName())) {
+ final ProfileParser profileParser = new ProfileParser();
+ profile = profileParser.parseSupplementProfile(profileElem);
+ } else {
+ final String profileID = DOMUtils.getText(profileElem);
+ profile = factory.createSupplementProfile(profileID);
+ }
+ supplementProfiles.add(profile);
+ }
+ return supplementProfiles;
+ }
+
+ /**
+ * Parse the SignatureManifestCheckParams
DOM element contained in
+ * the given VerifyXMLSignatureRequest
DOM element.
+ *
+ * @param requestElem The VerifyXMLSignatureRequest
DOM element.
+ * @return The SignatureManifestCheckParams
API object containing
+ * the data from the SignatureManifestCheckParams
DOM
+ * element.
+ * @throws MOAApplicationException An error occurred parsing the
+ * SignatureManifestCheckParams
DOM
+ * element.
+ */
+ private SignatureManifestCheckParams parseSignatureManifestCheckParams(Element requestElem)
+ throws MOAApplicationException {
+ final Element paramsElem = (Element) XPathUtils.selectSingleNode(requestElem,
+ SIGNATURE_MANIFEST_CHECK_PARAMS_XPATH);
+
+ if (paramsElem != null) {
+ final String returnReferenceInputDataStr = paramsElem.getAttribute("ReturnReferenceInputData");
+ final boolean returnReferencInputData = BoolUtils.valueOf(returnReferenceInputDataStr);
+ final List referenceInfos = parseReferenceInfos(paramsElem);
+
+ return factory.createSignatureManifestCheckParams(referenceInfos, returnReferencInputData);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Parse the ReferenceInfo
DOM elements contained in a
+ * SignatureManifestCheckParams
DOM element.
+ *
+ * @param paramsElem The SignatureManifestCheckParams
DOM element
+ * containing the ReferenceInfo
DOM elements.
+ * @return A List
of RefernceInfo
API objects
+ * containing the data from the ReferenceInfo
DOM elements.
+ * @throws MOAApplicationException An error occurred parsing the
+ * ReferenceInfo
DOM elements.
+ */
+ private List parseReferenceInfos(Element paramsElem) throws MOAApplicationException {
+
+ final List referenceInfos = new ArrayList();
+ final NodeIterator refInfoElems = XPathUtils.selectNodeIterator(paramsElem, REFERENCE_INFO_XPATH);
+ Element refInfoElem;
+
+ while ((refInfoElem = (Element) refInfoElems.nextNode()) != null) {
+ final ReferenceInfo referenceInfo = parseReferenceInfo(refInfoElem);
+
+ referenceInfos.add(referenceInfo);
+ }
+
+ return referenceInfos;
+ }
+
+ /**
+ * Parse a ReferenceInfo
DOM element.
+ *
+ * @param refInfoElem The ReferenceInfo
DOM element to parse.
+ * @return The ReferenceInfo
API object containing the data from
+ * the given ReferenceInfo
DOM element.
+ * @throws MOAApplicationException An error occurred parsing the
+ * ReferenceInfo
DOM element.
+ */
+ private ReferenceInfo parseReferenceInfo(Element refInfoElem) throws MOAApplicationException {
+ final List profiles = parseVerifyTransformsInfoProfiles(refInfoElem);
+ return factory.createReferenceInfo(profiles);
+ }
+
+ /**
+ * Parse the VerifyTransformsInfoProfile
DOM elements contained in
+ * a ReferenceInfo
DOM element.
+ *
+ * @param refInfoElem ReferenceInfo
DOM element containing the
+ * VerifyTransformsInfoProfile
DOM elements.
+ * @return A List
of VerifyTransformsInfoProfile
API
+ * objects containing the profile data.
+ * @throws MOAApplicationException An error occurred building the
+ * VerifyTransformsInfoProfile
s.
+ */
+ private List parseVerifyTransformsInfoProfiles(Element refInfoElem) throws MOAApplicationException {
+
+ final List profiles = new ArrayList();
+ final NodeIterator profileElems = XPathUtils.selectNodeIterator(refInfoElem,
+ VERIFY_TRANSFORMS_INFO_PROFILE_XPATH);
+ Element profileElem;
+
+ while ((profileElem = (Element) profileElems.nextNode()) != null) {
+ if ("VerifyTransformsInfoProfile".equals(profileElem.getLocalName())) {
+ final ProfileParser profileParser = new ProfileParser();
+ profiles.add(profileParser.parseVerifyTransformsInfoProfile(profileElem));
+ } else {
+ final String profileID = DOMUtils.getText(profileElem);
+ profiles.add(factory.createVerifyTransformsInfoProfile(profileID));
+ }
+ }
+ return profiles;
+ }
}
diff --git a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureResponseBuilder.java b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureResponseBuilder.java
index 0b73442..48206c9 100644
--- a/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureResponseBuilder.java
+++ b/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/VerifyXMLSignatureResponseBuilder.java
@@ -32,10 +32,6 @@ import org.w3c.dom.DocumentFragment;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import at.gv.egovernment.moaspss.logging.Logger;
-import at.gv.egovernment.moaspss.util.Base64Utils;
-import at.gv.egovernment.moaspss.util.Constants;
-import at.gv.egovernment.moaspss.util.MiscUtil;
import at.gv.egovernment.moa.spss.MOAApplicationException;
import at.gv.egovernment.moa.spss.MOASystemException;
import at.gv.egovernment.moa.spss.api.common.Content;
@@ -46,319 +42,315 @@ import at.gv.egovernment.moa.spss.api.xmlverify.AdESFormResults;
import at.gv.egovernment.moa.spss.api.xmlverify.ManifestRefsCheckResult;
import at.gv.egovernment.moa.spss.api.xmlverify.ReferencesCheckResult;
import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse;
-import at.gv.egovernment.moa.spss.server.config.ConfigurationException;
-import at.gv.egovernment.moa.spss.server.config.ConfigurationProvider;
+import at.gv.egovernment.moaspss.util.Base64Utils;
+import at.gv.egovernment.moaspss.util.Constants;
+import at.gv.egovernment.moaspss.util.MiscUtil;
/**
* Convert a VerifyXMLSignatureResponse
API object into its XML
* representation, according to the MOA XML schema.
- *
+ *
* @author Patrick Peck
* @version $Id$
*/
public class VerifyXMLSignatureResponseBuilder {
- private static final String MOA_NS_URI = Constants.MOA_NS_URI;
-
- /** The XML document containing the response element. */
- private Document responseDoc;
- /** The response VerifyXMLSignatureResponse
DOM element. */
- private Element responseElem;
-
- private boolean includeSigningTime = false;
- /**
- * Create a new VerifyXMLSignatureResponseBuilder
:
- *
- * @throws MOASystemException
- * An error occurred setting up the resulting XML document.
- */
- public VerifyXMLSignatureResponseBuilder() throws MOASystemException {
- responseDoc = ResponseBuilderUtils.createResponse("VerifyXMLSignatureResponse");
- responseElem = responseDoc.getDocumentElement();
- }
-
- public VerifyXMLSignatureResponseBuilder(boolean includeSigningTime) throws MOASystemException {
- responseDoc = ResponseBuilderUtils.createResponse("VerifyXMLSignatureResponse");
- responseElem = responseDoc.getDocumentElement();
- this.includeSigningTime = includeSigningTime;
- }
-
- public VerifyXMLSignatureResponseBuilder(Document responseDoc, String name, boolean includeSigningTime) throws MOASystemException {
- this.responseDoc = responseDoc;
- responseElem = responseDoc.createElementNS(MOA_NS_URI, name);
- this.includeSigningTime = includeSigningTime;
- }
-
- public Element buildElement(VerifyXMLSignatureResponse response) throws MOAApplicationException {
- this.build(response);
- return responseElem;
- }
-
- /**
- * Build a document containing a VerifyXMLSignatureResponse
DOM
- * element being the XML representation of the given
- * VerifyXMLSignatureResponse
API object.
- *
- * @param response
- * The VerifyXMLSignatureResponse
to convert to XML.
- * @return A document containing the VerifyXMLSignatureResponse
- * DOM element.
- * @throws MOAApplicationException
- * An error occurred building the response.
- */
- public Document build(VerifyXMLSignatureResponse response) throws MOAApplicationException {
-
- Iterator iter;
- List responseData;
-
- // add the SignerInfo
- ResponseBuilderUtils.addSignerInfo(responseDoc, responseElem, response.getSignerInfo().getSignerCertificate(),
- response.getSignerInfo().isQualifiedCertificate(), response.getSignerInfo().getQCSource(),
- response.getSignerInfo().isPublicAuthority(), response.getSignerInfo().getPublicAuhtorityID(),
- response.getSignerInfo().isSSCD(), response.getSignerInfo().getSSCDSource(),
- response.getSignerInfo().getIssuerCountryCode(),
- response.getSignerInfo().getTslInfos());
-
- if(this.includeSigningTime) {
- ResponseBuilderUtils.addSigningTime(responseDoc,
- responseElem, response.getSignerInfo().getSigningTime());
- }
-
- // add HashInputData elements
- responseData = response.getHashInputDatas();
- if (responseData != null && !responseData.isEmpty()) {
- for (iter = responseData.iterator(); iter.hasNext();) {
- InputData inputData = (InputData) iter.next();
- addContent("HashInputData", inputData);
- }
- }
-
- // add ReferenceInputData elements
- responseData = response.getReferenceInputDatas();
- if (responseData != null && !responseData.isEmpty()) {
- for (iter = responseData.iterator(); iter.hasNext();) {
- InputData inputData = (InputData) iter.next();
- addContent("ReferenceInputData", inputData);
- }
- }
-
- //add hash algorithm
- ResponseBuilderUtils.addSignatureAlgorithm(responseDoc, responseElem, response.getSignatureAlgorithm());
-
- // add the SignatureCheck
- addReferencesCheckResult("SignatureCheck", response.getSignatureCheck());
-
- // add the SignatureManifestCheck
- if (response.getSignatureManifestCheck() != null) {
- addReferencesCheckResult("SignatureManifestCheck", response.getSignatureManifestCheck());
- }
-
- // add the XMLDsigManifestChecks
- responseData = response.getXMLDsigManifestChecks();
- if (responseData != null && !responseData.isEmpty()) {
- for (iter = responseData.iterator(); iter.hasNext();) {
- ManifestRefsCheckResult checkResult = (ManifestRefsCheckResult) iter.next();
- addManifestRefsCheckResult("XMLDSIGManifestCheck", checkResult);
- }
- }
-
- // add the CertificateCheck
- ResponseBuilderUtils.addCodeInfoElement(responseDoc, responseElem, "CertificateCheck",
- response.getCertificateCheck().getCode(), response.getCertificateCheck().getInfo());
-
- if (response.getAdESFormResults() != null) {
-
- Iterator formIterator = response.getAdESFormResults().iterator();
-
- while (formIterator.hasNext()) {
- AdESFormResults adESFormResult = (AdESFormResults) formIterator.next();
- // add the CertificateCheck
- ResponseBuilderUtils.addFormCheckElement(responseDoc, responseElem, "FormCheckResult",
- adESFormResult.getCode().intValue(), adESFormResult.getName());
-
- }
- }
-
- if(response.getExtendedCertificateCheck() != null) {
- ResponseBuilderUtils.addExtendendResult(responseDoc, responseElem, response.getExtendedCertificateCheck());
- }
-
- return responseDoc;
- }
-
- /**
- * Add an element of type ContentBaseType
to the response.
- *
- * @param elementName
- * The name of the element.
- *
- * @param inputData
- * The InputData
to add. Based on the type of
- *
- * the InputData
, either a
- * Base64Content
element or a
- * XMLContent
subelement will be added. An
- * InputDataBinaryImpl
will be added as a Base64Content
- * child element. AnInputDataXMLImpl
will be added
- * as
- * XMLContent
child element.
- *
- * @throws MOAApplicationException
- * An error occurred adding the content.
- */
- private void addContent(String elementName, InputData inputData) throws MOAApplicationException {
-
- Element contentElem = responseDoc.createElementNS(MOA_NS_URI, elementName);
-
- contentElem.setAttributeNS(null, "PartOf", inputData.getPartOf());
- if (inputData.getReferringReferenceNumber() != InputData.REFERER_NONE_)
- contentElem.setAttributeNS(null, "ReferringSigReference",
- Integer.toString(inputData.getReferringReferenceNumber()));
-
- if (MiscUtil.isNotEmpty(inputData.getHashAlgorithm())) {
- contentElem.setAttribute("HashAlgorithm", inputData.getHashAlgorithm());
-
- }
-
- switch (inputData.getContentType()) {
- case Content.XML_CONTENT:
- ContentXML contentXml = (ContentXML) inputData;
- NodeList nodes = contentXml.getXMLContent();
- Element xmlElem;
- int i;
-
- xmlElem = responseDoc.createElementNS(MOA_NS_URI, "XMLContent");
- // xmlElem.setAttributeNS(XML_NS_URI, "xml:space", "preserve");
- xmlElem.setAttribute("xml:space", "preserve");
-
- for (i = 0; i < nodes.getLength(); i++) {
- xmlElem.appendChild(responseDoc.importNode(nodes.item(i), true));
- }
- contentElem.appendChild(xmlElem);
- responseElem.appendChild(contentElem);
- break;
- case Content.BINARY_CONTENT:
- Element binaryElem = responseDoc.createElementNS(MOA_NS_URI, "Base64Content");
- ContentBinary contentBinary = (ContentBinary) inputData;
- String base64Str;
-
- try {
- base64Str = Base64Utils.encode(contentBinary.getBinaryContent());
- } catch (IOException e) {
- throw new MOAApplicationException("2200", null, e);
- }
- binaryElem.appendChild(responseDoc.createTextNode(base64Str));
- contentElem.appendChild(binaryElem);
- responseElem.appendChild(contentElem);
- break;
- }
-
- }
-
- /**
- * Add a ReferencesCheckResult
to the response.
- *
- * @param elementName
- * The DOM element name to use.
- * @param checkResult
- * The ReferencesCheckResult
to add.
- */
- private void addReferencesCheckResult(String elementName, ReferencesCheckResult checkResult) {
-
- NodeList info = null;
-
- if (checkResult.getInfo() != null) {
- DocumentFragment fragment = responseDoc.createDocumentFragment();
- NodeList anyOtherInfo = checkResult.getInfo().getAnyOtherInfo();
- int[] failedReferences = checkResult.getInfo().getFailedReferences();
-
- if (anyOtherInfo != null) {
- addAnyOtherInfo(fragment, checkResult.getInfo().getAnyOtherInfo());
- }
-
- if (failedReferences != null) {
- addFailedReferences(fragment, failedReferences);
- }
-
- info = fragment.getChildNodes();
- }
-
- ResponseBuilderUtils.addCodeInfoElement(responseDoc, responseElem, elementName, checkResult.getCode(), info);
-
- }
-
- /**
- * Add a ManifestRefsCheckResult
to the response.
- *
- * @param elementName
- * The DOM element name to use.
- * @param checkResult
- * The ManifestRefsCheckResult
to add.
- */
- private void addManifestRefsCheckResult(String elementName, ManifestRefsCheckResult checkResult) {
-
- DocumentFragment fragment = responseDoc.createDocumentFragment();
- NodeList anyOtherInfo = checkResult.getInfo().getAnyOtherInfo();
- int[] failedReferences = checkResult.getInfo().getFailedReferences();
- Element referringSigRefElem;
- String referringSigRefStr;
-
- // add any other elements
- if (anyOtherInfo != null) {
- addAnyOtherInfo(fragment, checkResult.getInfo().getAnyOtherInfo());
- }
-
- // add the failed references
- if (failedReferences != null) {
- addFailedReferences(fragment, failedReferences);
- }
-
- // add the ReferringSigReference
- referringSigRefElem = responseDoc.createElementNS(MOA_NS_URI, "ReferringSigReference");
- referringSigRefStr = Integer.toString(checkResult.getInfo().getReferringSignatureReference());
- referringSigRefElem.appendChild(responseDoc.createTextNode(referringSigRefStr));
- fragment.appendChild(referringSigRefElem);
-
- // add XMLDSIGManifestCheckResult to the response
- ResponseBuilderUtils.addCodeInfoElement(responseDoc, responseElem, elementName, checkResult.getCode(),
- fragment.getChildNodes());
- }
-
- /**
- * Add arbitrary XML content to a DOM DocumentFragment
.
- *
- * @param fragment
- * The fragment to add the XML content to.
- * @param anyOtherInfo
- * The XML content to add.
- */
- private void addAnyOtherInfo(DocumentFragment fragment, NodeList anyOtherInfo) {
-
- int i;
-
- for (i = 0; i < anyOtherInfo.getLength(); i++) {
- fragment.appendChild(responseDoc.importNode(anyOtherInfo.item(i), true));
- }
- }
-
- /**
- * Add the failed references as FailedReference
DOM elements to
- * the fragment.
- *
- * @param fragment
- * The DOM document fragment to add the
- * FailedReference
elements to.
- * @param failedReferences
- * The indexes of the failed references.
- */
- private void addFailedReferences(DocumentFragment fragment, int[] failedReferences) {
- Element failedReferenceElem;
- int i;
-
- for (i = 0; i < failedReferences.length; i++) {
- failedReferenceElem = responseDoc.createElementNS(MOA_NS_URI, "FailedReference");
- failedReferenceElem.appendChild(responseDoc.createTextNode(Integer.toString(failedReferences[i])));
- fragment.appendChild(failedReferenceElem);
- }
- }
+ private static final String MOA_NS_URI = Constants.MOA_NS_URI;
+
+ /** The XML document containing the response element. */
+ private final Document responseDoc;
+ /** The response VerifyXMLSignatureResponse
DOM element. */
+ private final Element responseElem;
+
+ private boolean includeSigningTime = false;
+
+ /**
+ * Create a new VerifyXMLSignatureResponseBuilder
:
+ *
+ * @throws MOASystemException An error occurred setting up the resulting XML
+ * document.
+ */
+ public VerifyXMLSignatureResponseBuilder() throws MOASystemException {
+ responseDoc = ResponseBuilderUtils.createResponse("VerifyXMLSignatureResponse");
+ responseElem = responseDoc.getDocumentElement();
+ }
+
+ public VerifyXMLSignatureResponseBuilder(boolean includeSigningTime) throws MOASystemException {
+ responseDoc = ResponseBuilderUtils.createResponse("VerifyXMLSignatureResponse");
+ responseElem = responseDoc.getDocumentElement();
+ this.includeSigningTime = includeSigningTime;
+ }
+
+ public VerifyXMLSignatureResponseBuilder(Document responseDoc, String name, boolean includeSigningTime)
+ throws MOASystemException {
+ this.responseDoc = responseDoc;
+ responseElem = responseDoc.createElementNS(MOA_NS_URI, name);
+ this.includeSigningTime = includeSigningTime;
+ }
+
+ public Element buildElement(VerifyXMLSignatureResponse response) throws MOAApplicationException {
+ this.build(response);
+ return responseElem;
+ }
+
+ /**
+ * Build a document containing a VerifyXMLSignatureResponse
DOM
+ * element being the XML representation of the given
+ * VerifyXMLSignatureResponse
API object.
+ *
+ * @param response The VerifyXMLSignatureResponse
to convert to
+ * XML.
+ * @return A document containing the VerifyXMLSignatureResponse
DOM
+ * element.
+ * @throws MOAApplicationException An error occurred building the response.
+ */
+ public Document build(VerifyXMLSignatureResponse response) throws MOAApplicationException {
+
+ Iterator iter;
+ List responseData;
+
+ // add the SignerInfo
+ ResponseBuilderUtils.addSignerInfo(responseDoc, responseElem, response.getSignerInfo()
+ .getSignerCertificate(),
+ response.getSignerInfo().isQualifiedCertificate(), response.getSignerInfo().getQCSource(),
+ response.getSignerInfo().isPublicAuthority(), response.getSignerInfo().getPublicAuhtorityID(),
+ response.getSignerInfo().isSSCD(), response.getSignerInfo().getSSCDSource(),
+ response.getSignerInfo().getIssuerCountryCode(),
+ response.getSignerInfo().getTslInfos());
+
+ if (this.includeSigningTime) {
+ ResponseBuilderUtils.addSigningTime(responseDoc,
+ responseElem, response.getSignerInfo().getSigningTime());
+ }
+
+ // add HashInputData elements
+ responseData = response.getHashInputDatas();
+ if (responseData != null && !responseData.isEmpty()) {
+ for (iter = responseData.iterator(); iter.hasNext();) {
+ final InputData inputData = (InputData) iter.next();
+ addContent("HashInputData", inputData);
+ }
+ }
+
+ // add ReferenceInputData elements
+ responseData = response.getReferenceInputDatas();
+ if (responseData != null && !responseData.isEmpty()) {
+ for (iter = responseData.iterator(); iter.hasNext();) {
+ final InputData inputData = (InputData) iter.next();
+ addContent("ReferenceInputData", inputData);
+ }
+ }
+
+ // add hash algorithm
+ ResponseBuilderUtils.addSignatureAlgorithm(responseDoc, responseElem, response.getSignatureAlgorithm());
+
+ // add the SignatureCheck
+ addReferencesCheckResult("SignatureCheck", response.getSignatureCheck());
+
+ // add the SignatureManifestCheck
+ if (response.getSignatureManifestCheck() != null) {
+ addReferencesCheckResult("SignatureManifestCheck", response.getSignatureManifestCheck());
+ }
+
+ // add the XMLDsigManifestChecks
+ responseData = response.getXMLDsigManifestChecks();
+ if (responseData != null && !responseData.isEmpty()) {
+ for (iter = responseData.iterator(); iter.hasNext();) {
+ final ManifestRefsCheckResult checkResult = (ManifestRefsCheckResult) iter.next();
+ addManifestRefsCheckResult("XMLDSIGManifestCheck", checkResult);
+ }
+ }
+
+ // add the CertificateCheck
+ ResponseBuilderUtils.addCodeInfoElement(responseDoc, responseElem, "CertificateCheck",
+ response.getCertificateCheck().getCode(), response.getCertificateCheck().getInfo());
+
+ if (response.getAdESFormResults() != null) {
+
+ final Iterator formIterator = response.getAdESFormResults().iterator();
+
+ while (formIterator.hasNext()) {
+ final AdESFormResults adESFormResult = (AdESFormResults) formIterator.next();
+ // add the CertificateCheck
+ ResponseBuilderUtils.addFormCheckElement(responseDoc, responseElem, "FormCheckResult",
+ adESFormResult.getCode().intValue(), adESFormResult.getName());
+
+ }
+ }
+
+ if (response.getExtendedCertificateCheck() != null) {
+ ResponseBuilderUtils.addExtendendResult(responseDoc, responseElem, response
+ .getExtendedCertificateCheck());
+ }
+
+ return responseDoc;
+ }
+
+ /**
+ * Add an element of type ContentBaseType
to the response.
+ *
+ * @param elementName The name of the element.
+ *
+ * @param inputData The InputData
to add. Based on the type of
+ *
+ * the InputData
, either a
+ * Base64Content
element or a
+ * XMLContent
subelement will be added. An
+ *
+ * InputDataBinaryImpl
will be added as a Base64Content
+ * child element. AnInputDataXMLImpl
will be
+ * added as
+ * XMLContent
child element.
+ *
+ * @throws MOAApplicationException An error occurred adding the content.
+ */
+ private void addContent(String elementName, InputData inputData) throws MOAApplicationException {
+
+ final Element contentElem = responseDoc.createElementNS(MOA_NS_URI, elementName);
+
+ contentElem.setAttributeNS(null, "PartOf", inputData.getPartOf());
+ if (inputData.getReferringReferenceNumber() != InputData.REFERER_NONE_) {
+ contentElem.setAttributeNS(null, "ReferringSigReference",
+ Integer.toString(inputData.getReferringReferenceNumber()));
+ }
+
+ if (MiscUtil.isNotEmpty(inputData.getHashAlgorithm())) {
+ contentElem.setAttribute("HashAlgorithm", inputData.getHashAlgorithm());
+
+ }
+
+ switch (inputData.getContentType()) {
+ case Content.XML_CONTENT:
+ final ContentXML contentXml = (ContentXML) inputData;
+ final NodeList nodes = contentXml.getXMLContent();
+ Element xmlElem;
+ int i;
+
+ xmlElem = responseDoc.createElementNS(MOA_NS_URI, "XMLContent");
+ // xmlElem.setAttributeNS(XML_NS_URI, "xml:space", "preserve");
+ xmlElem.setAttribute("xml:space", "preserve");
+
+ for (i = 0; i < nodes.getLength(); i++) {
+ xmlElem.appendChild(responseDoc.importNode(nodes.item(i), true));
+ }
+ contentElem.appendChild(xmlElem);
+ responseElem.appendChild(contentElem);
+ break;
+ case Content.BINARY_CONTENT:
+ final Element binaryElem = responseDoc.createElementNS(MOA_NS_URI, "Base64Content");
+ final ContentBinary contentBinary = (ContentBinary) inputData;
+ String base64Str;
+
+ try {
+ base64Str = Base64Utils.encode(contentBinary.getBinaryContent());
+ } catch (final IOException e) {
+ throw new MOAApplicationException("2200", null, e);
+ }
+ binaryElem.appendChild(responseDoc.createTextNode(base64Str));
+ contentElem.appendChild(binaryElem);
+ responseElem.appendChild(contentElem);
+ break;
+ }
+
+ }
+
+ /**
+ * Add a ReferencesCheckResult
to the response.
+ *
+ * @param elementName The DOM element name to use.
+ * @param checkResult The ReferencesCheckResult
to add.
+ */
+ private void addReferencesCheckResult(String elementName, ReferencesCheckResult checkResult) {
+
+ NodeList info = null;
+
+ if (checkResult.getInfo() != null) {
+ final DocumentFragment fragment = responseDoc.createDocumentFragment();
+ final NodeList anyOtherInfo = checkResult.getInfo().getAnyOtherInfo();
+ final int[] failedReferences = checkResult.getInfo().getFailedReferences();
+
+ if (anyOtherInfo != null) {
+ addAnyOtherInfo(fragment, checkResult.getInfo().getAnyOtherInfo());
+ }
+
+ if (failedReferences != null) {
+ addFailedReferences(fragment, failedReferences);
+ }
+
+ info = fragment.getChildNodes();
+ }
+
+ ResponseBuilderUtils.addCodeInfoElement(responseDoc, responseElem, elementName, checkResult.getCode(),
+ info);
+
+ }
+
+ /**
+ * Add a ManifestRefsCheckResult
to the response.
+ *
+ * @param elementName The DOM element name to use.
+ * @param checkResult The ManifestRefsCheckResult
to add.
+ */
+ private void addManifestRefsCheckResult(String elementName, ManifestRefsCheckResult checkResult) {
+
+ final DocumentFragment fragment = responseDoc.createDocumentFragment();
+ final NodeList anyOtherInfo = checkResult.getInfo().getAnyOtherInfo();
+ final int[] failedReferences = checkResult.getInfo().getFailedReferences();
+ Element referringSigRefElem;
+ String referringSigRefStr;
+
+ // add any other elements
+ if (anyOtherInfo != null) {
+ addAnyOtherInfo(fragment, checkResult.getInfo().getAnyOtherInfo());
+ }
+
+ // add the failed references
+ if (failedReferences != null) {
+ addFailedReferences(fragment, failedReferences);
+ }
+
+ // add the ReferringSigReference
+ referringSigRefElem = responseDoc.createElementNS(MOA_NS_URI, "ReferringSigReference");
+ referringSigRefStr = Integer.toString(checkResult.getInfo().getReferringSignatureReference());
+ referringSigRefElem.appendChild(responseDoc.createTextNode(referringSigRefStr));
+ fragment.appendChild(referringSigRefElem);
+
+ // add XMLDSIGManifestCheckResult to the response
+ ResponseBuilderUtils.addCodeInfoElement(responseDoc, responseElem, elementName, checkResult.getCode(),
+ fragment.getChildNodes());
+ }
+
+ /**
+ * Add arbitrary XML content to a DOM DocumentFragment
.
+ *
+ * @param fragment The fragment to add the XML content to.
+ * @param anyOtherInfo The XML content to add.
+ */
+ private void addAnyOtherInfo(DocumentFragment fragment, NodeList anyOtherInfo) {
+
+ int i;
+
+ for (i = 0; i < anyOtherInfo.getLength(); i++) {
+ fragment.appendChild(responseDoc.importNode(anyOtherInfo.item(i), true));
+ }
+ }
+
+ /**
+ * Add the failed references as FailedReference
DOM elements to the
+ * fragment.
+ *
+ * @param fragment The DOM document fragment to add the
+ * FailedReference
elements to.
+ * @param failedReferences The indexes of the failed references.
+ */
+ private void addFailedReferences(DocumentFragment fragment, int[] failedReferences) {
+ Element failedReferenceElem;
+ int i;
+
+ for (i = 0; i < failedReferences.length; i++) {
+ failedReferenceElem = responseDoc.createElementNS(MOA_NS_URI, "FailedReference");
+ failedReferenceElem.appendChild(responseDoc.createTextNode(Integer.toString(failedReferences[i])));
+ fragment.appendChild(failedReferenceElem);
+ }
+ }
}
--
cgit v1.2.3