aboutsummaryrefslogtreecommitdiff
path: root/spss.server/src/at/gv/egovernment/moa/spss/server
diff options
context:
space:
mode:
authorgregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d>2005-07-26 14:43:17 +0000
committergregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d>2005-07-26 14:43:17 +0000
commit36df570f6c24d60498bb8c040ffbaa4ad0f7583f (patch)
tree88b72a0f804dab0395768df814997bc777fd64ea /spss.server/src/at/gv/egovernment/moa/spss/server
parent39ffc6c32b8c4c28e00f9b72a61542a40fb93946 (diff)
downloadmoa-id-spss-36df570f6c24d60498bb8c040ffbaa4ad0f7583f.tar.gz
moa-id-spss-36df570f6c24d60498bb8c040ffbaa4ad0f7583f.tar.bz2
moa-id-spss-36df570f6c24d60498bb8c040ffbaa4ad0f7583f.zip
Lösung für Bug 232 implementiert. Noch nicht final getestet.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@406 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'spss.server/src/at/gv/egovernment/moa/spss/server')
-rw-r--r--spss.server/src/at/gv/egovernment/moa/spss/server/invoke/VerifyXMLSignatureResponseBuilder.java195
-rw-r--r--spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvoker.java2
2 files changed, 162 insertions, 35 deletions
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/VerifyXMLSignatureResponseBuilder.java b/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/VerifyXMLSignatureResponseBuilder.java
index af5787795..076e9d1a5 100644
--- a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/VerifyXMLSignatureResponseBuilder.java
+++ b/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/VerifyXMLSignatureResponseBuilder.java
@@ -1,13 +1,5 @@
package at.gv.egovernment.moa.spss.server.invoke;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.NodeList;
-
import iaik.ixsil.algorithms.CanonicalizationAlgorithm;
import iaik.ixsil.algorithms.CanonicalizationAlgorithmImplExclusiveCanonicalXMLWithComments;
import iaik.server.modules.xml.BinaryDataObject;
@@ -24,19 +16,29 @@ import iaik.server.modules.xmlverify.XMLSignatureVerificationProfile;
import iaik.server.modules.xmlverify.XMLSignatureVerificationResult;
import iaik.x509.X509Certificate;
-import at.gv.egovernment.moa.util.CollectionUtils;
-import at.gv.egovernment.moa.util.DOMUtils;
-import at.gv.egovernment.moa.util.NodeListAdapter;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.NodeList;
import at.gv.egovernment.moa.spss.MOAApplicationException;
import at.gv.egovernment.moa.spss.api.SPSSFactory;
import at.gv.egovernment.moa.spss.api.common.CheckResult;
import at.gv.egovernment.moa.spss.api.common.Content;
+import at.gv.egovernment.moa.spss.api.common.InputData;
import at.gv.egovernment.moa.spss.api.common.SignerInfo;
+import at.gv.egovernment.moa.spss.api.impl.InputDataBinaryImpl;
+import at.gv.egovernment.moa.spss.api.impl.InputDataXMLImpl;
import at.gv.egovernment.moa.spss.api.xmlverify.ManifestRefsCheckResultInfo;
import at.gv.egovernment.moa.spss.api.xmlverify.ReferencesCheckResult;
import at.gv.egovernment.moa.spss.api.xmlverify.ReferencesCheckResultInfo;
import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse;
+import at.gv.egovernment.moa.util.CollectionUtils;
+import at.gv.egovernment.moa.util.DOMUtils;
+import at.gv.egovernment.moa.util.NodeListAdapter;
/**
* A class to build a <code>VerifyXMLSignatureResponse</code> object.
@@ -123,23 +125,76 @@ public class VerifyXMLSignatureResponseBuilder {
certResult.isPublicAuthorityCertificate(),
certResult.getPublicAuthorityID());
- // add HashInputData Content objects
+ // Create HashInputData Content objects
referenceDataList = result.getReferenceDataList();
if (profile.includeHashInputData()) {
hashInputDatas = new ArrayList();
- for (iter = referenceDataList.iterator(); iter.hasNext();) {
- referenceData = (ReferenceData) iter.next();
- hashInputDatas.add(buildContent(referenceData.getHashInputData()));
+
+ // Include SignedInfo references
+ addHashInputDatas(
+ hashInputDatas,
+ referenceDataList,
+ InputData.CONTAINER_SIGNEDINFO_,
+ InputData.REFERER_NONE_);
+
+ // Include SignatureManifest references
+ if (result.containsSecurityLayerManifest())
+ {
+ List sigMFReferenceDataList = result.getSecurityLayerManifest().getReferenceDataList();
+ addHashInputDatas(
+ hashInputDatas,
+ sigMFReferenceDataList,
+ InputData.CONTAINER_SIGNATUREMANIFEST_,
+ result.getSecurityLayerManifest().getReferringReferenceInfo().getReferenceIndex());
+ }
+
+ // Include XMLDSIGManifest references
+ List xMLDSIGManifests = result.getDsigManifestList();
+ for (iter = xMLDSIGManifests.iterator(); iter.hasNext();)
+ {
+ DsigManifest currentMF = (DsigManifest) iter.next();
+ List xMLDSIGMFReferenceDataList = currentMF.getReferenceDataList();
+ addHashInputDatas(
+ hashInputDatas,
+ xMLDSIGMFReferenceDataList,
+ InputData.CONTAINER_XMLDSIGMANIFEST_,
+ currentMF.getReferringReferenceInfo().getReferenceIndex());
}
}
- // create the ReferenceInputData Content objects
+ // Create the ReferenceInputData Content objects
if (profile.includeReferenceInputData()) {
referenceInputDatas = new ArrayList();
- for (iter = referenceDataList.iterator(); iter.hasNext();) {
- referenceData = (ReferenceData) iter.next();
- referenceInputDatas.add(
- buildContent(referenceData.getReferenceInputData()));
+
+ // Include SignedInfo references
+ addReferenceInputDatas(
+ referenceInputDatas,
+ referenceDataList,
+ InputData.CONTAINER_SIGNEDINFO_,
+ InputData.REFERER_NONE_);
+
+ // Include SignatureManifest references
+ if (result.containsSecurityLayerManifest())
+ {
+ List sigMFReferenceDataList = result.getSecurityLayerManifest().getReferenceDataList();
+ addReferenceInputDatas(
+ referenceInputDatas,
+ sigMFReferenceDataList,
+ InputData.CONTAINER_SIGNATUREMANIFEST_,
+ result.getSecurityLayerManifest().getReferringReferenceInfo().getReferenceIndex());
+ }
+
+ // Include XMLDSIGManifest references
+ List xMLDSIGManifests = result.getDsigManifestList();
+ for (iter = xMLDSIGManifests.iterator(); iter.hasNext();)
+ {
+ DsigManifest currentMF = (DsigManifest) iter.next();
+ List xMLDSIGMFReferenceDataList = currentMF.getReferenceDataList();
+ addReferenceInputDatas(
+ referenceInputDatas,
+ xMLDSIGMFReferenceDataList,
+ InputData.CONTAINER_XMLDSIGMANIFEST_,
+ currentMF.getReferringReferenceInfo().getReferenceIndex());
}
}
@@ -183,7 +238,7 @@ public class VerifyXMLSignatureResponseBuilder {
else
{
// security layer manifest exists, but has errors
- failedReferences = buildFailedReferences(slManifest.getReferenceInfoList());
+ failedReferences = buildFailedReferences(slManifest.getReferenceDataList());
checkResultInfo = (failedReferences != null)
? factory.createReferencesCheckResultInfo(null, failedReferences)
: null;
@@ -221,7 +276,7 @@ public class VerifyXMLSignatureResponseBuilder {
ManifestRefsCheckResultInfo manifestCheckResultInfo;
failedReferences =
- buildFailedReferences(dsigManifest.getReferenceInfoList());
+ buildFailedReferences(dsigManifest.getReferenceDataList());
manifestCheckResultInfo =
factory.createManifestRefsCheckResultInfo(
null,
@@ -239,27 +294,93 @@ public class VerifyXMLSignatureResponseBuilder {
}
/**
- * Build a <code>Content</code> object from the given <code>DataObject</code>.
+ * Adds {@link InputData} entries to the specified <code>inputDatas</code> list. The content of the entry will
+ * be created from {@link ReferenceData#getHashInputData()}.
+ *
+ * @param inputDatas The list to be amended.
+ *
+ * @param referenceDataList The list of {@link ReferenceData} objects to be investigated.
+ *
+ * @param containerType The type of container of the {@link InputData} objects to be created.
+ *
+ * @param refererNumber The number of the referring reference for the {@link InputData} objects to be created.
+ *
+ * @throws MOAApplicationException if creating an {@link InputData} fails.
+ */
+ private void addHashInputDatas(List inputDatas, List referenceDataList, String containerType, int refererNumber)
+ throws MOAApplicationException
+ {
+ for (Iterator iter = referenceDataList.iterator(); iter.hasNext();)
+ {
+ ReferenceData referenceData = (ReferenceData) iter.next();
+ inputDatas.add(buildInputData(
+ referenceData.getHashInputData(),
+ containerType,
+ refererNumber));
+ }
+ }
+
+ /**
+ * Adds {@link InputData} entries to the specified <code>inputDatas</code> list. The content of the entry will
+ * be created from {@link ReferenceData#getReferenceInputData()}.
+ *
+ * @param inputDatas The list to be amended.
+ *
+ * @param referenceDataList The list of {@link ReferenceData} objects to be investigated.
+ *
+ * @param containerType The type of container of the {@link InputData} objects to be created.
+ *
+ * @param refererNumber The number of the referring reference for the {@link InputData} objects to be created.
+ *
+ * @throws MOAApplicationException if creating an {@link InputData} fails.
+ */
+ private void addReferenceInputDatas(List inputDatas, List referenceDataList, String containerType, int refererNumber)
+ throws MOAApplicationException
+ {
+ for (Iterator iter = referenceDataList.iterator(); iter.hasNext();)
+ {
+ ReferenceData referenceData = (ReferenceData) iter.next();
+ inputDatas.add(buildInputData(
+ referenceData.getReferenceInputData(),
+ containerType,
+ refererNumber));
+ }
+ }
+
+ /**
+ * Build a <code>InputDataBinaryImpl</code> or an <code>InputDataXMLImpl</code>
+ * object from the given <code>DataObject</code> and the given attributes.
+ *
+ * @param dataObject The <code>DataObject</code> from which to build the result.
+ * Based on the type of this parameter, the type of the result will either be
+ * <code>InputDataBinaryImpl</code> or <code>InputDataXMLImpl</code>.
+ *
+ * @param partof see {@link InputData}
+ *
+ * @param referringReferenceNumber see {@link InputData}
*
- * @param dataObject The <code>DataObject</code> from which to build the
- * <code>Content</code>. Based on the type of this parameter, the type of
- * <code>Content</code> will either be <code>XML_CONTENT</code> or
- * <code>BINARY_CONTENT</code>.
- * @return The <code>Content</code> object containing the data.
- * @throws MOAApplicationException An error occurred adding the content.
+ * @return The corresponinding input data implementation.
+ *
+ * @throws MOAApplicationException An error occurred creating the result.
*/
- private Content buildContent(DataObject dataObject)
+ private Content buildInputData(DataObject dataObject, String partOf, int referringReferenceNumber)
throws MOAApplicationException {
if (dataObject instanceof BinaryDataObject) {
BinaryDataObject binaryData = (BinaryDataObject) dataObject;
- return factory.createContent(binaryData.getInputStream(), null);
+ return new InputDataBinaryImpl(
+ factory.createContent(binaryData.getInputStream(), null),
+ partOf,
+ referringReferenceNumber);
} else if (dataObject instanceof XMLDataObject) {
XMLDataObject xmlData = (XMLDataObject) dataObject;
List nodes = new ArrayList();
nodes.add(xmlData.getElement());
- return factory.createContent(new NodeListAdapter(nodes), null);
+ return new InputDataXMLImpl(
+ factory.createContent(new NodeListAdapter(nodes), null),
+ partOf,
+ referringReferenceNumber);
} else { // dataObject instanceof XMLNodeListDataObject
// if the data in the NodeList can be converted back to valid XML,
// write it as XMLContent; otherwise, write it as Base64Content
@@ -271,7 +392,10 @@ public class VerifyXMLSignatureResponseBuilder {
try {
DocumentFragment fragment = DOMUtils.nodeList2DocumentFragment(nodes);
- return factory.createContent(fragment.getChildNodes(), null);
+ return new InputDataXMLImpl(
+ factory.createContent(fragment.getChildNodes(), null),
+ partOf,
+ referringReferenceNumber);
} catch (Exception e) {
// not successful -> fall through to the Base64Content
}
@@ -285,7 +409,10 @@ public class VerifyXMLSignatureResponseBuilder {
c14n.setInput(nodes);
is = c14n.canonicalize();
- return factory.createContent(is, null);
+ return new InputDataBinaryImpl(
+ factory.createContent(is, null),
+ partOf,
+ referringReferenceNumber);
} catch (Exception e) {
throw new MOAApplicationException("2200", null);
}
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvoker.java b/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvoker.java
index 1f9d45ed1..e675a40d6 100644
--- a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvoker.java
+++ b/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureVerificationInvoker.java
@@ -501,7 +501,7 @@ public class XMLSignatureVerificationInvoker {
Set transformParameterURIs =
buildTransformParameterURIs(profile.getTransformationSupplements());
List referenceInfoList =
- result.getSecurityLayerManifest().getReferenceInfoList();
+ result.getSecurityLayerManifest().getReferenceDataList();
Iterator refIter;
for (refIter = referenceInfoList.iterator(); refIter.hasNext();) {