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 2008/08/22 19:43:18 UTC

svn commit: r688133 - in /cxf/trunk: api/src/main/java/org/apache/cxf/phase/ api/src/main/java/org/apache/cxf/service/model/ api/src/main/java/org/apache/cxf/ws/policy/ api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/ rt/bindings/soap/src/...

Author: dkulp
Date: Fri Aug 22 10:43:16 2008
New Revision: 688133

URL: http://svn.apache.org/viewvc?rev=688133&view=rev
Log:
[CXF-1656] Updates to policy engine to store policies on the service model itself (so it get's garbage collected with everything else)
Get the first WS-SecPol assertion working (HttpsToken)

Added:
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/HttpsTokenInterceptorProvider.java   (with props)
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/https_config.xml   (with props)
Removed:
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AbstractConfigurableSecurityAssertion.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/DoubleItImpl.java
Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/phase/AbstractPhaseInterceptor.java
    cxf/trunk/api/src/main/java/org/apache/cxf/service/model/EndpointInfo.java
    cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/APIMessages.properties
    cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java
    cxf/trunk/rt/ws/policy/src/main/java/org/apache/cxf/ws/policy/PolicyEngineImpl.java
    cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/WSSecurityPolicyInterceptorProvider.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AbstractSecurityAssertion.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AlgorithmSuite.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AsymmetricBinding.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/HttpsToken.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/SymmetricBinding.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportBinding.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportToken.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java
    cxf/trunk/systests/src/test/resources/wsdl_systest/DoubleIt.wsdl

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/phase/AbstractPhaseInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/phase/AbstractPhaseInterceptor.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/phase/AbstractPhaseInterceptor.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/phase/AbstractPhaseInterceptor.java Fri Aug 22 10:43:16 2008
@@ -101,4 +101,10 @@
         String method = (String)message.get(Message.HTTP_REQUEST_METHOD);
         return "GET".equals(method) && message.getContent(XMLStreamReader.class) == null;
     }
+    
+    protected boolean isRequestor(T message) {
+        return Boolean.TRUE.equals(message.containsKey(
+            org.apache.cxf.message.Message.REQUESTOR_ROLE));
+    }  
+
 }

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/service/model/EndpointInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/service/model/EndpointInfo.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/service/model/EndpointInfo.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/service/model/EndpointInfo.java Fri Aug 22 10:43:16 2008
@@ -42,6 +42,7 @@
         service = serv;
     }
     
+    
     public String getTransportId() {
         return transportId;
     }    
@@ -54,6 +55,9 @@
         return service.getInterface();
     }
     
+    public void setService(ServiceInfo s) {
+        service = s;
+    }
     public ServiceInfo getService() {
         return service;
     }
@@ -128,8 +132,8 @@
     }
 
     public String toString() {
-        return "BindingQName=" + binding.getName()
-                + ", ServiceQName=" + binding.getService().getName()
+        return "BindingQName=" + (binding == null ? "" : (binding.getName()
+                + ", ServiceQName=" + (binding.getService() == null ? "" : binding.getService().getName())))
                 + ", QName=" + name;
     }
 }

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/APIMessages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/APIMessages.properties?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/APIMessages.properties (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/APIMessages.properties Fri Aug 22 10:43:16 2008
@@ -18,5 +18,5 @@
 #    under the License.
 #
 #
-NO_ALTERNATIVE_EXC = These policy alternatives can be satisfied: {0}
+NO_ALTERNATIVE_EXC = These policy alternatives can not be satisfied: {0}
 NOT_ASSERTED_EXC = Assertion of type {0} could not be asserted.
\ No newline at end of file

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/ws/policy/builder/primitive/PrimitiveAssertion.java Fri Aug 22 10:43:16 2008
@@ -68,6 +68,9 @@
         }
     }
 
