You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by gi...@apache.org on 2013/03/24 21:07:11 UTC

svn commit: r1460432 - in /webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl: processor/input/WSSSignatureReferenceVerifyInputProcessor.java processor/output/WSSSignatureOutputProcessor.java transformer/STRTransformer.java

Author: giger
Date: Sun Mar 24 20:07:11 2013
New Revision: 1460432

URL: http://svn.apache.org/r1460432
Log:
correct inclusiveNamespace-PrefixList handling for STR

Modified:
    webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/WSSSignatureReferenceVerifyInputProcessor.java
    webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java
    webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/transformer/STRTransformer.java

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/WSSSignatureReferenceVerifyInputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/WSSSignatureReferenceVerifyInputProcessor.java?rev=1460432&r1=1460431&r2=1460432&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/WSSSignatureReferenceVerifyInputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/WSSSignatureReferenceVerifyInputProcessor.java Sun Mar 24 20:07:11 2013
@@ -44,7 +44,6 @@ import org.apache.wss4j.stax.securityEve
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import java.io.OutputStream;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
@@ -232,12 +231,6 @@ public class WSSSignatureReferenceVerify
                     InclusiveNamespaces inclusiveNamespacesType =
                             XMLSecurityUtils.getQNameType(canonicalizationMethodType.getContent(), XMLSecurityConstants.TAG_c14nExcl_InclusiveNamespaces);
                     List<String> inclusiveNamespaces = inclusiveNamespacesType != null ? inclusiveNamespacesType.getPrefixList() : null;
-                    if (WSSConstants.SOAPMESSAGE_NS10_STRTransform.equals(transformType.getAlgorithm())) {
-                        if (inclusiveNamespaces == null) {
-                            inclusiveNamespaces = new ArrayList<String>(1);
-                        }
-                        inclusiveNamespaces.add("#default");
-                    }
                     algorithm = canonicalizationMethodType.getAlgorithm();
                     parentTransformer = WSSUtils.getTransformer(inclusiveNamespaces, outputStream, algorithm, XMLSecurityConstants.DIRECTION.IN);
                 }

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java?rev=1460432&r1=1460431&r2=1460432&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureOutputProcessor.java Sun Mar 24 20:07:11 2013
@@ -188,17 +188,12 @@ public class WSSSignatureOutputProcessor
         }
 
         List<String> inclusiveNamespacePrefixes = null;
-        if (WSSConstants.SOAPMESSAGE_NS10_STRTransform.equals(transforms[0])) {
-            inclusiveNamespacePrefixes = new ArrayList<String>();
-            inclusiveNamespacePrefixes.add("#default");
-        }
 
         Transformer parentTransformer = null;
         for (int i = transforms.length - 1; i >= 0; i--) {
             String transform = transforms[i];
 
-            if (inclusiveNamespacePrefixes == null &&
-                    getSecurityProperties().isAddExcC14NInclusivePrefixes() &&
+            if (getSecurityProperties().isAddExcC14NInclusivePrefixes() &&
                     XMLSecurityConstants.NS_C14N_EXCL.equals(transform)) {
 
                 Set<String> prefixSet = XMLSecurityUtils.getExcC14NInclusiveNamespacePrefixes(xmlSecStartElement, signaturePartDef.isExcludeVisibleC14Nprefixes());

Modified: webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/transformer/STRTransformer.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/transformer/STRTransformer.java?rev=1460432&r1=1460431&r2=1460432&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/transformer/STRTransformer.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/transformer/STRTransformer.java Sun Mar 24 20:07:11 2013
@@ -18,7 +18,31 @@
  */
 package org.apache.wss4j.stax.impl.transformer;
 
+import org.apache.wss4j.common.ext.WSSecurityException;
+import org.apache.xml.security.exceptions.XMLSecurityException;
+import org.apache.xml.security.stax.ext.Transformer;
 import org.apache.xml.security.stax.impl.transformer.TransformIdentity;
+import org.apache.xml.security.stax.impl.transformer.canonicalizer.Canonicalizer20010315_Excl;
+
+import java.util.ArrayList;
+import java.util.List;
 
 public class STRTransformer extends TransformIdentity {
+
+    @Override
+    public void setTransformer(Transformer transformer) throws XMLSecurityException {
+        if (!(transformer instanceof Canonicalizer20010315_Excl)) {
+            throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY);
+        }
+        ((Canonicalizer20010315_Excl) transformer).setPropagateDefaultNamespace(true);
+        List<String> inclusiveNamespacesPrefixList = new ArrayList<String>();
+        inclusiveNamespacesPrefixList.add("#default");
+        transformer.setList(inclusiveNamespacesPrefixList);
+        super.setTransformer(transformer);
+    }
+
+    @Override
+    public void setList(List list) throws XMLSecurityException {
+        throw new UnsupportedOperationException();
+    }
 }