aboutsummaryrefslogtreecommitdiff
path: root/moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/ProfileParser.java
diff options
context:
space:
mode:
Diffstat (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/ProfileParser.java')
-rw-r--r--moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/ProfileParser.java246
1 files changed, 123 insertions, 123 deletions
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 <code>CreateTransformsInfoProfile</code> DOM element.
- *
- * @param profileElem The <code>CreateTransformsInfoProfile</code> element
- * to parse.
+ *
+ * @param profileElem The <code>CreateTransformsInfoProfile</code> element to
+ * parse.
* @return The <code>CreateTransformsInfoProfile</code> API object containing
- * the data from the <code>profileElem</code>.
- * @throws MOAApplicationException An error occurred parsing the DOM element.
+ * the data from the <code>profileElem</code>.
+ * @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 <code>CreateTransformsInfo</code> DOM element contained in a
+ * Parse the <code>CreateTransformsInfo</code> DOM element contained in a
* <code>CreateTransformsInfoProfile</code>.
- *
- * @param profileElem The <code>CreateTransformsInfoProfile</code> DOM
- * element containing the <code>CreateTransformsInfo</code>.
- * @return The <code>CreateTransformsInfo</code> API object containinig the
- * data from the <code>CreateTransformsInfo</code> DOM element.
+ *
+ * @param profileElem The <code>CreateTransformsInfoProfile</code> DOM element
+ * containing the <code>CreateTransformsInfo</code>.
+ * @return The <code>CreateTransformsInfo</code> API object containinig the data
+ * from the <code>CreateTransformsInfo</code> DOM element.
* @throws MOAApplicationException An error occurred parsing the
- * <code>CreateTransformsInfo</code> DOM element.
+ * <code>CreateTransformsInfo</code> 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 <code>CreateSignatureEnvironmentProfile</code> DOM element.
- *
- * @param profileElem The <code>CreateSignatureEnvironmentProfile</code>
- * DOM element to parse.
+ *
+ * @param profileElem The <code>CreateSignatureEnvironmentProfile</code> DOM
+ * element to parse.
* @return The <code>CreateSignatureEnvironmentProfile</code> API object
- * containing the data from the <code>profileElem</code>.
+ * containing the data from the <code>profileElem</code>.
*/
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 <code>CreateSignatureLocation</code> DOM element contained in
- * a <code>CreateSignatureEnvironmentProfile</code>.
- *
+ * Parse a <code>CreateSignatureLocation</code> DOM element contained in a
+ * <code>CreateSignatureEnvironmentProfile</code>.
+ *
* @param profileElem The <code>CreateSignatureEnvironmentProfile</code> DOM
- * element containing the <code>CreateSignatureLocation</code>.
- * @return The <code>CreateSignatureLocation</code> API object containing
- * the data from the <code>CreateSignatureLocation</code> DOM element.
+ * element containing the
+ * <code>CreateSignatureLocation</code>.
+ * @return The <code>CreateSignatureLocation</code> API object containing the
+ * data from the <code>CreateSignatureLocation</code> 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 <code>Supplement</code> DOM elements contained in a given
- * parent DOM element.
- *
+ * Parse all <code>Supplement</code> DOM elements contained in a given parent
+ * DOM element.
+ *
* @param supplementsParentElem The DOM element being the parent of the
- * <code>Supplement</code>s.
- * @return A <code>List</code> of <code>Supplement</code> API objects
- * containing the data from the <code>Supplement</code> DOM elements.
+ * <code>Supplement</code>s.
+ * @return A <code>List</code> of <code>Supplement</code> API objects containing
+ * the data from the <code>Supplement</code> 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 <code>SupplementProfile</code> DOM element.
- *
+ *
* @param profileElem The <code>SupplementProfile</code> DOM element to parse.
- * @return The <code>SupplementProfile</code> API object containing the
- * data from the <code>SupplementProfile</code> DOM element.
+ * @return The <code>SupplementProfile</code> API object containing the data
+ * from the <code>SupplementProfile</code> DOM element.
*/
public SupplementProfile parseSupplementProfile(Element profileElem) {
- XMLDataObjectAssociation supplementProfile =
- RequestParserUtils.parseXMLDataObjectAssociation(profileElem);
+ final XMLDataObjectAssociation supplementProfile =
+ RequestParserUtils.parseXMLDataObjectAssociation(profileElem);
return factory.createSupplementProfile(supplementProfile);
}
/**
- * Parse a <code>VerifyTransformsInfoProfile</code> DOM element.
- *
- * @param profileElem The <code>VerifyTransformsInfoProfile</code> DOM
- * element to parse.
- * @return A <code>VerifyTransformsInfoProfile</code> API object containing
- * the information from the <code>VerifyTransformsInfoProfile</code> DOM
- * element.
+ * Parse a <code>VerifyTransformsInfoProfile</code> DOM element.
+ *
+ * @param profileElem The <code>VerifyTransformsInfoProfile</code> DOM element
+ * to parse.
+ * @return A <code>VerifyTransformsInfoProfile</code> API object containing the
+ * information from the <code>VerifyTransformsInfoProfile</code> DOM
+ * element.
* @throws MOAApplicationException An error occurred parsing the
- * <code>VerifyTransformsInfoProfile</code>.
+ * <code>VerifyTransformsInfoProfile</code>.
*/
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 <code>TransformParameter</code> DOM element.
- *
- * @param paramElem The <code>TransformParameter</code> DOM element to
- * parse.
+ *
+ * @param paramElem The <code>TransformParameter</code> DOM element to parse.
* @return The <code>TransformParameter</code> API object containing the
- * information from the <code>TransformParameter</code> DOM element.
+ * information from the <code>TransformParameter</code> DOM element.
* @throws MOAApplicationException An error occurred parsing the
- * <code>TransformParameter</code> DOM element.
+ * <code>TransformParameter</code> 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);
}
}