+    public String toString() {
+        return name.toString();
+    }
     public boolean equal(PolicyComponent policyComponent) {
         if (policyComponent.getType() != Constants.TYPE_ASSERTION) {
             return false;

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java (original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/AbstractSoapInterceptor.java Fri Aug 22 10:43:16 2008
@@ -49,11 +49,6 @@
     }
 
     
-    protected boolean isRequestor(org.apache.cxf.message.Message message) {
-        return Boolean.TRUE.equals(message.containsKey(
-            org.apache.cxf.message.Message.REQUESTOR_ROLE));
-    }  
-    
     public Set<URI> getRoles() {
         return Collections.emptySet();
     }

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java (original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/SoapOutInterceptor.java Fri Aug 22 10:43:16 2008
@@ -210,10 +210,6 @@
         return endedHeader;
     }       
     
-    protected boolean isRequestor(Message message) {
-        return Boolean.TRUE.equals(message.containsKey(Message.REQUESTOR_ROLE));
-    }
-
     protected DataWriter<XMLStreamWriter> getDataWriter(Message message) {
         Service service = ServiceModelUtil.getService(message.getExchange());
         DataWriter<XMLStreamWriter> dataWriter = service.getDataBinding().createWriter(XMLStreamWriter.class);

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java (original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/AbstractJAXWSHandlerInterceptor.java Fri Aug 22 10:43:16 2008
@@ -46,11 +46,6 @@
             || message == ex.getOutFaultMessage();
     }
     
-    
-    protected boolean isRequestor(T message) {
-        return Boolean.TRUE.equals(message.containsKey(Message.REQUESTOR_ROLE));
-    }
-    
     protected HandlerChainInvoker getInvoker(T message) {
         Exchange ex = message.getExchange();
         HandlerChainInvoker invoker = 

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=688133&r1=688132&r2=688133&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 Aug 22 10:43:16 2008
@@ -20,15 +20,11 @@
 package org.apache.cxf.ws.policy;
 
 import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
 
 import javax.annotation.PostConstruct;
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.Bus;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.endpoint.ServerLifeCycleListener;
-import org.apache.cxf.endpoint.ServerLifeCycleManager;
 import org.apache.cxf.extension.BusExtension;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.service.model.BindingFaultInfo;
@@ -49,8 +45,17 @@
 /**
  * 
  */
-public class PolicyEngineImpl implements PolicyEngine, BusExtension, ServerLifeCycleListener {
-
+public class PolicyEngineImpl implements PolicyEngine, BusExtension {
+    private static final String POLICY_INFO_REQUEST_SERVER = "policy-engine-info-serve-request";
+    private static final String POLICY_INFO_FAULT_SERVER = "policy-engine-info-serve-fault";
+    private static final String POLICY_INFO_RESPONSE_SERVER = "policy-engine-info-serve-response";
+    private static final String POLICY_INFO_ENDPOINT_SERVER = "policy-engine-info-serve-rendpoint";
+    
+    private static final String POLICY_INFO_REQUEST_CLIENT = "policy-engine-info-client-request";
+    private static final String POLICY_INFO_FAULT_CLIENT = "policy-engine-info-client-fault";
+    private static final String POLICY_INFO_RESPONSE_CLIENT = "policy-engine-info-client-response";
+    private static final String POLICY_INFO_ENDPOINT_CLIENT = "policy-engine-info-client-endpoint";
+    
     private Bus bus;
     private PolicyRegistry registry;
     private Collection<PolicyProvider> policyProviders;
@@ -59,14 +64,6 @@
     private boolean addedBusInterceptors;
     private AlternativeSelector alternativeSelector;
 
-    private Map<BindingOperation, EffectivePolicy> clientRequestInfo;
-    private Map<BindingOperation, EffectivePolicy> clientResponseInfo;
-    private Map<BindingFault, EffectivePolicy> clientFaultInfo;
-    private Map<BindingOperation, EffectivePolicy> serverRequestInfo;
-    private Map<BindingOperation, EffectivePolicy> serverResponseInfo;
-    private Map<BindingFault, EffectivePolicy> serverFaultInfo;
-    private Map<EndpointInfo, EndpointPolicy> serverEndpointInfo;
-    private Map<EndpointInfo, EndpointPolicy> clientEndpointInfo;
 
     public PolicyEngineImpl() { 
         init();
@@ -137,16 +134,15 @@
 
     public EffectivePolicy getEffectiveClientRequestPolicy(EndpointInfo ei, BindingOperationInfo boi, 
                                                            Conduit c) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        EffectivePolicy effectivePolicy = clientRequestInfo.get(bo);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_CLIENT);
         if (null == effectivePolicy) {
             EffectivePolicyImpl epi = createOutPolicyInfo();
             Assertor assertor = null;
             if (c instanceof Assertor) {
                 assertor = (Assertor)c;
             }
-            epi.initialise(ei, bo.getBindingOperation(), this, assertor, true);
-            clientRequestInfo.put(bo, epi);
+            epi.initialise(ei, boi, this, assertor, true);
+            boi.setProperty(POLICY_INFO_REQUEST_CLIENT, epi);
             effectivePolicy = epi;
         }
         return effectivePolicy;
@@ -154,22 +150,21 @@
 
     public void setEffectiveClientRequestPolicy(EndpointInfo ei, BindingOperationInfo boi, 
                                                 EffectivePolicy ep) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        clientRequestInfo.put(bo, ep);
+        boi.setProperty(POLICY_INFO_REQUEST_CLIENT, ep);
     }
 
-    public EffectivePolicy getEffectiveServerResponsePolicy(EndpointInfo ei, BindingOperationInfo boi,
+    public EffectivePolicy getEffectiveServerResponsePolicy(EndpointInfo ei,
+                                                            BindingOperationInfo boi,
                                                             Destination d) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        EffectivePolicy effectivePolicy = serverResponseInfo.get(bo);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_RESPONSE_SERVER);
         if (null == effectivePolicy) {
             EffectivePolicyImpl epi = createOutPolicyInfo();
             Assertor assertor = null;
             if (d instanceof Assertor) {
                 assertor = (Assertor)d;
             }
-            epi.initialise(ei, bo.getBindingOperation(), this, assertor, false);
-            serverResponseInfo.put(bo, epi);
+            epi.initialise(ei, boi, this, assertor, false);
+            boi.setProperty(POLICY_INFO_RESPONSE_SERVER, epi);
             effectivePolicy = epi;
         }
         return effectivePolicy;
@@ -177,14 +172,12 @@
 
     public void setEffectiveServerResponsePolicy(EndpointInfo ei, BindingOperationInfo boi, 
                                                  EffectivePolicy ep) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        serverResponseInfo.put(bo, ep);
+        boi.setProperty(POLICY_INFO_RESPONSE_SERVER, ep);
     }
   
     public EffectivePolicy getEffectiveServerFaultPolicy(EndpointInfo ei, BindingFaultInfo bfi, 
                                                          Destination d) {
-        BindingFault bf = new BindingFault(ei, bfi);
-        EffectivePolicy effectivePolicy = serverFaultInfo.get(bf);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)bfi.getProperty(POLICY_INFO_FAULT_SERVER);
         if (null == effectivePolicy) {
             EffectivePolicyImpl epi = createOutPolicyInfo();
             Assertor assertor = null;
@@ -192,30 +185,33 @@
                 assertor = (Assertor)d;
             }
             epi.initialise(ei, bfi, this, assertor);
-            serverFaultInfo.put(bf, epi);
+            bfi.setProperty(POLICY_INFO_FAULT_SERVER, epi);
             effectivePolicy = epi;
         }
         return effectivePolicy;
     }
 
     public void setEffectiveServerFaultPolicy(EndpointInfo ei, BindingFaultInfo bfi, EffectivePolicy ep) {
-        BindingFault bf = new BindingFault(ei, bfi);
-        serverFaultInfo.put(bf, ep);
+        bfi.setProperty(POLICY_INFO_FAULT_SERVER, ep);
     }
 
     public EndpointPolicy getClientEndpointPolicy(EndpointInfo ei, Conduit conduit) {
         Assertor assertor = conduit instanceof Assertor ? (Assertor)conduit : null;
-        return getEndpointPolicy(ei, clientEndpointInfo.get(ei), true, assertor);
+        return getEndpointPolicy(ei, true, assertor);
     }
    
     public EndpointPolicy getServerEndpointPolicy(EndpointInfo ei, Destination destination) {
     
         Assertor assertor = destination instanceof Assertor ? (Assertor)destination : null;
-        return getEndpointPolicy(ei, serverEndpointInfo.get(ei), false, assertor);
+        return getEndpointPolicy(ei, false, assertor);
     }
 
     private EndpointPolicy getEndpointPolicy(
-        EndpointInfo ei, EndpointPolicy ep, boolean isRequestor, Assertor assertor) {
+        EndpointInfo ei, 
+        boolean isRequestor,
+        Assertor assertor) {
+        EndpointPolicy ep = (EndpointPolicy)ei.getProperty(isRequestor ? POLICY_INFO_ENDPOINT_CLIENT 
+                            : POLICY_INFO_ENDPOINT_SERVER);
         if (null != ep) {
             return ep; 
         }
@@ -223,20 +219,19 @@
     }
 
     public void setClientEndpointPolicy(EndpointInfo ei, EndpointPolicy ep) {
-        clientEndpointInfo.put(ei, ep);
+        ei.setProperty(POLICY_INFO_ENDPOINT_CLIENT, ep);
     }
 
     public void setServerEndpointPolicy(EndpointInfo ei, EndpointPolicy ep) {
-        serverEndpointInfo.put(ei, ep);
+        ei.setProperty(POLICY_INFO_ENDPOINT_SERVER, ep);
     }
 
     public EffectivePolicy getEffectiveServerRequestPolicy(EndpointInfo ei, BindingOperationInfo boi) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        EffectivePolicy effectivePolicy = serverRequestInfo.get(bo);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_REQUEST_SERVER);
         if (null == effectivePolicy) {
             EffectivePolicyImpl epi = createOutPolicyInfo();
-            epi.initialisePolicy(ei, bo.getBindingOperation(), this, false);
-            serverRequestInfo.put(bo, epi);
+            epi.initialisePolicy(ei, boi, this, false);
+            boi.setProperty(POLICY_INFO_REQUEST_SERVER, epi);
             effectivePolicy = epi;
         }
         return effectivePolicy;
@@ -244,17 +239,15 @@
 
     public void setEffectiveServerRequestPolicy(EndpointInfo ei, BindingOperationInfo boi, 
                                                 EffectivePolicy ep) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        serverRequestInfo.put(bo, ep);
+        boi.setProperty(POLICY_INFO_REQUEST_SERVER, ep);        
     }
 
     public EffectivePolicy getEffectiveClientResponsePolicy(EndpointInfo ei, BindingOperationInfo boi) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        EffectivePolicy effectivePolicy = clientResponseInfo.get(bo);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)boi.getProperty(POLICY_INFO_RESPONSE_CLIENT);
         if (null == effectivePolicy) {
             EffectivePolicyImpl epi = createOutPolicyInfo();
-            epi.initialisePolicy(ei, bo.getBindingOperation(), this, true);        
-            clientResponseInfo.put(bo, epi);
+            epi.initialisePolicy(ei, boi, this, true);        
+            boi.setProperty(POLICY_INFO_RESPONSE_CLIENT, epi);
             effectivePolicy = epi;
         }
         return effectivePolicy;
@@ -262,55 +255,29 @@
 
     public void setEffectiveClientResponsePolicy(EndpointInfo ei, BindingOperationInfo boi, 
                                                  EffectivePolicy ep) {
-        BindingOperation bo = new BindingOperation(ei, boi);
-        clientResponseInfo.put(bo, ep);
+        boi.setProperty(POLICY_INFO_RESPONSE_CLIENT, ep);
     }
 
     public EffectivePolicy getEffectiveClientFaultPolicy(EndpointInfo ei, BindingFaultInfo bfi) {
-        BindingFault bf = new BindingFault(ei, bfi);
-        EffectivePolicy effectivePolicy = clientFaultInfo.get(bf);
+        EffectivePolicy effectivePolicy = (EffectivePolicy)bfi.getProperty(POLICY_INFO_FAULT_CLIENT);
         if (null == effectivePolicy) {
             EffectivePolicyImpl epi = createOutPolicyInfo();
             epi.initialisePolicy(ei, bfi, this);
-            clientFaultInfo.put(bf, epi);
+            bfi.setProperty(POLICY_INFO_FAULT_CLIENT, epi);
             effectivePolicy = epi;
         }
         return effectivePolicy;
     }
 
     public void setEffectiveClientFaultPolicy(EndpointInfo ei, BindingFaultInfo bfi, EffectivePolicy ep) {
-        BindingFault bf = new BindingFault(ei, bfi);
-        clientFaultInfo.put(bf, ep);
+        bfi.setProperty(POLICY_INFO_FAULT_CLIENT, ep);
     }
 
     // implementation
 
     protected final void init() {
-    
         registry = new PolicyRegistryImpl();
-    
-        clientRequestInfo 
-            = new ConcurrentHashMap<BindingOperation, EffectivePolicy>();
-
-        clientResponseInfo 
-            = new ConcurrentHashMap<BindingOperation, EffectivePolicy>();
-
-        clientFaultInfo 
-            = new ConcurrentHashMap<BindingFault, EffectivePolicy>();
-
-        serverEndpointInfo 
-            = new EndpointPolicyMap();
-        clientEndpointInfo 
-            = new EndpointPolicyMap();
-
-        serverRequestInfo 
-            = new ConcurrentHashMap<BindingOperation, EffectivePolicy>();
 
-        serverResponseInfo 
-            = new ConcurrentHashMap<BindingOperation, EffectivePolicy>();
-
-        serverFaultInfo 
-            = new ConcurrentHashMap<BindingFault, EffectivePolicy>();    
     }
 
 
