You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2013/10/18 02:51:39 UTC

svn commit: r1533299 - in /cxf/trunk: rt/transports/http/src/main/java/org/apache/cxf/transport/http/ rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/ rt/ws/policy/src/test/java/org/apac...

Author: dkulp
Date: Fri Oct 18 00:51:39 2013
New Revision: 1533299

URL: http://svn.apache.org/r1533299
Log:
[CXF-5325] More updates to get contextual information available for policy alternative selection

Modified:
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicy.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInInterceptor.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProvider.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/WSPolicyFeature.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/FirstAlternativeSelector.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/MaximalAlternativeSelector.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/MinimalAlternativeSelector.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/selector/FirstAlternativeSelectorTest.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/selector/MinimalMaximalAlternativeSelectorTest.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/HttpsTokenInterceptorProvider.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/NegotiationUtils.java
    cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/security/DoubleIt.wsdl

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java (original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java Fri Oct 18 00:51:39 2013
@@ -841,7 +841,10 @@ public abstract class HTTPConduit 
      * HTTPConduit.
      */
     public HTTPClientPolicy getClient() {
-        updateClientPolicy(null);
+        Message m = new MessageImpl();
+        m.setExchange(new ExchangeImpl());
+        m.getExchange().put(EndpointInfo.class, this.endpointInfo);
+        updateClientPolicy(m);
         return clientSidePolicy;
     }
 

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/AbstractPolicyInterceptorProvider.java Fri Oct 18 00:51:39 2013
@@ -21,13 +21,12 @@ 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;
+import org.apache.neethi.Assertion;
 
 /**
  * 
@@ -50,20 +49,7 @@ public abstract class AbstractPolicyInte
         return assertionTypes;
     }
 
-    public List<Interceptor<? extends Message>> provideInFaultInterceptors(Message m) {
-        return getInFaultInterceptors();
+    public boolean configurationPresent(Message msg, Assertion assertion) {
+        return true;
     }
-
-    public List<Interceptor<? extends Message>> provideInInterceptors(Message m) {
-        return getInInterceptors();
-    }
-
-    public List<Interceptor<? extends Message>> provideOutFaultInterceptors(Message m) {
-        return getOutFaultInterceptors();
-    }
-
-    public List<Interceptor<? extends Message>> provideOutInterceptors(Message m) {
-        return getOutInterceptors();
-    } 
-    
 }

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/ClientPolicyInFaultInterceptor.java Fri Oct 18 00:51:39 2013
@@ -98,8 +98,8 @@ public class ClientPolicyInFaultIntercep
             EndpointPolicy ep = pe.getClientEndpointPolicy(ei, conduit, msg);        
             LOG.fine("ep: " + ep);
             if (ep != null) {
-                faultInterceptors.addAll(ep.getFaultInterceptors());
-                assertions.addAll(ep.getFaultVocabulary());
+                faultInterceptors.addAll(ep.getFaultInterceptors(msg));
+                assertions.addAll(ep.getFaultVocabulary(msg));
             }
         }
         

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EffectivePolicyImpl.java Fri Oct 18 00:51:39 2013
@@ -82,7 +82,7 @@ public class EffectivePolicyImpl impleme
         if (chosenAlternative == null) {
             chooseAlternative(engine, null, m);
         }
-        initialiseInterceptors(engine, inbound, fault);  
+        initialiseInterceptors(engine, inbound, fault, m);  
     }
     
     public void initialise(EndpointInfo ei, 
@@ -94,7 +94,7 @@ public class EffectivePolicyImpl impleme
                     Message m) {
         initialisePolicy(ei, boi, engine, requestor, request, assertor, m);
         chooseAlternative(engine, assertor, m);
-        initialiseInterceptors(engine, false);  
+        initialiseInterceptors(engine, false, m);  
     }
     
     public void initialise(EndpointInfo ei, 
@@ -105,7 +105,7 @@ public class EffectivePolicyImpl impleme
                     Message m) {
         initialisePolicy(ei, boi, engine, false, false, assertor, m);
         chooseAlternative(engine, assertor, incoming, m);
-        initialiseInterceptors(engine, false);  
+        initialiseInterceptors(engine, false, m);  
     }
     
     public void initialise(EndpointInfo ei, 
@@ -116,7 +116,7 @@ public class EffectivePolicyImpl impleme
         Assertor assertor = initialisePolicy(ei, boi, engine, requestor, request, null, m);
         if (requestor || !request) {
             chooseAlternative(engine, assertor, m);
-            initialiseInterceptors(engine, requestor);
+            initialiseInterceptors(engine, requestor, m);
         } else {
             //incoming server should not choose an alternative, need to include all the policies
             Collection<Assertion> alternative = ((PolicyEngineImpl)engine).getAssertions(this.policy, true);
@@ -132,7 +132,7 @@ public class EffectivePolicyImpl impleme
                     Message m) {
         initialisePolicy(ei, boi, bfi, engine, m);
         chooseAlternative(engine, assertor, m);
-        initialiseInterceptors(engine, false);  
+        initialiseInterceptors(engine, false, m);  
     }
     
     private <T> T getAssertorAs(Assertor as, Class<T> t) {
@@ -202,22 +202,22 @@ public class EffectivePolicyImpl impleme
         }   
     }
 
-    void initialiseInterceptors(PolicyEngine engine) {
-        initialiseInterceptors(engine, false);
+    void initialiseInterceptors(PolicyEngine engine, Message m) {
+        initialiseInterceptors(engine, false, m);
     }
     
-    void initialiseInterceptors(PolicyEngine engine, boolean useIn) {
-        initialiseInterceptors(engine, useIn, false);
+    void initialiseInterceptors(PolicyEngine engine, boolean useIn, Message m) {
+        initialiseInterceptors(engine, useIn, false, m);
     }
 
-    void initialiseInterceptors(PolicyEngine engine, boolean useIn, boolean fault) {
+    void initialiseInterceptors(PolicyEngine engine, boolean useIn, boolean fault, Message m) {
         if (((PolicyEngineImpl)engine).getBus() != null) {
             PolicyInterceptorProviderRegistry reg 
                 = ((PolicyEngineImpl)engine).getBus().getExtension(PolicyInterceptorProviderRegistry.class);
             Set<Interceptor<? extends org.apache.cxf.message.Message>> out 
                 = new LinkedHashSet<Interceptor<? extends org.apache.cxf.message.Message>>();
             for (Assertion a : getChosenAlternative()) {
-                initialiseInterceptors(reg, engine, out, a, useIn, fault);
+                initialiseInterceptors(reg, engine, out, a, useIn, fault, m);
             }        
             setInterceptors(new ArrayList<Interceptor<? extends  org.apache.cxf.message.Message>>(out));
         }
@@ -225,12 +225,13 @@ public class EffectivePolicyImpl impleme
     
     
     protected Collection<Assertion> getSupportedAlternatives(PolicyEngine engine,
-                                                                   Policy p) {
+                                                             Policy p, 
+                                                             Message m) {
         Collection<Assertion> alternatives = new ArrayList<Assertion>();
 
         for (Iterator<List<Assertion>> it = p.getAlternatives(); it.hasNext();) {
             List<Assertion> alternative = it.next();
-            if (engine.supportsAlternative(alternative, null)) {
+            if (engine.supportsAlternative(alternative, null, m)) {
                 alternatives.addAll(alternative);
             }
         }
@@ -239,7 +240,8 @@ public class EffectivePolicyImpl impleme
 
     void initialiseInterceptors(PolicyInterceptorProviderRegistry reg, PolicyEngine engine,
                                 Set<Interceptor<? extends org.apache.cxf.message.Message>> out, Assertion a,
-                                boolean useIn, boolean fault) {
+                                boolean useIn, boolean fault,
+                                Message m) {
         QName qn = a.getName();
         
         List<Interceptor<? extends org.apache.cxf.message.Message>> i = null;
@@ -257,8 +259,8 @@ public class EffectivePolicyImpl impleme
         if (a instanceof PolicyContainingAssertion) {
             Policy p = ((PolicyContainingAssertion)a).getPolicy();
             if (p != null) {
-                for (Assertion a2 : getSupportedAlternatives(engine, p)) {
-                    initialiseInterceptors(reg, engine, out, a2, useIn, fault);
+                for (Assertion a2 : getSupportedAlternatives(engine, p, m)) {
+                    initialiseInterceptors(reg, engine, out, a2, useIn, fault, m);
                 }
             }
         }

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicy.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicy.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicy.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicy.java Fri Oct 18 00:51:39 2013
@@ -36,15 +36,15 @@ import org.apache.neethi.Policy;
 public interface EndpointPolicy {
     
     Policy getPolicy();
-    EndpointPolicy updatePolicy(Policy p);
+    EndpointPolicy updatePolicy(Policy p, Message msg);
     
     Collection<Assertion> getChosenAlternative();
     
-    Collection<Assertion> getVocabulary();
+    Collection<Assertion> getVocabulary(Message m);
     
-    Collection<Assertion> getFaultVocabulary();
+    Collection<Assertion> getFaultVocabulary(Message m);
     
-    List<Interceptor<? extends Message>> getInterceptors();
+    List<Interceptor<? extends Message>> getInterceptors(Message m);
     
-    List<Interceptor<? extends Message>> getFaultInterceptors();
+    List<Interceptor<? extends Message>> getFaultInterceptors(Message m);
 }

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/EndpointPolicyImpl.java Fri Oct 18 00:51:39 2013
@@ -85,7 +85,7 @@ public class EndpointPolicyImpl implemen
         return assertor;
     }
     
-    public EndpointPolicy updatePolicy(Policy p) {
+    public EndpointPolicy updatePolicy(Policy p, Message msg) {
         EndpointPolicyImpl epi = createEndpointPolicy();
         
         if (!PolicyUtils.isEmptyPolicy(p)) {
@@ -99,7 +99,7 @@ public class EndpointPolicyImpl implemen
         }
         
         epi.checkExactlyOnes();
-        epi.finalizeConfig(null);
+        epi.finalizeConfig(msg);
         return epi;
     }
     
@@ -107,30 +107,30 @@ public class EndpointPolicyImpl implemen
         return chosenAlternative;
     }
     
-    public synchronized Collection<Assertion> getVocabulary() {
+    public Collection<Assertion> getVocabulary(Message m) {
         if (vocabulary == null) {
-            initializeVocabulary(null);
+            initializeVocabulary(m);
         }
         return vocabulary;
     }
     
-    public synchronized Collection<Assertion> getFaultVocabulary() {
+    public Collection<Assertion> getFaultVocabulary(Message m) {
         if (vocabulary == null) {
-            initializeVocabulary(null);
+            initializeVocabulary(m);
         }
         return faultVocabulary;
     }    
     
-    public synchronized List<Interceptor<? extends Message>> getInterceptors() {
+    public List<Interceptor<? extends Message>> getInterceptors(Message m) {
         if (interceptors == null) {
-            initializeInterceptors(null);
+            initializeInterceptors(m);
         }
         return interceptors;
     }
     
-    public synchronized List<Interceptor<? extends Message>> getFaultInterceptors() {
+    public List<Interceptor<? extends Message>> getFaultInterceptors(Message m) {
         if (interceptors == null) {
-            initializeInterceptors(null);
+            initializeInterceptors(m);
         }
         return faultInterceptors;
     }
@@ -160,7 +160,7 @@ public class EndpointPolicyImpl implemen
         if (requestor) {
             alternative = engine.getAlternativeSelector().selectAlternative(policy, engine, assertor, null, m);
         } else {
-            alternative = getSupportedAlternatives();
+            alternative = getSupportedAlternatives(m);
         }
         if (null == alternative) {
             throw new PolicyException(new org.apache.cxf.common.i18n.Message("NO_ALTERNATIVE_EXC", BUNDLE));
@@ -169,12 +169,12 @@ public class EndpointPolicyImpl implemen
         }
     }
     
-    protected Collection<Assertion> getSupportedAlternatives() {
+    protected Collection<Assertion> getSupportedAlternatives(Message msg) {
         Collection<Assertion> alternatives = new ArrayList<Assertion>();
 
         for (Iterator<List<Assertion>> it = policy.getAlternatives(); it.hasNext();) {
             List<Assertion> alternative = it.next();
-            if (engine.supportsAlternative(alternative, assertor)) {
+            if (engine.supportsAlternative(alternative, assertor, msg)) {
                 alternatives.addAll(alternative);
             }
         }
@@ -240,11 +240,11 @@ public class EndpointPolicyImpl implemen
         }
     }
 
-    Collection<Assertion> getSupportedAlternatives(Policy p) {
+    Collection<Assertion> getSupportedAlternatives(Policy p, Message msg) {
         Collection<Assertion> alternatives = new ArrayList<Assertion>();
         for (Iterator<List<Assertion>> it = p.getAlternatives(); it.hasNext();) {
             List<Assertion> alternative = it.next();
-            if (engine.supportsAlternative(alternative, null)) {
+            if (engine.supportsAlternative(alternative, null, msg)) {
                 alternatives.addAll(alternative);
             }
         }
@@ -253,7 +253,7 @@ public class EndpointPolicyImpl implemen
 
     void initializeInterceptors(PolicyInterceptorProviderRegistry reg,
                                 Set<Interceptor<? extends Message>> out, Assertion a, 
-                                boolean fault) {
+                                boolean fault, Message msg) {
         QName qn = a.getName();
         List<Interceptor<? extends org.apache.cxf.message.Message>> i 
             = fault ? reg.getInFaultInterceptorsForAssertion(qn)
@@ -262,8 +262,8 @@ public class EndpointPolicyImpl implemen
         if (a instanceof PolicyContainingAssertion) {
             Policy p = ((PolicyContainingAssertion)a).getPolicy();
             if (p != null) {
-                for (Assertion a2 : getSupportedAlternatives(p)) {
-                    initializeInterceptors(reg, out, a2, fault);
+                for (Assertion a2 : getSupportedAlternatives(p, msg)) {
+                    initializeInterceptors(reg, out, a2, fault, msg);
                 }
             }
         }
@@ -280,7 +280,7 @@ public class EndpointPolicyImpl implemen
         Set<Interceptor<? extends Message>> out = new LinkedHashSet<Interceptor<? extends Message>>();
         if (getChosenAlternative() != null) {
             for (Assertion a : getChosenAlternative()) {
-                initializeInterceptors(reg, out, a, false);
+                initializeInterceptors(reg, out, a, false, m);
             }
         }
 
@@ -288,7 +288,7 @@ public class EndpointPolicyImpl implemen
             interceptors = new ArrayList<Interceptor<? extends Message>>(out);
             out.clear();
             for (Assertion a : getChosenAlternative()) {
-                initializeInterceptors(reg, out, a, true);
+                initializeInterceptors(reg, out, a, true, m);
             }
             faultInterceptors = new ArrayList<Interceptor<? extends Message>>(out);
         } else if (ei != null && ei.getBinding() != null) {
@@ -300,8 +300,8 @@ public class EndpointPolicyImpl implemen
                 Collection<Assertion> c = engine.getAssertions(p, true);
                 if (c != null) {
                     for (Assertion a : c) {
-                        initializeInterceptors(reg, out, a, false);
-                        initializeInterceptors(reg, out, a, true);
+                        initializeInterceptors(reg, out, a, false, m);
+                        initializeInterceptors(reg, out, a, true, m);
                     }
                 }
             }

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngine.java Fri Oct 18 00:51:39 2013
@@ -53,7 +53,9 @@ public interface PolicyEngine {
     
     //
     
-    boolean supportsAlternative(Collection<? extends PolicyComponent> alterative, Assertor assertor);
+    boolean supportsAlternative(Collection<? extends PolicyComponent> alterative,
+                                Assertor assertor,
+                                Message m);
     
     // available throughout the outbound path
     

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java Fri Oct 18 00:51:39 2013
@@ -194,15 +194,19 @@ public class PolicyEngineImpl implements
 
     public EffectivePolicy getEffectiveClientRequestPolicy(EndpointInfo ei, BindingOperationInfo boi, 
                                                            Conduit c, Message m) {
-        EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_CLIENT);
-        if (null == effectivePolicy) {
-            EffectivePolicyImpl epi = createOutPolicyInfo();
-            Assertor assertor = PolicyUtils.createAsserter(c);
-            epi.initialise(ei, boi, this, assertor, true, true, m);
-            boi.setProperty(POLICY_INFO_REQUEST_CLIENT, epi);
-            effectivePolicy = epi;
+        synchronized (ei) {
+            EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_CLIENT);
+            if (null == effectivePolicy) {
+                EffectivePolicyImpl epi = createOutPolicyInfo();
+                Assertor assertor = PolicyUtils.createAsserter(c);
+                if (m != null) {
+                    boi.setProperty(POLICY_INFO_REQUEST_CLIENT, epi);
+                }
+                epi.initialise(ei, boi, this, assertor, true, true, m);
+                effectivePolicy = epi;
+            }
+            return effectivePolicy;
         }
-        return effectivePolicy;
     }
 
     public void setEffectiveClientRequestPolicy(EndpointInfo ei, BindingOperationInfo boi, 
@@ -216,15 +220,19 @@ public class PolicyEngineImpl implements
                                                             List<List<Assertion>> incoming, 
                                                             Message m) {
         if (incoming == null) {
-            EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_RESPONSE_SERVER);
-            if (null == effectivePolicy) {
-                EffectivePolicyImpl epi = createOutPolicyInfo();
-                Assertor assertor = PolicyUtils.createAsserter(d);
-                epi.initialise(ei, boi, this, assertor, false, false, null);
-                boi.setProperty(POLICY_INFO_RESPONSE_SERVER, epi);
-                effectivePolicy = epi;
+            synchronized (ei) {
+                EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_RESPONSE_SERVER);
+                if (null == effectivePolicy) {
+                    EffectivePolicyImpl epi = createOutPolicyInfo();
+                    Assertor assertor = PolicyUtils.createAsserter(d);
+                    if (m != null) {
+                        boi.setProperty(POLICY_INFO_RESPONSE_SERVER, epi);
+                    }
+                    epi.initialise(ei, boi, this, assertor, false, false, null);
+                    effectivePolicy = epi;
+                }
+                return effectivePolicy;
             } 
-            return effectivePolicy;
         }
         EffectivePolicyImpl epi = createOutPolicyInfo();
         Assertor assertor = PolicyUtils.createAsserter(d);
@@ -250,15 +258,19 @@ public class PolicyEngineImpl implements
             return epi;
         }
         bfi = mapToWrappedBindingFaultInfo(bfi);
-        EffectivePolicy effectivePolicy = (EffectivePolicy)bfi.getProperty(POLICY_INFO_FAULT_SERVER);
-        if (null == effectivePolicy) {
-            EffectivePolicyImpl epi = createOutPolicyInfo();
-            Assertor assertor = PolicyUtils.createAsserter(d);
-            epi.initialise(ei, boi, bfi, this, assertor, m);
-            bfi.setProperty(POLICY_INFO_FAULT_SERVER, epi);
-            effectivePolicy = epi;
+        synchronized (ei) {
+            EffectivePolicy effectivePolicy = (EffectivePolicy)bfi.getProperty(POLICY_INFO_FAULT_SERVER);
+            if (null == effectivePolicy) {
+                EffectivePolicyImpl epi = createOutPolicyInfo();
+                Assertor assertor = PolicyUtils.createAsserter(d);
+                if (m != null) {
+                    bfi.setProperty(POLICY_INFO_FAULT_SERVER, epi);
+                }
+                epi.initialise(ei, boi, bfi, this, assertor, m);
+                effectivePolicy = epi;
+            }
+            return effectivePolicy;
         }
-        return effectivePolicy;
     }
 
     private BindingFaultInfo mapToWrappedBindingFaultInfo(BindingFaultInfo bfi) {
@@ -292,12 +304,14 @@ public class PolicyEngineImpl implements
         boolean isRequestor,
         Assertor assertor,
         Message m) {
-        EndpointPolicy ep = (EndpointPolicy)ei.getProperty(isRequestor ? POLICY_INFO_ENDPOINT_CLIENT 
+        synchronized (ei) {
+            EndpointPolicy ep = (EndpointPolicy)ei.getProperty(isRequestor ? POLICY_INFO_ENDPOINT_CLIENT 
                             : POLICY_INFO_ENDPOINT_SERVER);
-        if (null != ep) {
-            return ep; 
+            if (null != ep) {
+                return ep; 
+            }
+            return createEndpointPolicyInfo(ei, isRequestor, assertor, m);
         }
-        return createEndpointPolicyInfo(ei, isRequestor, assertor, m);
     }
 
     public void setClientEndpointPolicy(EndpointInfo ei, EndpointPolicy ep) {
@@ -311,14 +325,18 @@ public class PolicyEngineImpl implements
     public EffectivePolicy getEffectiveServerRequestPolicy(EndpointInfo ei, 
                                                            BindingOperationInfo boi, 
                                                            Message m) {
-        EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_SERVER);
-        if (null == effectivePolicy) {
-            EffectivePolicyImpl epi = createOutPolicyInfo();
-            epi.initialise(ei, boi, this, false, true, m);
-            boi.setProperty(POLICY_INFO_REQUEST_SERVER, epi);
-            effectivePolicy = epi;
+        synchronized (ei) {
+            EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_SERVER);
+            if (null == effectivePolicy) {
+                EffectivePolicyImpl epi = createOutPolicyInfo();
+                if (m != null) {
+                    boi.setProperty(POLICY_INFO_REQUEST_SERVER, epi);
+                }
+                epi.initialise(ei, boi, this, false, true, m);
+                effectivePolicy = epi;
+            }
+            return effectivePolicy;
         }
-        return effectivePolicy;
     }
 
     public void setEffectiveServerRequestPolicy(EndpointInfo ei, BindingOperationInfo boi, 
@@ -329,14 +347,18 @@ public class PolicyEngineImpl implements
     public EffectivePolicy getEffectiveClientResponsePolicy(EndpointInfo ei,
                                                             BindingOperationInfo boi,
                                                             Message m) {
-        EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_RESPONSE_CLIENT);
-        if (null == effectivePolicy) {
-            EffectivePolicyImpl epi = createOutPolicyInfo();
-            epi.initialise(ei, boi, this, true, false, m);        
-            boi.setProperty(POLICY_INFO_RESPONSE_CLIENT, epi);
-            effectivePolicy = epi;
+        synchronized (ei) {
+            EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_RESPONSE_CLIENT);
+            if (null == effectivePolicy) {
+                EffectivePolicyImpl epi = createOutPolicyInfo();
+                if (m != null) {
+                    boi.setProperty(POLICY_INFO_RESPONSE_CLIENT, epi);
+                }
+                epi.initialise(ei, boi, this, true, false, m);
+                effectivePolicy = epi;
+            }
+            return effectivePolicy;
         }
-        return effectivePolicy;
     }
 
     public void setEffectiveClientResponsePolicy(EndpointInfo ei, BindingOperationInfo boi, 
@@ -348,19 +370,21 @@ public class PolicyEngineImpl implements
                                                          BindingOperationInfo boi,
                                                          BindingFaultInfo bfi,
                                                          Message m) {
-        EffectivePolicy effectivePolicy = null;
-        if (bfi != null) {
-            effectivePolicy = (EffectivePolicy)bfi.getProperty(POLICY_INFO_FAULT_CLIENT);
-        }
-        if (null == effectivePolicy) {
-            EffectivePolicyImpl epi = createOutPolicyInfo();
-            epi.initialisePolicy(ei, boi, bfi, this, m);
+        synchronized (ei) {
+            EffectivePolicy effectivePolicy = null;
             if (bfi != null) {
-                bfi.setProperty(POLICY_INFO_FAULT_CLIENT, epi);
+                effectivePolicy = (EffectivePolicy)bfi.getProperty(POLICY_INFO_FAULT_CLIENT);
+            }
+            if (null == effectivePolicy) {
+                EffectivePolicyImpl epi = createOutPolicyInfo();
+                if (bfi != null) {
+                    bfi.setProperty(POLICY_INFO_FAULT_CLIENT, epi);
+                }
+                epi.initialisePolicy(ei, boi, bfi, this, m);
+                effectivePolicy = epi;
             }
-            effectivePolicy = epi;
+            return effectivePolicy;
         }
-        return effectivePolicy;
     }
 
     public void setEffectiveClientFaultPolicy(EndpointInfo ei, BindingFaultInfo bfi, EffectivePolicy ep) {
@@ -558,7 +582,9 @@ public class PolicyEngineImpl implements
                                                 Message m) {
         EndpointPolicyImpl epi = new EndpointPolicyImpl(ei, this, isRequestor, assertor);
         epi.initialize(m);
-        ei.setProperty(isRequestor ? POLICY_INFO_ENDPOINT_CLIENT : POLICY_INFO_ENDPOINT_SERVER, epi);
+        if (m != null) {
+            ei.setProperty(isRequestor ? POLICY_INFO_ENDPOINT_CLIENT : POLICY_INFO_ENDPOINT_SERVER, epi);
+        }
         return epi;
     }
 
@@ -573,21 +599,33 @@ public class PolicyEngineImpl implements
      * @return true iff the alternative can be supported
      */
     public boolean supportsAlternative(Collection<? extends PolicyComponent> alternative, 
-                                       Assertor assertor) {
+                                       Assertor assertor,
+                                       Message m) {
         PolicyInterceptorProviderRegistry pipr = 
             bus.getExtension(PolicyInterceptorProviderRegistry.class);
         final boolean doLog = LOG.isLoggable(Level.FINE);
         for (PolicyComponent pc : alternative) {
             if (pc instanceof Assertion) {
                 Assertion a = (Assertion)pc;
-                if (!(a.isOptional() 
-                    || !pipr.get(a.getName()).isEmpty() 
-                    || (null != assertor && assertor.canAssert(a.getName())))) {
-                
-                    if (doLog) {
-                        LOG.fine("Alternative " + a.getName() + " is not supported");
+                if (!a.isOptional()) {
+                    if (null != assertor && assertor.canAssert(a.getName())) {
+                        continue;
+                    }
+                    Set<PolicyInterceptorProvider> s = pipr.get(a.getName());
+                    if (s.isEmpty()) {
+                        if (doLog) {
+                            LOG.fine("Alternative " + a.getName() + " is not supported");
+                        }
+                        return false;
+                    }
+                    for (PolicyInterceptorProvider p : s) {
+                        if (!p.configurationPresent(m, a)) {
+                            if (doLog) {
+                                LOG.fine("Alternative " + a.getName() + " is not supported");
+                            }
+                            return false;
+                        }
                     }
-                    return false;
                 }
             } else {
                 return false;

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInInterceptor.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInInterceptor.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInInterceptor.java Fri Oct 18 00:51:39 2013
@@ -89,8 +89,8 @@ public class PolicyInInterceptor extends
                 Conduit conduit = exchange.getConduit(msg);
                 EndpointPolicy ep = pe.getClientEndpointPolicy(ei, conduit, msg);
                 if (ep != null) {
-                    interceptors.addAll(ep.getInterceptors());
-                    assertions.addAll(ep.getVocabulary());
+                    interceptors.addAll(ep.getInterceptors(msg));
+                    assertions.addAll(ep.getVocabulary(msg));
                 }
             } else {
                 // We do not know the underlying message type yet - so we pre-emptively add interceptors 
@@ -115,8 +115,8 @@ public class PolicyInInterceptor extends
             
             EndpointPolicy ep = pe.getServerEndpointPolicy(ei, destination, msg);
             if (ep != null) {
-                interceptors.addAll(ep.getInterceptors());
-                assertions.addAll(ep.getVocabulary());
+                interceptors.addAll(ep.getInterceptors(msg));
+                assertions.addAll(ep.getVocabulary(msg));
             }
         }
         

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProvider.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProvider.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyInterceptorProvider.java Fri Oct 18 00:51:39 2013
@@ -20,13 +20,12 @@
 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;
+import org.apache.neethi.Assertion;
 
 /**
  * 
@@ -39,13 +38,17 @@ public interface PolicyInterceptorProvid
      * @return collection of QNames of known assertion types
      */
     Collection<QName> getAssertionTypes();
-    
-    List<Interceptor<? extends Message>> provideInInterceptors(Message m);
-    
-    List<Interceptor<? extends Message>> provideOutInterceptors(Message m);
-    
-    List<Interceptor<? extends Message>> provideOutFaultInterceptors(Message m);
-    
-    List<Interceptor<? extends Message>> provideInFaultInterceptors(Message m);
-    
+
+    /**
+     * Return false if the message does not contain enough contextual configuration to preemtively 
+     * support the given assertion.  Otherwise, return true.  If false, the PolicyEngine.supportsAlternative
+     * method will not select this policy and will attempt a different alternative. 
+     * 
+     * Example: If the context does not contain login information, an assertion that requires it 
+     * could return false to allow the Alternative selection algorithms to try a different alternative. 
+     * @param msg The contextual message, may be null if no message is in context at this point 
+     * @param assertion
+     * @return
+     */
+    boolean configurationPresent(Message msg, Assertion assertion);
 }

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/WSPolicyFeature.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/WSPolicyFeature.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/WSPolicyFeature.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/WSPolicyFeature.java Fri Oct 18 00:51:39 2013
@@ -34,6 +34,10 @@ import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.feature.AbstractFeature;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.DescriptionInfo;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.ws.policy.attachment.external.ExternalAttachmentProvider;
@@ -101,6 +105,16 @@ public class WSPolicyFeature extends Abs
             }
         }
     }
+    
+    private MessageImpl createMessage(Endpoint e, Bus b) {
+        MessageImpl m = new MessageImpl();
+        Exchange ex = new ExchangeImpl();
+        m.setExchange(ex);
+        ex.put(Endpoint.class, e);
+        ex.put(Bus.class, b);
+        ex.put(Service.class, e.getService());
+        return m;
+    }
 
     @Override
     public void initialize(Client client, Bus bus) {
@@ -109,7 +123,7 @@ public class WSPolicyFeature extends Abs
         PolicyEngine pe = bus.getExtension(PolicyEngine.class);
         EndpointInfo ei = endpoint.getEndpointInfo();
         EndpointPolicy ep = pe.getClientEndpointPolicy(ei, null, null);
-        pe.setClientEndpointPolicy(ei, ep.updatePolicy(p));
+        pe.setClientEndpointPolicy(ei, ep.updatePolicy(p, createMessage(endpoint, bus)));
     }
 
     @Override
@@ -119,7 +133,7 @@ public class WSPolicyFeature extends Abs
         PolicyEngine pe = bus.getExtension(PolicyEngine.class);
         EndpointInfo ei = endpoint.getEndpointInfo();
         EndpointPolicy ep = pe.getServerEndpointPolicy(ei, null, null);
-        pe.setServerEndpointPolicy(ei, ep.updatePolicy(p));
+        pe.setServerEndpointPolicy(ei, ep.updatePolicy(p, createMessage(endpoint, bus)));
 
         // Add policy to the service model (and consequently to the WSDL)
         // FIXME - ideally this should probably be moved up to where the policies are applied to the

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/FirstAlternativeSelector.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/FirstAlternativeSelector.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/FirstAlternativeSelector.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/FirstAlternativeSelector.java Fri Oct 18 00:51:39 2013
@@ -43,7 +43,7 @@ public class FirstAlternativeSelector ex
         Iterator<List<Assertion>> alternatives = policy.getAlternatives();
         while (alternatives.hasNext()) {
             List<Assertion> alternative = alternatives.next();
-            if (engine.supportsAlternative(alternative, assertor)
+            if (engine.supportsAlternative(alternative, assertor, msg)
                 && this.isCompatibleWithRequest(alternative, request)) {
                 return alternative;
             }
@@ -51,7 +51,7 @@ public class FirstAlternativeSelector ex
         alternatives = policy.getAlternatives();
         while (alternatives.hasNext()) {
             List<Assertion> alternative = alternatives.next();
-            if (engine.supportsAlternative(alternative, assertor)) {
+            if (engine.supportsAlternative(alternative, assertor, msg)) {
                 return alternative;
             }
         }        

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/MaximalAlternativeSelector.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/MaximalAlternativeSelector.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/MaximalAlternativeSelector.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/MaximalAlternativeSelector.java Fri Oct 18 00:51:39 2013
@@ -43,7 +43,7 @@ public class MaximalAlternativeSelector 
         Iterator<List<Assertion>> alternatives = policy.getAlternatives();
         while (alternatives.hasNext()) {
             List<Assertion> alternative = alternatives.next();
-            if (engine.supportsAlternative(alternative, assertor) 
+            if (engine.supportsAlternative(alternative, assertor, msg) 
                 && isCompatibleWithRequest(alternative, request)
                 && (null == choice || alternative.size() > choice.size())) {
                 choice = alternative;
@@ -53,7 +53,7 @@ public class MaximalAlternativeSelector 
             alternatives = policy.getAlternatives();
             while (alternatives.hasNext()) {
                 List<Assertion> alternative = alternatives.next();
-                if (engine.supportsAlternative(alternative, assertor) 
+                if (engine.supportsAlternative(alternative, assertor, msg) 
                     && (null == choice || alternative.size() > choice.size())) {
                     choice = alternative;
                 }

Modified: cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/MinimalAlternativeSelector.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/MinimalAlternativeSelector.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/MinimalAlternativeSelector.java (original)
+++ cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/selector/MinimalAlternativeSelector.java Fri Oct 18 00:51:39 2013
@@ -45,7 +45,7 @@ public class MinimalAlternativeSelector 
         while (alternatives.hasNext()) {
             List<Assertion> alternative = alternatives.next();
             
-            if (engine.supportsAlternative(alternative, assertor)
+            if (engine.supportsAlternative(alternative, assertor, msg)
                 && isCompatibleWithRequest(alternative, request)
                 && (null == choice || alternative.size() < choice.size())) {
                 choice = alternative;
@@ -57,7 +57,7 @@ public class MinimalAlternativeSelector 
             while (alternatives.hasNext()) {
                 List<Assertion> alternative = alternatives.next();
                 
-                if (engine.supportsAlternative(alternative, assertor)
+                if (engine.supportsAlternative(alternative, assertor, msg)
                     && (null == choice || alternative.size() < choice.size())) {
                     choice = alternative;
                 }

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EffectivePolicyImplTest.java Fri Oct 18 00:51:39 2013
@@ -52,6 +52,7 @@ import org.junit.Test;
 public class EffectivePolicyImplTest extends Assert {
 
     private IMocksControl control;
+    private Message msg = new MessageImpl();
     
     @Before
     public void setUp() {
@@ -92,7 +93,7 @@ public class EffectivePolicyImplTest ext
     @Test
     public void testInitialiseFromEndpointPolicy() throws NoSuchMethodException {
         Method m = EffectivePolicyImpl.class.getDeclaredMethod("initialiseInterceptors",
-                                                          new Class[] {PolicyEngine.class});
+                                                          new Class[] {PolicyEngine.class, Message.class});
         EffectivePolicyImpl effectivePolicy = EasyMock.createMockBuilder(EffectivePolicyImpl.class)
             .addMockedMethod(m).createMock(control);
         EndpointPolicyImpl endpointPolicy = control.createMock(EndpointPolicyImpl.class);
@@ -101,7 +102,7 @@ public class EffectivePolicyImplTest ext
         Collection<Assertion> chosenAlternative = new ArrayList<Assertion>();
         EasyMock.expect(endpointPolicy.getChosenAlternative()).andReturn(chosenAlternative);
         PolicyEngineImpl pe = new PolicyEngineImpl();
-        effectivePolicy.initialiseInterceptors(pe, false);
+        effectivePolicy.initialiseInterceptors(pe, false, msg);
         EasyMock.expectLastCall();
         control.replay();
         effectivePolicy.initialise(endpointPolicy, pe, false, null);
@@ -121,7 +122,7 @@ public class EffectivePolicyImplTest ext
         Method m2 = EffectivePolicyImpl.class.getDeclaredMethod("chooseAlternative",
             new Class[] {PolicyEngine.class, Assertor.class, Message.class});
         Method m3 = EffectivePolicyImpl.class.getDeclaredMethod("initialiseInterceptors",
-                                                          new Class[] {PolicyEngine.class});
+                                                          new Class[] {PolicyEngine.class, Message.class});
         EffectivePolicyImpl effectivePolicy = EasyMock.createMockBuilder(EffectivePolicyImpl.class)
             .addMockedMethods(m1, m2, m3).createMock(control);        
         EndpointInfo ei = control.createMock(EndpointInfo.class);
@@ -134,7 +135,7 @@ public class EffectivePolicyImplTest ext
         EasyMock.expectLastCall().andReturn(a);
         effectivePolicy.chooseAlternative(pe, a, null);
         EasyMock.expectLastCall();
-        effectivePolicy.initialiseInterceptors(pe, false);
+        effectivePolicy.initialiseInterceptors(pe, false, msg);
         EasyMock.expectLastCall();
         
         control.replay();
@@ -150,7 +151,7 @@ public class EffectivePolicyImplTest ext
         Method m2 = EffectivePolicyImpl.class.getDeclaredMethod("chooseAlternative",
             new Class[] {PolicyEngine.class, Assertor.class, Message.class});
         Method m3 = EffectivePolicyImpl.class.getDeclaredMethod("initialiseInterceptors",
-                                                          new Class[] {PolicyEngine.class});
+                                                          new Class[] {PolicyEngine.class, Message.class});
         EffectivePolicyImpl effectivePolicy = EasyMock.createMockBuilder(EffectivePolicyImpl.class)
             .addMockedMethods(m1, m2, m3).createMock(control);        
         EndpointInfo ei = control.createMock(EndpointInfo.class);
@@ -162,7 +163,7 @@ public class EffectivePolicyImplTest ext
         EasyMock.expectLastCall();
         effectivePolicy.chooseAlternative(pe, a, null);
         EasyMock.expectLastCall();
-        effectivePolicy.initialiseInterceptors(pe, false);
+        effectivePolicy.initialiseInterceptors(pe, false, msg);
         EasyMock.expectLastCall();
         
         control.replay();
@@ -307,7 +308,7 @@ public class EffectivePolicyImplTest ext
         setupPolicyInterceptorProviderRegistry(engine, reg);
         
         control.replay();
-        epi.initialiseInterceptors(engine, useIn, fault);
+        epi.initialiseInterceptors(engine, useIn, fault, msg);
         assertEquals(0, epi.getInterceptors().size());
         control.verify();
         
@@ -318,7 +319,7 @@ public class EffectivePolicyImplTest ext
         PolicyAssertion a = control.createMock(PolicyAssertion.class);        
         alternative.add(a);
         control.replay();
-        epi.initialiseInterceptors(engine, useIn, fault);
+        epi.initialiseInterceptors(engine, useIn, fault, msg);
         assertEquals(0, epi.getInterceptors().size());
         control.verify();
         
@@ -329,7 +330,7 @@ public class EffectivePolicyImplTest ext
         il = new ArrayList<Interceptor<? extends Message>>();
         setupRegistryInterceptors(useIn, fault, reg, qn, il);
         control.replay();
-        epi.initialiseInterceptors(engine, useIn, fault);
+        epi.initialiseInterceptors(engine, useIn, fault, msg);
         assertEquals(0, epi.getInterceptors().size());
         control.verify();
         
@@ -341,7 +342,7 @@ public class EffectivePolicyImplTest ext
         il.add(pi);
         setupRegistryInterceptors(useIn, fault, reg, qn, il);
         control.replay();
-        epi.initialiseInterceptors(engine, useIn, fault);
+        epi.initialiseInterceptors(engine, useIn, fault, msg);
         assertEquals(1, epi.getInterceptors().size());
         assertSame(pi, epi.getInterceptors().get(0));
         control.verify();

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/EndpointPolicyImplTest.java Fri Oct 18 00:51:39 2013
@@ -30,6 +30,8 @@ import javax.xml.namespace.QName;
 import org.apache.cxf.Bus;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.model.EndpointInfo;
@@ -82,10 +84,11 @@ public class EndpointPolicyImplTest exte
     @Test
     public void testAccessors() {
         EndpointPolicyImpl epi = new EndpointPolicyImpl();
+        Message m = new MessageImpl();
         assertNull(epi.getPolicy());
         assertNull(epi.getChosenAlternative());
-        assertNull(epi.getInterceptors());
-        assertNull(epi.getFaultInterceptors());
+        assertNull(epi.getInterceptors(m));
+        assertNull(epi.getFaultInterceptors(m));
 
         Policy p = control.createMock(Policy.class);
         Assertion a = control.createMock(Assertion.class);
@@ -97,13 +100,13 @@ public class EndpointPolicyImplTest exte
         epi.setChosenAlternative(la);
         assertSame(la, epi.getChosenAlternative());
         epi.setInterceptors(li);
-        assertSame(li, epi.getInterceptors());
+        assertSame(li, epi.getInterceptors(m));
         epi.setFaultInterceptors(li);
-        assertSame(li, epi.getFaultInterceptors());
+        assertSame(li, epi.getFaultInterceptors(m));
         epi.setVocabulary(la);
-        assertSame(la, epi.getVocabulary());
+        assertSame(la, epi.getVocabulary(m));
         epi.setFaultVocabulary(la);
-        assertSame(la, epi.getFaultVocabulary());
+        assertSame(la, epi.getFaultVocabulary(m));
         control.verify();
     }
 
@@ -186,6 +189,12 @@ public class EndpointPolicyImplTest exte
         control.verify();
     }
 
+    private MessageImpl createMessage() {
+        MessageImpl m = new MessageImpl();
+        Exchange ex = new ExchangeImpl();
+        m.setExchange(ex);
+        return m;
+    }
     @Test
     public void testUpdatePolicy() {
 
@@ -202,7 +211,7 @@ public class EndpointPolicyImplTest exte
 
         epi.setPolicy(p1.normalize(null, true));
 
-        Policy ep = epi.updatePolicy(p2).getPolicy();
+        Policy ep = epi.updatePolicy(p2, createMessage()).getPolicy();
 
         List<ExactlyOne> pops = CastUtils.cast(ep.getPolicyComponents(), ExactlyOne.class);
         assertEquals("New policy must have 1 top level policy operator", 1, pops.size());
@@ -261,7 +270,7 @@ public class EndpointPolicyImplTest exte
 
         epi.setPolicy(p1.normalize(true));
 
-        Policy ep = epi.updatePolicy(emptyPolicy).getPolicy();
+        Policy ep = epi.updatePolicy(emptyPolicy, createMessage()).getPolicy();
 
         List<ExactlyOne> pops = CastUtils.cast(ep.getPolicyComponents(), ExactlyOne.class);
         assertEquals("New policy must have 1 top level policy operator", 1, pops.size());
@@ -325,13 +334,13 @@ public class EndpointPolicyImplTest exte
         control.replay();
         Message m = new MessageImpl();
         epi.initializeInterceptors(m);
-        assertEquals(1, epi.getInterceptors().size());
-        assertSame(api, epi.getInterceptors().get(0));
+        assertEquals(1, epi.getInterceptors(m).size());
+        assertSame(api, epi.getInterceptors(m).get(0));
         if (requestor) {
-            assertEquals(1, epi.getFaultInterceptors().size());
-            assertSame(api, epi.getFaultInterceptors().get(0));
+            assertEquals(1, epi.getFaultInterceptors(m).size());
+            assertSame(api, epi.getFaultInterceptors(m).get(0));
         } else {
-            assertNull(epi.getFaultInterceptors());
+            assertNull(epi.getFaultInterceptors(m));
         }
         control.verify();
     }

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyInterceptorsTest.java Fri Oct 18 00:51:39 2013
@@ -145,7 +145,7 @@ public class PolicyInterceptorsTest exte
         EndpointPolicy endpointPolicy = control.createMock(EndpointPolicy.class);
         EasyMock.expect(pe.getClientEndpointPolicy(ei, conduit, message)).andReturn(endpointPolicy);
         List<Interceptor<? extends Message>> li = createMockInterceptorList();
-        EasyMock.expect(endpointPolicy.getFaultInterceptors())
+        EasyMock.expect(endpointPolicy.getFaultInterceptors(message))
             .andReturn(li);
         InterceptorChain ic = control.createMock(InterceptorChain.class);
         EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
@@ -153,7 +153,7 @@ public class PolicyInterceptorsTest exte
         EasyMock.expectLastCall();
         Collection<Assertion> assertions = 
             CastUtils.cast(Collections.EMPTY_LIST, Assertion.class);
-        EasyMock.expect(endpointPolicy.getFaultVocabulary()).andReturn(assertions);
+        EasyMock.expect(endpointPolicy.getFaultVocabulary(message)).andReturn(assertions);
         control.replay();
         interceptor.handleMessage(message);
         control.verify();        
@@ -170,7 +170,7 @@ public class PolicyInterceptorsTest exte
         EndpointPolicy endpointPolicy = control.createMock(EndpointPolicyImpl.class);
         EasyMock.expect(pe.getServerEndpointPolicy(ei, destination, message)).andReturn(endpointPolicy);
         List<Interceptor<? extends Message>> li = createMockInterceptorList();
-        EasyMock.expect(endpointPolicy.getInterceptors())
+        EasyMock.expect(endpointPolicy.getInterceptors(message))
             .andReturn(li);
         InterceptorChain ic = control.createMock(InterceptorChain.class);
         EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
@@ -178,7 +178,7 @@ public class PolicyInterceptorsTest exte
         EasyMock.expectLastCall();
         Collection<Assertion> assertions = 
             CastUtils.cast(Collections.EMPTY_LIST, Assertion.class);
-        EasyMock.expect(endpointPolicy.getVocabulary()).andReturn(assertions);
+        EasyMock.expect(endpointPolicy.getVocabulary(message)).andReturn(assertions);
         control.replay();
         interceptor.handleMessage(message);
         control.verify();       

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/selector/FirstAlternativeSelectorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/selector/FirstAlternativeSelectorTest.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/selector/FirstAlternativeSelectorTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/selector/FirstAlternativeSelectorTest.java Fri Oct 18 00:51:39 2013
@@ -68,16 +68,16 @@ public class FirstAlternativeSelectorTes
         Collection<PolicyAssertion> firstAlternative = 
             CastUtils.cast(all.getPolicyComponents(), PolicyAssertion.class);
         policy.addPolicyComponent(ea);
-        
-        EasyMock.expect(engine.supportsAlternative(firstAlternative, assertor)).andReturn(false);
+        Message m = new MessageImpl();
+
+        EasyMock.expect(engine.supportsAlternative(firstAlternative, assertor, m)).andReturn(false);
         control.replay();
         
-        Message m = new MessageImpl();
         assertNull(selector.selectAlternative(policy, engine, assertor, null, m));  
         control.verify();
         
         control.reset();        
-        EasyMock.expect(engine.supportsAlternative(firstAlternative, assertor)).andReturn(true);
+        EasyMock.expect(engine.supportsAlternative(firstAlternative, assertor, m)).andReturn(true);
         control.replay();         
         Collection<Assertion> chosen = selector.selectAlternative(policy, engine, assertor, null, m); 
         assertSame(1, chosen.size());
@@ -91,8 +91,8 @@ public class FirstAlternativeSelectorTes
         ea.addPolicyComponent(other);
         Collection<PolicyAssertion> secondAlternative = 
             CastUtils.cast(other.getPolicyComponents(), PolicyAssertion.class);
-        EasyMock.expect(engine.supportsAlternative(firstAlternative, assertor)).andReturn(false);
-        EasyMock.expect(engine.supportsAlternative(secondAlternative, assertor)).andReturn(true);
+        EasyMock.expect(engine.supportsAlternative(firstAlternative, assertor, m)).andReturn(false);
+        EasyMock.expect(engine.supportsAlternative(secondAlternative, assertor, m)).andReturn(true);
         control.replay();        
       
         chosen = selector.selectAlternative(policy, engine, assertor, null, m); 

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/selector/MinimalMaximalAlternativeSelectorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/selector/MinimalMaximalAlternativeSelectorTest.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/selector/MinimalMaximalAlternativeSelectorTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/selector/MinimalMaximalAlternativeSelectorTest.java Fri Oct 18 00:51:39 2013
@@ -74,8 +74,8 @@ public class MinimalMaximalAlternativeSe
         Collection<PolicyAssertion> minAlternative = 
             CastUtils.cast(all.getPolicyComponents(), PolicyAssertion.class);
         policy.addPolicyComponent(ea);  
-        EasyMock.expect(engine.supportsAlternative(maxAlternative, assertor)).andReturn(true);
-        EasyMock.expect(engine.supportsAlternative(minAlternative, assertor)).andReturn(true);
+        EasyMock.expect(engine.supportsAlternative(maxAlternative, assertor, m)).andReturn(true);
+        EasyMock.expect(engine.supportsAlternative(minAlternative, assertor, m)).andReturn(true);
         
         control.replay();        
         Collection<Assertion> choice = 
@@ -86,6 +86,7 @@ public class MinimalMaximalAlternativeSe
     
     @Test
     public void testChooseMaxAlternative() {
+        Message m = new MessageImpl();
         AlternativeSelector selector = new MaximalAlternativeSelector();
         
         PolicyEngine engine = control.createMock(PolicyEngine.class);
@@ -104,11 +105,10 @@ public class MinimalMaximalAlternativeSe
         Collection<PolicyAssertion> minAlternative = 
             CastUtils.cast(all.getPolicyComponents(), PolicyAssertion.class);
         policy.addPolicyComponent(ea);  
-        EasyMock.expect(engine.supportsAlternative(maxAlternative, assertor)).andReturn(true);
-        EasyMock.expect(engine.supportsAlternative(minAlternative, assertor)).andReturn(true);
+        EasyMock.expect(engine.supportsAlternative(maxAlternative, assertor, m)).andReturn(true);
+        EasyMock.expect(engine.supportsAlternative(minAlternative, assertor, m)).andReturn(true);
         
         control.replay();        
-        Message m = new MessageImpl();
         Collection<Assertion> choice = selector.selectAlternative(policy, engine, assertor, null, m); 
         assertEquals(1, choice.size());
         assertSame(a1, choice.iterator().next());

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/HttpsTokenInterceptorProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/HttpsTokenInterceptorProvider.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/HttpsTokenInterceptorProvider.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/HttpsTokenInterceptorProvider.java Fri Oct 18 00:51:39 2013
@@ -30,14 +30,18 @@ import java.util.TreeMap;
 import java.util.logging.Logger;
 
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.configuration.security.AuthorizationPolicy;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.security.SecurityContext;
 import org.apache.cxf.security.transport.TLSSessionInfo;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.http.HTTPConduit;
 import org.apache.cxf.transport.http.MessageTrustDecider;
 import org.apache.cxf.transport.http.URLConnectionInfo;
 import org.apache.cxf.transport.http.UntrustedURLConnectionIOException;
@@ -46,6 +50,7 @@ import org.apache.cxf.ws.policy.Abstract
 import org.apache.cxf.ws.policy.AssertionInfo;
 import org.apache.cxf.ws.policy.AssertionInfoMap;
 import org.apache.cxf.ws.policy.PolicyException;
+import org.apache.neethi.Assertion;
 import org.apache.wss4j.policy.SP11Constants;
 import org.apache.wss4j.policy.SP12Constants;
 import org.apache.wss4j.policy.SPConstants;
@@ -85,6 +90,33 @@ public class HttpsTokenInterceptorProvid
         return headers;
     }
 
+    public boolean configurationPresent(Message msg, Assertion assertion) {
+        if (msg == null || !MessageUtils.isRequestor(msg) || !SP11Constants.HTTPS_TOKEN.equals(assertion.getName())) {
+            return true;
+        }
+        
+        HttpsToken token = (HttpsToken)assertion;        
+        if (token.getAuthenticationType() == HttpsToken.AuthenticationType.HttpBasicAuthentication
+            || token.getAuthenticationType() == HttpsToken.AuthenticationType.HttpDigestAuthentication) {
+            try {
+                return tryAuth(msg);
+            } catch (Throwable t) {
+                //ignore, can catch it later
+            }
+        }
+        return true;
+    }    
+    
+    private boolean tryAuth(Message msg) {
+        Conduit conduit = msg.getExchange().getConduit(msg);
+        AuthorizationPolicy p = ((HTTPConduit)conduit).getEffectiveAuthPolicy(msg);
+
+        if (StringUtils.isEmpty(p.getUserName())) {
+            return false;
+        }
+        return true;
+    }
+    
     static class HttpsTokenOutInterceptor extends AbstractPhaseInterceptor<Message> {
         public HttpsTokenOutInterceptor() {
             super(Phase.PRE_STREAM);

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/NegotiationUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/NegotiationUtils.java?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/NegotiationUtils.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/NegotiationUtils.java Fri Oct 18 00:51:39 2013
@@ -227,12 +227,12 @@ final class NegotiationUtils {
             message.getExchange().put(TokenStore.class.getName(), store);
 
             EndpointPolicy ep = pe.getServerEndpointPolicy(endpoint.getEndpointInfo(), destination, message);
-            List<Interceptor<? extends Message>> interceptors = ep.getInterceptors();
+            List<Interceptor<? extends Message>> interceptors = ep.getInterceptors(message);
             for (Interceptor<? extends Message> i : interceptors) {
                 message.getInterceptorChain().add(i);
             }
 
-            Collection<Assertion> assertions = ep.getVocabulary();
+            Collection<Assertion> assertions = ep.getVocabulary(message);
             if (null != assertions) {
                 message.put(AssertionInfoMap.class, new AssertionInfoMap(assertions));
             }

Modified: cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/security/DoubleIt.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/security/DoubleIt.wsdl?rev=1533299&r1=1533298&r2=1533299&view=diff
==============================================================================
--- cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/security/DoubleIt.wsdl (original)
+++ cxf/trunk/systests/ws-security/src/test/resources/org/apache/cxf/systest/ws/security/DoubleIt.wsdl Fri Oct 18 00:51:39 2013
@@ -240,7 +240,23 @@
         </wsdl:operation>
     </wsdl:binding>
 
-
+    <wsdl:binding name="DoubleItBindingCXF5325" type="tns:DoubleItPortType">
+        <wsp:PolicyReference URI="#CXF5325" />
+        <soap:binding style="document"
+          transport="http://schemas.xmlsoap.org/soap/http" />
+        <wsdl:operation name="DoubleIt">
+            <soap:operation soapAction="" />
+            <wsdl:input>
+                <soap:body use="literal" />
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal" />
+            </wsdl:output>
+            <wsdl:fault name="DoubleItFault">
+                <soap:body use="literal" name="DoubleItFault" />
+            </wsdl:fault>
+        </wsdl:operation>
+    </wsdl:binding>
 
     <wsdl:service name="DoubleItService">
         <wsdl:port name="DoubleItPortHttps" binding="tns:DoubleItBinding">
@@ -282,6 +298,9 @@
         <wsdl:port name="DoubleItPortCXF4122" binding="tns:DoubleItBindingCXF4122">
             <soap:address location="http://localhost:9010/SecPolTestCXF4122" />
         </wsdl:port>
+        <wsdl:port name="DoubleItPortCXF5325" binding="tns:DoubleItBindingCXF5325">
+            <soap:address location="https://localhost:9009/SecPolTestCXF5325" />
+        </wsdl:port>
     </wsdl:service>
 
     <wsp:Policy wsu:Id="DoubleItBindingPolicy">
@@ -942,4 +961,83 @@
             </wsp:All>
         </wsp:ExactlyOne>
     </wsp:Policy>
+    
+    
+    <wsp:Policy wsu:Id="CXF5325">
+        <wsp:ExactlyOne>
+            <wsp:All>
+                <wsaw:UsingAddressing
+                    xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+                    wsp:Optional="true" />
+                <wsp:All>
+                    <sp:TransportBinding
+                        xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"
+                        xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/policy"
+                        xmlns:wsa="http://www.w3.org/2005/08/addressing"
+                        xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512"
+                        xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility"
+                        xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
+                        <wsp:Policy>
+                            <sp:TransportToken>
+                                <wsp:Policy>
+                                    <sp:HttpsToken>
+                                        <wsp:Policy>
+                                            <sp:HttpBasicAuthentication />
+                                        </wsp:Policy>
+                                    </sp:HttpsToken>
+                                </wsp:Policy>
+                            </sp:TransportToken>
+                            <sp:AlgorithmSuite>
+                                <wsp:Policy>
+                                    <sp:Basic128Rsa15 />
+                                </wsp:Policy>
+                            </sp:AlgorithmSuite>
+                            <sp:Layout>
+                                <wsp:Policy>
+                                    <sp:Strict />
+                                </wsp:Policy>
+                            </sp:Layout>
+                        </wsp:Policy>
+                    </sp:TransportBinding>
+                </wsp:All>
+            </wsp:All>
+            <wsp:All>
+                <wsaw:UsingAddressing
+                    xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+                    wsp:Optional="true" />
+                <wsp:All>
+                    <sp:TransportBinding
+                        xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"
+                        xmlns:sapsp="http://www.sap.com/webas/630/soap/features/security/policy"
+                        xmlns:wsa="http://www.w3.org/2005/08/addressing"
+                        xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512"
+                        xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility"
+                        xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex">
+                        <wsp:Policy>
+                            <sp:TransportToken>
+                                <wsp:Policy>
+                                    <sp:HttpsToken>
+                                        <wsp:Policy>
+                                            <sp:RequireClientCertificate />
+                                        </wsp:Policy>
+                                    </sp:HttpsToken>
+                                </wsp:Policy>
+                            </sp:TransportToken>
+                            <sp:AlgorithmSuite>
+                                <wsp:Policy>
+                                    <sp:Basic128Rsa15 />
+                                </wsp:Policy>
+                            </sp:AlgorithmSuite>
+                            <sp:Layout>
+                                <wsp:Policy>
+                                    <sp:Strict />
+                                </wsp:Policy>
+                            </sp:Layout>
+                        </wsp:Policy>
+                    </sp:TransportBinding>
+                </wsp:All>
+            </wsp:All>
+        </wsp:ExactlyOne>
+    </wsp:Policy>
+    
 </wsdl:definitions>