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

svn commit: r1527049 - in /webservices/neethi/trunk/src: main/java/org/apache/neethi/util/ test/java/org/apache/neethi/ test/test-resources/bugs/ test/test-resources/bugs/neethi15/ test/test-resources/bugs/neethi15/input/

Author: dkulp
Date: Fri Sep 27 19:51:23 2013
New Revision: 1527049

URL: http://svn.apache.org/r1527049
Log:
[NEETHI-15] Fix policy intersection
Patch from Jörn Schneider applied

Added:
    webservices/neethi/trunk/src/test/test-resources/bugs/
    webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/
    webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/Policy1-2-lax.xml
    webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/Policy2-1-lax.xml
    webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/input/
    webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/input/Policy1.xml
    webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/input/Policy2.xml
Modified:
    webservices/neethi/trunk/src/main/java/org/apache/neethi/util/PolicyIntersector.java
    webservices/neethi/trunk/src/test/java/org/apache/neethi/IntersectTest.java

Modified: webservices/neethi/trunk/src/main/java/org/apache/neethi/util/PolicyIntersector.java
URL: http://svn.apache.org/viewvc/webservices/neethi/trunk/src/main/java/org/apache/neethi/util/PolicyIntersector.java?rev=1527049&r1=1527048&r2=1527049&view=diff
==============================================================================
--- webservices/neethi/trunk/src/main/java/org/apache/neethi/util/PolicyIntersector.java (original)
+++ webservices/neethi/trunk/src/main/java/org/apache/neethi/util/PolicyIntersector.java Fri Sep 27 19:51:23 2013
@@ -174,10 +174,9 @@ public class PolicyIntersector {
                 if (compatibleAlternatives(alt1, alt2)) {
                     return true;                    
                 }
-            }             
-            return false;
+            }
         }        