@@ -364,14 +331,6 @@
         addedBusInterceptors = true;
     }  
 
-    @PostConstruct
-    public void registerListener() {
-        ServerLifeCycleManager slm = bus.getExtension(ServerLifeCycleManager.class);
-        if (slm != null) {
-            slm.registerListener(this);
-        }
-    }
-
     Policy getAggregatedServicePolicy(ServiceInfo si) {
         Policy aggregated = null;
         for (PolicyProvider pp : getPolicyProviders()) {
@@ -500,13 +459,12 @@
         return vocabulary;
     } 
 
-    EndpointPolicyImpl createEndpointPolicyInfo(EndpointInfo ei, boolean isRequestor, Assertor assertor) {
+    EndpointPolicyImpl createEndpointPolicyInfo(EndpointInfo ei, 
+                                                boolean isRequestor, 
+                                                Assertor assertor) {
         EndpointPolicyImpl epi = new EndpointPolicyImpl(ei, this, isRequestor, assertor);
         epi.initialize();
-    
-        Map<EndpointInfo, EndpointPolicy> map = isRequestor ? clientEndpointInfo : serverEndpointInfo;
-        map.put(ei, epi);
-
+        ei.setProperty(isRequestor ? POLICY_INFO_ENDPOINT_CLIENT : POLICY_INFO_ENDPOINT_SERVER, epi);
         return epi;
     }
 
@@ -534,160 +492,11 @@
         return true;
     }
 
-    public void startServer(Server server) {
-        // empty
-    }
-
-    /**
-     * Callback recieved while the server side endpoint is being undeployed.
-     *
-     * @param server
-     */
-    public void stopServer(Server server) {
-        EndpointInfo ei = server.getEndpoint().getEndpointInfo();
-        serverEndpointInfo.remove(ei);
-        clientEndpointInfo.remove(ei);
-
-        /**
-         * While cleaning up the entries of requestInfo's, responseInfo's and faultInfo's map, we create
-         * a temperory Set with all the keys. Later we iterate over the keys of this temp set,
-         * and if it's same as that of the endpoint being undeployed, we remove the corresponding
-         * entries from the client and server maps.
-         */
-
-        cleanupBindingOperations(ei, new HashSet<BindingOperation>(clientRequestInfo.keySet()),
-                clientRequestInfo);
-        cleanupBindingOperations(ei, new HashSet<BindingOperation>(clientResponseInfo.keySet()),
-                clientResponseInfo);
-
-        cleanupBindingOperations(ei, new HashSet<BindingOperation>(serverRequestInfo.keySet()),
-                serverRequestInfo);
-        cleanupBindingOperations(ei, new HashSet<BindingOperation>(serverResponseInfo.keySet()),
-                serverResponseInfo);
-
-        cleanupBindingFaults(ei, new HashSet<BindingFault>(clientFaultInfo.keySet()),
-                clientFaultInfo);
-        cleanupBindingFaults(ei, new HashSet<BindingFault>(serverFaultInfo.keySet()),
-                serverFaultInfo);
-    }
-
-    private void cleanupBindingOperations(EndpointInfo ei,
-                                          Set<BindingOperation> bindingOperations,
-                                          Map<BindingOperation, EffectivePolicy> originalMap) {
-        
-        Iterator<BindingOperation> bindingOpsItr = bindingOperations.iterator();
-        while (bindingOpsItr.hasNext()) {
-            BindingOperation bindingOperation = bindingOpsItr.next();
-            if (ei.isSameAs(bindingOperation.getEndpoint())) {
-                originalMap.remove(bindingOperation);
-            }
-        }
-    }
-
-    private void cleanupBindingFaults(EndpointInfo ei, Set <BindingFault> bindingFaults,
-                                      Map<BindingFault, EffectivePolicy> originalMap) {
-        Iterator<BindingFault> bindingFaultsItr = bindingFaults.iterator();
-        while (bindingFaultsItr.hasNext()) {
-            BindingFault bindingFault = bindingFaultsItr.next();
-            if (ei.isSameAs(bindingFault.getEndpoint())) {
-                originalMap.remove(bindingFault);
-            }
-        }
-    }
-    /**
-     * Class used as key in the client request policy and server response policy maps.
-     */
-    class BindingOperation {
-        private EndpointInfo ei;
-        private BindingOperationInfo boi;
-    
-        BindingOperation(EndpointInfo e, BindingOperationInfo b) {
-            ei = e;
-            boi = b.isUnwrapped() ? b.getWrappedOperation() : b;
-        }
-    
-        EndpointInfo getEndpoint() {
-            return ei;
-        }
-    
-        BindingOperationInfo getBindingOperation() {
-            return boi;
-        }
-
-        @Override
-        public int hashCode() {
-            return boi.hashCode();
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            BindingOperation other = (BindingOperation)obj;
-            return boi.equals(other.boi) && ei.equals(other.ei);
-        }
-    
-        @Override
-        public String toString() {
-            return ei.getName().toString() + "." + boi.getName().toString();
-        }
-    
-    
-    }
-
-    /**
-     * Class used as key in the server fault policy map.
-     */
-    class BindingFault {
-        private EndpointInfo ei;
-        private BindingFaultInfo bfi;
-    
-        BindingFault(EndpointInfo e, BindingFaultInfo b) {
-            ei = e;
-            bfi = b;
-        }
-    
-        EndpointInfo getEndpoint() {
-            return ei;
-        }
-    
-        BindingFaultInfo getBindingFault() {
-            return bfi;
-        }
-    
-        @Override
-        public int hashCode() {
-            return bfi.hashCode();
-        }
-    
-        @Override
-        public boolean equals(Object obj) {
-            BindingFault other = (BindingFault)obj;
-            return bfi.equals(other.bfi) && ei.equals(other.ei);
-        }
-    
-        @Override
-        public String toString() {
-            return ei.getName().toString() + "." + bfi.getFaultInfo().toString();
-        }
-    }
 
     // for test
-
     EffectivePolicyImpl createOutPolicyInfo() {
         return new EffectivePolicyImpl();
     }
     
-    private class EndpointPolicyMap extends ConcurrentHashMap<EndpointInfo, EndpointPolicy> {
-        public EndpointPolicy remove(Object key) {
-            EndpointInfo toRemove = (EndpointInfo) key;
-            EndpointPolicy pol = null;
-            for (EndpointInfo info : keySet()) {
-                if (info.isSameAs(toRemove)) {
-                    pol = super.remove(info);
-                }
-            }
-            return pol;
-        }
-    }
-
 
 }

Modified: cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java (original)
+++ cxf/trunk/rt/ws/policy/src/test/java/org/apache/cxf/ws/policy/PolicyEngineTest.java Fri Aug 22 10:43:16 2008
@@ -66,8 +66,22 @@
         control = EasyMock.createNiceControl(); 
     } 
     
+    private EndpointInfo createMockEndpointInfo() throws Exception {
+        EndpointInfo ei = new EndpointInfo();
+        ei.setName(new QName("mock", "mock"));
+        return ei;
+    }
+    private BindingOperationInfo createMockBindingOperationInfo() throws Exception {
+        BindingOperationInfo boi = new BindingOperationInfo() {
+            public boolean isUnwrapped() {
+                return false;
+            }
+        };
+        return boi;
+    }
+    
     @Test
