aboutsummaryrefslogtreecommitdiff
path: root/spss.server
diff options
context:
space:
mode:
Diffstat (limited to 'spss.server')
-rw-r--r--spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationInvoker.java36
-rw-r--r--spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationProfileFactory.java39
-rw-r--r--spss.server/src/at/gv/egovernment/moa/spss/server/util/IdGenerator.java2
3 files changed, 53 insertions, 24 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 });
}
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationProfileFactory.java b/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationProfileFactory.java
index 6078c7fb0..7ac971da8 100644
--- a/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationProfileFactory.java
+++ b/spss.server/src/at/gv/egovernment/moa/spss/server/invoke/XMLSignatureCreationProfileFactory.java
@@ -1,5 +1,13 @@
package at.gv.egovernment.moa.spss.server.invoke;
+import iaik.server.modules.algorithms.HashAlgorithms;
+import iaik.server.modules.keys.KeyEntryID;
+import iaik.server.modules.keys.KeyModule;
+import iaik.server.modules.keys.KeyModuleFactory;
+import iaik.server.modules.xmlsign.SignatureStructureTypes;
+import iaik.server.modules.xmlsign.XMLSignatureCreationProfile;
+import iaik.server.modules.xmlsign.XMLSignatureInsertionLocation;
+
import java.math.BigInteger;
import java.security.Principal;
import java.security.cert.X509Certificate;
@@ -12,18 +20,8 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import iaik.server.modules.algorithms.HashAlgorithms;
-import iaik.server.modules.keys.KeyEntryID;
-import iaik.server.modules.keys.KeyModule;
-import iaik.server.modules.keys.KeyModuleFactory;
-import iaik.server.modules.xmlsign.SignatureStructureTypes;
-import iaik.server.modules.xmlsign.XMLSignatureCreationProfile;
-import iaik.server.modules.xmlsign.XMLSignatureInsertionLocation;
-
import at.gv.egovernment.moa.logging.LogMsg;
import at.gv.egovernment.moa.logging.Logger;
-import at.gv.egovernment.moa.util.Constants;
-
import at.gv.egovernment.moa.spss.MOAApplicationException;
import at.gv.egovernment.moa.spss.MOASystemException;
import at.gv.egovernment.moa.spss.api.common.XMLDataObjectAssociation;
@@ -44,6 +42,7 @@ import at.gv.egovernment.moa.spss.server.transaction.TransactionContext;
import at.gv.egovernment.moa.spss.server.transaction.TransactionContextManager;
import at.gv.egovernment.moa.spss.server.util.IdGenerator;
import at.gv.egovernment.moa.spss.util.MessageProvider;
+import at.gv.egovernment.moa.util.Constants;
/**
* A factory to create <code>XMLSignatureCreationProfile</code>s from a
@@ -91,6 +90,8 @@ public class XMLSignatureCreationProfileFactory {
*
* @param singleSignatureInfo The <code>SingleSignatureInfo</code> object
* containing information about the creation of a signature.
+ * @param sigInfoReservedIDs The <code>Set</code> of reserved ID attribue values
+ * for the particular <code>singleSignatureInfo</code>.
* @return The <code>XMLSignatureCreationProfile</code> containing additional
* information for creating an XML signature.
* @throws MOASystemException A system error occurred during creation of the
@@ -98,11 +99,14 @@ public class XMLSignatureCreationProfileFactory {
* @throws MOAApplicationException An application error occurred during
* creation of the profile. See message for details.
*/
- public XMLSignatureCreationProfile createProfile(SingleSignatureInfo singleSignatureInfo)
- throws MOASystemException, MOAApplicationException {
+ public XMLSignatureCreationProfile createProfile(SingleSignatureInfo singleSignatureInfo,
+ Set sigInfoReservedIDs) throws MOASystemException, MOAApplicationException {
+
+ HashSet allReservedIDs = new HashSet(reserved);
+ allReservedIDs.addAll(sigInfoReservedIDs);
XMLSignatureCreationProfileImpl profile =
- new XMLSignatureCreationProfileImpl(createProfileCount, reserved);
+ new XMLSignatureCreationProfileImpl(createProfileCount, allReservedIDs);
TransactionContext context =
TransactionContextManager.getInstance().getTransactionContext();
ConfigurationProvider config = context.getConfiguration();
@@ -124,7 +128,8 @@ public class XMLSignatureCreationProfileFactory {
buildDataObjectTreatmentList(
singleSignatureInfo,
createTransformsProfiles,
- transformationSupplements);
+ transformationSupplements,
+ allReservedIDs);
profile.setDataObjectTreatmentList(dataObjectTreatmentList);
// set the key set
@@ -259,6 +264,7 @@ public class XMLSignatureCreationProfileFactory {
* <code>singleSignatureInfo</code>.
* @param transformationSupplements Additional parameters for
* transformations contained in <code>DataObjectTreatment</code>s.
+ * @param reservedIDs The <code>Set</code> of reserved object IDs.
* @return A <code>List</code> of <code>DataObjectTreatment</code> objects.
* @throws MOAApplicationException An error occurred building one of the
* <code>DataObjectTreatment</code>s.
@@ -268,7 +274,8 @@ public class XMLSignatureCreationProfileFactory {
private List buildDataObjectTreatmentList(
SingleSignatureInfo singleSignatureInfo,
List createTransformsInfoProfiles,
- List transformationSupplements)
+ List transformationSupplements,
+ Set reservedIDs)
throws MOASystemException, MOAApplicationException {
TransactionContext context =
@@ -290,7 +297,7 @@ public class XMLSignatureCreationProfileFactory {
new IdGenerator(
("signed-data-" + createProfileCount)
+ ("-" + dataObjectTreatmentCount++),
- reserved);
+ reservedIDs);
DataObjectTreatmentImpl treatment = new DataObjectTreatmentImpl(objIdGen);
treatment.setFinalContentType(
diff --git a/spss.server/src/at/gv/egovernment/moa/spss/server/util/IdGenerator.java b/spss.server/src/at/gv/egovernment/moa/spss/server/util/IdGenerator.java
index 92e8cb0f8..2dfd22140 100644
--- a/spss.server/src/at/gv/egovernment/moa/spss/server/util/IdGenerator.java
+++ b/spss.server/src/at/gv/egovernment/moa/spss/server/util/IdGenerator.java
@@ -36,7 +36,7 @@ public class IdGenerator {
*
* @return The next ID value in the sequence.
*/
- public String nextId() {
+ protected String nextId() {
return base + "-" + count++;
}