-        return true;
+        return false;
     }
     
     public Policy intersect(Policy p1, Policy p2) {

Modified: webservices/neethi/trunk/src/test/java/org/apache/neethi/IntersectTest.java
URL: http://svn.apache.org/viewvc/webservices/neethi/trunk/src/test/java/org/apache/neethi/IntersectTest.java?rev=1527049&r1=1527048&r2=1527049&view=diff
==============================================================================
--- webservices/neethi/trunk/src/test/java/org/apache/neethi/IntersectTest.java (original)
+++ webservices/neethi/trunk/src/test/java/org/apache/neethi/IntersectTest.java Fri Sep 27 19:51:23 2013
@@ -20,6 +20,12 @@
 package org.apache.neethi;
 
 import java.io.File;
+import java.io.StringWriter;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.dom.DOMSource;
 
 import org.apache.neethi.util.PolicyComparator;
 
@@ -30,6 +36,10 @@ public class IntersectTest extends Polic
     
     public IntersectTest() {
     }
+    @Test
+    public void testNeethi15() throws Exception {
+        doTest("bugs/neethi15/input", "bugs/neethi15", 1);
+    }
     
     @Test
     public void testOM() throws Exception {
@@ -77,6 +87,9 @@ public class IntersectTest extends Polic
             if (f.startsWith(".")) {
                 continue;
             }
+            if (files[i].isDirectory()) {
+                continue;
+            }
 
             
             boolean strict = !f.contains("lax");
@@ -112,12 +125,19 @@ public class IntersectTest extends Polic
         // result
         Policy p4 = (Policy)p1.intersect(p2, strict);
 
+        
         if (p4 == null || !PolicyComparator.compare(p4, p3)) {
             /*
              System.out.println(++failCount + " Fail: " + base + File.separator + "Policy" 
                                + f1 + ".intersect(Policy" + f2 + ", "
                                + strict +")");
             */
+            StringWriter swriter = new StringWriter();
+            XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(swriter);
+            p4.serialize(writer);;
+            writer.flush();
+            System.out.println(swriter.toString());
+            
             fail(base + File.separator + " Policy" + f1 + ".intersect(Policy" 
                  + f2 + ", " + strict + ") FAILED");
             /*

Added: webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/Policy1-2-lax.xml
URL: http://svn.apache.org/viewvc/webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/Policy1-2-lax.xml?rev=1527049&view=auto
==============================================================================
--- webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/Policy1-2-lax.xml (added)
+++ webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/Policy1-2-lax.xml Fri Sep 27 19:51:23 2013
@@ -0,0 +1,34 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<wsp:Policy xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+  <wsp:ExactlyOne>
+    <wsp:All>
+      <sp:SecurityToken xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext">
+        <sp:TokenType>sp:X509v3</sp:TokenType>
+      </sp:SecurityToken>
+      <sp:UsernameToken>
+      </sp:UsernameToken>
+      <sp:SecurityToken>
+        <sp:TokenType>sp:X509v3</sp:TokenType>
+      </sp:SecurityToken>
+      <sp:UsernameToken>
+      </sp:UsernameToken>
+    </wsp:All>
+  </wsp:ExactlyOne>
+</wsp:Policy>
\ No newline at end of file

Added: webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/Policy2-1-lax.xml
URL: http://svn.apache.org/viewvc/webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/Policy2-1-lax.xml?rev=1527049&view=auto
==============================================================================
--- webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/Policy2-1-lax.xml (added)
+++ webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/Policy2-1-lax.xml Fri Sep 27 19:51:23 2013
@@ -0,0 +1,34 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<wsp:Policy xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+  <wsp:ExactlyOne>
+    <wsp:All>
+      <sp:SecurityToken xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext">
+        <sp:TokenType>sp:X509v3</sp:TokenType>
+      </sp:SecurityToken>
+      <sp:UsernameToken>
+      </sp:UsernameToken>
+      <sp:SecurityToken>
+        <sp:TokenType>sp:X509v3</sp:TokenType>
+      </sp:SecurityToken>
+      <sp:UsernameToken>
+      </sp:UsernameToken>
+    </wsp:All>
+  </wsp:ExactlyOne>
+</wsp:Policy>
\ No newline at end of file

Added: webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/input/Policy1.xml
URL: http://svn.apache.org/viewvc/webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/input/Policy1.xml?rev=1527049&view=auto
==============================================================================
--- webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/input/Policy1.xml (added)
+++ webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/input/Policy1.xml Fri Sep 27 19:51:23 2013
@@ -0,0 +1,43 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<wsp:Policy
+xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext" >
+  <wsp:ExactlyOne>
+    <wsp:All>
+      <sp:SecurityToken>
+        <sp:TokenType>sp:X509v3</sp:TokenType>
+      </sp:SecurityToken>
+      <sp:UsernameToken /> 
+      <sp:SignedParts />
+      <sp:EncryptedParts>
+        <sp:Body />
+      </sp:EncryptedParts>
+      <sp:TransportBinding>
+        <sp:IncludeTimeStamp />
+      </sp:TransportBinding>
+    </wsp:All>
+    <wsp:All>
+      <sp:SecurityToken>
+        <sp:TokenType>sp:X509v3</sp:TokenType>
+      </sp:SecurityToken>
+      <sp:UsernameToken /> 
+    </wsp:All>
+  </wsp:ExactlyOne>
+</wsp:Policy>
\ No newline at end of file

Added: webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/input/Policy2.xml
URL: http://svn.apache.org/viewvc/webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/input/Policy2.xml?rev=1527049&view=auto
==============================================================================
--- webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/input/Policy2.xml (added)
+++ webservices/neethi/trunk/src/test/test-resources/bugs/neethi15/input/Policy2.xml Fri Sep 27 19:51:23 2013
@@ -0,0 +1,38 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<wsp:Policy
+xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
+xmlns:sp="http://schemas.xmlsoap.org/ws/2002/12/secext" >
+
+  <wsp:ExactlyOne>
+    <wsp:All>
+      <sp:SecurityToken>
+        <sp:TokenType>sp:X509v3</sp:TokenType>
+      </sp:SecurityToken>
+      <sp:SignedParts />
+      <sp:EncryptedParts />
+    </wsp:All>
+    <wsp:All>
+      <sp:SecurityToken>
+        <sp:TokenType>sp:X509v3</sp:TokenType>
+      </sp:SecurityToken>
+      <sp:UsernameToken /> 
+    </wsp:All>
+  </wsp:ExactlyOne>
+</wsp:Policy>
\ No newline at end of file