-    public void testAccessors() {
+    public void testAccessors() throws Exception {
         engine = new PolicyEngineImpl();
         assertNotNull(engine.getRegistry());
         assertNull(engine.getBus());
@@ -94,12 +108,12 @@
     }
     
     @Test
-    public void testGetEffectiveClientRequestPolicy() throws NoSuchMethodException {
+    public void testGetEffectiveClientRequestPolicy() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[] {});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class); 
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo(); 
         AssertingConduit conduit = control.createMock(AssertingConduit.class);
         EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
         EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
@@ -112,11 +126,10 @@
     }
     
     @Test 
-    public void testSetEffectiveClientRequestPolicy() {
+    public void testSetEffectiveClientRequestPolicy() throws Exception {
         engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
-        EasyMock.expect(boi.isUnwrapped()).andReturn(false).times(2);
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo();
         EffectivePolicy effectivePolicy = control.createMock(EffectivePolicy.class);
         control.replay();
         engine.setEffectiveClientRequestPolicy(ei, boi, effectivePolicy);
@@ -126,12 +139,12 @@
     }
     
     @Test
-    public void testGetEffectiveServerResponsePolicy() throws NoSuchMethodException {
+    public void testGetEffectiveServerResponsePolicy() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[] {});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class); 
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo(); 
         AssertingDestination destination = control.createMock(AssertingDestination.class);
         EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
         EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
@@ -144,11 +157,10 @@
     }
     
     @Test
-    public void testSetEffectiveServerResponsePolicy() {
+    public void testSetEffectiveServerResponsePolicy() throws Exception {
         engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
-        EasyMock.expect(boi.isUnwrapped()).andReturn(false).times(2);
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo();
         EffectivePolicy effectivePolicy = control.createMock(EffectivePolicy.class);
         control.replay();
         engine.setEffectiveServerResponsePolicy(ei, boi, effectivePolicy);
@@ -158,12 +170,12 @@
     }
    
     @Test
-    public void testGetEffectiveServerFaultPolicy() throws NoSuchMethodException {
+    public void testGetEffectiveServerFaultPolicy() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[] {});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class); 
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingFaultInfo bfi = new BindingFaultInfo(null, null); 
         AssertingDestination destination = control.createMock(AssertingDestination.class);
         EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
         EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
@@ -176,22 +188,22 @@
     }
     
     @Test
-    public void testSetEffectiveServerFaultPolicy() {
+    public void testSetEffectiveServerFaultPolicy() throws Exception {
         engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class);
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingFaultInfo bfi = new BindingFaultInfo(null, null); 
         EffectivePolicy epi = control.createMock(EffectivePolicy.class);
         engine.setEffectiveServerFaultPolicy(ei, bfi, epi);
         assertSame(epi, engine.getEffectiveServerFaultPolicy(ei, bfi, (Destination)null));   
     }
        
     @Test
-    public void testGetEffectiveServerRequestPolicyInfo() throws NoSuchMethodException {
+    public void testGetEffectiveServerRequestPolicyInfo() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[] {});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class); 
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo(); 
         EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
         EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
         epi.initialisePolicy(ei, boi, engine, false);
@@ -203,11 +215,10 @@
     }
     
     @Test 
-    public void testSetEffectiveServerRequestPolicy() {
+    public void testSetEffectiveServerRequestPolicy() throws Exception {
         engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
-        EasyMock.expect(boi.isUnwrapped()).andReturn(false).times(2);
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo();
         EffectivePolicy effectivePolicy = control.createMock(EffectivePolicy.class);
         control.replay();
         engine.setEffectiveServerRequestPolicy(ei, boi, effectivePolicy);
@@ -216,12 +227,12 @@
     }
     
     @Test
-    public void testGetEffectiveClientResponsePolicy() throws NoSuchMethodException {
+    public void testGetEffectiveClientResponsePolicy() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[] {});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class); 
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo(); 
         EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
         EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
         epi.initialisePolicy(ei, boi, engine, true);
@@ -233,11 +244,10 @@
     }
     
     @Test 
-    public void testSetEffectiveClientResponsePolicy() {
+    public void testSetEffectiveClientResponsePolicy() throws Exception {
         engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
-        EasyMock.expect(boi.isUnwrapped()).andReturn(false).times(2);
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingOperationInfo boi = createMockBindingOperationInfo();
         EffectivePolicy epi = control.createMock(EffectivePolicy.class);
         control.replay();
         engine.setEffectiveClientResponsePolicy(ei, boi, epi);
@@ -246,12 +256,12 @@
     }
     
     @Test
-    public void testGetEffectiveClientFaultPolicy() throws NoSuchMethodException {
+    public void testGetEffectiveClientFaultPolicy() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createOutPolicyInfo", new Class[] {});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class); 
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingFaultInfo bfi = new BindingFaultInfo(null, null); 
         EffectivePolicyImpl epi = control.createMock(EffectivePolicyImpl.class);
         EasyMock.expect(engine.createOutPolicyInfo()).andReturn(epi);
         epi.initialisePolicy(ei, bfi, engine);
@@ -263,22 +273,22 @@
     }
     
     @Test 
-    public void testSetEffectiveClientFaultPolicy() {
+    public void testSetEffectiveClientFaultPolicy() throws Exception {
         engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class);
+        EndpointInfo ei = createMockEndpointInfo();
+        BindingFaultInfo bfi = new BindingFaultInfo(null, null); 
         EffectivePolicy epi = control.createMock(EffectivePolicy.class);
         engine.setEffectiveClientFaultPolicy(ei, bfi, epi);
         assertSame(epi, engine.getEffectiveClientFaultPolicy(ei, bfi));        
     }
     
     @Test
-    public void testGetEndpointPolicyClientSide() throws NoSuchMethodException {
+    public void testGetEndpointPolicyClientSide() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createEndpointPolicyInfo", 
             new Class[] {EndpointInfo.class, boolean.class, Assertor.class});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
+        EndpointInfo ei = createMockEndpointInfo();
         AssertingConduit conduit = control.createMock(AssertingConduit.class);
         EndpointPolicyImpl epi = control.createMock(EndpointPolicyImpl.class);
         EasyMock.expect(engine.createEndpointPolicyInfo(ei, true, conduit)).andReturn(epi);
@@ -288,12 +298,12 @@
     }
     
     @Test
