cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r629609 [1/3] - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/ws/policy/ api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/ api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/ api/src/main/java/org/apache/cxf/ws/...
Date Wed, 20 Feb 2008 20:40:46 GMT
Author: dkulp
Date: Wed Feb 20 12:40:27 2008
New Revision: 629609

URL: http://svn.apache.org/viewvc?rev=629609&view=rev
Log:
[CXF-1411] Big policy patch from Sergey applied.  Thanks!


Added:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider.java
      - copied, changed from r629582, incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderImpl.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyAssertion.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/AddressingAnonymousPolicyTest.java   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-anon-client.xml   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-anon-server.xml   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-external-anonymous-client.xml   (with props)
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-external-anonymous-server.xml   (with props)
Removed:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderImpl.java
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AlternativeSelector.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilder.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilderRegistry.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EffectivePolicy.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EndpointPolicy.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/Intersector.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProvider.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistry.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertion.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilder.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XmlPrimitiveAssertion.java
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/util/PolicyComparator.java
    incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/AssertionInfoMapTest.java
    incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilderTest.java
    incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilderTest.java
    incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilder.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java
    incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/policy/AddressingAssertionBuilder.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/policy/AddressingPolicyInterceptorProvider.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AssertionBuilderRegistryImpl.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyBuilderImpl.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistryImpl.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/mtom/MTOMAssertionBuilder.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/mtom/MTOMPolicyInterceptorProvider.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/FirstAlternativeSelector.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/MaximalAlternativeSelector.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/MinimalAlternativeSelector.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyExtensionsTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/TestAssertion.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/attachment/external/ExternalAttachmentProviderTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/selector/FirstAlternativeSelectorTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/selector/MinimalMaximalAlternativeSelectorTest.java
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RMAssertionBuilder.java
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/policy/RMPolicyInterceptorProvider.java
    incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/AbstractRMInterceptorTest.java
    incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMEndpointTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/PolicyLoggingInterceptor.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/RMPolicyWsdlTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/addr-external.xml

Copied: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider.java (from r629582, incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderImpl.java)
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider.java?p2=incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider.java&p1=incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderImpl.java&r1=629582&r2=629609&rev=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderImpl.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider.java Wed Feb 20 12:40:27 2008
@@ -20,24 +20,49 @@
 package org.apache.cxf.ws.policy;
 
 import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.interceptor.AbstractAttributedInterceptorProvider;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Message;
 
 /**
  * 
  */
