diff options
author | gregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2005-07-04 10:04:19 +0000 |
---|---|---|
committer | gregor <gregor@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2005-07-04 10:04:19 +0000 |
commit | 0601ac474d00a8723b490355132993e26a9c29f9 (patch) | |
tree | 527aa5f5d255633d1e90a4f4277ce461d3380f1c /spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvoker.java | |
parent | db9446d46d671ebebedf3a17a6dc19dc748a471d (diff) | |
download | moa-id-spss-0601ac474d00a8723b490355132993e26a9c29f9.tar.gz moa-id-spss-0601ac474d00a8723b490355132993e26a9c29f9.tar.bz2 moa-id-spss-0601ac474d00a8723b490355132993e26a9c29f9.zip |
Bug 214 behoben.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@374 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvoker.java')
-rw-r--r-- | spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvoker.java | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvoker.java b/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvoker.java index 7de8ba48f..15e5955aa 100644 --- a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvoker.java +++ b/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvoker.java @@ -3,6 +3,7 @@ package at.gv.egovernment.moa.spss.server.invoke; import java.text.ParseException; import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -11,6 +12,7 @@ import java.util.Set; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import iaik.IAIKException; import iaik.IAIKRuntimeException; @@ -24,7 +26,9 @@ import iaik.server.modules.xmlsign.XMLSignatureCreationProfile; import at.gv.egovernment.moa.logging.Logger; import at.gv.egovernment.moa.logging.LoggingContext; import at.gv.egovernment.moa.logging.LoggingContextManager; +import at.gv.egovernment.moa.util.Constants; import at.gv.egovernment.moa.util.DateTimeUtils; +import at.gv.egovernment.moa.util.XPathUtils; import at.gv.egovernment.moa.spss.MOAApplicationException; import at.gv.egovernment.moa.spss.MOAException; @@ -110,9 +114,9 @@ public class XMLSignatureCreationInvoker { TransactionContextManager.getInstance().getTransactionContext(); LoggingContext loggingCtx = LoggingContextManager.getInstance().getLoggingContext(); - Set reservedIDs = new HashSet(reserved); + reserved = new HashSet(reserved); XMLSignatureCreationProfileFactory profileFactory = - new XMLSignatureCreationProfileFactory(request, reservedIDs); + new XMLSignatureCreationProfileFactory(request, reserved); CreateXMLSignatureResponseBuilder responseBuilder = new CreateXMLSignatureResponseBuilder(); int createCount = 1; @@ -142,8 +146,6 @@ public class XMLSignatureCreationInvoker { Element requestElement = null; try { - // create the reference id generator - refIdGen = new IdGenerator("reference-" + createCount++, reservedIDs); // build the signature environment createSignatureInfo = singleSignatureInfo.getCreateSignatureInfo(); @@ -157,6 +159,26 @@ public class XMLSignatureCreationInvoker { } else { signatureEnvironment = null; } + + HashSet sigInfoReservedIDs = new HashSet(); + if (signatureEnvironment != null) + { + // Find Id attributes of existing XML signatures in signature environment + HashMap nSMap = new HashMap(); + String dsp = Constants.DSIG_PREFIX; + nSMap.put(dsp, Constants.DSIG_NS_URI); + String xPathExpr = "//" + dsp + ":Signature/@Id | //" + dsp + ":Reference/@Id | //" + + dsp + ":Object/@Id | //" + dsp + ":Manifest/@Id"; + NodeList idAttrs = XPathUtils.selectNodeList(signatureEnvironment.getElement(), nSMap, xPathExpr); + + // Add found Id attributes to set of reserved IDs + for (int i = 0; i < idAttrs.getLength(); i++) sigInfoReservedIDs.add(idAttrs.item(i).getNodeValue()); + } + + // create the reference id generator + HashSet allReservedIDs = new HashSet(reserved); + allReservedIDs.addAll(sigInfoReservedIDs); + refIdGen = new IdGenerator("reference-" + createCount++, allReservedIDs); // build the list of DataObjects List createTransformsProfiles = profileFactory.getCreateTransformsInfoProfiles(singleSignatureInfo); @@ -168,7 +190,7 @@ public class XMLSignatureCreationInvoker { refIdGen); // build the XMLSignatureCreationProfile - profile = profileFactory.createProfile(singleSignatureInfo); + profile = profileFactory.createProfile(singleSignatureInfo, sigInfoReservedIDs); // build the additionalSignedProperties additionalSignedProperties = buildAdditionalSignedProperties(); @@ -329,14 +351,14 @@ public class XMLSignatureCreationInvoker { buildEnvelopingDataObject( dataObjInfo.getDataObject(), finalDataMetaInfo, - idGen.nextId())); + idGen.uniqueId())); } else if (DataObjectInfo.STRUCTURE_DETACHED.equals(structure)) { dataObjects.add( buildDetachedDataObject( dataObjInfo.getDataObject(), finalDataMetaInfo, signatureEnvironment, - idGen.nextId())); + idGen.uniqueId())); } else { throw new MOAApplicationException("1103", new Object[] { structure }); } |