-    public void testGetEndpointPolicyServerSide() throws NoSuchMethodException {
+    public void testGetEndpointPolicyServerSide() throws Exception {
         Method m = PolicyEngineImpl.class.getDeclaredMethod("createEndpointPolicyInfo", 
             new Class[] {EndpointInfo.class, boolean.class, Assertor.class});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
+        EndpointInfo ei = createMockEndpointInfo();
         AssertingDestination destination = control.createMock(AssertingDestination.class);
         EndpointPolicyImpl epi = control.createMock(EndpointPolicyImpl.class);
         EasyMock.expect(engine.createEndpointPolicyInfo(ei, false, destination)).andReturn(epi);
@@ -303,12 +313,12 @@
     }
     
     @Test
-    public void testCreateEndpointPolicyInfo() throws NoSuchMethodException {
+    public void testCreateEndpointPolicyInfo() throws Exception {
         Method m1 = PolicyEngineImpl.class.getDeclaredMethod("createEndpointPolicyInfo", 
             new Class[] {EndpointInfo.class, boolean.class, Assertor.class});
         engine = control.createMock(PolicyEngineImpl.class, new Method[] {m1});
         engine.init();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
+        EndpointInfo ei = createMockEndpointInfo();
         Assertor assertor = control.createMock(Assertor.class);
         EndpointPolicyImpl epi = control.createMock(EndpointPolicyImpl.class);
         EasyMock.expect(engine.createEndpointPolicyInfo(ei, false, assertor)).andReturn(epi);
@@ -318,12 +328,11 @@
     }
     
     @Test
-    public void testEndpointPolicyWithEqualPolicies() {
+    public void testEndpointPolicyWithEqualPolicies() throws Exception {
         engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
+        EndpointInfo ei = createMockEndpointInfo();
         ServiceInfo si = control.createMock(ServiceInfo.class);
-        ei.getService();
-        EasyMock.expectLastCall().andReturn(si).times(2);
+        ei.setService(si);
         si.getExtensor(Policy.class);
         EasyMock.expectLastCall().andReturn(null).times(2);
         EndpointPolicyImpl epi = control.createMock(EndpointPolicyImpl.class);
@@ -335,8 +344,7 @@
         assertSame(epi, engine.getServerEndpointPolicy(ei, (Destination)null));
         
         control.reset();
-        ei.getService();
-        EasyMock.expectLastCall().andReturn(si).times(2);
+        ei.setService(si);
         Policy p = new Policy();
         si.getExtensor(Policy.class);
         EasyMock.expectLastCall().andReturn(p).times(2);
@@ -444,11 +452,11 @@
     }
     
     @Test
-    public void testGetAggregatedEndpointPolicy() {
+    public void testGetAggregatedEndpointPolicy() throws Exception {
         engine = new PolicyEngineImpl();
         List<PolicyProvider> providers = new ArrayList<PolicyProvider>();
         engine.setPolicyProviders(providers);
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
+        EndpointInfo ei = createMockEndpointInfo();
         
         control.replay();
         Policy p = engine.getAggregatedEndpointPolicy(ei);
@@ -480,11 +488,11 @@
     }
     
     @Test
-    public void testGetAggregatedOperationPolicy() {
+    public void testGetAggregatedOperationPolicy() throws Exception {
         engine = new PolicyEngineImpl();
         List<PolicyProvider> providers = new ArrayList<PolicyProvider>();
         engine.setPolicyProviders(providers);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);
+        BindingOperationInfo boi = createMockBindingOperationInfo();
         
         control.replay();
         Policy p = engine.getAggregatedOperationPolicy(boi);
@@ -660,32 +668,7 @@
         assertEquals(1, assertions.size());
         assertSame(a, assertions.iterator().next());       
     }
-    
-    @Test
-    public void testKeys() {
-        engine = new PolicyEngineImpl();
-        EndpointInfo ei = control.createMock(EndpointInfo.class);
-        BindingOperationInfo boi = control.createMock(BindingOperationInfo.class);      
-        BindingFaultInfo bfi = control.createMock(BindingFaultInfo.class);  
-        control.replay();
-        
-        PolicyEngineImpl.BindingOperation bo = engine.new BindingOperation(ei, boi); 
-        assertNotNull(bo);
-        PolicyEngineImpl.BindingOperation bo2 = engine.new BindingOperation(ei, boi);
-        assertEquals(bo, bo2);
-        assertEquals(bo.hashCode(), bo2.hashCode());
-                  
-        PolicyEngineImpl.BindingFault bf = engine.new BindingFault(ei, bfi);
-        assertNotNull(bf);
-        PolicyEngineImpl.BindingFault bf2 = engine.new BindingFault(ei, bfi);
-        assertEquals(bf, bf2);
-        assertEquals(bf.hashCode(), bf2.hashCode());
-              
-        control.verify();
-    }
-    
-    
-    
+        
     private Set<String> getInterceptorIds(List<Interceptor> interceptors) {
         Set<String> ids = new HashSet<String>();
         for (Interceptor i : interceptors) {

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/WSSecurityPolicyLoader.java Fri Aug 22 10:43:16 2008
@@ -54,6 +54,7 @@
 import org.apache.cxf.ws.security.policy.builders.WSS10Builder;
 import org.apache.cxf.ws.security.policy.builders.WSS11Builder;
 import org.apache.cxf.ws.security.policy.builders.X509TokenBuilder;
+import org.apache.cxf.ws.security.policy.interceptors.HttpsTokenInterceptorProvider;
 import org.apache.cxf.ws.security.policy.interceptors.WSSecurityPolicyInterceptorProvider;
 
 
@@ -113,6 +114,9 @@
             return;
         }
         reg.register(new WSSecurityPolicyInterceptorProvider());
+        
+        reg.register(new HttpsTokenInterceptorProvider(SP11Constants.HTTPS_TOKEN));
+        reg.register(new HttpsTokenInterceptorProvider(SP12Constants.HTTPS_TOKEN));
     }
 
 }

Added: 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=688133&view=auto
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/HttpsTokenInterceptorProvider.java (added)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/HttpsTokenInterceptorProvider.java Fri Aug 22 10:43:16 2008
@@ -0,0 +1,188 @@
+/**
+ * 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.security.policy.interceptors;
+
+import java.net.HttpURLConnection;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.security.transport.TLSSessionInfo;
+import org.apache.cxf.ws.policy.AbstractPolicyInterceptorProvider;
+import org.apache.cxf.ws.policy.AssertionInfo;
+import org.apache.cxf.ws.policy.AssertionInfoMap;
+import org.apache.cxf.ws.security.policy.model.HttpsToken;
+
+/**
+ * 
+ */
+public class HttpsTokenInterceptorProvider extends AbstractPolicyInterceptorProvider {
+
+    public HttpsTokenInterceptorProvider(QName name) {
+        super(Collections.singleton(name));
+        this.getOutInterceptors().add(new HttpsTokenOutInterceptor(name));
+        this.getOutFaultInterceptors().add(new HttpsTokenOutInterceptor(name));
+        this.getInInterceptors().add(new HttpsTokenInInterceptor(name));
+        this.getInFaultInterceptors().add(new HttpsTokenInInterceptor(name));
+    }
+    
+    private static Map<String, List<String>> getSetProtocolHeaders(Message message) {
+        Map<String, List<String>> headers =
+            CastUtils.cast((Map<?, ?>)message.get(Message.PROTOCOL_HEADERS));        
+        if (null == headers) {
+            headers = new HashMap<String, List<String>>();
+            message.put(Message.PROTOCOL_HEADERS, headers);
+        }
+        return headers;
+    }
+
+    static class HttpsTokenOutInterceptor extends AbstractPhaseInterceptor<Message> {
+        QName name;
+        public HttpsTokenOutInterceptor(QName n) {
+            super(Phase.PREPARE_SEND);
+            name = n;
+        }
+        public void handleMessage(Message message) throws Fault {
+            AssertionInfoMap aim = message.get(AssertionInfoMap.class);
+            // extract Assertion information
+            if (aim != null) {
+                Collection<AssertionInfo> ais = aim.get(name);
+                if (ais == null) {
+                    return;
+                }
+                if (isRequestor(message)) {
+                    assertHttps(ais, message);
+                } else {
+                    //server side should be checked on the way in
+                    for (AssertionInfo ai : ais) {
+                        ai.setAsserted(true);
+                    }                    
+                }
+            }
+        }
+        private void assertHttps(Collection<AssertionInfo> ais, Message message) {
+            for (AssertionInfo ai : ais) {
+                HttpsToken token = (HttpsToken)ai.getAssertion();
+                
+                boolean asserted = true;
+                HttpURLConnection connection = 
+                    (HttpURLConnection) message.get("http.connection");
+                
+                Map<String, List<String>> headers = getSetProtocolHeaders(message);
+                if (connection instanceof HttpsURLConnection) {
+                    HttpsURLConnection https = (HttpsURLConnection)connection;
+                    if (token.isRequireClientCertificate()
+                        && https.getLocalCertificates().length == 0) {
+                        asserted = false;
+                    }
+                    if (token.isHttpBasicAuthentication()) {
+                        List<String> auth = headers.get("Authorization");
+                        if (auth == null || auth.size() == 0 
+                            || !auth.get(0).startsWith("Basic")) {
+                            asserted = false;
+                        }
+                    }
+                    if (token.isHttpDigestAuthentication()) {
+                        List<String> auth = headers.get("Authorization");
+                        if (auth == null || auth.size() == 0 
+                            || !auth.get(0).startsWith("Digest")) {
+                            asserted = false;
+                        }                        
+                    }
+                } else {
+                    asserted = false;
+                }
+                ai.setAsserted(asserted);
+            }            
+        }
+
+    }
+    
+    static class HttpsTokenInInterceptor extends AbstractPhaseInterceptor<Message> {
+        QName name;
+        public HttpsTokenInInterceptor(QName n) {
+            super(Phase.PRE_STREAM);
+            name = n;
+        }
+
+        public void handleMessage(Message message) throws Fault {
+            AssertionInfoMap aim = message.get(AssertionInfoMap.class);
+            // extract Assertion information
+            if (aim != null) {
+                Collection<AssertionInfo> ais = aim.get(name);
+                if (ais == null) {
+                    return;
+                }
+                if (!isRequestor(message)) {
+                    assertHttps(ais, message);
+                } else {
+                    //client side should be checked on the way out
+                    for (AssertionInfo ai : ais) {
+                        ai.setAsserted(true);
+                    }                    
+                }
+            }
+        }
+        private void assertHttps(Collection<AssertionInfo> ais, Message message) {
+            for (AssertionInfo ai : ais) {
+                boolean asserted = true;
+                HttpsToken token = (HttpsToken)ai.getAssertion();
+                
+                Map<String, List<String>> headers = getSetProtocolHeaders(message);                
+                if (token.isHttpBasicAuthentication()) {
+                    List<String> auth = headers.get("Authorization");
+                    if (auth == null || auth.size() == 0 
+                        || !auth.get(0).startsWith("Basic")) {
+                        asserted = false;
+                    }
+                }
+                if (token.isHttpDigestAuthentication()) {
+                    List<String> auth = headers.get("Authorization");
+                    if (auth == null || auth.size() == 0 
+                        || !auth.get(0).startsWith("Digest")) {
+                        asserted = false;
+                    }                        
+                }
+
+                TLSSessionInfo tlsInfo = message.get(TLSSessionInfo.class);                
+                if (tlsInfo != null) {
+                    if (token.isRequireClientCertificate()
+                        && tlsInfo.getPeerCertificates().length == 0) {
+                        asserted = false;
+                    }
+                } else {
+                    asserted = false;
+                }                
+                
+                ai.setAsserted(asserted);
+            }
+        }
+    }
+}

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

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

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/WSSecurityPolicyInterceptorProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/WSSecurityPolicyInterceptorProvider.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/WSSecurityPolicyInterceptorProvider.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/interceptors/WSSecurityPolicyInterceptorProvider.java Fri Aug 22 10:43:16 2008
@@ -36,7 +36,6 @@
         ASSERTION_TYPES = new ArrayList<QName>();
         ASSERTION_TYPES.add(SP11Constants.TRANSPORT_BINDING);
         ASSERTION_TYPES.add(SP11Constants.TRANSPORT_TOKEN);
-        ASSERTION_TYPES.add(SP11Constants.HTTPS_TOKEN);
         ASSERTION_TYPES.add(SP11Constants.LAYOUT);
         ASSERTION_TYPES.add(SP11Constants.INCLUDE_TIMESTAMP);
         ASSERTION_TYPES.add(SP11Constants.ALGORITHM_SUITE);

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AbstractSecurityAssertion.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AbstractSecurityAssertion.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AbstractSecurityAssertion.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AbstractSecurityAssertion.java Fri Aug 22 10:43:16 2008
@@ -18,6 +18,9 @@
  */
 package org.apache.cxf.ws.security.policy.model;
 
+import java.util.Collection;
+
+import org.apache.cxf.ws.policy.AssertionInfo;
 import org.apache.cxf.ws.policy.AssertionInfoMap;
 import org.apache.cxf.ws.policy.PolicyAssertion;
 import org.apache.cxf.ws.security.policy.SPConstants;
@@ -48,7 +51,7 @@
     }
 
     public boolean equal(PolicyComponent policyComponent) {
-        throw new UnsupportedOperationException();
+        return policyComponent == this;
     }
 
     public void setNormalized(boolean normalized) {
@@ -60,18 +63,21 @@
     }
 
     public PolicyComponent normalize() {
-
-        /*
-         * TODO: Handling the isOptional:TRUE case
-         */
         return this;
     }
 
-    public boolean isAsserted(AssertionInfoMap aim) {
-        return false;
-    }
     
     public Policy getPolicy() {
         return null;
     }
+    
+    public boolean isAsserted(AssertionInfoMap aim) {
+        Collection<AssertionInfo> ail = aim.getAssertionInfo(getName());
+        for (AssertionInfo ai : ail) {
+            if (ai.isAsserted() && ai.getAssertion().equal(this)) {
+                return true;
+            }
+        }
+        return false;
+    }
 }

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AlgorithmSuite.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AlgorithmSuite.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AlgorithmSuite.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AlgorithmSuite.java Fri Aug 22 10:43:16 2008
@@ -30,7 +30,7 @@
 import org.apache.cxf.ws.security.policy.WSSPolicyException;
 import org.apache.neethi.PolicyComponent;
 
-public class AlgorithmSuite extends AbstractConfigurableSecurityAssertion {
+public class AlgorithmSuite extends AbstractSecurityAssertion {
     private static final Logger LOG = LogUtils.getL7dLogger(AlgorithmSuite.class);
     
     private String algoSuiteString;

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AsymmetricBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AsymmetricBinding.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AsymmetricBinding.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/AsymmetricBinding.java Fri Aug 22 10:43:16 2008
@@ -18,8 +18,6 @@
  */
 package org.apache.cxf.ws.security.policy.model;
 
-import java.util.Iterator;
-import java.util.List;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -80,34 +78,29 @@
         }
 
         AlgorithmSuite algorithmSuite = getAlgorithmSuite();
-        List configs = algorithmSuite.getConfigurations();
 
         Policy policy = new Policy();
         ExactlyOne exactlyOne = new ExactlyOne();
 
         policy.addPolicyComponent(exactlyOne);
 
-        All wrapper;
-        AsymmetricBinding asymmetricBinding;
 
-        for (Iterator iterator = configs.iterator(); iterator.hasNext();) {
-            wrapper = new All();
-            asymmetricBinding = new AsymmetricBinding(constants);
-
-            asymmetricBinding.setAlgorithmSuite((AlgorithmSuite)iterator.next());
-            asymmetricBinding.setEntireHeadersAndBodySignatures(isEntireHeadersAndBodySignatures());
-            asymmetricBinding.setIncludeTimestamp(isIncludeTimestamp());
-            asymmetricBinding.setInitiatorToken(getInitiatorToken());
-            asymmetricBinding.setLayout(getLayout());
-            asymmetricBinding.setProtectionOrder(getProtectionOrder());
-            asymmetricBinding.setRecipientToken(getRecipientToken());
-            asymmetricBinding.setSignatureProtection(isSignatureProtection());
-            asymmetricBinding.setSignedEndorsingSupportingTokens(getSignedEndorsingSupportingTokens());
-            asymmetricBinding.setTokenProtection(isTokenProtection());
+        All wrapper = new All();
+        AsymmetricBinding asymmetricBinding = new AsymmetricBinding(constants);
 
-            asymmetricBinding.setNormalized(true);
-            wrapper.addPolicyComponent(wrapper);
-        }
+        asymmetricBinding.setAlgorithmSuite(algorithmSuite);
+        asymmetricBinding.setEntireHeadersAndBodySignatures(isEntireHeadersAndBodySignatures());
+        asymmetricBinding.setIncludeTimestamp(isIncludeTimestamp());
+        asymmetricBinding.setInitiatorToken(getInitiatorToken());
+        asymmetricBinding.setLayout(getLayout());
+        asymmetricBinding.setProtectionOrder(getProtectionOrder());
+        asymmetricBinding.setRecipientToken(getRecipientToken());
+        asymmetricBinding.setSignatureProtection(isSignatureProtection());
+        asymmetricBinding.setSignedEndorsingSupportingTokens(getSignedEndorsingSupportingTokens());
+        asymmetricBinding.setTokenProtection(isTokenProtection());
+
+        asymmetricBinding.setNormalized(true);
+        wrapper.addPolicyComponent(wrapper);
 
         return policy;
 

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/HttpsToken.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/HttpsToken.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/HttpsToken.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/HttpsToken.java Fri Aug 22 10:43:16 2008
@@ -23,7 +23,6 @@
 import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.cxf.ws.security.policy.SPConstants;
-import org.apache.neethi.PolicyComponent;
 
 /**
  * @author Ruchith Fernando (ruchith.fernando@gmail.com)
@@ -78,10 +77,6 @@
         return constants.getHttpsToken();
     }
 
-    public PolicyComponent normalize() {
-        throw new UnsupportedOperationException();
-    }
-
     public void serialize(XMLStreamWriter writer) throws XMLStreamException {
 
         String localname = getName().getLocalPart();

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/SymmetricBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/SymmetricBinding.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/SymmetricBinding.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/SymmetricBinding.java Fri Aug 22 10:43:16 2008
@@ -18,9 +18,6 @@
  */
 package org.apache.cxf.ws.security.policy.model;
 
-import java.util.Iterator;
-import java.util.List;
-
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
@@ -108,37 +105,30 @@
         }
 
         AlgorithmSuite algorithmSuite = getAlgorithmSuite();
-        List configurations = algorithmSuite.getConfigurations();
 
         Policy policy = new Policy();
         ExactlyOne exactlyOne = new ExactlyOne();
 
-        All wrapper;
-        SymmetricBinding symmetricBinding;
+        All wrapper = new All();
+        SymmetricBinding symmetricBinding = new SymmetricBinding(constants);
 
-        for (Iterator iterator = configurations.iterator(); iterator.hasNext();) {
-            wrapper = new All();
-            symmetricBinding = new SymmetricBinding(constants);
-
-            algorithmSuite = (AlgorithmSuite)iterator.next();
-            symmetricBinding.setAlgorithmSuite(algorithmSuite);
-
-            symmetricBinding.setEncryptionToken(getEncryptionToken());
-            symmetricBinding.setEntireHeadersAndBodySignatures(isEntireHeadersAndBodySignatures());
-            symmetricBinding.setIncludeTimestamp(isIncludeTimestamp());
-            symmetricBinding.setLayout(getLayout());
-            symmetricBinding.setProtectionOrder(getProtectionOrder());
-            symmetricBinding.setProtectionToken(getProtectionToken());
-            symmetricBinding.setSignatureProtection(isSignatureProtection());
-            symmetricBinding.setSignatureToken(getSignatureToken());
-            symmetricBinding.setSignedEndorsingSupportingTokens(getSignedEndorsingSupportingTokens());
-            symmetricBinding.setSignedSupportingToken(getSignedSupportingToken());
-            symmetricBinding.setTokenProtection(isTokenProtection());
-
-            symmetricBinding.setNormalized(true);
-            wrapper.addPolicyComponent(symmetricBinding);
-            exactlyOne.addPolicyComponent(wrapper);
-        }
+        symmetricBinding.setAlgorithmSuite(algorithmSuite);
+
+        symmetricBinding.setEncryptionToken(getEncryptionToken());
+        symmetricBinding.setEntireHeadersAndBodySignatures(isEntireHeadersAndBodySignatures());
+        symmetricBinding.setIncludeTimestamp(isIncludeTimestamp());
+        symmetricBinding.setLayout(getLayout());
+        symmetricBinding.setProtectionOrder(getProtectionOrder());
+        symmetricBinding.setProtectionToken(getProtectionToken());
+        symmetricBinding.setSignatureProtection(isSignatureProtection());
+        symmetricBinding.setSignatureToken(getSignatureToken());
+        symmetricBinding.setSignedEndorsingSupportingTokens(getSignedEndorsingSupportingTokens());
+        symmetricBinding.setSignedSupportingToken(getSignedSupportingToken());
+        symmetricBinding.setTokenProtection(isTokenProtection());
+
+        symmetricBinding.setNormalized(true);
+        wrapper.addPolicyComponent(symmetricBinding);
+        exactlyOne.addPolicyComponent(wrapper);
 
         policy.addPolicyComponent(exactlyOne);
         return policy;

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportBinding.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportBinding.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportBinding.java Fri Aug 22 10:43:16 2008
@@ -18,10 +18,6 @@
  */
 package org.apache.cxf.ws.security.policy.model;
 
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
@@ -36,8 +32,6 @@
 
     private TransportToken transportToken;
 
-    private List<TransportBinding> transportBindings;
-
     public TransportBinding(SPConstants version) {
         super(version);
     }
@@ -56,66 +50,10 @@
         this.transportToken = transportToken;
     }
 
