diff options
author | Thomas <> | 2021-03-22 18:40:26 +0100 |
---|---|---|
committer | Thomas <> | 2021-03-22 18:40:26 +0100 |
commit | 578ad0d6bc408edf9e6c875156054374f5fd8337 (patch) | |
tree | 11ca8a04bd045e20d4b381fc76762d21b9e5abaa /moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java | |
parent | eb37b2c969c85ca966f0a0ad1d8b9941647a7f6a (diff) | |
download | moa-sig-578ad0d6bc408edf9e6c875156054374f5fd8337.tar.gz moa-sig-578ad0d6bc408edf9e6c875156054374f5fd8337.tar.bz2 moa-sig-578ad0d6bc408edf9e6c875156054374f5fd8337.zip |
change to EGIZ codestyle
Diffstat (limited to 'moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java')
-rw-r--r-- | moaSig/moa-sig-lib/src/main/java/at/gv/egovernment/moa/spss/api/xmlbind/CreateXMLSignatureRequestParser.java | 243 |
1 files changed, 120 insertions, 123 deletions
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 <code>CreateXMLSignatureRequest</code> DOM trees into * <code>CreateXMLSignatureRequest</code> 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 <code>CreateXMLSignatureRequestParser</code>. @@ -86,44 +85,43 @@ public class CreateXMLSignatureRequestParser { } /** - * Parse a <code>CreateXMLSignatureRequest</code> DOM element, as defined - * by the MOA schema. - * + * 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. + * 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 { + 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 <code>SingleSignatureInfo</code> elements of the + * 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. + * @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 { + 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 <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>. + * + * @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 { + 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 <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. + * + * @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. + * containing the data from the <code>DataObjectInfo</code> DOM + * elements. * @throws MOAApplicationException An error occurred parsing one of the - * <code>DataObjectInfo</code>s. + * <code>DataObjectInfo</code>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 <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>. + * + * @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>. + * <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); + 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 <code>CreateTransformsInfoProfile</code> DOM element. - * - * @param dataObjInfoElem The <code>DataObjectInfo</code> DOM element - * containing the <code>CreateTransformsInfoProfile</code>. + * + * @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>. + * the profile found in <code>dataObjInfoElem</code>. + * @throws MOAApplicationException An error occurred parsing the + * <code>CreateTransformsInfoProfile</code>. */ 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 <code>CreateSignatureInfo</code> DOM element contained in - * a <code>SingleSignatureInfo</code>. - * + * 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. + * 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); + 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 <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.. + * 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); + 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); } } |