cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1558092 - in /cxf/trunk: rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/ systests/ws-security/src/test/java/org/apache/cxf/systest/ws/bindings/
Date Tue, 14 Jan 2014 16:12:50 GMT
Author: coheigea
Date: Tue Jan 14 16:12:50 2014
New Revision: 1558092

URL: http://svn.apache.org/r1558092
Log:
Added support for LaxTsFirst policies for the DOM code

Modified:
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
    cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/bindings/BindingPropertiesTest.java

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java?rev=1558092&r1=1558091&r2=1558092&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AbstractBindingBuilder.java
Tue Jan 14 16:12:50 2014
@@ -50,6 +50,7 @@ import javax.xml.xpath.XPathFactory;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.apache.cxf.Bus;
 import org.apache.cxf.binding.soap.SoapMessage;
@@ -364,6 +365,25 @@ public abstract class AbstractBindingBui
         return timestamp;
     }
     
+    protected void reshuffleTimestamp() {
+        // Make sure that the Timestamp is in first place, if that is what the policy requires
+        if (binding.getLayout() != null && timestampEl != null) {
+            if (binding.getLayout().getLayoutType() == LayoutType.LaxTsFirst
+                && secHeader.getSecurityHeader().getFirstChild() != timestampEl.getElement())
{
+                Node firstChild = secHeader.getSecurityHeader().getFirstChild();
+                while (firstChild != null && firstChild.getNodeType() != Node.ELEMENT_NODE)
{
+                    firstChild = firstChild.getNextSibling();
+                }
+                if (firstChild != null && firstChild != timestampEl.getElement())
{
+                    secHeader.getSecurityHeader().insertBefore(timestampEl.getElement(),
firstChild);
+                }
+            } else if (binding.getLayout().getLayoutType() == LayoutType.LaxTsLast
+                && secHeader.getSecurityHeader().getLastChild() != timestampEl.getElement())
{
+                secHeader.getSecurityHeader().appendChild(timestampEl.getElement());
+            } 
+        }
+    }
+    
     private List<SupportingToken> handleSupportingTokens(
         Collection<AssertionInfo> tokensInfos, 
         boolean endorse

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java?rev=1558092&r1=1558091&r2=1558092&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/AsymmetricBindingHandler.java
Tue Jan 14 16:12:50 2014
@@ -110,6 +110,7 @@ public class AsymmetricBindingHandler ex
             assertPolicy(
                 new QName(abinding.getName().getNamespaceURI(), SPConstants.SIGN_BEFORE_ENCRYPTING));
         }
+        reshuffleTimestamp();
         
         assertAlgorithmSuite(abinding.getAlgorithmSuite());
         assertWSSProperties(abinding.getName().getNamespaceURI());

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java?rev=1558092&r1=1558091&r2=1558092&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/policyhandlers/SymmetricBindingHandler.java
Tue Jan 14 16:12:50 2014
@@ -126,6 +126,7 @@ public class SymmetricBindingHandler ext
             assertPolicy(
                 new QName(sbinding.getName().getNamespaceURI(), SPConstants.SIGN_BEFORE_ENCRYPTING));
         }
+        reshuffleTimestamp();
         
         assertAlgorithmSuite(sbinding.getAlgorithmSuite());
         assertWSSProperties(sbinding.getName().getNamespaceURI());

Modified: cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/bindings/BindingPropertiesTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/bindings/BindingPropertiesTest.java?rev=1558092&r1=1558091&r2=1558092&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/bindings/BindingPropertiesTest.java
(original)
+++ cxf/trunk/systests/ws-security/src/test/java/org/apache/cxf/systest/ws/bindings/BindingPropertiesTest.java
Tue Jan 14 16:12:50 2014
@@ -338,9 +338,8 @@ public class BindingPropertiesTest exten
             SecurityTestUtil.enableStreaming(port);
         }
         
-        // TODO It's not sending the Timestamp "first" correctly - DOM
         // TODO Timestamp First/Last validation not working - see WSS-444
-        if (test.isStreaming() && !STAX_PORT.equals(test.getPort())) {
+        if (!STAX_PORT.equals(test.getPort())) {
             port.doubleIt(25);
         }
         
@@ -354,15 +353,14 @@ public class BindingPropertiesTest exten
         }
         
         try {
-            // TODO DOM not working as above
             // TODO Timestamp First/Last validation not working - see WSS-444
-            if (test.isStreaming() && !STAX_PORT.equals(test.getPort())) {
+            if (!STAX_PORT.equals(test.getPort())) {
                 port.doubleIt(25);
                 fail("Failure expected on on sending the timestamp last");
             }
         } catch (javax.xml.ws.soap.SOAPFaultException ex) {
-            // String error = "Layout does not match the requirements";
-            // assertTrue(ex.getMessage().contains(error));
+            String error = "Layout does not match the requirements";
+            assertTrue(ex.getMessage().contains(error));
         }
         
         ((java.io.Closeable)port).close();



Mime
View raw message