You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by sa...@apache.org on 2006/08/31 07:25:36 UTC

svn commit: r438802 - in /webservices/commons/trunk/modules/neethi/src: main/java/org/apache/neethi/ main/java/org/apache/neethi/util/ test/java/org/apache/ws/policy/ test/test-resources/samples/ test/test3/org/apache/neethi/ test/test3/org/apache/neet...

Author: sanka
Date: Wed Aug 30 22:25:34 2006
New Revision: 438802

URL: http://svn.apache.org/viewvc?rev=438802&view=rev
Log:

(1) Added two new interfaces called PolicyAlternatives and PolicyAlternative.

(2) Refactored the existing codebase as it is now taking into shape :) .

Added:
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyAlternative.java
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyAlternatives.java
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/PolicyComparator.java
Removed:
    webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/util/PolicyComparator.java
Modified:
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AbstractPolicyOperator.java
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/All.java
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Assertion.java
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AssertionBuilderFactory.java
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/ExactlyOne.java
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Policy.java
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyComponent.java
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyOperator.java
    webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/XmlPrimtiveAssertion.java
    webservices/commons/trunk/modules/neethi/src/test/java/org/apache/ws/policy/PolicyTestCase.java
    webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test1.xml
    webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test21.xml
    webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test3.xml
    webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test8.xml
    webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/MergeTest.java
    webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/NormalizeTest.java

Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AbstractPolicyOperator.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AbstractPolicyOperator.java?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AbstractPolicyOperator.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AbstractPolicyOperator.java Wed Aug 30 22:25:34 2006
@@ -19,7 +19,7 @@
 import java.util.Iterator;
 import java.util.List;
 
-import javax.xml.namespace.QName;
+import org.apache.neethi.util.PolicyComparator;
 
 /**
  * 
@@ -48,90 +48,157 @@
         return policyComponents.isEmpty();
     }
 
-    protected List crossProduct(ArrayList allTerms, int index,
-            boolean matchVacabulary) {
-
-        ArrayList result = new ArrayList();
-        ExactlyOne firstTerm = (ExactlyOne) allTerms.get(index);
-
-        List restTerms;
-
-        if (allTerms.size() == ++index) {
-            restTerms = new ArrayList();
-            All newTerm = new All();
-            restTerms.add(newTerm);
-        } else {
-            restTerms = crossProduct(allTerms, index, matchVacabulary);
-        }
-
-        Iterator firstTermIter = firstTerm.getPolicyComponents().iterator();
-
-        while (firstTermIter.hasNext()) {
-            
-            All assertion = (All) firstTermIter.next();
-            Iterator restTermsItr = restTerms.iterator();
-
-            while (restTermsItr.hasNext()) {
-                All restTerm = (All) restTermsItr.next();
-                All newTerm = new All();
-
-                if (matchVacabulary) {
-                    if (matchVocabulary(
-                            ((All) assertion).getPolicyComponents(),
-                            ((All) restTerm).getPolicyComponents())) {
-                        newTerm.addPolicyComponents(((All) assertion)
-                                .getPolicyComponents());
-                        newTerm.addPolicyComponents(((All) restTerm)
-                                .getPolicyComponents());
-                        result.add(newTerm);
-                    }
+    public PolicyComponent normalize() {
+        return normalize(true);
+    }
 
-                } else {
-                    newTerm.addPolicyComponents(((All) assertion)
-                            .getPolicyComponents());
-                    newTerm.addPolicyComponents(((All) restTerm)
-                            .getPolicyComponents());
-                    result.add(newTerm);
-                }
+    /**
+     * normalized form of the the assertion, all and Exactly one define as
+     * <ExactlyOne>
+     * <All>
+     * <Assertion/>
+     * </All>
+     * <ExactlyOne>
+     *
+     * @param deep - normalize the assertions or not - currently assertion normalization is not implemented
+     * @return the normalize form of this policy commponent
+     */
+
+    public PolicyComponent normalize(boolean deep) {
+        return AbstractPolicyOperator.normalize(this, deep);
+    }
+    
+    /**
+     * here it is assumed that the two arguments passed to the method are not empty arguments
+     * and exactlyOne1 and exactlyOne2 in normal form
+     *
+     * @param exactlyOne1
+     * @param exactlyOne2
+     * @return cross product of the two exactlyones
+     */
+    private static ExactlyOne getCrossProduct(ExactlyOne exactlyOne1, ExactlyOne exactlyOne2) {
+        ExactlyOne crossProduct = new ExactlyOne();
+        All crossProductAll;
+
+        All currentAll1;
+        All currentAll2;
+
+        for (Iterator iter1 = exactlyOne1.getPolicyComponents().iterator(); iter1.hasNext();) {
+            currentAll1 = (All) iter1.next();
+
+            for (Iterator iter2 = exactlyOne2.getPolicyComponents().iterator(); iter2.hasNext();) {
+                currentAll2 = (All) iter2.next();
+                crossProductAll = new All();
+                crossProductAll.addPolicyComponents(currentAll1.getPolicyComponents());
+                crossProductAll.addPolicyComponents(currentAll2.getPolicyComponents());
+                crossProduct.addPolicyComponent(crossProductAll);
             }
         }
 
-        return result;
+        return crossProduct;
     }
