aboutsummaryrefslogtreecommitdiff
path: root/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java
diff options
context:
space:
mode:
Diffstat (limited to 'spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java')
-rw-r--r--spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java288
1 files changed, 0 insertions, 288 deletions
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java b/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java
deleted file mode 100644
index 319d3ac9d..000000000
--- a/spss.server/src/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java
+++ /dev/null
@@ -1,288 +0,0 @@
-package at.gv.egovernment.moa.spss.api.xmlbind;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.traversal.NodeIterator;
-
-import at.gv.egovernment.moa.util.BoolUtils;
-import at.gv.egovernment.moa.util.Constants;
-import at.gv.egovernment.moa.util.DOMUtils;
-import at.gv.egovernment.moa.util.XPathUtils;
-
-import at.gv.egovernment.moa.spss.MOAApplicationException;
-import at.gv.egovernment.moa.spss.api.SPSSFactory;
-import at.gv.egovernment.moa.spss.api.common.Content;
-import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureEnvironmentProfile;
-import at.gv.egovernment.moa.spss.api.xmlsign.CreateSignatureInfo;
-import at.gv.egovernment.moa.spss.api.xmlsign.CreateTransformsInfoProfile;
-import at.gv.egovernment.moa.spss.api.xmlsign.CreateXMLSignatureRequest;
-import at.gv.egovernment.moa.spss.api.xmlsign.DataObjectInfo;
-import at.gv.egovernment.moa.spss.api.xmlsign.SingleSignatureInfo;
-
-/**
- * A parser to parse <code>CreateXMLSignatureRequest</code> DOM trees into
- * <code>CreateXMLSignatureRequest</code> API objects.
- *
- * @author Patrick Peck
- * @version $Id$
- */
-public class CreateXMLSignatureRequestParser {
-
- //
- // XPath expresssions to select elements in the CreateXMLSignatureRequest
- //
- private static final String MOA = Constants.MOA_PREFIX + ":";
- private static final String KEY_IDENTIFIER_XPATH =
- "/" + MOA + "CreateXMLSignatureRequest/" + MOA + "KeyIdentifier";
- private static final String SINGLE_SIGNATURE_INFO_XPATH =
- "/" + 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";
- private static final String CREATE_TRANSFORMS_INFO_PROFILE_XPATH =
- (MOA + "CreateTransformsInfoProfile | ")
- + (MOA + "CreateTransformsInfoProfileID");
- private static final String CREATE_SIGNATURE_ENVIRONMENT_XPATH =
- MOA + "CreateSignatureEnvironment";
- private static final String CREATE_SIGNATURE_ENVIRONMENT_PROFILE_XPATH =
- (MOA + "CreateSignatureEnvironmentProfile | ")
- + (MOA + "CreateSignatureEnvironmentProfileID");
- private static final String SL_CONFORM_ATTR_NAME = "SecurityLayerConformity";
-
- /** The factory to create API objects. */
- private SPSSFactory factory;
-
- /**
- * Create a new <code>CreateXMLSignatureRequestParser</code>.
- */
- public CreateXMLSignatureRequestParser() {
- this.factory = SPSSFactory.getInstance();
- }
-
- /**
- * Parse a <code>CreateXMLSignatureRequest</code> DOM element, as defined
- * by the MOA schema.
- *
- * @param requestElem The <code>CreateXMLSignatureRequest</code> to parse. The
- * request must have been successfully parsed against the schema for this
- * method to succeed.
- * @return A <code>CreateXMLSignatureRequest</code> API object containing
- * the data from the DOM element.
- * @throws MOAApplicationException An error occurred parsing the request.
- */
- public CreateXMLSignatureRequest parse(Element requestElem)
- throws MOAApplicationException {
-
- List singleSignatureInfos = parseSingleSignatureInfos(requestElem);
- String keyIdentifier =
- XPathUtils.getElementValue(requestElem, KEY_IDENTIFIER_XPATH, null);
-
- return factory.createCreateXMLSignatureRequest(
- keyIdentifier,
- singleSignatureInfos);
- }
-
- /**
- * Parse all <code>SingleSignatureInfo</code> elements of the
- * <code>CreateXMLSignatureRequest</code>.
- *
- * @param requestElem The <code>CreateXMLSignatureRequest</code> to parse.
- * @return A <code>List</code> of <code>SingleSignatureInfo</code> API
- * objects.
- * @throws MOAApplicationException An error occurred parsing on of the
- * <code>SingleSignatureInfo</code> elements.
- */
- private List parseSingleSignatureInfos(Element requestElem)
- throws MOAApplicationException {
-
- List singleSignatureInfos = new ArrayList();
- NodeIterator sigInfoElems =
- XPathUtils.selectNodeIterator(requestElem, SINGLE_SIGNATURE_INFO_XPATH);
- Element sigInfoElem;
-
- while ((sigInfoElem = (Element) sigInfoElems.nextNode()) != null) {
- singleSignatureInfos.add(parseSingleSignatureInfo(sigInfoElem));
- }
-
- return singleSignatureInfos;
- }
-
- /**
- * Parse a <code>SingleSignatureInfo</code> DOM element.
- *
- * @param sigInfoElem The <code>SingleSignatureInfo</code> DOM element to
- * parse.
- * @return A <code>SingleSignatureInfo</code> API object containing the
- * information of <code>sigInfoElem</code>.
- * @throws MOAApplicationException An error occurred parsing the
- * <code>SingleSignatureInfo</code>.
- */
- private SingleSignatureInfo parseSingleSignatureInfo(Element sigInfoElem)
- throws MOAApplicationException {
-
- List dataObjectInfos = parseDataObjectInfos(sigInfoElem);
- CreateSignatureInfo createSignatureInfo =
- parseCreateSignatureInfo(sigInfoElem);
- boolean securityLayerConform;
-
- if (sigInfoElem.hasAttribute(SL_CONFORM_ATTR_NAME)) {
- securityLayerConform =
- BoolUtils.valueOf(sigInfoElem.getAttribute(SL_CONFORM_ATTR_NAME));
- } else {
- securityLayerConform = true;
- }
-
- return factory.createSingleSignatureInfo(
- dataObjectInfos,
- createSignatureInfo,
- securityLayerConform);
- }
-
- /**
- * Parse the <code>DataObjectInfo</code> DOM elements contained in the given
- * <code>SingleSignatureInfo</code> DOM element.
- *
- * @param sigInfoElem The <code>SingleSignatureInfo</code> DOM element
- * whose <code>DataObjectInfo</code>s to parse.
- * @return A <code>List</code> of <code>DataObjectInfo</code> API objects
- * containing the data from the <code>DataObjectInfo</code> DOM elements.
- * @throws MOAApplicationException An error occurred parsing one of the
- * <code>DataObjectInfo</code>s.
- */
- private List parseDataObjectInfos(Element sigInfoElem)
- throws MOAApplicationException {
-
- List dataObjectInfos = new ArrayList();
- NodeIterator dataObjInfoElems =
- XPathUtils.selectNodeIterator(sigInfoElem, DATA_OBJECT_INFO_XPATH);
- Element dataObjInfoElem;
-
- while ((dataObjInfoElem = (Element) dataObjInfoElems.nextNode()) != null) {
- dataObjectInfos.add(parseDataObjectInfo(dataObjInfoElem));
- }
- return dataObjectInfos;
- }
-
- /**
- * Parse a <code>DataObjectInfo</code> DOM element.
- *
- * @param dataObjInfoElem The <code>DataObjectInfo</code> DOM element to
- * parse.
- * @return A <code>DataObjectInfo</code> API element containing the data
- * from <code>dataObjInfoElem</code>.
- * @throws MOAApplicationException An error occurred parsing the
- * <code>DataObjectInfo</code>.
- */
- 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);
- boolean childOfManifest;
-
- if (dataObjInfoElem.hasAttribute("ChildOfManifest")) {
- childOfManifest =
- BoolUtils.valueOf(dataObjInfoElem.getAttribute("ChildOfManifest"));
- } else {
- childOfManifest = false;
- }
-
- return factory.createDataObjectInfo(
- structure,
- childOfManifest,
- dataObject,
- createTransformsInfoProfile);
- }
-
- /**
- * Parse a <code>CreateTransformsInfoProfile</code> DOM element.
- *
- * @param dataObjInfoElem The <code>DataObjectInfo</code> DOM element
- * containing the <code>CreateTransformsInfoProfile</code>.
- * @return The <code>CreateTransformsInfoProfile</code> API object containing
- * the profile found in <code>dataObjInfoElem</code>.
- * @throws MOAApplicationException An error occurred parsing the
- * <code>CreateTransformsInfoProfile</code>.
- */
- private CreateTransformsInfoProfile parseCreateTransformsInfoProfile(Element dataObjInfoElem)
- throws MOAApplicationException {
-
- Element profileElem =
- (Element) XPathUtils.selectSingleNode(
- dataObjInfoElem,
- CREATE_TRANSFORMS_INFO_PROFILE_XPATH);
-
- if ("CreateTransformsInfoProfile".equals(profileElem.getLocalName())) {
- ProfileParser profileParser = new ProfileParser();
- return profileParser.parseCreateTransformsInfoProfile(profileElem);
-
- } else {
- String profileID = DOMUtils.getText(profileElem);
- return factory.createCreateTransformsInfoProfile(profileID);
- }
- }
-
- /**
- * Parse the <code>CreateSignatureInfo</code> DOM element contained in
- * a <code>SingleSignatureInfo</code>.
- *
- * @param sigInfoElem The <code>SingleSignatureInfo</code> DOM element
- * containing the <code>CreateSignatureInfo</code> to be parsed.
- * @return A <code>CreateSignatureInfo</code> API object containing the
- * data from the <code>CreateSignatureInfo</code> DOM element, or
- * <code>null</code>, if none was found.
- */
- private CreateSignatureInfo parseCreateSignatureInfo(Element sigInfoElem) {
- 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);
-
- return factory.createCreateSignatureInfo(environment, environmentProfile);
- } else {
- return null;
- }
- }
-
- /**
- * Parse the <code>CreateSignatureEnvironmentProfile</code> contained in
- * the given <code>CreateSignatureInfo</code> DOM element.
- *
- * @param createInfoElem <code>CreateSignatureInfo</code> DOM element to
- * parse.
- * @return The <code>CreateSignatureEnvironmentProfile</code> contained
- * in the given <code>CreateSignatureInfo</code> DOM element..
- */
- private CreateSignatureEnvironmentProfile parseCreateSignatureEnvironmentProfile(Element createInfoElem) {
- Element profileElem =
- (Element) XPathUtils.selectSingleNode(
- createInfoElem,
- CREATE_SIGNATURE_ENVIRONMENT_PROFILE_XPATH);
-
- if ("CreateSignatureEnvironmentProfile"
- .equals(profileElem.getLocalName())) {
- ProfileParser profileParser = new ProfileParser();
- return profileParser.parseCreateSignatureEnvironmentProfile(profileElem);
- } else {
- String profileID = DOMUtils.getText(profileElem);
- return factory.createCreateSignatureEnvironmentProfile(profileID);
- }
- }
-
-} \ No newline at end of file