aboutsummaryrefslogtreecommitdiff
path: root/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/TransformParser.java
diff options
context:
space:
mode:
Diffstat (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/TransformParser.java')
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/TransformParser.java149
1 files changed, 71 insertions, 78 deletions
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 <code>Transform</code> DOM elements into their
- * MOA SPSS API representation.
- *
+ * A parser to parse XMLDsig <code>Transform</code> 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 <code>SPSSFactory</code> to use for creating new API objects.
*/
- private SPSSFactory factory = SPSSFactory.getInstance();
+ private final SPSSFactory factory = SPSSFactory.getInstance();
/**
* Parse an XMLDsig <code>Transforms</code> DOM element.
- *
+ *
* @param transformsElem The <code>Transforms</code> DOM element to parse.
- * @return A <code>List</code> of <code>Transform</code> API objects
- * containing the data from the individual <code>Transform</code> DOM
- * elements.
- * @throws MOAApplicationException An error occurred parsing the
- * <code>Transforms</code> DOM element.
+ * @return A <code>List</code> of <code>Transform</code> API objects containing
+ * the data from the individual <code>Transform</code> DOM elements.
+ * @throws MOAApplicationException An error occurred parsing the
+ * <code>Transforms</code> 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 <code>Transform</code> DOM element.
- *
+ *
* @param transformElem <code>Transform</code> DOM element to parse.
- * @return The <code>Transform</code> API object containing the data
- * from the <code>Transform</code> DOM element.
- * @throws MOAApplicationException An error occurred parsing the
- * <code>Transform</code> DOM element.
+ * @return The <code>Transform</code> API object containing the data from the
+ * <code>Transform</code> DOM element.
+ * @throws MOAApplicationException An error occurred parsing the
+ * <code>Transform</code> 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 <code>Transform</code> DOM element to parse.
* @return An <code>ExclusiveCanonicalizationTransform</code> API object
- * containing the data from the <code>transformElem</code>.
+ * containing the data from the <code>transformElem</code>.
*/
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 <code>XPath</code> type of <code>Transform</code>.
- *
+ *
* @param transformElem The <code>Transform</code> DOM element to parse.
* @return The <code>Transform</code> API object representation of the
- * <code>Transform</code> DOM element.
- * @throws MOAApplicationException An error occurred parsing the
- * <code>Transform</code> DOM element.
+ * <code>Transform</code> DOM element.
+ * @throws MOAApplicationException An error occurred parsing the
+ * <code>Transform</code> 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 <code>XPathFilter2</code> type of <code>Transform</code>.
- *
+ *
* @param transformElem The <code>Transform</code> DOM element to parse.
* @return The <code>Transform</code> API object representation of the
- * <code>Transform</code> DOM element.
- * @throws MOAApplicationException An error occurred parsing the
- * <code>Transform</code> DOM element.
+ * <code>Transform</code> DOM element.
+ * @throws MOAApplicationException An error occurred parsing the
+ * <code>Transform</code> 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 <code>XSLT</code> type of <code>Transform</code>.
- *
+ *
* @param transformElem The <code>Transform</code> DOM element to parse.
* @return The <code>Transform</code> API object representation of the
- * <code>Transform</code> DOM element.
- * @throws MOAApplicationException An error occurred parsing the
- * <code>Transform</code> DOM element.
+ * <code>Transform</code> DOM element.
+ * @throws MOAApplicationException An error occurred parsing the
+ * <code>Transform</code> 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);