You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2014/02/13 17:16:05 UTC

svn commit: r1567968 - /cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JStaxInInterceptor.java

Author: coheigea
Date: Thu Feb 13 16:16:05 2014
New Revision: 1567968

URL: http://svn.apache.org/r1567968
Log:
Add support for streaming WS-Security with the Dispatch API

Modified:
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JStaxInInterceptor.java

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JStaxInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JStaxInInterceptor.java?rev=1567968&r1=1567967&r2=1567968&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JStaxInInterceptor.java (original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JStaxInInterceptor.java Thu Feb 13 16:16:05 2014
@@ -482,7 +482,7 @@ public class PolicyBasedWSS4JStaxInInter
     private PolicyEnforcer createPolicyEnforcer(
         EndpointInfo endpointInfo, SoapMessage msg
     ) throws WSSPolicyException {
-
+        EffectivePolicy dispatchPolicy = null;
         List<OperationPolicy> operationPolicies = new ArrayList<OperationPolicy>();
         Collection<BindingOperationInfo> bindingOperationInfos = endpointInfo.getBinding().getOperations();
         for (Iterator<BindingOperationInfo> bindingOperationInfoIterator =
@@ -502,13 +502,25 @@ public class PolicyBasedWSS4JStaxInInter
             if (MessageUtils.isRequestor(msg)) {
                 policy = 
                     (EffectivePolicy)bindingOperationInfo.getProperty("policy-engine-info-client-response");
-                MessageInfo messageInfo = bindingOperationInfo.getOutput().getMessageInfo();
-                localName = messageInfo.getName().getLocalPart();
-                if (!messageInfo.getMessageParts().isEmpty()) {
-                    localName = messageInfo.getMessagePart(0).getConcreteName().getLocalPart();
+                // Save the Dispatch Policy as it may be used on another BindingOperationInfo
+                if (policy != null 
+                    && "http://cxf.apache.org/jaxws/dispatch".equals(operationName.getNamespaceURI())) {
+                    dispatchPolicy = policy;
+                }
+                if (bindingOperationInfo.getOutput() != null) {
+                    MessageInfo messageInfo = bindingOperationInfo.getOutput().getMessageInfo();
+                    localName = messageInfo.getName().getLocalPart();
+                    if (!messageInfo.getMessageParts().isEmpty()
+                        && messageInfo.getMessagePart(0).getConcreteName() != null) {
+                        localName = messageInfo.getMessagePart(0).getConcreteName().getLocalPart();
+                    }
                 }
             }
             SoapOperationInfo soapOperationInfo = bindingOperationInfo.getExtensor(SoapOperationInfo.class);
+            if (soapOperationInfo != null && policy == null && dispatchPolicy != null) {
+                policy = dispatchPolicy;
+            }
+            
             if (policy != null && soapOperationInfo != null) {
                 String soapNS;
                 BindingInfo bindingInfo = bindingOperationInfo.getBinding();