-public class PolicyInterceptorProviderImpl extends AbstractAttributedInterceptorProvider 
+public abstract class AbstractPolicyInterceptorProvider extends AbstractAttributedInterceptorProvider 
     implements PolicyInterceptorProvider {
     
     private Collection<QName> assertionTypes;
     
-    PolicyInterceptorProviderImpl(Collection<QName> at) {
+    public AbstractPolicyInterceptorProvider(QName type) {
+        this(Collections.singletonList(type));
+    }
+    
+    public AbstractPolicyInterceptorProvider(Collection<QName> at) {
         assertionTypes = at;
     }
 
     public Collection<QName> getAssertionTypes() {
         return assertionTypes;
+    }
+
+    public List<Interceptor> provideInFaultInterceptors(Message m) {
+        return getInFaultInterceptors();
+    }
+
+    public List<Interceptor> provideInInterceptors(Message m) {
+        return getInInterceptors();
+    }
+
+    public List<Interceptor> provideOutFaultInterceptors(Message m) {
+        return getOutFaultInterceptors();
+    }
+
+    public List<Interceptor> provideOutInterceptors(Message m) {
+        return getOutInterceptors();
     } 
+    
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AlternativeSelector.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AlternativeSelector.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AlternativeSelector.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AlternativeSelector.java Wed Feb 20 12:40:27 2008
@@ -21,7 +21,6 @@
 
 import java.util.Collection;
 
-import org.apache.neethi.Assertion;
 import org.apache.neethi.Policy;
 
 /**
@@ -29,6 +28,6 @@
  */
 public interface AlternativeSelector {
  
-    Collection<Assertion> selectAlternative(Policy policy, PolicyEngine engine, Assertor assertor);
+    Collection<PolicyAssertion> selectAlternative(Policy policy, PolicyEngine engine, Assertor assertor);
     
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilder.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilder.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilder.java Wed Feb 20 12:40:27 2008
@@ -25,8 +25,6 @@
 
 import org.w3c.dom.Element;
 
-import org.apache.neethi.Assertion;
-
 
 /**
  * AssertionBuilder is an interface used to build an Assertion object from a
@@ -46,7 +44,7 @@
      * @param element the element from which to build an assertion
      * @return an Assertion built from the given element
      */
-    Assertion build(Element element);
+    PolicyAssertion build(Element element);
 
 
     /**
@@ -62,5 +60,5 @@
      * Returns a new assertion that is compatible with the two specified
      * assertions or null if no compatible assertion can be built.
      */ 
-    Assertion buildCompatible(Assertion a, Assertion b);
+    PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b);
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilderRegistry.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilderRegistry.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilderRegistry.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionBuilderRegistry.java Wed Feb 20 12:40:27 2008
@@ -22,10 +22,7 @@
 import javax.xml.namespace.QName;
 
 import org.w3c.dom.Element;
-
 import org.apache.cxf.extension.Registry;
-import org.apache.neethi.Assertion;
-
 
 /**
  * AssertionBuilderRegistry is used to manage AssertionBuilders and
@@ -39,7 +36,7 @@
      * @param element the element from which to build an Assertion.
      * @return an Assertion that is built using the specified element.
      */
-    Assertion build(Element element);
+    PolicyAssertion build(Element element);
     
     /**
      * Indicates if unknown assertions should simply be ignored.

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java Wed Feb 20 12:40:27 2008
@@ -19,7 +19,6 @@
 
 package org.apache.cxf.ws.policy;
 
-import org.apache.neethi.Assertion;
 
 /**
  * 
@@ -27,9 +26,9 @@
 public class AssertionInfo {
     
     private boolean asserted;
-    private final Assertion assertion;
+    private final PolicyAssertion assertion;
     
-    public AssertionInfo(Assertion a) {
+    public AssertionInfo(PolicyAssertion a) {
         assertion = a;
     }
     public boolean isAsserted() {
@@ -38,7 +37,7 @@
     public void setAsserted(boolean a) {
         asserted = a;
     }
-    public Assertion getAssertion() {
+    public PolicyAssertion getAssertion() {
         return assertion;
     }
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java Wed Feb 20 12:40:27 2008
@@ -21,6 +21,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -31,61 +32,69 @@
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.helpers.CastUtils;
-import org.apache.neethi.Assertion;
 import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyComponent;
+import org.apache.neethi.PolicyOperator;
 
-/**
- * 
- */
 public class AssertionInfoMap extends HashMap<QName, Collection<AssertionInfo>> {
     
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(AssertionInfoMap.class, "APIMessages");
     
-    public AssertionInfoMap(Collection<Assertion> assertions) {
+    public AssertionInfoMap(Policy p) {
+        this(getAssertions(p));
+    }
+    
+    public AssertionInfoMap(Collection<PolicyAssertion> assertions) {
         super(assertions.size());
-        for (Assertion a : assertions) {
-            AssertionInfo ai = new AssertionInfo(a);
-            Collection<AssertionInfo> ais = get(a.getName());
-            if (null == ais) {
-                ais = new ArrayList<AssertionInfo>();
-                put(a.getName(), ais);
-            }
-            ais.add(ai);
+        for (PolicyAssertion a : assertions) {
+            putAssertionInfo(a);
         }
     }
     
-    public boolean supportsAlternative(Collection<Assertion> alternative) {
-        for (Assertion a : alternative) {          
-            boolean asserted = false;
-            Collection<AssertionInfo> ais = get(a.getName());
-            if (null != ais) {
-                for (AssertionInfo ai : ais) {
-                    // if (ai.getAssertion() == a && ai.isAsserted()) {
-                    if (ai.getAssertion().equal(a) && ai.isAsserted()) {
-                        asserted = true;
-                        break;
-                    }
-                }
+    private void putAssertionInfo(PolicyAssertion a) {
+        Policy p = a.getPolicy();
+        if (p != null) {
+            for (PolicyAssertion na : getAssertions(p)) {
+                putAssertionInfo(na);
             }
-            if (!asserted) {
+        }
+        AssertionInfo ai = new AssertionInfo(a);
+        Collection<AssertionInfo> ail = get(a.getName());
+        if (ail == null) {
+            ail = new ArrayList<AssertionInfo>();
+            put(a.getName(), ail);
+        }
+        ail.add(ai);
+    }
+    
+    public Collection<AssertionInfo> getAssertionInfo(QName name) {
+        Collection<AssertionInfo> ail = get(name);
+        return ail != null ? ail
+            : CastUtils.cast(Collections.EMPTY_LIST, AssertionInfo.class);
+
+    }
+    
+    public boolean supportsAlternative(Collection<PolicyAssertion> alternative) {
+        for (PolicyAssertion a : alternative) {          
+            if (!a.isAsserted(this)) {
                 return false;
             }
         }
-        
         return true;
     }
     
     public void checkEffectivePolicy(Policy policy) {
         Iterator alternatives = policy.getAlternatives();
         while (alternatives.hasNext()) {      
-            List<Assertion> alternative = CastUtils.cast((List)alternatives.next(), Assertion.class);
+            List<PolicyAssertion> alternative = CastUtils.cast((List)alternatives.next(), 
+                                                               PolicyAssertion.class);
             if (supportsAlternative(alternative)) {
                 return;
             }
         }
         throw new PolicyException(new Message("NO_ALTERNATIVE_EXC", BUNDLE));
     }
-    
+        
     public void check() {
         for (Collection<AssertionInfo> ais : values()) {
             for (AssertionInfo ai : ais) {
@@ -95,5 +104,18 @@
                 }
             }
         }
+    }
+    
+    private static Collection<PolicyAssertion> getAssertions(PolicyOperator p) {
+        List<PolicyComponent> pcs = 
+            CastUtils.cast(p.getPolicyComponents(), PolicyComponent.class);
+        if (pcs.size() == 0 || pcs.get(0) instanceof PolicyAssertion) {
+            return CastUtils.cast(pcs, PolicyAssertion.class);
+        }
+        Collection<PolicyAssertion> assertions = new ArrayList<PolicyAssertion>();
+        for (PolicyComponent pc : pcs) {
+            assertions.addAll(getAssertions((PolicyOperator)pc));
+        }
+        return assertions;   
     }
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EffectivePolicy.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EffectivePolicy.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EffectivePolicy.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EffectivePolicy.java Wed Feb 20 12:40:27 2008
@@ -23,7 +23,6 @@
 import java.util.List;
 
 import org.apache.cxf.interceptor.Interceptor;
-import org.apache.neethi.Assertion;
 import org.apache.neethi.Policy;
 
 /**
@@ -33,7 +32,7 @@
     
     Policy getPolicy();
     
-    Collection<Assertion> getChosenAlternative();
+    Collection<PolicyAssertion> getChosenAlternative();
     
     List<Interceptor> getInterceptors();
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EndpointPolicy.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EndpointPolicy.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EndpointPolicy.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/EndpointPolicy.java Wed Feb 20 12:40:27 2008
@@ -23,7 +23,6 @@
 import java.util.List;
 
 import org.apache.cxf.interceptor.Interceptor;
-import org.apache.neethi.Assertion;
 import org.apache.neethi.Policy;
 
 /**
@@ -37,11 +36,11 @@
     Policy getPolicy();
     EndpointPolicy updatePolicy(Policy p);
     
-    Collection<Assertion> getChosenAlternative();
+    Collection<PolicyAssertion> getChosenAlternative();
     
-    Collection<Assertion> getVocabulary();
+    Collection<PolicyAssertion> getVocabulary();
     
-    Collection<Assertion> getFaultVocabulary();
+    Collection<PolicyAssertion> getFaultVocabulary();
     
     List<Interceptor> getInterceptors();
     

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/Intersector.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/Intersector.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/Intersector.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/Intersector.java Wed Feb 20 12:40:27 2008
@@ -26,7 +26,6 @@
 
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.neethi.All;
-import org.apache.neethi.Assertion;
 import org.apache.neethi.ExactlyOne;
 import org.apache.neethi.Policy;
 
@@ -54,7 +53,7 @@
         strict = s;
     }
 
-    boolean compatibleAssertions(Assertion a1, Assertion a2) {
+    boolean compatibleAssertions(PolicyAssertion a1, PolicyAssertion a2) {
         AssertionBuilder ab = assertionBuilderRegistry.get(a1.getName());
         if (null == ab) {
             return false;
@@ -62,17 +61,18 @@
         return null != ab.buildCompatible(a1, a2);
     }
         
-    boolean compatibleAlternatives(Collection<Assertion> alt1, Collection<Assertion> alt2) {
+    boolean compatibleAlternatives(Collection<PolicyAssertion> alt1, 
+                                   Collection<PolicyAssertion> alt2) {
         if (alt1.isEmpty() || alt2.isEmpty()) {
             return true;
         }
         if (strict) {
-            for (Assertion a1 : alt1) {
+            for (PolicyAssertion a1 : alt1) {
                 if (null == findCompatibleAssertion(a1, alt2)) {
                     return false;
                 }
             }
-            for (Assertion a2 : alt2) {
+            for (PolicyAssertion a2 : alt2) {
                 if (null == findCompatibleAssertion(a2, alt1)) {
                     return false;
                 }
@@ -87,10 +87,12 @@
     boolean compatiblePolicies(Policy p1, Policy p2) {
         Iterator i1 = p1.getAlternatives();
         while (i1.hasNext()) {
-            Collection<Assertion> alt1 = CastUtils.cast((Collection)i1.next(), Assertion.class);
+            Collection<PolicyAssertion> alt1 = 
+                CastUtils.cast((Collection)i1.next(), PolicyAssertion.class);
             Iterator i2 = p2.getAlternatives();
             while (i2.hasNext()) {                
-                Collection<Assertion> alt2 = CastUtils.cast((Collection)i2.next(), Assertion.class);
+                Collection<PolicyAssertion> alt2 = 
+                    CastUtils.cast((Collection)i2.next(), PolicyAssertion.class);
                 if (compatibleAlternatives(alt1, alt2)) {
                     return true;                    
                 }
@@ -100,7 +102,7 @@
         return true;
     }
     
-    public Assertion intersect(Assertion a1, Assertion a2) {
+    public PolicyAssertion intersect(PolicyAssertion a1, PolicyAssertion a2) {
         AssertionBuilder ab = assertionBuilderRegistry.get(a1.getName());
         if (null == ab) {
             return null;
@@ -108,12 +110,13 @@
         return ab.buildCompatible(a1, a2);
     }
     
-    public Collection<Assertion> intersect(Collection<Assertion> alt1, 
-                                                       Collection<Assertion> alt2) {
+    public Collection<PolicyAssertion> intersect(Collection<PolicyAssertion> alt1, 
+                                                 Collection<PolicyAssertion> alt2) {
         if (!compatibleAlternatives(alt1, alt2)) {
             return null;
         }
-        Collection<Assertion> intersection = new ArrayList<Assertion>();
+        Collection<PolicyAssertion> intersection = 
+            new ArrayList<PolicyAssertion>();
         intersection.addAll(alt1);
         intersection.addAll(alt2);
         return intersection;
@@ -129,10 +132,12 @@
                 
         Iterator i1 = p1.getAlternatives();
         while (i1.hasNext()) {
-            List<Assertion> alt1 = CastUtils.cast((List)i1.next(), Assertion.class);
+            List<PolicyAssertion> alt1 = 
+                CastUtils.cast((List)i1.next(), PolicyAssertion.class);
             Iterator i2 = p2.getAlternatives();
             while (i2.hasNext()) {                
-                List<Assertion> alt2 = CastUtils.cast((List)i2.next(), Assertion.class);
+                List<PolicyAssertion> alt2 = 
+                    CastUtils.cast((List)i2.next(), PolicyAssertion.class);
                 if (compatibleAlternatives(alt1, alt2)) {
                     All all = new All();
                     all.addPolicyComponents(alt1);
@@ -149,9 +154,10 @@
         return compatible;
     }
     
-    private Assertion findCompatibleAssertion(Assertion assertion, Collection<Assertion> alt) {
-        for (Assertion a : alt) {
-            Assertion compatible = intersect(assertion, a);
+    private PolicyAssertion findCompatibleAssertion(
+        PolicyAssertion assertion, Collection<PolicyAssertion> alt) {
+        for (PolicyAssertion a : alt) {
+            PolicyAssertion compatible = intersect(assertion, a);
             if (null != compatible) {
                 return compatible;
             }

Added: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyAssertion.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyAssertion.java?rev=629609&view=auto
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyAssertion.java (added)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyAssertion.java Wed Feb 20 12:40:27 2008
@@ -0,0 +1,28 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.ws.policy;
+
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
+public interface PolicyAssertion extends Assertion {
+    boolean isAsserted(AssertionInfoMap aim);
+    Policy getPolicy();
+}

Propchange: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyAssertion.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyAssertion.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java Wed Feb 20 12:40:27 2008
@@ -26,7 +26,6 @@
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.Conduit;
 import org.apache.cxf.transport.Destination;
-import org.apache.neethi.Assertion;
 import org.apache.neethi.PolicyRegistry;
 
 /**
@@ -50,7 +49,7 @@
     
     //
     
-    boolean supportsAlternative(Collection<Assertion> alterative, Assertor assertor);
+    boolean supportsAlternative(Collection<PolicyAssertion> alterative, Assertor assertor);
     
     // available throughout the outbound path
     

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProvider.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProvider.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProvider.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProvider.java Wed Feb 20 12:40:27 2008
@@ -20,10 +20,13 @@
 package org.apache.cxf.ws.policy;
 
 import java.util.Collection;
+import java.util.List;
 
 import javax.xml.namespace.QName;
 
+import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.InterceptorProvider;
+import org.apache.cxf.message.Message;
 
 /**
  * 
@@ -36,4 +39,13 @@
      * @return collection of QNames of known assertion types
      */
     Collection<QName> getAssertionTypes();
+    
+    List<Interceptor> provideInInterceptors(Message m);
+    
+    List<Interceptor> provideOutInterceptors(Message m);
+    
+    List<Interceptor> provideOutFaultInterceptors(Message m);
+    
+    List<Interceptor> provideInFaultInterceptors(Message m);
+    
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistry.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistry.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistry.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProviderRegistry.java Wed Feb 20 12:40:27 2008
@@ -26,7 +26,6 @@
 
 import org.apache.cxf.extension.Registry;
 import org.apache.cxf.interceptor.Interceptor;
-import org.apache.neethi.Assertion;
 
 
 /**
@@ -36,6 +35,6 @@
 public interface PolicyInterceptorProviderRegistry 
     extends Registry<QName, PolicyInterceptorProvider> {
     
-    List<Interceptor> getInterceptors(Collection<Assertion> alterative, boolean out, boolean fault);
+    List<Interceptor> getInterceptors(Collection<PolicyAssertion> alterative, boolean out, boolean fault);
 
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertion.java Wed Feb 20 12:40:27 2008
@@ -21,8 +21,8 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion;
-import org.apache.neethi.Assertion;
 import org.apache.neethi.PolicyComponent;
 
 
@@ -58,19 +58,19 @@
         return data;
     }
 
-    protected Assertion cloneMandatory() {
+    protected PolicyAssertion cloneMandatory() {
         JaxbAssertion<T> a = new JaxbAssertion<T>(getName(), false);
         a.setData(data);
         return a;        
     } 
     
     @SuppressWarnings("unchecked")
-    public static <T> JaxbAssertion<T> cast(Assertion a) {
+    public static <T> JaxbAssertion<T> cast(PolicyAssertion a) {
         return (JaxbAssertion<T>)a;
     }
     
     @SuppressWarnings("unchecked")
-    public static <T> JaxbAssertion<T> cast(Assertion a, Class<T> type) {
+    public static <T> JaxbAssertion<T> cast(PolicyAssertion a, Class<T> type) {
         return (JaxbAssertion<T>)a;
     }
 

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilder.java Wed Feb 20 12:40:27 2008
@@ -37,7 +37,7 @@
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.jaxb.JAXBUtils;
 import org.apache.cxf.ws.policy.AssertionBuilder;
-import org.apache.neethi.Assertion;
+import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.neethi.Constants;
 
 public class JaxbAssertionBuilder<T> implements AssertionBuilder {
@@ -104,7 +104,7 @@
         unmarshaller = context.createUnmarshaller();
     }
     
-    public Assertion build(Element element) {
+    public PolicyAssertion build(Element element) {
         QName name = new QName(element.getNamespaceURI(), element.getLocalName());
         JaxbAssertion<T> assertion = buildAssertion();
         assertion.setName(name);
@@ -118,7 +118,7 @@
     }
 
     @SuppressWarnings("unchecked")
-    public Assertion buildCompatible(Assertion a, Assertion b) {
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
         if (a.equal(b)) {
             JaxbAssertion<T> ja = (JaxbAssertion<T>)a;
             JaxbAssertion<T> compatible = buildAssertion();

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertion.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertion.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertion.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertion.java Wed Feb 20 12:40:27 2008
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.ws.policy.builder.primitive;
 
+
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.ResourceBundle;
@@ -31,14 +33,17 @@
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.ws.policy.AssertionInfo;
+import org.apache.cxf.ws.policy.AssertionInfoMap;
+import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.PolicyBuilder;
 import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.PolicyException;
 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;
+import org.apache.neethi.PolicyOperator;
 
 /**
  * Implementation of an assertion that required exactly one (possibly empty) child element
@@ -49,13 +54,27 @@
 
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(NestedPrimitiveAssertion.class);    
     private Policy nested;
+    private boolean assertionRequired = true;
+    public NestedPrimitiveAssertion(QName name, boolean optional) {
+        this(name, optional, null, true);
+    }
     
-    protected NestedPrimitiveAssertion(QName name, boolean optional) {
+    public NestedPrimitiveAssertion(QName name, boolean optional, 
+                                    Policy p, boolean assertionRequired) {
         super(name, optional);
+        this.assertionRequired = assertionRequired;
+        this.nested = p;
+    }
+
+    public NestedPrimitiveAssertion(Element elem, PolicyBuilder builder, 
+                                    PolicyConstants constants) {
+        this(elem, builder, constants, true);
     }
     
-    public NestedPrimitiveAssertion(Element elem, PolicyBuilder builder, PolicyConstants constants) {
+    public NestedPrimitiveAssertion(Element elem, PolicyBuilder builder, 
+                                    PolicyConstants constants, boolean assertionRequired) {
         super(elem, constants);
+        this.assertionRequired = assertionRequired;
         
         // expect exactly one child element of type Policy
        
@@ -93,7 +112,8 @@
         Iterator alternatives = normalisedNested.getAlternatives();
         while (alternatives.hasNext()) {
             All all = new All();
-            List<Assertion> alternative = CastUtils.cast((List)alternatives.next(), Assertion.class);
+            List<PolicyAssertion> alternative = 
+                CastUtils.cast((List)alternatives.next(), PolicyAssertion.class);
             NestedPrimitiveAssertion a = new NestedPrimitiveAssertion(getName(), false);
             a.nested = new Policy();
             ExactlyOne nea = new ExactlyOne();
@@ -107,22 +127,69 @@
         return p;      
     } 
     
-    public Policy getNested() {
-        return nested;
-    }
-
     @Override
     public boolean equal(PolicyComponent policyComponent) {
+        
         if (!super.equal(policyComponent)) {
             return false;
         }
         NestedPrimitiveAssertion other = (NestedPrimitiveAssertion)policyComponent;
-        return getNested().equal(other.getNested());
+        return getPolicy().equal(other.getPolicy());
     }
     
-    protected void setNested(Policy n) {
+    protected void setPolicy(Policy n) {
         nested = n;
     }
     
+    @Override
+    public Policy getPolicy() {
+        return nested;
+    }
+
+    @Override
+    public boolean isAsserted(AssertionInfoMap aim) {
+        
+        if (assertionRequired) {
+            Collection<AssertionInfo> ail = aim.getAssertionInfo(name);
+            for (AssertionInfo ai : ail) {
+                if (ai.isAsserted() && isPolicyAsserted(nested, aim)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+        
+        return isPolicyAsserted(nested, aim);
+    }
     
+    protected boolean isPolicyAsserted(PolicyOperator p, AssertionInfoMap aim) {
+        if (p == null) {
+            return true;
+        }
+        List<PolicyComponent> pcs = 
+            CastUtils.cast(p.getPolicyComponents(), PolicyComponent.class);
+        if (pcs.size() == 0) {
+            return true;
+        }
+        
+        if (pcs.get(0) instanceof PolicyAssertion) {
+            List<PolicyAssertion> assertions = 
+                CastUtils.cast(pcs, PolicyAssertion.class);
+            for (PolicyAssertion pa : assertions) {
+                if (!pa.isAsserted(aim)) {
+                    return false;
+                }
+            }
+            return true;
+        } else {
+            List<PolicyOperator> assertions = 
+                CastUtils.cast(pcs, PolicyOperator.class);
+            for (PolicyOperator po : assertions) {
+                if (isPolicyAsserted(po, aim)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilder.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilder.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilder.java Wed Feb 20 12:40:27 2008
@@ -23,8 +23,8 @@
 
 import org.apache.cxf.ws.policy.AssertionBuilderRegistry;
 import org.apache.cxf.ws.policy.Intersector;
+import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.PolicyBuilder;
-import org.apache.neethi.Assertion;
 import org.apache.neethi.Policy;
 
 public class NestedPrimitiveAssertionBuilder extends PrimitiveAssertionBuilder {
@@ -41,7 +41,7 @@
     }
     
     @Override
-    public Assertion build(Element elem) {
+    public PolicyAssertion build(Element elem) {
         return new NestedPrimitiveAssertion(elem, builder, getPolicyConstants()); 
     }
 
@@ -51,7 +51,7 @@
      * . 
      * The compatible policy is optional iff both assertions are optional.
      */
-    public Assertion buildCompatible(Assertion a, Assertion b) {
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
         if (!getKnownElements().contains(a.getName()) || !a.getName().equals(b.getName())) {
             return null;
         }
@@ -66,14 +66,14 @@
         
         Intersector intersector = new Intersector(assertionBuilderRegistry);
         
-        Policy nested = intersector.intersect(na.getNested(), nb.getNested());        
+        Policy nested = intersector.intersect(na.getPolicy(), nb.getPolicy());        
         if (null == nested) {
             return  null;
         }
         
         NestedPrimitiveAssertion compatible = 
             new NestedPrimitiveAssertion(a.getName(), a.isOptional() && b.isOptional());
-        compatible.setNested(nested);
+        compatible.setPolicy(nested);
         
         return compatible;
     }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java Wed Feb 20 12:40:27 2008
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.ws.policy.builder.primitive;
 
+import java.util.Collection;
+
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
@@ -26,9 +28,11 @@
 import org.w3c.dom.Attr;
 import org.w3c.dom.Element;
 
+import org.apache.cxf.ws.policy.AssertionInfo;
+import org.apache.cxf.ws.policy.AssertionInfoMap;
+import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.neethi.All;
-import org.apache.neethi.Assertion;
 import org.apache.neethi.Constants;
 import org.apache.neethi.ExactlyOne;
 import org.apache.neethi.Policy;
@@ -37,7 +41,7 @@
 /**
  * 
  */
-public class PrimitiveAssertion implements Assertion {
+public class PrimitiveAssertion implements PolicyAssertion {
     
     protected QName name;
     protected boolean optional;
@@ -68,7 +72,7 @@
         if (policyComponent.getType() != Constants.TYPE_ASSERTION) {
             return false;
         }
-        return getName().equals(((Assertion)policyComponent).getName());
+        return getName().equals(((PolicyAssertion)policyComponent).getName());
     }
 
     public short getType() {
@@ -111,7 +115,21 @@
     public void serialize(XMLStreamWriter writer) throws XMLStreamException {
     }
     
-    protected Assertion cloneMandatory() {
+    protected PolicyAssertion cloneMandatory() {
         return new PrimitiveAssertion(name, false);
+    }
+
+    public Policy getPolicy() {
+        return null;
+    }
+
+    public boolean isAsserted(AssertionInfoMap aim) {
+        Collection<AssertionInfo> ail = aim.getAssertionInfo(name);
+        for (AssertionInfo ai : ail) {
+            if (ai.isAsserted() && ai.getAssertion().equal(this)) {
+                return true;
+            }
+        }
+        return false;
     }
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertionBuilder.java Wed Feb 20 12:40:27 2008
@@ -24,13 +24,12 @@
 
 import javax.xml.namespace.QName;
 
-
 import org.w3c.dom.Element;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.ws.policy.AssertionBuilder;
+import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.PolicyConstants;
-import org.apache.neethi.Assertion;
 
 public class PrimitiveAssertionBuilder implements AssertionBuilder {
 
@@ -41,7 +40,7 @@
         bus = b;
     }
     
-    public Assertion build(Element element) {  
+    public PolicyAssertion build(Element element) {  
         return new PrimitiveAssertion(element, getPolicyConstants());
     }
 
@@ -57,7 +56,7 @@
      * If the two assertions are equal, they are also compatible. 
      * The compatible policy is optional iff both assertions are optional.
      */
-    public Assertion buildCompatible(Assertion a, Assertion b) {
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
         if (knownElements.contains(a.getName()) && a.getName().equals(b.getName())) {
             return new PrimitiveAssertion(a.getName(), a.isOptional() && b.isOptional());
         }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XMLPrimitiveAssertionBuilder.java Wed Feb 20 12:40:27 2008
@@ -21,12 +21,12 @@
 
 import org.w3c.dom.Element;
 
+import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertionBuilder;
-import org.apache.neethi.Assertion;
 
 public class XMLPrimitiveAssertionBuilder extends PrimitiveAssertionBuilder {
  
-    public Assertion build(Element element) {
+    public PolicyAssertion build(Element element) {
         return new XmlPrimitiveAssertion(element, getPolicyConstants());
     }
 }

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XmlPrimitiveAssertion.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XmlPrimitiveAssertion.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XmlPrimitiveAssertion.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/xml/XmlPrimitiveAssertion.java Wed Feb 20 12:40:27 2008
@@ -21,9 +21,9 @@
 
 import org.w3c.dom.Element;
 
+import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion;
-import org.apache.neethi.Assertion;
 import org.apache.neethi.PolicyComponent;
 
 /**
@@ -65,7 +65,7 @@
         throw new UnsupportedOperationException();
     }
     
-    protected Assertion cloneMandatory() {
+    protected PolicyAssertion cloneMandatory() {
         Element e = (Element)element.cloneNode(true);
         if (isOptional()) {
             e.removeAttributeNode(e.getAttributeNodeNS(constants.getNamespace(), 

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/util/PolicyComparator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/util/PolicyComparator.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/util/PolicyComparator.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/util/PolicyComparator.java Wed Feb 20 12:40:27 2008
@@ -22,6 +22,7 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.neethi.All;
 import org.apache.neethi.Assertion;
 import org.apache.neethi.ExactlyOne;
@@ -72,8 +73,8 @@
         } else if (arg1 instanceof ExactlyOne) {
             return compare((ExactlyOne) arg1, (ExactlyOne) arg2);
 
-        } else if (arg1 instanceof Assertion) {
-            return compare((Assertion) arg1, (Assertion) arg2);
+        } else if (arg1 instanceof PolicyAssertion) {
+            return compare((PolicyAssertion)arg1, (PolicyAssertion)arg2);
 
         } else {
             // TODO should I throw an exception ..

Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/AssertionInfoMapTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/AssertionInfoMapTest.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/AssertionInfoMapTest.java (original)
+++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/AssertionInfoMapTest.java Wed Feb 20 12:40:27 2008
@@ -27,9 +27,9 @@
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.ws.policy.builder.primitive.NestedPrimitiveAssertion;
 import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion;
 import org.apache.neethi.All;
-import org.apache.neethi.Assertion;
 import org.apache.neethi.ExactlyOne;
 import org.apache.neethi.Policy;
 import org.easymock.classextension.EasyMock;
@@ -52,18 +52,19 @@
     
     @Test
     public void testAlternativeSupported() {
-        Assertion a1 = control.createMock(Assertion.class);
+        PolicyAssertion a1 = control.createMock(PolicyAssertion.class);
         QName aqn = new QName("http://x.y.z", "a");
         EasyMock.expect(a1.getName()).andReturn(aqn).anyTimes();
-        Assertion a2 = control.createMock(Assertion.class);
+        PolicyAssertion a2 = control.createMock(PolicyAssertion.class);
         EasyMock.expect(a2.getName()).andReturn(aqn).anyTimes();
-        Assertion b = control.createMock(Assertion.class);
+        PolicyAssertion b = control.createMock(PolicyAssertion.class);
         QName bqn = new QName("http://x.y.z", "b");
         EasyMock.expect(b.getName()).andReturn(bqn).anyTimes();
-        Assertion c = control.createMock(Assertion.class);
+        PolicyAssertion c = control.createMock(PolicyAssertion.class);
         QName cqn = new QName("http://x.y.z", "c");
         EasyMock.expect(c.getName()).andReturn(cqn).anyTimes();
-        AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, Assertion.class));
+        AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, 
+                                                                   PolicyAssertion.class));
         AssertionInfo ai1 = new AssertionInfo(a1);
         AssertionInfo ai2 = new AssertionInfo(a2);
         Collection<AssertionInfo> ais = new ArrayList<AssertionInfo>();
@@ -82,12 +83,16 @@
         EasyMock.expect(b.equal(b)).andReturn(true).anyTimes();
         EasyMock.expect(c.equal(c)).andReturn(true).anyTimes();
         
+        EasyMock.expect(a2.isAsserted(aim)).andReturn(true).anyTimes();
+        EasyMock.expect(b.isAsserted(aim)).andReturn(true).anyTimes();
+        EasyMock.expect(c.isAsserted(aim)).andReturn(true).anyTimes();
         
-        List<Assertion> alt1 = new ArrayList<Assertion>();
+        
+        List<PolicyAssertion> alt1 = new ArrayList<PolicyAssertion>();
         alt1.add(a1);
         alt1.add(b);
         
-        List<Assertion> alt2 = new ArrayList<Assertion>();
+        List<PolicyAssertion> alt2 = new ArrayList<PolicyAssertion>();
         alt2.add(a2);
         alt2.add(c);
                 
@@ -101,11 +106,11 @@
     public void testCheckEffectivePolicy() { 
         Policy p = new Policy();
         QName aqn = new QName("http://x.y.z", "a");
-        Assertion a = new PrimitiveAssertion(aqn);
+        PolicyAssertion a = new PrimitiveAssertion(aqn);
         QName bqn = new QName("http://x.y.z", "b");
-        Assertion b = new PrimitiveAssertion(bqn);
+        PolicyAssertion b = new PrimitiveAssertion(bqn);
         QName cqn = new QName("http://x.y.z", "c");
-        Assertion c = new PrimitiveAssertion(cqn);
+        PolicyAssertion c = new PrimitiveAssertion(cqn);
         All alt1 = new All();
         alt1.addAssertion(a);
         alt1.addAssertion(b);
@@ -115,7 +120,8 @@
         ea.addPolicyComponent(alt1);
         ea.addPolicyComponent(alt2);
         p.addPolicyComponent(ea);   
-        AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, Assertion.class));
+        AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, 
+                                                                   PolicyAssertion.class));
         AssertionInfo ai = new AssertionInfo(a);
         AssertionInfo bi = new AssertionInfo(b);
         AssertionInfo ci = new AssertionInfo(c);
@@ -139,8 +145,8 @@
     @Test
     public void testCheck() throws PolicyException {
         QName aqn = new QName("http://x.y.z", "a");
-        Assertion a = new PrimitiveAssertion(aqn);
-        Collection<Assertion> assertions = new ArrayList<Assertion>();
+        PolicyAssertion a = new PrimitiveAssertion(aqn);
+        Collection<PolicyAssertion> assertions = new ArrayList<PolicyAssertion>();
         assertions.add(a);
         AssertionInfoMap aim = new AssertionInfoMap(assertions);
         try {
@@ -151,5 +157,61 @@
         }
         aim.get(aqn).iterator().next().setAsserted(true);
         aim.check();
+    }
+    
+    @Test
+    public void testAllAssertionsIn() { 
+        
+        Policy nested = new Policy();
+        PolicyAssertion nb = new PrimitiveAssertion(
+            new QName("http://x.y.z", "b"));
+        nested.addAssertion(nb);
+        
+        Policy p = new Policy();
+        PolicyAssertion a1 = new PrimitiveAssertion(
+                                new QName("http://x.y.z", "a"));
+        PolicyAssertion a2 = new PrimitiveAssertion(
+                                 new QName("http://x.y.z", "a"));
+        PolicyAssertion b = new PrimitiveAssertion(
+                                new QName("http://x.y.z", "b"));
+        PolicyAssertion c = new NestedPrimitiveAssertion(
+                               new QName("http://x.y.z", "c"), false, nested, true);
+        
+        All alt1 = new All();
+        alt1.addAssertion(a1);
+        alt1.addAssertion(b);
+        All alt2 = new All();
+        alt1.addAssertion(a2);
+        alt2.addAssertion(c);
+        ExactlyOne ea = new ExactlyOne();
+        ea.addPolicyComponent(alt1);
+        ea.addPolicyComponent(alt2);
+        p.addPolicyComponent(ea);  
+        
+        AssertionInfoMap aim = new AssertionInfoMap(p);
+        
+        Collection<AssertionInfo> listA = 
+            aim.getAssertionInfo(new QName("http://x.y.z", "a"));
+        assertEquals("2 A assertions should've been added", 2, listA.size());
+        AssertionInfo[] ais = listA.toArray(new AssertionInfo[] {});
+        assertTrue("Two different A instances should be added", 
+                   ais[0].getAssertion() == a1 && ais[1].getAssertion() == a2 
+                   || ais[0].getAssertion() == a2 && ais[1].getAssertion() == a1);
+        
+        Collection<AssertionInfo> listB = 
+            aim.getAssertionInfo(new QName("http://x.y.z", "b"));
+        assertEquals("2 B assertions should've been added", 2, listB.size());
+        ais = listB.toArray(new AssertionInfo[] {});
+        assertTrue("Two different B instances should be added", 
+                   ais[0].getAssertion() == nb && ais[1].getAssertion() == b 
+                   || ais[0].getAssertion() == b && ais[1].getAssertion() == nb);
+        
+        Collection<AssertionInfo> listC = 
+            aim.getAssertionInfo(new QName("http://x.y.z", "c"));
+        assertEquals("1 C assertion should've been added", 1, listC.size());
+        ais = listC.toArray(new AssertionInfo[] {});
+        assertSame("One C instances should be added", 
+                   ais[0].getAssertion(), c);
+        
     }
 }

Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilderTest.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilderTest.java (original)
+++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/jaxb/JaxbAssertionBuilderTest.java Wed Feb 20 12:40:27 2008
@@ -28,7 +28,7 @@
 
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.test.assertions.foo.FooType;
-import org.apache.neethi.Assertion;
+import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -70,7 +70,7 @@
         Document doc = DOMUtils.readXml(is);
         Element elem = (Element)doc.getDocumentElement()
             .getElementsByTagNameNS("http://cxf.apache.org/test/assertions/foo", "foo").item(0);
-        Assertion a = ab.build(elem);
+        PolicyAssertion a = ab.build(elem);
         JaxbAssertion<FooType> jba = JaxbAssertion.cast(a, FooType.class);
         FooType foo = jba.getData();
         assertEquals("CXF", foo.getName());

Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilderTest.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilderTest.java (original)
+++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionBuilderTest.java Wed Feb 20 12:40:27 2008
@@ -30,10 +30,10 @@
 import org.apache.cxf.Bus;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.ws.policy.AssertionBuilderRegistry;
+import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.PolicyBuilder;
 import org.apache.cxf.ws.policy.PolicyConstants;
 import org.apache.cxf.ws.policy.PolicyException;
-import org.apache.neethi.Assertion;
 import org.apache.neethi.Policy;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
@@ -96,7 +96,7 @@
         control.replay();
         NestedPrimitiveAssertion npc = (NestedPrimitiveAssertion)npab.build(getElement(data));
         assertEquals(TEST_NAME1, npc.getName());
-        assertSame(nested, npc.getNested());
+        assertSame(nested, npc.getPolicy());
         assertTrue(npc.isOptional());
         control.verify();
     }
@@ -121,7 +121,7 @@
         npab.setBus(bus);
         NestedPrimitiveAssertion npc = (NestedPrimitiveAssertion)npab.build(getElement(data));
         assertEquals(TEST_NAME1, npc.getName());
-        assertSame(nested, npc.getNested());
+        assertSame(nested, npc.getPolicy());
         assertTrue(npc.isOptional());
         control.verify();
     }
@@ -130,7 +130,8 @@
     public void testBuildCompatibleNoRegistry() {
         npab.setAssertionBuilderRegistry(null);
         Policy[] policies = NestedPrimitiveAssertionTest.buildTestPolicies(); 
-        Assertion a = (Assertion)policies[4].getFirstPolicyComponent();   
+        PolicyAssertion a = 
+            (PolicyAssertion)policies[4].getFirstPolicyComponent();   
         assertNull("Should not have been able to build compatible policy.", npab.buildCompatible(a, a));
     }
     
@@ -146,8 +147,9 @@
         EasyMock.expect(reg.get(TEST_NAME3)).andReturn(ab2).anyTimes();
         
         control.replay();
-        Assertion a = (Assertion)policies[2].getFirstPolicyComponent();          
-        Assertion compatible = npab.buildCompatible(a, a);
+        PolicyAssertion a = 
+            (PolicyAssertion)policies[2].getFirstPolicyComponent();          
+        PolicyAssertion compatible = npab.buildCompatible(a, a);
         assertNotNull("assertion in policy 2 should be compatible with itself.", compatible);
         control.verify();
     }
@@ -165,23 +167,27 @@
         
         control.replay();
         for (int i = 0; i < policies.length; i++) {
-            Assertion a = (Assertion)policies[i].getFirstPolicyComponent();          
-            Assertion compatible = npab.buildCompatible(a, a);
+            PolicyAssertion a = 
+                (PolicyAssertion)policies[i].getFirstPolicyComponent();          
+            PolicyAssertion compatible = npab.buildCompatible(a, a);
             assertNotNull("assertion in policy " + i + " should be compatible with itself.", compatible);
         }
         
         for (int i = 1; i < 5; i++) {
-            Assertion a = (Assertion)policies[0].getFirstPolicyComponent();
-            Assertion b = (Assertion)policies[i].getFirstPolicyComponent();
-            Assertion compatible = npab.buildCompatible(a, b);
+            PolicyAssertion a = 
+                (PolicyAssertion)policies[0].getFirstPolicyComponent();
+            PolicyAssertion b = (PolicyAssertion)policies[i].getFirstPolicyComponent();
+            PolicyAssertion compatible = npab.buildCompatible(a, b);
             assertNotNull("assertion in policy 0 should be compatible with assertion in policy " + i + ".",
                           compatible);
         }
         
         for (int i = 2; i < 5; i++) {
-            Assertion a = (Assertion)policies[1].getFirstPolicyComponent();
-            Assertion b = (Assertion)policies[i].getFirstPolicyComponent();
-            Assertion compatible = npab.buildCompatible(a, b);
+            PolicyAssertion a = 
+                (PolicyAssertion)policies[1].getFirstPolicyComponent();
+            PolicyAssertion b = 
+                (PolicyAssertion)policies[i].getFirstPolicyComponent();
+            PolicyAssertion compatible = npab.buildCompatible(a, b);
             assertNotNull("assertion in policy " + 1 + " should be compatible with assertion in policy i.",
                           compatible);
         }

Modified: incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java (original)
+++ incubator/cxf/trunk/api/src/test/java/org/apache/cxf/ws/policy/builder/primitive/NestedPrimitiveAssertionTest.java Wed Feb 20 12:40:27 2008
@@ -19,11 +19,21 @@
 
 package org.apache.cxf.ws.policy.builder.primitive;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
 import javax.xml.namespace.QName;
 
+import org.apache.cxf.ws.policy.AssertionInfo;
+import org.apache.cxf.ws.policy.AssertionInfoMap;
+import org.apache.cxf.ws.policy.PolicyAssertion;
+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;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -39,6 +49,23 @@
     private static final QName TEST_NAME2 = new QName(TEST_NAMESPACE, "AnonymousResponses");
     private static final QName TEST_NAME3 = new QName(TEST_NAMESPACE, "NonAnonymousResponses");
     
+    public class CustomPrimitiveAssertion extends PrimitiveAssertion {
+        private int x;
+        public CustomPrimitiveAssertion(QName type, int x) {
+            super(type, false);
+            this.x = x;
+        }
+        
+        @Override
+        public boolean equal(PolicyComponent pc) {
+            if (!(pc instanceof CustomPrimitiveAssertion)
+                || !super.equal(pc)) {
+                return false;
+            }
+            return x == ((CustomPrimitiveAssertion)pc).x;
+        }
+    }
+    
     private Policy[] policies;
     
     
@@ -48,10 +75,124 @@
     }
     
     @Test
+    public void testNoNeedToAssertWithEmptyPolicy() {
+        PolicyAssertion a = new NestedPrimitiveAssertion(
+                                new QName("abc"), false, null, false);
+        AssertionInfoMap aim = new AssertionInfoMap(
+                                Collections.singletonList(a));
+        assertTrue("No need to assert", a.isAsserted(aim));
+        a = new NestedPrimitiveAssertion(new QName("abc"), 
+                                         false, 
+                                         null, 
+                                         false);
+        assertTrue("No need to assert", a.isAsserted(aim));
+    }
+    
+    
+    @Test
+    public void testNoNeedToAssertWithNonEmptyPolicy() {
+        PolicyAssertion a = new NestedPrimitiveAssertion(
+                                new QName("abc"), false, null, false);
+        AssertionInfoMap aim = new AssertionInfoMap(
+                                Collections.singletonList(a));
+        assertTrue("No need to assert", a.isAsserted(aim));
+        Policy p = new Policy();
+        p.addAssertion(new PrimitiveAssertion(new QName("abc"), false));
+        a = new NestedPrimitiveAssertion(new QName("abc"), 
+                                         false, 
+                                         p, 
+                                         false);
+        assertFalse("Primitive Assertions need to be asserted", 
+                    a.isAsserted(aim));
+        
+        p = new Policy();
+        p.addAssertion(new NestedPrimitiveAssertion(new QName("abc"), 
+                                         false, 
+                                         null, 
+                                         false));
+        a = new NestedPrimitiveAssertion(new QName("abc"), 
+                                         false, 
+                                         p, 
+                                         false);
+        assertTrue("No need to assert", a.isAsserted(aim));
+    }
+    
+    
+    @Test
+    public void testAsserted() {
+        PolicyAssertion a1 = 
+            new CustomPrimitiveAssertion(new QName("abc"), 1);
+        PolicyAssertion a2 = 
+            new CustomPrimitiveAssertion(new QName("abc"), 2);
+        Policy nested = new Policy();
+        All all = new All();
+        all.addAssertion(a2);
+        nested.addPolicyComponent(all);
+        
+        NestedPrimitiveAssertion na = new NestedPrimitiveAssertion(new QName("nested"), 
+                                         false, 
+                                         nested,
+                                         true);
+        List<PolicyAssertion> ais = 
+            new ArrayList<PolicyAssertion>();
+        
+        ais.add(a1);
+        ais.add(a2);
+        ais.add(na);
+                
+        AssertionInfoMap aim = new AssertionInfoMap(ais);
+        
+        assertFalse("Assertion has been asserted even though nether na nor a2 have been", 
+                    na.isAsserted(aim));
+        
+        assertAssertion(aim, new QName("nested"), true, true);
+        assertFalse("Assertion has been asserted even though a2 has not been", 
+                    na.isAsserted(aim));
+        
+        // assert a1 only
+        assertAssertion(aim, new QName("abc"), true, false);
+        assertFalse("Assertion has been asserted even though a2 has not been", 
+                    na.isAsserted(aim));
+        // assert a2 tpp
+        assertAssertion(aim, new QName("abc"), true, true);
+        assertTrue("Assertion has not been asserted even though both na nad a2 have been", 
+                    na.isAsserted(aim));
+        
+        PolicyAssertion a3 = new CustomPrimitiveAssertion(new QName("abc"), 3);
+        all.addAssertion(a3);
+        aim.getAssertionInfo(new QName("abc")).add(new AssertionInfo(a3));
+        
+        assertFalse("Assertion has been asserted even though a3 has not been", 
+                    na.isAsserted(aim));
+        
+        assertAssertion(aim, new QName("abc"), true, true);
+        assertTrue("Assertion has not been asserted even though na,a2,a3 have been", 
+                   na.isAsserted(aim));
+        
+    }
+    
+    private void assertAssertion(AssertionInfoMap aim, 
+                                 QName type, 
+                                 boolean value,
+                                 boolean all) {
+        Collection<AssertionInfo> aic = aim.getAssertionInfo(type);
+        if (!all) {
+            AssertionInfo ai = aic.iterator().next();
+            ai.setAsserted(value);
+        } else {
+            for (AssertionInfo ai : aic) {
+                ai.setAsserted(value);
+            }
+        }
+    }
+    
+       
+    @Test
     public void testEqual() {
-        Assertion other = new PrimitiveAssertion(new QName("abc"));
+        PolicyAssertion other = new PrimitiveAssertion(new QName("abc"));
         for (int i = 0; i < policies.length; i++) {
-            Assertion a = (Assertion)policies[i].getFirstPolicyComponent();
+            PolicyAssertion a = 
+                (PolicyAssertion)policies[i].getFirstPolicyComponent();
             assertTrue("Assertion " + i + " should equal itself.", a.equal(a)); 
             assertTrue("Assertion " + i + " should not equal other.", !a.equal(other)); 
             for (int j = i + 1; j < policies.length; j++) {
@@ -72,19 +213,19 @@
         p[i] = new Policy();
         NestedPrimitiveAssertion a = new NestedPrimitiveAssertion(TEST_NAME1, true);
         Policy nested = new Policy();
-        a.setNested(nested);
+        a.setPolicy(nested);
         p[i++].addPolicyComponent(a);
         
         p[i] = new Policy();
         a = new NestedPrimitiveAssertion(TEST_NAME1, false);
         nested = new Policy();
-        a.setNested(nested);
+        a.setPolicy(nested);
         p[i++].addPolicyComponent(a);
         
         p[i] = new Policy();
         a = new NestedPrimitiveAssertion(TEST_NAME1, false);
         nested = new Policy();
-        a.setNested(nested);
+        a.setPolicy(nested);
         nested.addPolicyComponent(new PrimitiveAssertion(TEST_NAME2, true));
         nested.addPolicyComponent(new PrimitiveAssertion(TEST_NAME3, true));
         p[i++].addPolicyComponent(a);
@@ -92,7 +233,7 @@
         p[i] = new Policy();
         a = new NestedPrimitiveAssertion(TEST_NAME1, false);
         nested = new Policy();
-        a.setNested(nested);
+        a.setPolicy(nested);
         ExactlyOne eo = new ExactlyOne();
         nested.addPolicyComponent(eo);
         eo.addPolicyComponent(new PrimitiveAssertion(TEST_NAME2));
@@ -102,7 +243,7 @@
         p[i] = new Policy();
         a = new NestedPrimitiveAssertion(TEST_NAME1, false);
         nested = new Policy();
-        a.setNested(nested);
+        a.setPolicy(nested);
         nested.addPolicyComponent(new PrimitiveAssertion(TEST_NAME3));  
         p[i++].addPolicyComponent(a); 
         

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilder.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilder.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPClientAssertionBuilder.java Wed Feb 20 12:40:27 2008
@@ -22,9 +22,9 @@
 import javax.xml.bind.JAXBException;
 
 import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
+import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion;
 import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertionBuilder;
-import org.apache.neethi.Assertion;
 import org.apache.neethi.Constants;
 import org.apache.neethi.PolicyComponent;
 
@@ -38,7 +38,7 @@
     }
 
     @Override
-    public Assertion buildCompatible(Assertion a, Assertion b) {
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
         if (PolicyUtils.HTTPCLIENTPOLICY_ASSERTION_QNAME.equals(a.getName())
             && PolicyUtils.HTTPCLIENTPOLICY_ASSERTION_QNAME.equals(b.getName())) {
             
@@ -70,15 +70,15 @@
         @Override
         public boolean equal(PolicyComponent policyComponent) {
             if (policyComponent.getType() != Constants.TYPE_ASSERTION
-                || !getName().equals(((Assertion)policyComponent).getName())) {
+                || !getName().equals(((PolicyAssertion)policyComponent).getName())) {
                 return false;
             }
-            JaxbAssertion<HTTPClientPolicy> other = JaxbAssertion.cast((Assertion)policyComponent);
+            JaxbAssertion<HTTPClientPolicy> other = JaxbAssertion.cast((PolicyAssertion)policyComponent);
             return PolicyUtils.equals(this.getData(), other.getData());  
         }
         
         @Override
-        protected Assertion cloneMandatory() {
+        protected PolicyAssertion cloneMandatory() {
             HTTPClientPolicyAssertion a = new HTTPClientPolicyAssertion();
             a.setData(getData());
             return a;        

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/HTTPServerAssertionBuilder.java Wed Feb 20 12:40:27 2008
@@ -22,9 +22,9 @@
 import javax.xml.bind.JAXBException;
 
 import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
+import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion;
 import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertionBuilder;
-import org.apache.neethi.Assertion;
 import org.apache.neethi.Constants;
 import org.apache.neethi.PolicyComponent;
 
@@ -38,7 +38,7 @@
     }
 
     @Override
-    public Assertion buildCompatible(Assertion a, Assertion b) {
+    public PolicyAssertion buildCompatible(PolicyAssertion a, PolicyAssertion b) {
         if (PolicyUtils.HTTPSERVERPOLICY_ASSERTION_QNAME.equals(a.getName())
             && PolicyUtils.HTTPSERVERPOLICY_ASSERTION_QNAME.equals(b.getName())) {
             
@@ -70,15 +70,15 @@
         @Override
         public boolean equal(PolicyComponent policyComponent) {
             if (policyComponent.getType() != Constants.TYPE_ASSERTION
-                || !getName().equals(((Assertion)policyComponent).getName())) {
+                || !getName().equals(((PolicyAssertion)policyComponent).getName())) {
                 return false;
             }
-            JaxbAssertion<HTTPServerPolicy> other = JaxbAssertion.cast((Assertion)policyComponent);
+            JaxbAssertion<HTTPServerPolicy> other = JaxbAssertion.cast((PolicyAssertion)policyComponent);
             return PolicyUtils.equals(this.getData(), other.getData());  
         }
         
         @Override
-        protected Assertion cloneMandatory() {
+        protected PolicyAssertion cloneMandatory() {
             HTTPServerPolicyAssertion a = new HTTPServerPolicyAssertion();
             a.setData(getData());
             return a;        

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/policy/PolicyUtils.java Wed Feb 20 12:40:27 2008
@@ -36,10 +36,10 @@
 import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
 import org.apache.cxf.ws.policy.AssertionInfo;
 import org.apache.cxf.ws.policy.AssertionInfoMap;
+import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.PolicyEngine;
 import org.apache.cxf.ws.policy.PolicyException;
 import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion;
-import org.apache.neethi.Assertion;
 
 /**
  * 
@@ -81,7 +81,7 @@
         if (null == ais) {
             return confPolicy;
         }
-        Collection<Assertion> alternative = new ArrayList<Assertion>();
+        Collection<PolicyAssertion> alternative = new ArrayList<PolicyAssertion>();
         for (AssertionInfo ai : ais) {
             alternative.add(ai.getAssertion());
         }
@@ -116,7 +116,7 @@
         if (null == ais) {
             return confPolicy;
         }
-        Collection<Assertion> alternative = new ArrayList<Assertion>();
+        Collection<PolicyAssertion> alternative = new ArrayList<PolicyAssertion>();
         for (AssertionInfo ai : ais) {
             alternative.add(ai.getAssertion());
         }
@@ -143,9 +143,9 @@
      * @throws PolicyException if no compatible HTTPClientPolicy can be determined
      */
     public static HTTPClientPolicy getClient(PolicyEngine pe, EndpointInfo ei, Conduit c) {
-        Collection<Assertion> alternative = pe.getClientEndpointPolicy(ei, c).getChosenAlternative();
+        Collection<PolicyAssertion> alternative = pe.getClientEndpointPolicy(ei, c).getChosenAlternative();
         HTTPClientPolicy compatible = null;
-        for (Assertion a : alternative) {
+        for (PolicyAssertion a : alternative) {
             if (HTTPCLIENTPOLICY_ASSERTION_QNAME.equals(a.getName())) {
                 HTTPClientPolicy p = JaxbAssertion.cast(a, HTTPClientPolicy.class).getData();
                 if (null == compatible) {
@@ -173,9 +173,9 @@
      * @throws PolicyException if no compatible HTTPServerPolicy can be determined
      */
     public static HTTPServerPolicy getServer(PolicyEngine pe, EndpointInfo ei, Destination d) {
-        Collection<Assertion> alternative = pe.getServerEndpointPolicy(ei, d).getChosenAlternative();
+        Collection<PolicyAssertion> alternative = pe.getServerEndpointPolicy(ei, d).getChosenAlternative();
         HTTPServerPolicy compatible = null;
-        for (Assertion a : alternative) {
+        for (PolicyAssertion a : alternative) {
             if (HTTPSERVERPOLICY_ASSERTION_QNAME.equals(a.getName())) {
                 HTTPServerPolicy p = JaxbAssertion.cast(a, HTTPServerPolicy.class).getData();
                 if (null == compatible) {
@@ -615,9 +615,9 @@
         return s1 == null || s2 == null || s1.equals(s2);
     }
     
-    private static HTTPClientPolicy getClient(Collection<Assertion> alternative) {      
+    private static HTTPClientPolicy getClient(Collection<PolicyAssertion> alternative) {      
         HTTPClientPolicy compatible = null;
-        for (Assertion a : alternative) {
+        for (PolicyAssertion a : alternative) {
             if (HTTPCLIENTPOLICY_ASSERTION_QNAME.equals(a.getName())) {
                 HTTPClientPolicy p = JaxbAssertion.cast(a, HTTPClientPolicy.class).getData();
                 if (null == compatible) {
@@ -637,9 +637,9 @@
         return compatible;
     }
     
-    private static HTTPServerPolicy getServer(Collection<Assertion> alternative) {      
+    private static HTTPServerPolicy getServer(Collection<PolicyAssertion> alternative) {      
         HTTPServerPolicy compatible = null;
-        for (Assertion a : alternative) {
+        for (PolicyAssertion a : alternative) {
             if (HTTPSERVERPOLICY_ASSERTION_QNAME.equals(a.getName())) {
                 HTTPServerPolicy p = JaxbAssertion.cast(a, HTTPServerPolicy.class).getData();
                 if (null == compatible) {

Modified: incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java?rev=629609&r1=629608&r2=629609&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/policy/PolicyUtilsTest.java Wed Feb 20 12:40:27 2008
@@ -30,8 +30,8 @@
 import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
 import org.apache.cxf.ws.policy.AssertionInfo;
 import org.apache.cxf.ws.policy.AssertionInfoMap;
+import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion;
-import org.apache.neethi.Assertion;
 import org.easymock.classextension.EasyMock;
 import org.easymock.classextension.IMocksControl;
 import org.junit.Assert;
@@ -171,7 +171,7 @@
         control.verify();
 
         control.reset();
-        Collection<Assertion> as = new ArrayList<Assertion>();
+        Collection<PolicyAssertion> as = new ArrayList<PolicyAssertion>();
         AssertionInfoMap aim = new AssertionInfoMap(as);
         EasyMock.expect(message.get(AssertionInfoMap.class)).andReturn(aim);
         control.replay();
@@ -216,7 +216,8 @@
         AssertionInfo cmai = new AssertionInfo(cma);
         AssertionInfo icmai = new AssertionInfo(icma);
 
-        AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, Assertion.class));
+        AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST,
+                                                                   PolicyAssertion.class));
         Collection<AssertionInfo> ais = new ArrayList<AssertionInfo>();
         ais.add(eai);
         ais.add(cmai);
@@ -275,7 +276,8 @@
         AssertionInfo cmai = new AssertionInfo(cma);
         AssertionInfo icmai = new AssertionInfo(icma);
 
-        AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, Assertion.class));
+        AssertionInfoMap aim = new AssertionInfoMap(CastUtils.cast(Collections.EMPTY_LIST, 
+                                                                   PolicyAssertion.class));
         Collection<AssertionInfo> ais = new ArrayList<AssertionInfo>();
         ais.add(eai);
         ais.add(mai);



Mime
View raw message