-    public List getConfigurations() {
-        return transportBindings;
-    }
-
-    public TransportBinding getDefaultConfiguration() {
-        if (transportBindings != null) {
-            return (TransportBinding)transportBindings.get(0);
-        }
-        return null;
-    }
-
-    public void addConfiguration(TransportBinding transportBinding) {
-        if (transportBindings == null) {
-            transportBindings = new ArrayList<TransportBinding>();
-        }
-        transportBindings.add(transportBinding);
-    }
-
     public QName getName() {
         return constants.getTransportBinding();
     }
 
-    public PolicyComponent normalize() {
-        if (isNormalized()) {
-            return this;
-        }
-
-        AlgorithmSuite algorithmSuite = getAlgorithmSuite();
-        List configurations = algorithmSuite.getConfigurations();
-
-        if (configurations == null || configurations.size() == 1) {
-            setNormalized(true);
-            return this;
-        }
-
-        Policy policy = new Policy();
-        ExactlyOne exactlyOne = new ExactlyOne();
-
-        All wrapper;
-        TransportBinding transportBinding;
-
-        for (Iterator iterator = configurations.iterator(); iterator.hasNext();) {
-            wrapper = new All();
-            transportBinding = new TransportBinding(constants);
-
-            algorithmSuite = (AlgorithmSuite)iterator.next();
-            transportBinding.setAlgorithmSuite(algorithmSuite);
-            transportBinding.setIncludeTimestamp(isIncludeTimestamp());
-            transportBinding.setLayout(getLayout());
-            transportBinding.setSignedEndorsingSupportingTokens(getSignedEndorsingSupportingTokens());
-            transportBinding.setSignedSupportingToken(getSignedSupportingToken());
-            transportBinding.setTransportToken(getTransportToken());
-
-            wrapper.addPolicyComponent(transportBinding);
-            exactlyOne.addPolicyComponent(wrapper);
-        }
-
-        policy.addPolicyComponent(exactlyOne);
-        return policy;
-    }
 
     public void serialize(XMLStreamWriter writer) throws XMLStreamException {
         String localName = getName().getLocalPart();
@@ -181,5 +119,13 @@
         writer.writeEndElement();
 
     }