-
-    private boolean matchVocabulary(List assertions1, List assertions2) {
-
-        Iterator S, L;
-
-        if (assertions1.size() < assertions2.size()) {
-            S = assertions1.iterator();
-            L = assertions2.iterator();
-        } else {
-            S = assertions2.iterator();
-            L = assertions1.iterator();
+        
+    private static PolicyComponent normalize(PolicyOperator operator, boolean deep) {
+                
+        short type = operator.getType();
+                
+        
+        if (operator.isEmpty()) {
+            ExactlyOne exactlyOne = new ExactlyOne();
+            
+            if (PolicyComponent.EXACTLYONE != type) {
+                exactlyOne.addPolicyComponent(new All());
+            }
+            return exactlyOne;
         }
-
-        QName Sq, Lq;
-        boolean found;
-
-        for (; L.hasNext();) {
-            Lq = ((Assertion) L.next()).getName();
-
-            found = false;
-
-            for (; S.hasNext();) {
-                Sq = ((Assertion) S.next()).getName();
                 
-                if (Lq.equals(Sq)) {
-                    found = true;
-                    break;
+        ArrayList childComponentsList = new ArrayList();
+        PolicyComponent policyComponent;
+        
+        for (Iterator iterator = operator.getPolicyComponents().iterator(); iterator.hasNext();) {
+            policyComponent = (PolicyComponent) iterator.next();
+            
+            if (policyComponent.getType() == PolicyComponent.ASSERTION) {
+                policyComponent = ((Assertion) policyComponent).normalize();
+                
+                if (policyComponent.getType() == PolicyComponent.POLICY) {
+                    childComponentsList.add(((Policy) policyComponent).getFirstPolicyComponent());
+                    
+                } else  {
+                    ExactlyOne exactlyOne = new ExactlyOne();
+                    All all = new All();
+                    
+                    all.addPolicyComponent(policyComponent);
+                    exactlyOne.addPolicyComponent(all);
+                    childComponentsList.add(exactlyOne);
                 }
+                
+            } else if (policyComponent.getType() == PolicyComponent.POLICY) {
+                All all = new All();
+                all.addPolicyComponents(((Policy) policyComponent).getPolicyComponents());
+                childComponentsList.add(all.normalize(deep));
+                
+            } else {
+                childComponentsList.add(((AbstractPolicyOperator) policyComponent).normalize(deep));
+            }            
+        }
+        
+        return computeResultantComponent(childComponentsList, type);
+    }
+    
+    /**
+     * 
+     * @param normalizedInnerComponets
+     * @param componentType
+     * @return
+     */
+    private static PolicyComponent computeResultantComponent(List normalizedInnerComponets, short componentType) {
+        
+        ExactlyOne exactlyOne = new ExactlyOne();
+        
+        if (componentType == PolicyComponent.EXACTLYONE) {            
+            ExactlyOne innerExactlyOne;
+            
+            for (Iterator iter = normalizedInnerComponets.iterator(); iter.hasNext();) {
+                innerExactlyOne = (ExactlyOne) iter.next();
+                exactlyOne.addPolicyComponents(innerExactlyOne.getPolicyComponents());
             }
+            
+        } else if ((componentType == PolicyComponent.POLICY) || (componentType == PolicyComponent.ALL)) {
+            // if the parent type is All then we have to get the cross product
+            if (normalizedInnerComponets.size() > 1) {
+                // then we have to get the cross product with each other to process all elements
+                Iterator iter = normalizedInnerComponets.iterator();
+                // first get the first element
+                exactlyOne = (ExactlyOne) iter.next();
+                // if this is empty, this is an not admissible policy and total result is equalent to that
+                if (!exactlyOne.isEmpty()) {
+                    ExactlyOne currentExactlyOne;
+
+                    for (; iter.hasNext();) {
+                        currentExactlyOne = (ExactlyOne) iter.next();
+                        if (currentExactlyOne.isEmpty()) {
+                            // if this is empty, this is an not admissible policy and total result is equalent to that
+                            exactlyOne = currentExactlyOne;
+                            break;
+                        } else {
+                            exactlyOne = getCrossProduct(exactlyOne, currentExactlyOne);
+                        }
+                    }
 
-            if (!found) {
-                return false;
+                }
+
+            } else {
+                // i.e only one element exists in the list then we can safely
+                // return that element this is ok even if it is an empty element
+                exactlyOne = (ExactlyOne) normalizedInnerComponets.iterator().next();
             }
         }
-        return true;
+        
+        return exactlyOne;
+    }
+
+    public boolean equal(PolicyComponent policyComponent) {
+        return PolicyComparator.compare(this, policyComponent);
     }
 }

Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/All.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/All.java?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/All.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/All.java Wed Aug 30 22:25:34 2006
@@ -15,8 +15,8 @@
  */
 package org.apache.neethi;
 
-import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
@@ -25,95 +25,25 @@
  * 
  *
  */
-public class All extends AbstractPolicyOperator {
-
-    public PolicyComponent normalize(boolean deep) {
-
-        All all = new All();
-        ExactlyOne exactlyOne = new ExactlyOne();
-
-        ArrayList exactlyOnes = new ArrayList();
-
-        if (isEmpty()) {
-            return all;
-        }
-
-        PolicyComponent component;
-
-        for (Iterator iterator = getPolicyComponents().iterator(); iterator
-                .hasNext();) {
-            component = (PolicyComponent) iterator.next();
-            short type = component.getType();
-
-            if (type == PolicyComponent.ASSERTION && deep) {
-                component = ((Assertion) component).normalize();
-                type = component.getType();
-            }
-
-            if (type == PolicyComponent.POLICY) {
-                All wrapper = new All();
-                wrapper.addPolicyComponents(((Policy) component)
-                        .getPolicyComponents());
-                component = wrapper.normalize(deep);
-                type = component.getType();
-                
-            } else if (!(type == PolicyComponent.ASSERTION)) {
-                component = ((PolicyOperator) component).normalize(deep);
-            }
-
-            if (type == PolicyComponent.EXACTLYONE) {
-
-                if (((ExactlyOne) component).isEmpty()) {
-                    ExactlyOne anExactlyOne = new ExactlyOne();
-                    return anExactlyOne;
-
-                } else {
-                    exactlyOnes.add(component);
-                }
-
-            } else if (type == PolicyComponent.ALL) {
-                all
-                        .addPolicyComponents(((All) component)
-                                .getPolicyComponents());
-
-            } else {
-                all.addPolicyComponent(component);
-            }
-        }
-
-        // processing child ExactlyOne operators
-        if (exactlyOnes.size() > 1) {
-            exactlyOne.addPolicyComponents(crossProduct(exactlyOnes, 0, false));
-
-        } else if (exactlyOnes.size() == 1) {
-            ExactlyOne anExactlyOne = (ExactlyOne) exactlyOnes.get(0);
-            exactlyOne.addPolicyComponents(anExactlyOne.getPolicyComponents());
-        }
+public class All extends AbstractPolicyOperator implements PolicyAlternative {
+    
+    public void addAssertion(Assertion assertion) {
+        addPolicyComponent(assertion);
+    }
 
-        if (exactlyOne.isEmpty()) {
-            return all;
-        } else if (all.isEmpty()) {
-            return exactlyOne;
-        } else {
-            All anAll;
-            for (Iterator iterator = exactlyOne.getPolicyComponents()
-                    .iterator(); iterator.hasNext();) {
-                anAll = (All) iterator.next();
-                anAll.addPolicyComponents(all.getPolicyComponents());
-            }
-            return exactlyOne;
-        }
+    public List getAssertions() {
+        return policyComponents;
     }
 
     public void serialize(XMLStreamWriter writer) throws XMLStreamException {
         String prefix = writer.getPrefix(NAMESPACE);
 
         if (prefix == null) {
-            writer.writeStartElement(PREFIX, ALL, NAMESPACE);
+            writer.writeStartElement(PREFIX, LOCAL_NAME_ALL, NAMESPACE);
             writer.writeNamespace(PREFIX, NAMESPACE);
             writer.setPrefix(PREFIX, NAMESPACE);
         } else {
-            writer.writeStartElement(NAMESPACE, ALL);
+            writer.writeStartElement(NAMESPACE, LOCAL_NAME_ALL);
         }
 
         PolicyComponent policyComponent;
@@ -127,7 +57,7 @@
         writer.writeEndElement();
     }
 
-    public final short getType() {
+    public short getType() {
         return PolicyComponent.ALL;
     }
 }

Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Assertion.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Assertion.java?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Assertion.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Assertion.java Wed Aug 30 22:25:34 2006
@@ -16,12 +16,33 @@
 package org.apache.neethi;
 
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
 
+/**
+ * This is an interface that any Assertion must implement. Hence any domain 
+ * specific type can be used with this framework if it implements this 
+ * interface.
+ */
 public interface Assertion extends PolicyComponent {
     
+    /**
+     * Returns the QName of the Root Element of this Assertion.
+     *  
+     * @return QName the QName of the Root Element of this Assertion.
+     */
     public QName getName();
     
+    /**
+     * Returns true if this Assertion is optional. Returns false otherwise. 
+     * 
+     * @return true if the assertion is optional.
+     */
     public boolean isOptional();
     
-    public PolicyComponent normalize();
+    /**
+     * Serialize this Assertion into its XML infoset using XMLStreamWriter.
+     */
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException;
+    
 }

Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AssertionBuilderFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AssertionBuilderFactory.java?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AssertionBuilderFactory.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AssertionBuilderFactory.java Wed Aug 30 22:25:34 2006
@@ -90,5 +90,4 @@
     public AssertionBuilder getBuilder(QName qname) {
         return (AssertionBuilder) registeredBuilders.get(qname);
     }
-
 }

Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/ExactlyOne.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/ExactlyOne.java?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/ExactlyOne.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/ExactlyOne.java Wed Aug 30 22:25:34 2006
@@ -16,80 +16,48 @@
 package org.apache.neethi;
 
 import java.util.Iterator;
+import java.util.List;
 
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
-public class ExactlyOne extends AbstractPolicyOperator {
-
-    public PolicyComponent normalize(boolean deep) {
-        ExactlyOne exactlyOne = new ExactlyOne();
-
-        if (isEmpty()) {
-            return exactlyOne;
-        }
-        
-        for (Iterator iterator = getPolicyComponents().iterator(); iterator.hasNext();) {
-            PolicyComponent component = (PolicyComponent) iterator.next();
-            short type = component.getType();
-            
-            if (type == PolicyComponent.ASSERTION && deep) {
-                component = ((Assertion) component).normalize();
-                type = component.getType();       
-            } 
-            
-            if (type == PolicyComponent.POLICY) {
-                All wrapper = new All();
-                wrapper.addPolicyComponents(((Policy) component).getPolicyComponents());
-                
-                component = wrapper.normalize(deep);
-                type = component.getType();
-                
-            } else if (type != PolicyComponent.ASSERTION) {
-                component = ((PolicyOperator) component).normalize(deep);
-                type = component.getType();
-            }
-            
-            if (type == PolicyComponent.EXACTLYONE) {
-                exactlyOne.addPolicyComponents(((ExactlyOne) component).getPolicyComponents());
-                
-            } else if (type == PolicyComponent.ALL) {
-                exactlyOne.addPolicyComponent(component);
-                
-            } else {
-                All wrapper = new All();
-                wrapper.addPolicyComponent(component);
-                exactlyOne.addPolicyComponent(wrapper);                
-            }
-        }
-        
-        return exactlyOne;
+public class ExactlyOne extends AbstractPolicyOperator implements PolicyAlternatives {
+    
+    public void addAlternative(PolicyAlternative policyAlternative) {
+        addPolicyComponent(policyAlternative);
     }
     
+
+    public List getAlternatives() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
     public void serialize(XMLStreamWriter writer) throws XMLStreamException {
         String prefix = writer.getPrefix(NAMESPACE);
 
         if (prefix == null) {
-            writer.writeStartElement(PREFIX, EXACTLYONE, NAMESPACE);
+            writer.writeStartElement(PREFIX, LOCAL_NAME_EXACTLYONE, NAMESPACE);
             writer.writeNamespace(PREFIX, NAMESPACE);
             writer.setPrefix(PREFIX, NAMESPACE);
         } else {
-            writer.writeStartElement(NAMESPACE, EXACTLYONE);
+            writer.writeStartElement(NAMESPACE, LOCAL_NAME_EXACTLYONE);
         }
-        
+
         PolicyComponent policyComponent;
-        
+
         for (Iterator iterator = getPolicyComponents().iterator(); iterator.hasNext();) {
             policyComponent = (PolicyComponent) iterator.next();
             policyComponent.serialize(writer);
         }
-        
+
         writer.writeEndElement();
 
     }
-    
+
     public final short getType() {
         return PolicyComponent.EXACTLYONE;
     }
-    
+
+
 }

Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Policy.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Policy.java?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Policy.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Policy.java Wed Aug 30 22:25:34 2006
@@ -15,176 +15,69 @@
  */
 package org.apache.neethi;
 
-import java.util.ArrayList;
 import java.util.Iterator;
 
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
-public class Policy extends AbstractPolicyOperator {
+public class Policy extends All {
 
     public PolicyComponent normalize(boolean deep) {
-        
-        All all = new All();
-        ExactlyOne exactlyOne = new ExactlyOne();
-
-        ArrayList exactlyOnes = new ArrayList();
-
-        if (isEmpty()) {
-            Policy policy = new Policy();
-            policy.addPolicyComponent(exactlyOne);
-            exactlyOne.addPolicyComponent(all);
-            return policy;
-        }
-
-        PolicyComponent component;
-
-        for (Iterator iterator = getPolicyComponents().iterator(); iterator
-                .hasNext();) {
-            component = (PolicyComponent) iterator.next();
-            short type = component.getType();
-            
-            if (type == PolicyComponent.ASSERTION && deep) {
-                component = ((Assertion) component).normalize();
-                type = component.getType();
-            }
-            
-            if (type == PolicyComponent.POLICY) {
-                All wrapper = new All();
-                wrapper.addPolicyComponents(((Policy) component)
-                        .getPolicyComponents());
-                component = wrapper.normalize(deep);
-                type = component.getType();
-                
-            } else if (type != PolicyComponent.ASSERTION) {
-                component = ((PolicyOperator) component).normalize(deep);
-                type = component.getType();
-            }
-            
-            if (type == PolicyComponent.EXACTLYONE) {
-
-                if (((ExactlyOne) component).isEmpty()) {
-                    Policy policy = new Policy();
-                    ExactlyOne anExactlyOne = new ExactlyOne();
-                    
-                    policy.addPolicyComponent(anExactlyOne);
-                    return policy;
-
-                } else {
-                    exactlyOnes.add(component);
-                }
-
-            } else if (type == PolicyComponent.ALL) {
-                all
-                        .addPolicyComponents(((All) component)
-                                .getPolicyComponents());
-
-            } else {
-                all.addPolicyComponent(component);
-            }
-        }
-
-        // processing child ExactlyOne operators
-        if (exactlyOnes.size() > 1) {
-            exactlyOne.addPolicyComponents(crossProduct(exactlyOnes, 0, false));
-
-        } else if (exactlyOnes.size() == 1) {
-            ExactlyOne anExactlyOne = (ExactlyOne) exactlyOnes.get(0);
-            exactlyOne.addPolicyComponents(anExactlyOne.getPolicyComponents());
-        }
-
-        if (exactlyOne.isEmpty()) {
-            Policy policy = new Policy();
-            ExactlyOne anExactlyOne = new ExactlyOne();
-            
-            policy.addPolicyComponent(anExactlyOne);
-            anExactlyOne.addPolicyComponent(all);
-            return policy;
-            
-        } else if (all.isEmpty()) {
-            Policy policy = new Policy();
-            policy.addPolicyComponent(exactlyOne);
-            
-            return policy;
-            
-        } else {
-            Policy policy = new Policy();
-            
-            All anAll;
-            
-            for (Iterator iterator = exactlyOne.getPolicyComponents()
-                    .iterator(); iterator.hasNext();) {
-                anAll = (All) iterator.next();
-                anAll.addPolicyComponents(all.getPolicyComponents());
-            }
-            
-            policy.addPolicyComponent(exactlyOne);
-            return policy;
-        }
+        Policy policy = new Policy();
+        policy.addPolicyComponent(super.normalize(deep));
+        return policy;
     }
-    
+
     public Policy merge(Policy policy) {
-        
         Policy result = new Policy();
-        ExactlyOne alternative = new ExactlyOne();
-        result.addPolicyComponent(alternative);
-        
-        ArrayList alternatives = new ArrayList();
-        
-        policy = (Policy) policy.normalize(false);
-        alternatives.add(policy.getFirstPolicyComponent());
-        
-        policy = (Policy) normalize(false);
-        alternatives.add(policy.getFirstPolicyComponent());
-        
-        alternative.addPolicyComponents(crossProduct(alternatives, 0, false));
-        
+        result.addPolicyComponents(getPolicyComponents());
+        result.addPolicyComponents(policy.getPolicyComponents());
         return result;
     }
-    
+
     public Policy intersect(Policy policy) {
-        
-        
-        throw new UnsupportedOperationException("still not implemented");
+        throw new UnsupportedOperationException();
     }
-    
+
     public void serialize(XMLStreamWriter writer) throws XMLStreamException {
         String prefix = writer.getPrefix(NAMESPACE);
 
         if (prefix == null) {
-            writer.writeStartElement(PREFIX, POLICY, NAMESPACE);
+            writer.writeStartElement(PREFIX, LOCAL_NAME_POLICY, NAMESPACE);
             writer.writeNamespace(PREFIX, NAMESPACE);
             writer.setPrefix(PREFIX, NAMESPACE);
-            
+
         } else {
-            writer.writeStartElement(NAMESPACE, POLICY);
+            writer.writeStartElement(NAMESPACE, LOCAL_NAME_POLICY);
         }
-        
+
         PolicyComponent policyComponent;
-        
-        for (Iterator iterator = getPolicyComponents().iterator(); iterator.hasNext();) {
+
+        for (Iterator iterator = getPolicyComponents().iterator(); iterator
+                .hasNext();) {
             policyComponent = (PolicyComponent) iterator.next();
             policyComponent.serialize(writer);
         }
-        
+
         writer.writeEndElement();
 
     }
-    
-    public final short getType() {
+
+    public short getType() {
         return PolicyComponent.POLICY;
     }
-    
+
     public Iterator getAlternatives() {
         return new PolicyIterator(this);
     }
-    
+
     private class PolicyIterator implements Iterator {
         Iterator alternatives = null;
-        
+
         public PolicyIterator(Policy policy) {
             policy = (Policy) policy.normalize(false);
-            ExactlyOne exactlyOne = (ExactlyOne) policy.getFirstPolicyComponent();
+            ExactlyOne exactlyOne = (ExactlyOne) policy
+                    .getFirstPolicyComponent();
             alternatives = exactlyOne.getPolicyComponents().iterator();
         }
 
@@ -197,9 +90,9 @@
         }
 
         public void remove() {
-            throw new UnsupportedOperationException("policyAlternative.remove() is not supported");
+            throw new UnsupportedOperationException(
+                    "policyAlternative.remove() is not supported");
         }
-        
+
     }
-    
 }

Added: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyAlternative.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyAlternative.java?rev=438802&view=auto
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyAlternative.java (added)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyAlternative.java Wed Aug 30 22:25:34 2006
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+package org.apache.neethi;
+
+import java.util.List;
+
+public interface PolicyAlternative extends PolicyComponent {
+    
+    public void addAssertion(Assertion assertion);
+    
+    public List getAssertions();
+
+}

Added: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyAlternatives.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyAlternatives.java?rev=438802&view=auto
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyAlternatives.java (added)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyAlternatives.java Wed Aug 30 22:25:34 2006
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+package org.apache.neethi;
+
+import java.util.List;
+
+public interface PolicyAlternatives extends PolicyComponent {
+    
+    public void addAlternative(PolicyAlternative policyAlternative);
+    
+    public List getAlternatives();
+}

Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyComponent.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyComponent.java?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyComponent.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyComponent.java Wed Aug 30 22:25:34 2006
@@ -20,7 +20,6 @@
 
 /**
  * This is an interface which any component of the frame must implement.
- * 
  */
 public interface PolicyComponent {
 
@@ -34,24 +33,25 @@
 
     /**
      * Serializes the PolicyComponent using an XMLStreamWriter.
-     * 
-     * @param writer
-     *            the writer that the component should write itself
-     * @throws XMLStreamException
-     *             if an errors in the process of serialization of the
-     *             PolicyComponent.
+     *
+     * @param writer the writer that the component should write itself
+     * @throws XMLStreamException if an errors in the process of serialization of the
+     *                            PolicyComponent.
      */
     public void serialize(XMLStreamWriter writer) throws XMLStreamException;
 
     /**
      * Returns a short value which uniquely identify the type of the
      * PolicyComponent.
-     * 
+     *
      * @return PolicyComponent.POLICY for Policy type PolicyComponent
      *         PolicyComponent.EXACTLYONE for ExactlyOne type PolicyComponent
      *         PolicyComponent.All for All type PolicyComponent
      *         PolicyComponent.ASSERTION for Assertion type PolicyComponent
-     * 
      */
     public short getType();
+
+    public PolicyComponent normalize();
+    
+    public boolean equal(PolicyComponent policyComponent);
 }

Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java Wed Aug 30 22:25:34 2006
@@ -122,16 +122,16 @@
 
             if (PolicyOperator.NAMESPACE.equals(childElement.getNamespace().getNamespaceURI())) {
 
-                if (PolicyOperator.POLICY.equals(childElement.getLocalName())) {
+                if (PolicyOperator.LOCAL_NAME_POLICY.equals(childElement.getLocalName())) {
                     operator
                             .addPolicyComponent(getPolicyOperator(childElement));
 
-                } else if (PolicyOperator.EXACTLYONE.equals(childElement
+                } else if (PolicyOperator.LOCAL_NAME_EXACTLYONE.equals(childElement
                         .getLocalName())) {
                     operator
                             .addPolicyComponent(getExactlyOneOperator(childElement));
 
-                } else if (PolicyOperator.ALL.equals(childElement
+                } else if (PolicyOperator.LOCAL_NAME_ALL.equals(childElement
                         .getLocalName())) {
                     operator.addPolicyComponent(getAllOperator(childElement));
                 }

Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyOperator.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyOperator.java?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyOperator.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyOperator.java Wed Aug 30 22:25:34 2006
@@ -27,11 +27,11 @@
 
     public static final String PREFIX = "wsp";
 
-    public static final String POLICY = "Policy";
+    public static final String LOCAL_NAME_POLICY = "Policy";
 
-    public static final String EXACTLYONE = "ExactlyOne";
+    public static final String LOCAL_NAME_EXACTLYONE = "ExactlyOne";
 
-    public static final String ALL = "All";
+    public static final String LOCAL_NAME_ALL = "All";
 
     /**
      * Add a PolicyComponent to the PolicyOperator.
@@ -59,4 +59,12 @@
      * @return
      */
     public PolicyComponent normalize(boolean deep);
+    
+    
+    /**
+     * Returns true if the PolicyOperator doesn't contain any PolicyComponents.
+     * 
+     * @return true if this PolicyOperator doesn't contain any PolicyComponenets
+     */
+    public boolean isEmpty();
 }

Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/XmlPrimtiveAssertion.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/XmlPrimtiveAssertion.java?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/XmlPrimtiveAssertion.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/XmlPrimtiveAssertion.java Wed Aug 30 22:25:34 2006
@@ -22,84 +22,153 @@
 import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMElement;
 
+import java.util.Iterator;
+
 public class XmlPrimtiveAssertion implements Assertion {
 
     OMElement element;
+
     boolean isOptional;
-    QName optionalAttri = new QName(PolicyOperator.NAMESPACE, "Optional", PolicyOperator.PREFIX);
-    
-    
+
+    QName optionalAttri = new QName(PolicyOperator.NAMESPACE, "Optional",
+            PolicyOperator.PREFIX);
+
+    // Assertions can contain policies inside it.
+    Policy policy;
+
     public XmlPrimtiveAssertion(OMElement element) {
         setValue(element);
-        setOptionality(element);        
+        setOptionality(element);
     }
-    
+
     public QName getName() {
-        System.out.println(element.getQName());
-        
         return (element != null) ? element.getQName() : null;
     }
 
     public void setValue(OMElement element) {
         this.element = element;
+        // get all the policy namespace children
+        // actually there can only be one nested policy
+        Iterator iter = element.getChildrenWithName(new QName(
+                PolicyOperator.NAMESPACE, PolicyOperator.LOCAL_NAME_POLICY));
+        if (iter.hasNext()) {
+            OMElement policyOMElement = (OMElement) iter.next();
+            this.policy = PolicyEngine.getPolicy(policyOMElement);
+            // detach element from the om tree
+            policyOMElement.detach();
+        }
+
     }
 
     public OMElement getValue() {
         return element;
     }
-    
+
     public boolean isOptional() {
         return isOptional;
     }
-    
-    public PolicyComponent normalize() throws IllegalArgumentException {
-        return normalize(null);
+
+    public PolicyComponent normalize() {
+        if (isOptional) {
+            Policy policy = new Policy();
+            ExactlyOne exactlyOne = new ExactlyOne();
+
+            All all = new All();
+            OMElement omElement = element.cloneOMElement();
+
+            omElement.removeAttribute(omElement.getAttribute(optionalAttri));
+            all.addPolicyComponent(new XmlPrimtiveAssertion(omElement));
+            exactlyOne.addPolicyComponent(all);
+
+            exactlyOne.addPolicyComponent(new All());
+            policy.addPolicyComponent(exactlyOne);
+
+            return policy;
+        }
+
+        return this;
+    }
+
+    public PolicyComponent normalize(boolean isDeep) {
+        throw new UnsupportedOperationException();
     }
 
     public PolicyComponent normalize(PolicyRegistry registry) {
-        
+
         if (isOptional) {
             Policy policy = new Policy();
             ExactlyOne alternatives = new ExactlyOne();
-            
+
             All alternative1 = new All();
             OMElement element1 = element.cloneOMElement();
             element1.removeAttribute(element1.getAttribute(optionalAttri));
             alternative1.addPolicyComponent(new XmlPrimtiveAssertion(element1));
             alternatives.addPolicyComponent(alternative1);
-            
+
             All alternative2 = new All();
             alternatives.addPolicyComponent(alternative2);
-            
+
             policy.addPolicyComponent(alternatives);
             return policy;
         }
         return this;
     }
 
-    public void serialize(XMLStreamWriter writer) {
+    public void serialize(XMLStreamWriter writer) throws XMLStreamException {
         if (element != null) {
-            try {
+
+            if (policy != null) {
+                // write the start part of the element
+                String prefix = writer.getPrefix(element.getNamespace()
+                        .getNamespaceURI());
+                if (prefix == null) {
+                    writer.writeStartElement(element.getQName().getPrefix(),
+                            element.getQName().getLocalPart(), element
+                                    .getNamespace().getNamespaceURI());
+                    writer.writeNamespace(element.getQName().getPrefix(),
+                            element.getNamespace().getNamespaceURI());
+                    writer.setPrefix(element.getQName().getPrefix(), element
+                            .getNamespace().getNamespaceURI());
+
+                } else {
+                    writer.writeStartElement(element.getNamespace()
+                            .getNamespaceURI(), element.getQName()
+                            .getLocalPart());
+                }
+                // TODO : write attributes and inner elements
+                policy.serialize(writer);
+                writer.writeEndElement();
+            } else {
+                // we can not serialize as follows since OMElement seriali
                 element.serialize(writer);
-            } catch (XMLStreamException ex) {
-                throw new RuntimeException(ex);
             }
+
         } else {
             // TODO throw an exception??
         }
     }
-    
+
     public final short getType() {
         return PolicyComponent.ASSERTION;
     }
-    
+
     private void setOptionality(OMElement element) {
         OMAttribute attribute = element.getAttribute(optionalAttri);
         if (attribute != null) {
-            this.isOptional = (new Boolean(attribute.getAttributeValue()).booleanValue());
-            
+            this.isOptional = (new Boolean(attribute.getAttributeValue())
+                    .booleanValue());
+
         } else {
-            this.isOptional = false;            
-        }        
+            this.isOptional = false;
+        }
     }
+
+    public boolean equal(PolicyComponent policyComponent) {
+        if (policyComponent.getType() != Assertion.ASSERTION) {
+            return false;
+        }
+
+        return getName().equals(((Assertion) policyComponent).getName());
+    }
+
 }

Added: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/PolicyComparator.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/PolicyComparator.java?rev=438802&view=auto
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/PolicyComparator.java (added)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/PolicyComparator.java Wed Aug 30 22:25:34 2006
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ * 
+ * Licensed 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.
+ */
+package org.apache.neethi.util;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.neethi.All;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.ExactlyOne;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyComponent;
+
+public class PolicyComparator {
+
+    public static boolean compare(Policy arg1, Policy arg2) {
+        return compare(arg1.getPolicyComponents(), arg2.getPolicyComponents());
+    }
+    
+    public static boolean compare(PolicyComponent arg1, PolicyComponent arg2) {
+        if (! arg1.getClass().equals(arg2.getClass())) {
+            return false;
+        }
+
+        if (arg1 instanceof Policy) {
+            return compare((Policy) arg1, (Policy) arg2);
+
+        } else if (arg1 instanceof All) {
+            return compare((All) arg1,(All) arg2);
+
+        } else if (arg1 instanceof ExactlyOne) {
+            return compare((ExactlyOne) arg1,
+                    (ExactlyOne) arg2);
+
+        } else if (arg1 instanceof Assertion) {
+            return compare((Assertion) arg1, (Assertion) arg2);
+
+        } else {
+            // TODO should I throw an exception ..
+        }
+
+        return false;
+    }
+
+    public static boolean compare(All arg1,
+            All arg2) {
+        return compare(arg1.getPolicyComponents(), arg2.getPolicyComponents());
+    }
+
+    public static boolean compare(ExactlyOne arg1,
+            ExactlyOne arg2) {
+        return compare(arg1.getPolicyComponents(), arg2.getPolicyComponents());
+    }
+
+    public static boolean compare(Assertion arg1,
+            Assertion arg2) {
+        if (!(arg1.getName().equals(arg2.getName()))) {
+            return false;
+        }
+        return true;
+    }
+
+    private static boolean compare(List arg1, List arg2) {
+        if (arg1.size() != arg2.size()) {
+            return false;
+        }
+        
+        Iterator iterator = arg1.iterator();
+        PolicyComponent assertion1;
+
+        while (iterator.hasNext()) {
+            assertion1 = (PolicyComponent) iterator.next();
+
+            Iterator iterator2 = arg2.iterator();
+            boolean match = false;
+            PolicyComponent assertion2;
+
+            while (iterator2.hasNext()) {
+                assertion2 = (PolicyComponent) iterator2.next();
+                if (compare(assertion1, assertion2)) {
+                    match = true;
+                    break;
+                }
+            }
+
+            if (!match) {
+                return false;
+            }
+        }
+        return true;
+    }
+}

Modified: webservices/commons/trunk/modules/neethi/src/test/java/org/apache/ws/policy/PolicyTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/java/org/apache/ws/policy/PolicyTestCase.java?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/java/org/apache/ws/policy/PolicyTestCase.java (original)
+++ webservices/commons/trunk/modules/neethi/src/test/java/org/apache/ws/policy/PolicyTestCase.java Wed Aug 30 22:25:34 2006
@@ -35,6 +35,7 @@
 
 	public InputStream getResource(String name) {
 		String filePath = new File(testResourceDir, name).getAbsolutePath(); 
+
 		try {
 			FileInputStream fis = new FileInputStream(filePath);
 			return fis;

Modified: webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test1.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test1.xml?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test1.xml (original)
+++ webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test1.xml Wed Aug 30 22:25:34 2006
@@ -1 +1,4 @@
-<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"><wsp:ExactlyOne /></wsp:Policy>
\ No newline at end of file
+
+<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+	<wsp:ExactlyOne />
+</wsp:Policy>
\ No newline at end of file

Modified: webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test21.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test21.xml?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test21.xml (original)
+++ webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test21.xml Wed Aug 30 22:25:34 2006
@@ -1 +1,10 @@
-<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:sec="http://schemas.xmlsoap.org/ws/2002/12/secext"><!-- 2 --><sec:SecurityToken><sec:TokenType>sec:X509v3</sec:TokenType></sec:SecurityToken><sec:SecurityHeader wsp:Optional="true" MustPrepend="true" MustManifestEncryption="true"/><sec:Integrity wsp:Optional="false" ><sec:MessageParts Dialect="http://schemas.xmlsoap.org/ws/2002/12/wsse#soap">wsp:Body()</sec:MessageParts></sec:Integrity></wsp:Policy>
\ No newline at end of file
+
+<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:sec="http://schemas.xmlsoap.org/ws/2002/12/secext"><!-- 2 -->
+	<sec:SecurityToken>
+		<sec:TokenType>sec:X509v3</sec:TokenType>
+	</sec:SecurityToken>
+	<sec:SecurityHeader wsp:Optional="true" MustPrepend="true" MustManifestEncryption="true"/>
+	<sec:Integrity wsp:Optional="false">
+		<sec:MessageParts Dialect="http://schemas.xmlsoap.org/ws/2002/12/wsse#soap">wsp:Body()</sec:MessageParts>
+	</sec:Integrity>
+</wsp:Policy>
\ No newline at end of file

Modified: webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test3.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test3.xml?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test3.xml (original)
+++ webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test3.xml Wed Aug 30 22:25:34 2006
@@ -1 +1,20 @@
-<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:sec="http://schemas.xmlsoap.org/ws/2002/12/secext"><wsp:ExactlyOne><wsp:All><sec:SecurityToken><sec:TokenType>sec:X509v3</sec:TokenType></sec:SecurityToken></wsp:All><wsp:All><sec:SecurityToken><sec:TokenType>sec:X509v3</sec:TokenType></sec:SecurityToken></wsp:All><wsp:All><sec:SecurityToken><sec:TokenType>sec:Kerberosv5TGT</sec:TokenType></sec:SecurityToken></wsp:All></wsp:ExactlyOne></wsp:Policy>
\ No newline at end of file
+
+<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:sec="http://schemas.xmlsoap.org/ws/2002/12/secext">
+	<wsp:ExactlyOne>
+		<wsp:All>
+			<sec:SecurityToken>
+				<sec:TokenType>sec:X509v3</sec:TokenType>
+			</sec:SecurityToken>
+		</wsp:All>
+		<wsp:All>
+			<sec:SecurityToken>
+				<sec:TokenType>sec:X509v3</sec:TokenType>
+			</sec:SecurityToken>
+		</wsp:All>
+		<wsp:All>
+			<sec:SecurityToken>
+				<sec:TokenType>sec:Kerberosv5TGT</sec:TokenType>
+			</sec:SecurityToken>
+		</wsp:All>
+	</wsp:ExactlyOne>
+</wsp:Policy>
\ No newline at end of file

Modified: webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test8.xml
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test8.xml?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test8.xml (original)
+++ webservices/commons/trunk/modules/neethi/src/test/test-resources/samples/test8.xml Wed Aug 30 22:25:34 2006
@@ -1 +1,4 @@
-<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" ><!-- 1C --><wsp:Policy /></wsp:Policy>
\ No newline at end of file
+
+<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"><!-- 1C -->
+	<wsp:Policy />
+</wsp:Policy>
\ No newline at end of file

Modified: webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/MergeTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/MergeTest.java?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/MergeTest.java (original)
+++ webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/MergeTest.java Wed Aug 30 22:25:34 2006
@@ -55,10 +55,15 @@
 
             // result
             p4 = (Policy) p1.merge(p2);
+            p4 = (Policy) p4.normalize();
+            
+//            System.out.println("samples2" + File.separator + " Policy" + f1
+//                    + ".merge(Policy" + f2 + ") PASSED");
 
             if (!PolicyComparator.compare(p4, p3)) {
 //                System.out.println("samples2" + File.separator + " Policy" + f1
 //                        + ".merge(Policy" + f2 + ") FAILED");
+                
                 fail("samples2" + File.separator + " Policy" + f1
                         + ".merge(Policy" + f2 + ") FAILED");
             }

Modified: webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/NormalizeTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/NormalizeTest.java?rev=438802&r1=438801&r2=438802&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/NormalizeTest.java (original)
+++ webservices/commons/trunk/modules/neethi/src/test/test3/org/apache/neethi/NormalizeTest.java Wed Aug 30 22:25:34 2006
@@ -32,15 +32,15 @@
 
     public void test() throws Exception {
         String r1, r2;
-        Policy p1, p2, test;
-
-        for (int i = 1; i < 26; i++) {
+        Policy p1, p2;
+        
+        for (int i =1; i < 26; i++) {
 
             r1 = "samples" + File.separator + "test" + i + ".xml";
             r2 = "normalized" + File.separator + "test" + i + ".xml";
 
+            
             p1 = PolicyEngine.getPolicy(getResourceAsElement(r1));
-            test = p1;
             p1 = (Policy) p1.normalize(true);
             p2 = PolicyEngine.getPolicy(getResourceAsElement(r2));
             
@@ -48,16 +48,10 @@
                 XMLStreamWriter writer;
                 
                 writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
-                test.serialize(writer);
-                writer.flush();
-                
-                System.out.println("----");
-                
-                writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
                 p1.serialize(writer);
                 writer.flush();
                 
-                System.out.println("----");
+                System.out.println("\n ------------ \n");
                 
                 writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
                 p2.serialize(writer);



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org