You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by an...@apache.org on 2007/02/28 10:29:45 UTC

svn commit: r512674 [1/2] - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/service/model/ api/src/main/java/org/apache/cxf/ws/policy/ rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/ rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/...

Author: andreasmyth
Date: Wed Feb 28 01:29:43 2007
New Revision: 512674

URL: http://svn.apache.org/viewvc?view=rev&rev=512674
Log:
[JIRA CXF-381] Policy verification.

Added:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java   (with props)
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/OutPolicyInfo.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyInfoTest.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/OutPolicyInfoTest.java
      - copied, changed from r510865, incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/ClientPolicyInfoTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptorTest.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptorTest.java   (with props)
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptorTest.java   (with props)
Removed:
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientRequestPolicyInfo.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/Names.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerResponsePolicyInfo.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/ClientPolicyInfoTest.java
Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/FaultInfo.java
    incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.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/EndpointPolicyInfo.java
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/Messages.properties
    incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.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/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
    incubator/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/FaultInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/FaultInfo.java?view=diff&rev=512674&r1=512673&r2=512674
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/FaultInfo.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/FaultInfo.java Wed Feb 28 01:29:43 2007
@@ -21,7 +21,7 @@
 
 import javax.xml.namespace.QName;
 
-public final class FaultInfo extends AbstractMessageContainer {
+public class FaultInfo extends AbstractMessageContainer {
     private QName faultName;
     
     public FaultInfo(QName fname, QName mname, OperationInfo info) {

Added: 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?view=auto&rev=512674
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java (added)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfo.java Wed Feb 28 01:29:43 2007
@@ -0,0 +1,44 @@
+/**
+ * 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;
+
+/**
+ * 
+ */
+public class AssertionInfo {
+    
+    private boolean asserted;
+    private final Assertion assertion;
+    
+    public AssertionInfo(Assertion a) {
+        assertion = a;
+    }
+    public boolean isAsserted() {
+        return asserted;
+    }
+    public void setAsserted(boolean a) {
+        asserted = a;
+    }
+    public Assertion getAssertion() {
+        return assertion;
+    }
+}

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

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

Added: 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?view=auto&rev=512674
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java (added)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/AssertionInfoMap.java Wed Feb 28 01:29:43 2007
@@ -0,0 +1,46 @@
+/**
+ * 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 java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+
+import javax.xml.namespace.QName;
+
+import org.apache.neethi.Assertion;
+
+/**
+ * 
+ */
+public class AssertionInfoMap extends HashMap<QName, Collection<AssertionInfo>> {
+    public AssertionInfoMap(Collection<Assertion> 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);
+        }
+    }
+}

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

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

Modified: incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java?view=diff&rev=512674&r1=512673&r2=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java (original)
+++ incubator/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java Wed Feb 28 01:29:43 2007
@@ -35,7 +35,6 @@
 
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
-import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.OutgoingChainSetupInterceptor;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
@@ -45,8 +44,8 @@
 import org.apache.cxf.transport.Conduit;
 import org.apache.cxf.transport.Destination;
 import org.apache.cxf.ws.addressing.policy.MetadataConstants;
-import org.apache.cxf.ws.policy.PolicyConstants;
-import org.apache.neethi.Assertion;
+import org.apache.cxf.ws.policy.AssertionInfo;
+import org.apache.cxf.ws.policy.AssertionInfoMap;
 
 
 /**
@@ -166,19 +165,43 @@
      * @pre requestor role
      */
     private boolean hasAddressingAssertion(Message message) {
-        Collection<Assertion> assertions = 
-            CastUtils.cast((Collection)message.get(PolicyConstants.CLIENT_OUT_ASSERTIONS), Assertion.class);
-        if (null == assertions) {
+        AssertionInfoMap aim = message.get(AssertionInfoMap.class);
+        if (null == aim) {
             return false;
+            
         }
-        for (Assertion a : assertions) {
-            if (MetadataConstants.ADDRESSING_ASSERTION_QNAME.equals(a.getName())) {
-                return true;
-            }
+        Collection<AssertionInfo> ais = aim.get(MetadataConstants.ADDRESSING_ASSERTION_QNAME);
+        if (null == ais || ais.size() == 0) {
+            return false;
+        }
+        // no need to analyse the content of the Addressing assertion here
+        
+        return true;
+    }
+    
+    /**
+     * Asserts all Addressing assertions for the current message, regardless their nested 
+     * Policies.
+     * @param message the current message
+     */
+    private void assertAddressing(Message message) {
+        AssertionInfoMap aim = message.get(AssertionInfoMap.class);
+        if (null == aim) {
+            return;
+            
+        }
+        Collection<AssertionInfo> ais = aim.get(MetadataConstants.ADDRESSING_ASSERTION_QNAME);
+        if (null == ais || ais.size() == 0) {
+            return;
+        }
+        
+        for (AssertionInfo ai : ais) {
+            ai.setAsserted(true);
+            System.out.println("Asserted Addressing assertion: " + ai.getAssertion());
         }
-        return false;
     }
 
+
     /**
      * @param exts list of extension elements
      * @return true iff the UsingAddressing element is found
@@ -233,6 +256,9 @@
                 // must be aggregated
                 aggregate(message, isFault);
             }
+        }
+        if (null != ContextUtils.retrieveMAPs(message, false, ContextUtils.isOutbound(message))) {            
+            assertAddressing(message);
         }
         return continueProcessing;
     }

Added: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java?view=auto&rev=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptor.java Wed Feb 28 01:29:43 2007
@@ -0,0 +1,40 @@
+/**
+ * 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.cxf.Bus;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+
+/**
+ * 
+ */
+public abstract class AbstractPolicyInterceptor extends AbstractPhaseInterceptor<Message> {
+    
+    protected Bus bus;
+    
+    public void setBus(Bus b) {
+        bus = b;
+    }
+    
+    public Bus getBus() {
+        return bus;
+    }
+}

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

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

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java?view=diff&rev=512674&r1=512673&r2=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java Wed Feb 28 01:29:43 2007
@@ -19,40 +19,31 @@
 
 package org.apache.cxf.ws.policy;
 
+import java.util.Collection;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
-import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.transport.Conduit;
+import org.apache.neethi.Assertion;
 
 /**
  * 
  */
-public class ClientPolicyInFaultInterceptor extends AbstractPhaseInterceptor<Message> {
+public class ClientPolicyInFaultInterceptor extends AbstractPolicyInterceptor {
 
     private static final Logger LOG = LogUtils.getL7dLogger(ClientPolicyInFaultInterceptor.class);
-    private Bus bus;
     
     public ClientPolicyInFaultInterceptor() {
         setId(PolicyConstants.CLIENT_POLICY_IN_FAULT_INTERCEPTOR_ID);
         setPhase(Phase.RECEIVE);
     }
-        
-    public void setBus(Bus b) {
-        bus = b;
-    }
-    
-    public Bus getBus() {
-        return bus;
-    }
     
     public void handleMessage(Message msg) {        
         if (!PolicyUtils.isRequestor(msg)) {
@@ -79,12 +70,19 @@
         // We do not know the underlying message type yet - so we pre-emptively add interceptors 
         // that can deal with the response and all of the operation's possible fault messages.
         
-        List<Interceptor> policyInFaultInterceptors = pe.getClientInFaultInterceptors(e, conduit);
+        EndpointPolicyInfo epi = pe.getEndpointPolicyInfo(e, conduit);
+        
+        List<Interceptor> policyInFaultInterceptors = epi.getInFaultInterceptors();
         for (Interceptor poi : policyInFaultInterceptors) {
             msg.getInterceptorChain().add(poi);
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Added interceptor of type " + poi.getClass().getSimpleName());
-            }
+            LOG.log(Level.INFO, "Added interceptor of type {0}", poi.getClass().getSimpleName());
+        }
+        
+        // insert assertions of endpoint's fault vocabulary into message
+        
+        Collection<Assertion> assertions = epi.getFaultVocabulary();
+        if (null != assertions) {
+            msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
         }
     }
 }

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java?view=diff&rev=512674&r1=512673&r2=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInInterceptor.java Wed Feb 28 01:29:43 2007
@@ -19,40 +19,31 @@
 
 package org.apache.cxf.ws.policy;
 
+import java.util.Collection;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
-import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.transport.Conduit;
+import org.apache.neethi.Assertion;
 
 /**
  * 
  */
-public class ClientPolicyInInterceptor extends AbstractPhaseInterceptor<Message> {
+public class ClientPolicyInInterceptor extends AbstractPolicyInterceptor {
 
     private static final Logger LOG = LogUtils.getL7dLogger(ClientPolicyInInterceptor.class);
-    private Bus bus;
     
     public ClientPolicyInInterceptor() {
         setId(PolicyConstants.CLIENT_POLICY_IN_INTERCEPTOR_ID);
         setPhase(Phase.RECEIVE);
     }
-        
-    public void setBus(Bus b) {
-        bus = b;
-    }
-    
-    public Bus getBus() {
-        return bus;
-    }
     
     public void handleMessage(Message msg) {        
         if (!PolicyUtils.isRequestor(msg)) {
@@ -79,12 +70,19 @@
         // We do not know the underlying message type yet - so we pre-emptively add interceptors 
         // that can deal with the response and all of the operation's possible fault messages.
         
-        List<Interceptor> policyInInterceptors = pe.getClientInInterceptors(e, conduit);
+        EndpointPolicyInfo epi = pe.getEndpointPolicyInfo(e, conduit);
+        
+        List<Interceptor> policyInInterceptors = epi.getInInterceptors();
         for (Interceptor poi : policyInInterceptors) {
             msg.getInterceptorChain().add(poi);
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Added interceptor of type " + poi.getClass().getSimpleName());
-            }
+            LOG.log(Level.INFO, "Added interceptor of type {0}", poi.getClass().getSimpleName());            
+        }
+        
+        // insert assertions of endpoint's vocabulary into message
+        
+        Collection<Assertion> assertions = epi.getVocabulary();
+        if (null != assertions) {
+            msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
         }
         
     }

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java?view=diff&rev=512674&r1=512673&r2=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyOutInterceptor.java Wed Feb 28 01:29:43 2007
@@ -19,42 +19,33 @@
 
 package org.apache.cxf.ws.policy;
 
+import java.util.Collection;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
-import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.transport.Conduit;
+import org.apache.neethi.Assertion;
 
 /**
  * 
  */
-public class ClientPolicyOutInterceptor extends AbstractPhaseInterceptor<Message> {
+public class ClientPolicyOutInterceptor extends AbstractPolicyInterceptor {
 
     private static final Logger LOG = LogUtils.getL7dLogger(ClientPolicyOutInterceptor.class);
-    private Bus bus;
     
     public ClientPolicyOutInterceptor() {
         setId(PolicyConstants.CLIENT_POLICY_OUT_INTERCEPTOR_ID);
         setPhase(Phase.SETUP);
     }
     
-    public void setBus(Bus b) {
-        bus = b;
-    }
-    
-    public Bus getBus() {
-        return bus;
-    }
-    
     public void handleMessage(Message msg) {
         if (!PolicyUtils.isRequestor(msg)) {
             LOG.fine("Not a requestor.");
@@ -85,16 +76,19 @@
         
         // add the required interceptors
         
-        List<Interceptor> policyOutInterceptors = pe.getClientOutInterceptors(e, boi, conduit);
+        OutPolicyInfo opi = pe.getClientRequestPolicyInfo(e, boi, conduit);
+        
+        List<Interceptor> policyOutInterceptors = opi.getInterceptors();
         for (Interceptor poi : policyOutInterceptors) {            
             msg.getInterceptorChain().add(poi);
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Added interceptor of type " + poi.getClass().getSimpleName());
-            }
+            LOG.log(Level.INFO, "Added interceptor of type {0}", poi.getClass().getSimpleName());
         }
         
         // insert assertions of the chosen alternative into the message
         
-        msg.put(PolicyConstants.CLIENT_OUT_ASSERTIONS, pe.getClientOutAssertions(e, boi, conduit));
+        Collection<Assertion> assertions = opi.getChosenAlternative();
+        if (null != assertions) {
+            msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
+        }
     }
 }

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyInfo.java?view=diff&rev=512674&r1=512673&r2=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyInfo.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyInfo.java Wed Feb 28 01:29:43 2007
@@ -20,6 +20,7 @@
 package org.apache.cxf.ws.policy;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
@@ -46,24 +47,35 @@
     private static final ResourceBundle BUNDLE = BundleUtils.getBundle(EndpointPolicyInfo.class);
     
     private Policy policy;
-    private List<Assertion> chosenAlternative;
+    private Collection<Assertion> chosenAlternative;
+    private Collection<Assertion> vocabulary;
+    private Collection<Assertion> faultVocabulary;
     private List<Interceptor> inInterceptors;
     private List<Interceptor> inFaultInterceptors;
     
     void initialise(EndpointInfo ei, boolean isServer, PolicyEngine engine, Assertor assertor) {
         initialisePolicy(ei, engine);
         chooseAlternative(engine, assertor);
-        initialiseInterceptors(ei, isServer, engine);  
+        initialiseVocabulary(ei, isServer, engine);
+        initialiseInterceptors(ei, isServer, engine); 
     }
    
     public Policy getPolicy() {
         return policy;        
     }
     
-    public List<Assertion> getChosenAlternative() {
+    public Collection<Assertion> getChosenAlternative() {
         return chosenAlternative;
     }
     
+    public Collection<Assertion> getVocabulary() {
+        return vocabulary;
+    }
+    
+    public Collection<Assertion> getFaultVocabulary() {
+        return faultVocabulary;
+    }    
+    
     public List<Interceptor> getInInterceptors() {
         return inInterceptors;
     }
@@ -89,81 +101,86 @@
         }
         throw new PolicyException(new Message("NO_ALTERNATIVE_EXC", BUNDLE));
     }
-
-    void initialiseInterceptors(EndpointInfo ei, boolean isServer, PolicyEngine engine) {
-        PolicyInterceptorProviderRegistry reg 
-            = engine.getBus().getExtension(PolicyInterceptorProviderRegistry.class);
-        inInterceptors = new ArrayList<Interceptor>();
-        inFaultInterceptors = new ArrayList<Interceptor>();
+    
+    void initialiseVocabulary(EndpointInfo ei, boolean requestor, PolicyEngine engine) {
+        vocabulary = new ArrayList<Assertion>();
+        if (requestor) {
+            faultVocabulary = new ArrayList<Assertion>();
+        }
+       
+        // vocabulary of alternative chosen for endpoint
         
-        // the minimal set of interceptors required to satisfy the effective policy for
-        // any inbound message 
         for (Assertion a : getChosenAlternative()) {
             if (a.isOptional()) {
                 continue;
             }
-            QName qn = a.getName();
-            PolicyInterceptorProvider pp = reg.get(qn);
-            if (null != pp) {
-                inInterceptors.addAll(pp.getInInterceptors());
-                inFaultInterceptors.addAll(pp.getInInterceptors());
+            vocabulary.add(a);            
+            if (null != faultVocabulary) {
+                faultVocabulary.add(a);
             }
         }
+   
+        // add assertions for specific inbound (in case of a server endpoint) or outbound 
+        // (in case of a client endpoint) messages
         
-        // add the interceptors that may be needed to support the additional assertions
-        // for specific inbound (in case of a server endpoint) or outbound (in case of a client endpoint)
-        // messages
-        
-        Set<QName> vocabulary = null;
-  
         for (BindingOperationInfo boi : ei.getBinding().getOperations()) {
             Policy p = engine.getAggregatedOperationPolicy(boi);
-            Set<QName> v = engine.getVocabulary(p, false);
-            if (null == vocabulary) {
-                vocabulary = v;
-            } else {
-                vocabulary.addAll(v); 
+            Collection<Assertion> c = engine.getAssertions(p, false);
+            vocabulary.addAll(c);
+            if (null != faultVocabulary) {
+                faultVocabulary.addAll(c);
             }
-            if (isServer) {
+ 
+            if (!requestor) {
                 p = engine.getAggregatedMessagePolicy(boi.getInput());
-                vocabulary.addAll(engine.getVocabulary(p, false));
+                vocabulary.addAll(engine.getAssertions(p, false));
             } else if (null != boi.getOutput()) {
-                for (BindingFaultInfo bfi : boi.getFaults()) {
+                p = engine.getAggregatedMessagePolicy(boi.getOutput());
+                vocabulary.addAll(engine.getAssertions(p, false));
+                
+                for (BindingFaultInfo bfi : boi.getFaults()) { 
                     p = engine.getAggregatedFaultPolicy(bfi);
-                    vocabulary.addAll(engine.getVocabulary(p, false)); 
+                    faultVocabulary.addAll(engine.getAssertions(p, false));
                 }
             }
         }
+    }
+
+    void initialiseInterceptors(EndpointInfo ei, boolean requestor, PolicyEngine engine) {
+        PolicyInterceptorProviderRegistry reg 
+            = engine.getBus().getExtension(PolicyInterceptorProviderRegistry.class);
+        inInterceptors = new ArrayList<Interceptor>();
+        if (requestor) {
+            inFaultInterceptors = new ArrayList<Interceptor>();
+        }
         
-        Set<QName> clientVocabulary = isServer ? null : new HashSet<QName>();
-        if (!isServer) {
-            clientVocabulary.addAll(vocabulary);
-            for (BindingOperationInfo boi : ei.getBinding().getOperations()) {
-                if (null != boi.getOutput()) {
-                    Policy p = engine.getAggregatedMessagePolicy(boi.getOutput());
-                    clientVocabulary.addAll(engine.getVocabulary(p, false)); 
-                }
-            }
+        Set<QName> v = new HashSet<QName>();
+        for (Assertion a : vocabulary) {
+            v.add(a.getName());
         }
-
-        for (QName qn : vocabulary) {
+        
+        for (QName qn : v) {
             PolicyInterceptorProvider pp = reg.get(qn);
             if (null != pp) {
-                if (isServer) {
-                    inInterceptors.addAll(pp.getInInterceptors());
-                } else {
-                    inFaultInterceptors.addAll(pp.getInFaultInterceptors());
-                }
+                inInterceptors.addAll(pp.getInInterceptors());
             }
         }
-        if (!isServer) {
-            for (QName qn : clientVocabulary) {
-                PolicyInterceptorProvider pp = reg.get(qn);
-                if (null != pp) {
-                    inInterceptors.addAll(pp.getInInterceptors());
-                }
-            }
+        
+        if (!requestor) {
+            return;
         }
+        
+        Set<QName> faultV = new HashSet<QName>();
+        for (Assertion a : faultVocabulary) {
+            faultV.add(a.getName());
+        }
+        
+        for (QName qn : faultV) {
+            PolicyInterceptorProvider pp = reg.get(qn);
+            if (null != pp) {
+                inFaultInterceptors.addAll(pp.getInFaultInterceptors());
+            }
+        }        
     }
     
     // for test
@@ -172,8 +189,16 @@
         policy = ep;
     }
     
-    void setChosenAlternative(List<Assertion> c) {
+    void setChosenAlternative(Collection<Assertion> c) {
         chosenAlternative = c;
+    }
+    
+    void setVocabulary(Collection<Assertion> v) {
+        vocabulary = v;
+    }
+    
+    void setFaultVocabulary(Collection<Assertion> v) {
+        faultVocabulary = v;
     }
     
     void setInInterceptors(List<Interceptor> in) {

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/Messages.properties?view=diff&rev=512674&r1=512673&r2=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/Messages.properties (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/Messages.properties Wed Feb 28 01:29:43 2007
@@ -23,4 +23,5 @@
 NOT_A_POLICY_ELEMENT_EXC = Specified element is not a Policy element.
 NOT_A_POLICYREF_ELEMENT_EXC = Specified element is not a PolicyReference element.
 NO_ALTERNATIVE_EXC = None of the policy alternatives can be satisfied.
-UNRESOLVED_POLICY_REEFERENCE_EXC = Policy reference {0} could not be resolved.
\ No newline at end of file
+UNRESOLVED_POLICY_REEFERENCE_EXC = Policy reference {0} could not be resolved.
+NOT_ASSERTED_EXC = Assertion of type {0} could not be asserted.
\ No newline at end of file

Added: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/OutPolicyInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/OutPolicyInfo.java?view=auto&rev=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/OutPolicyInfo.java (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/OutPolicyInfo.java Wed Feb 28 01:29:43 2007
@@ -0,0 +1,191 @@
+/**
+ * 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 java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.service.model.BindingFaultInfo;
+import org.apache.cxf.service.model.BindingMessageInfo;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.Destination;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
+/**
+ * 
+ */
+public class OutPolicyInfo  {
+    
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(OutPolicyInfo.class);
+    
+    protected Policy policy;     
+    protected Collection<Assertion> chosenAlternative;
+    protected List<Interceptor> interceptors;
+    
+    void initialise(Endpoint e, 
+                    BindingOperationInfo boi, 
+                    PolicyEngine engine, 
+                    Assertor assertor,
+                    boolean requestor) {
+        initialisePolicy(e, boi, engine, requestor);
+        chooseAlternative(engine, assertor);
+        initialiseInterceptors(engine);  
+    }
+    
+    void initialise(Endpoint e, 
+                    BindingFaultInfo bfi, 
+                    PolicyEngine engine, 
+                    Assertor assertor) {
+        initialisePolicy(e, bfi, engine);
+        chooseAlternative(engine, assertor);
+        initialiseInterceptors(engine);  
+    }
+   
+    public Policy getPolicy() {
+        return policy;        
+    }
+    
+    public List<Interceptor> getInterceptors() {
+        return interceptors;
+    }
+    
+    public Collection<Assertion> getChosenAlternative() {
+        return chosenAlternative;
+    }
+    
+    
+    
+    void initialisePolicy(Endpoint e,
+                          BindingOperationInfo boi,  
+                          PolicyEngine engine, 
+                          boolean requestor) {
+        BindingMessageInfo bmi = requestor ? boi.getInput() : boi.getOutput();
+        if (requestor) {
+            policy = engine.getEndpointPolicyInfo(e, (Conduit)null).getPolicy();
+        } else {
+            policy = engine.getEndpointPolicyInfo(e, (Destination)null).getPolicy();
+        }
+        
+        policy = policy.merge(engine.getAggregatedOperationPolicy(boi));
+        if (null != bmi) {
+            policy = policy.merge(engine.getAggregatedMessagePolicy(bmi));
+        }
+        policy = (Policy)policy.normalize(true);
+    }
+    
+    void initialisePolicy(Endpoint e, BindingFaultInfo bfi, PolicyEngine engine) {
+        BindingOperationInfo boi = bfi.getBindingOperation();
+        policy = engine.getEndpointPolicyInfo(e, (Destination)null).getPolicy();         
+        policy = policy.merge(engine.getAggregatedOperationPolicy(boi));
+        policy = policy.merge(engine.getAggregatedFaultPolicy(bfi));
+        policy = (Policy)policy.normalize(true);
+    }
+
+    void chooseAlternative(PolicyEngine engine, Assertor assertor) {
+        Iterator alternatives = policy.getAlternatives();
+        while (alternatives.hasNext()) {
+            List<Assertion> alternative = CastUtils.cast((List)alternatives.next(), Assertion.class);
+            if (engine.supportsAlternative(alternative, assertor)) {
+                setChosenAlternative(alternative);
+                return;
+            }
+        }
+        throw new PolicyException(new Message("NO_ALTERNATIVE_EXC", BUNDLE));
+
+    }
+
+    void initialiseInterceptors(PolicyEngine engine) {
+        PolicyInterceptorProviderRegistry reg 
+            = engine.getBus().getExtension(PolicyInterceptorProviderRegistry.class);
+        List<Interceptor> out = new ArrayList<Interceptor>();
+        for (Assertion a : getChosenAlternative()) {
+            if (a.isOptional()) {
+                continue;
+            }
+            QName qn = a.getName();
+            PolicyInterceptorProvider pp = reg.get(qn);
+            if (null != pp) {
+                out.addAll(pp.getOutInterceptors());
+            }
+        }
+        setInterceptors(out);
+    }
+    
+    void checkEffectivePolicy(AssertionInfoMap aim) {
+        Iterator alternatives = policy.getAlternatives();
+        while (alternatives.hasNext()) {      
+            List<Assertion> alternative = CastUtils.cast((List)alternatives.next(), Assertion.class);
+            if (alternativeSupported(alternative, aim)) {
+                return;
+            }
+        }
+        
+        throw new PolicyException(new Message("NO_ALTERNATIVE_EXC", BUNDLE));
+    }
+    
+    boolean alternativeSupported(List<Assertion> alternative, AssertionInfoMap aim) {
+        
+        for (Assertion a : alternative) {
+            boolean asserted = false;
+            Collection<AssertionInfo> ais = aim.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;
+                    }
+                }
+            }
+            if (!asserted) {
+                return false;
+            }
+        }
+        
+        return true;
+    }
+    
+    // for tests
+    
+    void setPolicy(Policy ep) {
+        policy = ep;
+    }
+    
+    void setChosenAlternative(Collection<Assertion> c) {
+        chosenAlternative = c;
+    }
+    
+    void setInterceptors(List<Interceptor> out) {
+        interceptors = out;
+    }
+   
+}

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

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

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java?view=diff&rev=512674&r1=512673&r2=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java Wed Feb 28 01:29:43 2007
@@ -21,7 +21,6 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -35,7 +34,6 @@
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.extension.BusExtension;
 import org.apache.cxf.helpers.CastUtils;
-import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.service.model.BindingFaultInfo;
 import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
@@ -61,14 +59,26 @@
     private Collection<PolicyProvider> policyProviders;
     private boolean registerInterceptors;
 
-    private Map<BindingOperation, ClientRequestPolicyInfo> clientRequestInfo 
-        = new ConcurrentHashMap<BindingOperation, ClientRequestPolicyInfo>();
+    private Map<BindingOperation, OutPolicyInfo> clientRequestInfo 
+        = new ConcurrentHashMap<BindingOperation, OutPolicyInfo>();
+    
+    private Map<BindingOperation, OutPolicyInfo> clientResponseInfo 
+        = new ConcurrentHashMap<BindingOperation, OutPolicyInfo>();
+    
+    private Map<BindingFault, OutPolicyInfo> clientFaultInfo 
+        = new ConcurrentHashMap<BindingFault, OutPolicyInfo>();
     
     private Map<Endpoint, EndpointPolicyInfo> endpointInfo 
         = new ConcurrentHashMap<Endpoint, EndpointPolicyInfo>();
     
-    private Map<BindingOperation, ServerResponsePolicyInfo> serverResponseInfo 
-        = new ConcurrentHashMap<BindingOperation, ServerResponsePolicyInfo>();
+    private Map<BindingOperation, OutPolicyInfo> serverRequestInfo 
+        = new ConcurrentHashMap<BindingOperation, OutPolicyInfo>();
+    
+    private Map<BindingOperation, OutPolicyInfo> serverResponseInfo 
+        = new ConcurrentHashMap<BindingOperation, OutPolicyInfo>();
+    
+    private Map<BindingFault, OutPolicyInfo> serverFaultInfo 
+        = new ConcurrentHashMap<BindingFault, OutPolicyInfo>();
 
     public PolicyEngine() {
         registry = new PolicyRegistryImpl();
@@ -136,15 +146,24 @@
         serverOutFault.setBus(bus);
         bus.getOutFaultInterceptors().add(serverOutFault);
         
-        // TODO: policy verification interceptors
+        PolicyVerificationOutInterceptor verifyOut = new PolicyVerificationOutInterceptor();
+        verifyOut.setBus(bus);
+        bus.getOutInterceptors().add(verifyOut);
+        PolicyVerificationInInterceptor verifyIn = new PolicyVerificationInInterceptor();
+        verifyIn.setBus(bus);
+        bus.getInInterceptors().add(verifyIn);
+        PolicyVerificationInFaultInterceptor verifyInFault = new PolicyVerificationInFaultInterceptor();
+        verifyInFault.setBus(bus);
+        bus.getInFaultInterceptors().add(verifyInFault);
     }  
     
+    /*
     public Collection<Assertion> getClientOutAssertions(Endpoint e, BindingOperationInfo boi, Conduit c) {
         return getClientRequestPolicyInfo(e, boi, c).getChosenAlternative();
     }
 
     public List<Interceptor> getClientOutInterceptors(Endpoint e, BindingOperationInfo boi, Conduit c) {
-        return getClientRequestPolicyInfo(e, boi, c).getOutInterceptors();
+        return getClientRequestPolicyInfo(e, boi, c).getInterceptors();
     }
     
     public List<Interceptor> getClientInInterceptors(Endpoint e, Conduit c) {        
@@ -166,13 +185,19 @@
                                                        
     public List<Interceptor> getServerOutInterceptors(Endpoint e, BindingOperationInfo boi, 
                                                       Destination d) {
-        return getServerResponsePolicyInfo(e, boi, d).getOutInterceptors();
+        return getServerResponsePolicyInfo(e, boi, d).getInterceptors();
+    }
+    
+    public Collection<Assertion> getServerOutFaultAssertions(Endpoint e, BindingFaultInfo bfi,
+                                                             Destination d) {
+        return getServerFaultPolicyInfo(e, bfi, d).getChosenAlternative();
     }
     
-    public List<Interceptor> getServerOutFaultInterceptors(Endpoint e, BindingOperationInfo boi, 
+    public List<Interceptor> getServerOutFaultInterceptors(Endpoint e, BindingFaultInfo bfi, 
                                                       Destination d) {
-        return getServerResponsePolicyInfo(e, boi, d).getOutFaultInterceptors();
+        return getServerFaultPolicyInfo(e, bfi, d).getInterceptors();
     }
+    */
 
     public Policy getAggregatedServicePolicy(ServiceInfo si) {
         Policy aggregated = null;
@@ -249,24 +274,28 @@
      */
     public Collection<Assertion> getAssertions(PolicyComponent pc, boolean includeOptional) {
         
-        if (Constants.TYPE_ASSERTION == pc.getType()) {
-            return Collections.singletonList((Assertion)pc);
-        } 
-        
         Collection<Assertion> assertions = new ArrayList<Assertion>();
-        addAssertions(pc, includeOptional, assertions);
+        
+        if (Constants.TYPE_ASSERTION == pc.getType()) {
+            Assertion a = (Assertion)pc;
+            if (includeOptional || !a.isOptional()) {
+                assertions.add(a);
+            }
+        } else {       
+            addAssertions(pc, includeOptional, assertions);
+        }
         return assertions;
     }
     
-    private void addAssertions(PolicyComponent pc, boolean includeOptional, 
+    void addAssertions(PolicyComponent pc, boolean includeOptional, 
                                Collection<Assertion> assertions) {
-
+       
         if (Constants.TYPE_ASSERTION == pc.getType()) {
             Assertion a = (Assertion)pc;
             if (includeOptional || !a.isOptional()) {
-                assertions.add((Assertion)pc);
-                return;
+                assertions.add((Assertion)pc);                
             }
+            return;
         } 
         
         if (Constants.TYPE_POLICY_REF == pc.getType()) {
@@ -274,10 +303,6 @@
             pc = pr.normalize(registry, false);
         }
 
-        assert Constants.TYPE_POLICY == pc.getType() 
-                || Constants.TYPE_POLICY == pc.getType() 
-                || Constants.TYPE_EXACTLYONE == pc.getType();
-
         PolicyOperator po = (PolicyOperator)pc;
 
         List<PolicyComponent> pcs = CastUtils.cast(po.getPolicyComponents(), PolicyComponent.class);
@@ -324,19 +349,52 @@
         return true;
     }
     
-    ClientRequestPolicyInfo getClientRequestPolicyInfo(Endpoint e, BindingOperationInfo boi, Conduit c) {
+    OutPolicyInfo getClientRequestPolicyInfo(Endpoint e, BindingOperationInfo boi, Conduit c) {
         BindingOperation bo = new BindingOperation(e, boi);
-        ClientRequestPolicyInfo crpi = clientRequestInfo.get(bo);
-        if (null == crpi) {
-            crpi = new ClientRequestPolicyInfo();
+        OutPolicyInfo opi = clientRequestInfo.get(bo);
+        if (null == opi) {
+            opi = new OutPolicyInfo();
             Assertor assertor = null;
             if (c instanceof Assertor) {
                 assertor = (Assertor)c;
             }
-            crpi.initialise(boi, e.getEndpointInfo(), this, assertor);
-            clientRequestInfo.put(bo, crpi);
+            opi.initialise(e, boi, this, assertor, true);
+            clientRequestInfo.put(bo, opi);
         }
-        return crpi;
+        return opi;
+    }
+    
+    OutPolicyInfo getServerRequestPolicyInfo(Endpoint e, BindingOperationInfo boi) {
+        BindingOperation bo = new BindingOperation(e, boi);
+        OutPolicyInfo opi = serverRequestInfo.get(bo);
+        if (null == opi) {
+            opi = new OutPolicyInfo();
+            opi.initialisePolicy(e, boi, this, false);
+            serverRequestInfo.put(bo, opi);
+        }
+        return opi;
+    }
+    
+    OutPolicyInfo getClientResponsePolicyInfo(Endpoint e, BindingOperationInfo boi) {
+        BindingOperation bo = new BindingOperation(e, boi);
+        OutPolicyInfo opi = clientResponseInfo.get(bo);
+        if (null == opi) {
+            opi = new OutPolicyInfo();
+            opi.initialisePolicy(e, boi, this, true);
+            clientResponseInfo.put(bo, opi);
+        }
+        return opi;
+    }
+    
+    OutPolicyInfo getClientFaultPolicyInfo(Endpoint e, BindingFaultInfo bfi) {
+        BindingFault bf = new BindingFault(e, bfi);
+        OutPolicyInfo opi = clientFaultInfo.get(bf);
+        if (null == opi) {
+            opi = new OutPolicyInfo();
+            opi.initialisePolicy(e, bfi, this);
+            clientFaultInfo.put(bf, opi);
+        }
+        return opi;
     }
     
     EndpointPolicyInfo getEndpointPolicyInfo(Endpoint e, Conduit conduit) {
@@ -365,31 +423,60 @@
         return epi;
     }
     
-    ServerResponsePolicyInfo getServerResponsePolicyInfo(Endpoint e, BindingOperationInfo boi, 
+    OutPolicyInfo getServerResponsePolicyInfo(Endpoint e, BindingOperationInfo boi, 
                                                          Destination d) {
         BindingOperation bo = new BindingOperation(e, boi);
-        ServerResponsePolicyInfo srpi = serverResponseInfo.get(bo);
-        if (null == srpi) {
-            srpi = new ServerResponsePolicyInfo();
+        OutPolicyInfo opi = serverResponseInfo.get(bo);
+        if (null == opi) {
+            opi = new OutPolicyInfo();
+            Assertor assertor = null;
+            if (d instanceof Assertor) {
+                assertor = (Assertor)d;
+            }
+            opi.initialise(e, boi, this, assertor, false);
+            serverResponseInfo.put(bo, opi);
+        }
+        return opi;
+    }
+    
+    OutPolicyInfo getServerFaultPolicyInfo(Endpoint e, BindingFaultInfo bfi, 
+                                                         Destination d) {
+        BindingFault bf = new BindingFault(e, bfi);
+        OutPolicyInfo opi = serverFaultInfo.get(bf);
+        if (null == opi) {
+            opi = new OutPolicyInfo();
             Assertor assertor = null;
             if (d instanceof Assertor) {
                 assertor = (Assertor)d;
             }
-            srpi.initialise(e, boi, this, assertor);
-            serverResponseInfo.put(bo, srpi);
+            opi.initialise(e, bfi, this, assertor);
+            serverFaultInfo.put(bf, opi);
         }
-        return srpi;
+        return opi;
     }
     
     
     /**
-     * Class used as key in the client request policy map.
+     * Class used as key in the client request policy and server response policy maps.
      */
     class BindingOperation {
         Endpoint endpoint;
         BindingOperationInfo boi;
         
         BindingOperation(Endpoint e, BindingOperationInfo b) {
+            endpoint = e;
+            boi = b;
+        }
+    }
+    
+    /**
+     * Class used as key in the server fault policy map.
+     */
+    class BindingFault {
+        Endpoint endpoint;
+        BindingFaultInfo boi;
+        
+        BindingFault(Endpoint e, BindingFaultInfo b) {
             endpoint = e;
             boi = b;
         }

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java?view=diff&rev=512674&r1=512673&r2=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyUtils.java Wed Feb 28 01:29:43 2007
@@ -52,6 +52,16 @@
     }
     
     /**
+     * Determine if the current message is a partial response.
+     * 
+     * @param message the current message
+     * @return true iff the current messags is a partial response
+     */
+    public static boolean isPartialResponse(Message message) {
+        return Boolean.TRUE.equals(message.get(Message.PARTIAL_RESPONSE_MESSAGE));
+    }
+    
+    /**
      * Determine if a collection of assertions contains a given assertion, using
      * the equal method from the Assertion interface.
      * 

Added: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java?view=auto&rev=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInFaultInterceptor.java Wed Feb 28 01:29:43 2007
@@ -0,0 +1,85 @@
+/**
+ * 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 java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingFaultInfo;
+
+/**
+ * 
+ */
+public class PolicyVerificationInFaultInterceptor extends AbstractPolicyInterceptor {
+
+    private static final Logger LOG 
+        = LogUtils.getL7dLogger(PolicyVerificationInFaultInterceptor.class);
+
+    public PolicyVerificationInFaultInterceptor() {
+        setPhase(Phase.PRE_INVOKE);
+    }
+
+    /** 
+     * Determines the effective policy, and checks if one of its alternatives  
+     * is supported.
+     *  
+     * @param message
+     */
+    public void handleMessage(Message message) throws Fault {
+        
+        if (!PolicyUtils.isRequestor(message)) {
+            return; 
+        }
+        
+        Exchange exchange = message.getExchange();
+        assert null != exchange;
+        
+        BindingFaultInfo bfi = message.get(BindingFaultInfo.class);
+        if (null == bfi) {
+            LOG.fine("No binding fault info.");
+            return;
+        }
+        
+        Endpoint e = exchange.get(Endpoint.class);
+        if (null == e) {
+            LOG.fine("No endpoint.");
+            return;
+        }        
+        
+        PolicyEngine pe = bus.getExtension(PolicyEngine.class);
+        if (null == pe) {
+            return;
+        }
+        
+        AssertionInfoMap aim = message.get(AssertionInfoMap.class);
+        if (null == aim) {
+            return;
+        }
+        
+        OutPolicyInfo opi = pe.getClientFaultPolicyInfo(e, bfi);
+        opi.checkEffectivePolicy(aim);
+    }
+
+}

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

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

Added: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java?view=auto&rev=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationInInterceptor.java Wed Feb 28 01:29:43 2007
@@ -0,0 +1,90 @@
+/**
+ * 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 java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingOperationInfo;
+
+/**
+ * 
+ */
+public class PolicyVerificationInInterceptor extends AbstractPolicyInterceptor {
+
+    private static final Logger LOG = LogUtils.getL7dLogger(PolicyVerificationInInterceptor.class);
+
+    public PolicyVerificationInInterceptor() {
+        setPhase(Phase.PRE_INVOKE);
+    }
+
+    /** 
+     * Determines the effective policy, and checks if one of its alternatives  
+     * is supported.
+     *  
+     * @param message
+     */
+    public void handleMessage(Message message) throws Fault {
+        Exchange exchange = message.getExchange();
+        assert null != exchange;
+        
+        BindingOperationInfo boi = exchange.get(BindingOperationInfo.class);
+        if (null == boi) {
+            LOG.fine("No binding operation info.");
+            return;
+        }
+        
+        Endpoint e = exchange.get(Endpoint.class);
+        if (null == e) {
+            LOG.fine("No endpoint.");
+            return;
+        }        
+        
+        PolicyEngine pe = bus.getExtension(PolicyEngine.class);
+        if (null == pe) {
+            return;
+        }
+        
+        AssertionInfoMap aim = message.get(AssertionInfoMap.class);
+        if (null == aim) {
+            return;
+        }
+        
+        if (PolicyUtils.isPartialResponse(message)) {
+            LOG.fine("This is a partial response - policies are not verified.");
+            return;
+        }
+        
+        OutPolicyInfo opi = null;
+        if (PolicyUtils.isRequestor(message)) {
+            opi = pe.getClientResponsePolicyInfo(e, boi);
+        } else {
+            opi = pe.getServerRequestPolicyInfo(e, boi);
+        }
+                
+        opi.checkEffectivePolicy(aim);
+    }
+
+}

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

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

Added: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java?view=auto&rev=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java (added)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyVerificationOutInterceptor.java Wed Feb 28 01:29:43 2007
@@ -0,0 +1,69 @@
+/**
+ * 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 java.util.Collection;
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.Phase;
+
+/**
+ * 
+ */
+public class PolicyVerificationOutInterceptor extends AbstractPolicyInterceptor {
+
+    private static final Logger LOG 
+        = LogUtils.getL7dLogger(PolicyVerificationOutInterceptor.class);
+    private static final ResourceBundle BUNDLE 
+        = BundleUtils.getBundle(PolicyVerificationOutInterceptor.class);
+
+    public PolicyVerificationOutInterceptor() {
+        setPhase(Phase.POST_STREAM);
+    }
+
+    /** 
+     * Checks if all assertions in the chosen alternative have been asserted.
+     * Note that although the alternative was chosen in such a way that at least all
+     * interceptors necessary to assert the assertions are present, it is not possible
+     * to predict if these interceptors actually have asserted their assertions.  
+     * @param message
+     */
+    public void handleMessage(Message message) throws Fault {
+        AssertionInfoMap aim = message.get(AssertionInfoMap.class);
+        if (null == aim) {
+            return;
+        }
+        for (Collection<AssertionInfo> ais : aim.values()) {
+            for (AssertionInfo ai : ais) {
+                if (!ai.isAsserted()) {
+                    throw new PolicyException(new org.apache.cxf.common.i18n.Message(
+                        "NOT_ASSERTED_EXC", BUNDLE, ai.getAssertion().getName()));
+                }
+            }
+        }
+        LOG.fine("At least one alternative of the policy for the output message is supported.");
+    }
+
+}

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

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

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java?view=diff&rev=512674&r1=512673&r2=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyInInterceptor.java Wed Feb 28 01:29:43 2007
@@ -19,40 +19,31 @@
 
 package org.apache.cxf.ws.policy;
 
+import java.util.Collection;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
-import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.transport.Destination;
+import org.apache.neethi.Assertion;
 
 /**
  * 
  */
-public class ServerPolicyInInterceptor extends AbstractPhaseInterceptor<Message> {
+public class ServerPolicyInInterceptor extends AbstractPolicyInterceptor {
 
     private static final Logger LOG = LogUtils.getL7dLogger(ServerPolicyInInterceptor.class);
-    private Bus bus;
     
     public ServerPolicyInInterceptor() {
         setId(PolicyConstants.SERVER_POLICY_IN_INTERCEPTOR_ID);
         setPhase(Phase.RECEIVE);
     }
-        
-    public void setBus(Bus b) {
-        bus = b;
-    }
-    
-    public Bus getBus() {
-        return bus;
-    }
     
     public void handleMessage(Message msg) {        
         if (PolicyUtils.isRequestor(msg)) {
@@ -79,12 +70,19 @@
         // We do not know the underlying message type yet - so we pre-emptively add interceptors 
         // that can deal with any requests on the underlying endpoint
         
-        List<Interceptor> policyInInterceptors = pe.getServerInInterceptors(e, destination);
+        EndpointPolicyInfo epi = pe.getEndpointPolicyInfo(e, destination);
+        
+        List<Interceptor> policyInInterceptors = epi.getInInterceptors();
         for (Interceptor poi : policyInInterceptors) {
             msg.getInterceptorChain().add(poi);
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Added interceptor of type " + poi.getClass().getSimpleName());
-            }
+            LOG.log(Level.INFO, "Added interceptor of type {0}", poi.getClass().getSimpleName());
+        }
+        
+        // insert assertions of endpoint's vocabulary into message
+        
+        Collection<Assertion> assertions = epi.getVocabulary();
+        if (null != assertions) {
+            msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
         }
     }
 }

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java?view=diff&rev=512674&r1=512673&r2=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutFaultInterceptor.java Wed Feb 28 01:29:43 2007
@@ -19,42 +19,34 @@
 
 package org.apache.cxf.ws.policy;
 
+import java.util.Collection;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
-import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
+import org.apache.cxf.service.model.BindingFaultInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.transport.Destination;
+import org.apache.neethi.Assertion;
 
 /**
  * 
  */
-public class ServerPolicyOutFaultInterceptor extends AbstractPhaseInterceptor<Message> {
+public class ServerPolicyOutFaultInterceptor extends AbstractPolicyInterceptor {
 
     private static final Logger LOG = LogUtils.getL7dLogger(ServerPolicyOutFaultInterceptor.class);
-    private Bus bus;
     
     public ServerPolicyOutFaultInterceptor() {
         setId(PolicyConstants.SERVER_POLICY_OUT_FAULT_INTERCEPTOR_ID);
         setPhase(Phase.SETUP);
     }
-        
-    public void setBus(Bus b) {
-        bus = b;
-    }
-    
-    public Bus getBus() {
-        return bus;
-    }
-    
+       
     public void handleMessage(Message msg) {        
         if (PolicyUtils.isRequestor(msg)) {
             LOG.fine("Is a requestor.");
@@ -83,12 +75,43 @@
         
         Destination destination = msg.getDestination();
         
-        List<Interceptor> outInterceptors = pe.getServerOutFaultInterceptors(e, boi, destination);
+        Exception ex = exchange.get(Exception.class);
+        assert null != ex;
+        
+        BindingFaultInfo bfi = getBindingFaultInfo(msg, ex, boi);
+        if (null == bfi) {
+            LOG.fine("No binding fault info.");
+            return;
+        }  
+        
+        OutPolicyInfo opi = pe.getServerFaultPolicyInfo(e, bfi, destination);
+        
+        List<Interceptor> outInterceptors = opi.getInterceptors();
         for (Interceptor oi : outInterceptors) {
             msg.getInterceptorChain().add(oi);
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Added interceptor of type " + oi.getClass().getSimpleName());
-            }
+            LOG.log(Level.INFO, "Added interceptor of type {0}", oi.getClass().getSimpleName());
+        }
+        
+        // insert assertions of the chosen alternative into the message
+        
+        Collection<Assertion> assertions = opi.getChosenAlternative();
+        if (null != assertions) {
+            msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
+        }
+    }
+    
+    BindingFaultInfo getBindingFaultInfo(Message msg, Exception ex, BindingOperationInfo boi) {
+        BindingFaultInfo bfi = msg.get(BindingFaultInfo.class);
+        if (null == bfi) {
+            for (BindingFaultInfo b : boi.getFaults()) {
+                Class<?> faultClass = b.getFaultInfo().getProperty(Class.class.getName(), Class.class);
+                if (faultClass.isAssignableFrom(ex.getClass())) {
+                    bfi = b;
+                    msg.put(BindingFaultInfo.class, bfi);
+                    break;
+                }
+            }            
         }
+        return bfi;
     }
 }

Modified: incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java?view=diff&rev=512674&r1=512673&r2=512674
==============================================================================
--- incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ServerPolicyOutInterceptor.java Wed Feb 28 01:29:43 2007
@@ -19,41 +19,32 @@
 
 package org.apache.cxf.ws.policy;
 
+import java.util.Collection;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
-import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.transport.Destination;
+import org.apache.neethi.Assertion;
 
 /**
  * 
  */
-public class ServerPolicyOutInterceptor extends AbstractPhaseInterceptor<Message> {
+public class ServerPolicyOutInterceptor extends AbstractPolicyInterceptor {
 
     private static final Logger LOG = LogUtils.getL7dLogger(ServerPolicyOutInterceptor.class);
-    private Bus bus;
     
     public ServerPolicyOutInterceptor() {
         setId(PolicyConstants.SERVER_POLICY_OUT_INTERCEPTOR_ID);
         setPhase(Phase.SETUP);
     }
-        
-    public void setBus(Bus b) {
-        bus = b;
-    }
-    
-    public Bus getBus() {
-        return bus;
-    }
     
     public void handleMessage(Message msg) {        
         if (PolicyUtils.isRequestor(msg)) {
@@ -82,18 +73,19 @@
         }
         
         Destination destination = msg.getDestination();
+        OutPolicyInfo opi = pe.getServerResponsePolicyInfo(e, boi, destination);
         
-        List<Interceptor> outInterceptors = pe.getServerOutInterceptors(e, boi, destination);
-        LOG.fine("Required out interceptors: " + outInterceptors);
+        List<Interceptor> outInterceptors = opi.getInterceptors();
         for (Interceptor oi : outInterceptors) {
             msg.getInterceptorChain().add(oi);
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Added interceptor of type " + oi.getClass().getSimpleName());
-            }
+            LOG.log(Level.INFO, "Added interceptor of type {0}", oi.getClass().getSimpleName());           
         }
         
         // insert assertions of the chosen alternative into the message
-        
-        msg.put(PolicyConstants.SERVER_OUT_ASSERTIONS, pe.getServerOutAssertions(e, boi, destination));
+             
+        Collection<Assertion> assertions = opi.getChosenAlternative();
+        if (null != assertions) {
+            msg.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
+        }
     }
 }