-
+    public PolicyComponent normalize() {        
+        Policy p = new Policy();
+        ExactlyOne ea = new ExactlyOne();
+        p.addPolicyComponent(ea);
+        All all = new All();
+        ea.addPolicyComponent(all);
+        all.addPolicyComponent(transportToken);
+        return p.normalize(true);
+    }
 }

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportToken.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportToken.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportToken.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/model/TransportToken.java Fri Aug 22 10:43:16 2008
@@ -45,13 +45,13 @@
     }
 
     public boolean isOptional() {
-        throw new UnsupportedOperationException();
+        return false;
     }
 
     public PolicyComponent normalize() {
-        throw new UnsupportedOperationException();
+        return transportToken;
     }
-
+    
     public short getType() {
         return org.apache.neethi.Constants.TYPE_ASSERTION;
     }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/MtomPolicyTest.java Fri Aug 22 10:43:16 2008
@@ -76,7 +76,7 @@
         
         Node res = invoke(address, "http://schemas.xmlsoap.org/soap/http", "nonmtom.xml");
         
-        assertValid("//faultstring[text()='These policy alternatives can be satisfied: "
+        assertValid("//faultstring[text()='These policy alternatives can not be satisfied: "
                     + "[{http://schemas.xmlsoap.org/ws/2004/09/policy/optimizedmimeserialization}"
                     + "OptimizedMimeSerialization]']", res);
     }

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/policy/HTTPServerPolicyTest.java Fri Aug 22 10:43:16 2008
@@ -119,7 +119,7 @@
         } catch (WebServiceException wse) {
             SoapFault sf = (SoapFault)wse.getCause();
             assertEquals("Server", sf.getFaultCode().getLocalPart());
-            assertEquals("These policy alternatives can be satisfied: "
+            assertEquals("These policy alternatives can not be satisfied: "
                          + "[{http://cxf.apache.org/transports/http/configuration}server]",
                          sf.getMessage());
             // assertEquals("INCOMPATIBLE_HTTPSERVERPOLICY_ASSERTIONS", ex.getCode());

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/SecurityPolicyTest.java Fri Aug 22 10:43:16 2008
@@ -21,9 +21,8 @@
 
 import java.math.BigInteger;
 
-import javax.xml.ws.BindingProvider;
+import javax.jws.WebService;
 import javax.xml.ws.Endpoint;
-import javax.xml.ws.soap.SOAPFaultException;
 
 import org.apache.cxf.policytest.doubleit.DoubleItPortType;
 import org.apache.cxf.policytest.doubleit.DoubleItService;
@@ -35,10 +34,16 @@
 
 
 public class SecurityPolicyTest extends AbstractBusClientServerTestBase  {
-    public static final String POLICY_ADDRESS = "http://localhost:9009/SecPolTest";
+    public static final String POLICY_ADDRESS = "http://localhost:9010/SecPolTest";
+    public static final String POLICY_HTTPS_ADDRESS = "https://localhost:9009/SecPolTest";
+
     @BeforeClass 
     public static void init() throws Exception {
-        createStaticBus().getExtension(PolicyEngine.class).setEnabled(true);
+        
+        createStaticBus(SecurityPolicyTest.class.getResource("https_config.xml").toString())
+            .getExtension(PolicyEngine.class).setEnabled(true);
+        Endpoint.publish(POLICY_HTTPS_ADDRESS,
+                         new DoubleItImplHttps());
         Endpoint.publish(POLICY_ADDRESS,
                          new DoubleItImpl());
     }
@@ -46,16 +51,41 @@
     @Test
     public void testPolicy() throws Exception {
         DoubleItService service = new DoubleItService();
-        DoubleItPortType pt = service.getDoubleItPort();
-        ((BindingProvider)pt).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
-                                                      POLICY_ADDRESS);
+        DoubleItPortType pt = service.getDoubleItPortHttp();
         try {
             pt.doubleIt(BigInteger.valueOf(25));
-        } catch (SOAPFaultException ex) {
+            fail("https policy should have triggered");
+        } catch (Exception ex) {
             assertTrue(ex.getCause().getCause() instanceof PolicyException);
-            //expected - we don't support any of the policies yet
         }
+        
+        pt = service.getDoubleItPortHttps();
+        pt.doubleIt(BigInteger.valueOf(25));
     }
     
     
+    
+    @WebService(targetNamespace = "http://cxf.apache.org/policytest/DoubleIt", 
+                portName = "DoubleItPortHttp",
+                serviceName = "DoubleItService", 
+                endpointInterface = "org.apache.cxf.policytest.doubleit.DoubleItPortType",
+                wsdlLocation = "classpath:/wsdl_systest/DoubleIt.wsdl")
+    public static class DoubleItImpl implements DoubleItPortType {
+        /** {@inheritDoc}*/
+        public BigInteger doubleIt(BigInteger numberToDouble) {
+            return numberToDouble.multiply(new BigInteger("2"));
+        }
+    }
+    
+    @WebService(targetNamespace = "http://cxf.apache.org/policytest/DoubleIt", 
+                portName = "DoubleItPortHttps",
+                serviceName = "DoubleItService", 
+                endpointInterface = "org.apache.cxf.policytest.doubleit.DoubleItPortType",
+                wsdlLocation = "classpath:/wsdl_systest/DoubleIt.wsdl")
+    public static class DoubleItImplHttps implements DoubleItPortType {
+        /** {@inheritDoc}*/
+        public BigInteger doubleIt(BigInteger numberToDouble) {
+            return numberToDouble.multiply(new BigInteger("2"));
+        }
+    }
 }

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/https_config.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/https_config.xml?rev=688133&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/https_config.xml (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/https_config.xml Fri Aug 22 10:43:16 2008
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:http="http://cxf.apache.org/transports/http/configuration"
+       xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
+       xmlns:jaxws="http://cxf.apache.org/jaxws"
+       xmlns:sec="http://cxf.apache.org/configuration/security"
+       xsi:schemaLocation="
+        http://www.springframework.org/schema/beans                 http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+        http://cxf.apache.org/jaxws                                 http://cxf.apache.org/schemas/jaxws.xsd
+        http://cxf.apache.org/transports/http/configuration         http://cxf.apache.org/schemas/configuration/http-conf.xsd
+        http://cxf.apache.org/transports/http-jetty/configuration   http://cxf.apache.org/schemas/configuration/http-jetty.xsd
+        http://cxf.apache.org/configuration/security                http://cxf.apache.org/schemas/configuration/security.xsd
+        ">
+
+    <!-- -->
+    <!-- This Spring config file is designed to represent a minimal -->
+    <!-- configuration for spring-loading a CXF servant, where the -->
+    <!-- servant listens using HTTP/S as the transport protocol. -->
+    <!-- -->
+    <!-- Note that the service endpoint is spring-loaded.  In the -->
+    <!-- scenario in which this config is designed to run, the -->
+    <!-- server application merely instantiates a Bus, and does not -->
+    <!-- publish any services programmatically -->
+    <!-- -->
+
+
+    <!-- -->
+    <!-- TLS Port configuration parameters for port 9009 -->
+    <!-- -->
+    <httpj:engine-factory id="port-9009-tls-config">
+        <httpj:engine port="9009">
+            <httpj:tlsServerParameters>
+               <sec:keyManagers keyPassword="password">
+                   <sec:keyStore type="JKS" password="password" 
+                        file="src/test/java/org/apache/cxf/systest/http/resources/Bethal.jks"/>
+                        </sec:keyManagers>
+                        <sec:trustManagers>
+                        <sec:keyStore type="JKS" password="password"
+                       file="src/test/java/org/apache/cxf/systest/http/resources/Truststore.jks"/>
+                        </sec:trustManagers>
+            </httpj:tlsServerParameters>
+        </httpj:engine>
+    </httpj:engine-factory>
+
+    <!-- -->
+    <!-- HTTP/S configuration for clients -->
+    <!-- -->
+    <http:conduit name="{http://cxf.apache.org/policytest/DoubleIt}DoubleItPortHttps.http-conduit">
+        <http:tlsClientParameters disableCNCheck="true">
+            <sec:keyManagers keyPassword="password">
+                   <sec:keyStore type="JKS" password="password" 
+                        file="src/test/java/org/apache/cxf/systest/http/resources/Morpit.jks"/>
+                   </sec:keyManagers>
+                <sec:trustManagers>
+                   <sec:keyStore type="JKS" password="password"
+                       file="src/test/java/org/apache/cxf/systest/http/resources/Truststore.jks"/>
+                </sec:trustManagers>
+        </http:tlsClientParameters>
+    </http:conduit>
+
+</beans>
\ No newline at end of file

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/https_config.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/https_config.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/security/https_config.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: cxf/trunk/systests/src/test/resources/wsdl_systest/DoubleIt.wsdl
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/resources/wsdl_systest/DoubleIt.wsdl?rev=688133&r1=688132&r2=688133&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/resources/wsdl_systest/DoubleIt.wsdl (original)
+++ cxf/trunk/systests/src/test/resources/wsdl_systest/DoubleIt.wsdl Fri Aug 22 10:43:16 2008
@@ -69,9 +69,13 @@
       </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="DoubleItService">
-      <wsdl:port name="DoubleItPort" binding="tns:DoubleItBinding">
+      <wsdl:port name="DoubleItPortHttps" binding="tns:DoubleItBinding">
          <soap:address 
-            location="http://localhost:9009/doubleit/services/doubleit"/>
+            location="https://localhost:9009/SecPolTest"/>
+      </wsdl:port>
+      <wsdl:port name="DoubleItPortHttp" binding="tns:DoubleItBinding">
+         <soap:address 
+            location="http://localhost:9010/SecPolTest"/>
       </wsdl:port>
    </wsdl:service>
    
@@ -99,7 +103,7 @@
                   </sp:AlgorithmSuite>
                </wsp:Policy>
             </sp:TransportBinding>
-            <sp:Wss10>
+            <!-- sp:Wss10>
                <wsp:Policy>
                   <sp:MustSupportRefKeyIdentifier/>
                </wsp:Policy>
@@ -112,7 +116,7 @@
                      </wsp:Policy>
                   </sp:UsernameToken>
                </wsp:Policy>
-            </sp:SignedSupportingTokens>
+            </sp:SignedSupportingTokens -->
          </wsp:All>
       </wsp:ExactlyOne>
    </wsp:Policy>