You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by eg...@apache.org on 2008/11/06 00:05:12 UTC
svn commit: r711736 - in /cxf/branches/2.1.x-fixes:
rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/
systests/src/test/java/org/apache/cxf/systest/ws/security/
Author: eglynn
Date: Wed Nov 5 15:05:11 2008
New Revision: 711736
URL: http://svn.apache.org/viewvc?rev=711736&view=rev
Log:
Fix to allow the JAX-WS SoapHandlerInterceptor peacefully co-exist with an explicitly configured SAAJOutInterceptor - previously installing a JAX-WS SoapHandler in a (WS-)secure CXF application caused outgoing SOAP bodies to be truncated.
Added:
cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/security/TestOutHandler.java (with props)
Modified:
cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java
Modified: cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java?rev=711736&r1=711735&r2=711736&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java (original)
+++ cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/handler/soap/SOAPHandlerInterceptor.java Wed Nov 5 15:05:11 2008
@@ -24,6 +24,7 @@
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.ListIterator;
import java.util.Set;
import javax.xml.namespace.QName;
@@ -52,6 +53,7 @@
import org.apache.cxf.endpoint.Endpoint;
import org.apache.cxf.helpers.CastUtils;
import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.Interceptor;
import org.apache.cxf.interceptor.InterceptorChain;
import org.apache.cxf.interceptor.OutgoingChainInterceptor;
import org.apache.cxf.jaxws.handler.AbstractProtocolHandlerInterceptor;
@@ -109,10 +111,12 @@
}
if (getInvoker(message).isOutbound()) {
+ if (!chainAlreadyContainsSAAJ(message)) {
- SAAJ_OUT.handleMessage(message);
+ SAAJ_OUT.handleMessage(message);
- message.getInterceptorChain().add(ending);
+ message.getInterceptorChain().add(ending);
+ }
} else {
boolean isFault = handleMessageInternal(message);
SOAPMessage msg = message.getContent(SOAPMessage.class);
@@ -281,7 +285,8 @@
}
public void handleFault(SoapMessage message) {
- if (getInvoker(message).isOutbound()) {
+ if (getInvoker(message).isOutbound()
+ && !chainAlreadyContainsSAAJ(message)) {
SAAJ_OUT.handleFault(message);
}
}
@@ -309,4 +314,14 @@
return null;
}
+ private static boolean chainAlreadyContainsSAAJ(SoapMessage message) {
+ ListIterator<Interceptor<? extends Message>> listIterator =
+ message.getInterceptorChain().getIterator();
+ while (listIterator.hasNext()) {
+ if (listIterator.next() instanceof SAAJOutInterceptor) {
+ return true;
+ }
+ }
+ return false;
+ }
}
Added: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/security/TestOutHandler.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/security/TestOutHandler.java?rev=711736&view=auto
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/security/TestOutHandler.java (added)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/security/TestOutHandler.java Wed Nov 5 15:05:11 2008
@@ -0,0 +1,45 @@
+/**
+ * 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.systest.ws.security;
+
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+public class TestOutHandler implements SOAPHandler<SOAPMessageContext> {
+ public Set<QName> getHeaders() {
+ return null;
+ }
+
+ public void close(MessageContext mc) {
+ }
+
+ public boolean handleFault(SOAPMessageContext smc) {
+ return true;
+ }
+
+ public boolean handleMessage(SOAPMessageContext smc) {
+ return true;
+ }
+
+}
Propchange: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/security/TestOutHandler.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/security/TestOutHandler.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java?rev=711736&r1=711735&r2=711736&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java (original)
+++ cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java Wed Nov 5 15:05:11 2008
@@ -19,6 +19,9 @@
package org.apache.cxf.systest.ws.security;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.xml.namespace.QName;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
@@ -26,8 +29,11 @@
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
+import javax.xml.ws.Binding;
+import javax.xml.ws.BindingProvider;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
+import javax.xml.ws.handler.Handler;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.http.HTTPBinding;
@@ -99,6 +105,18 @@
TIMESTAMP_SIGN_ENCRYPT_PORT_QNAME,
Greeter.class
);
+
+ // Add a No-Op JAX-WS SoapHandler to the dispatch chain to
+ // verify that the SoapHandlerInterceptor can peacefully co-exist
+ // with the explicitly configured SAAJOutInterceptor
+ //
+ List<Handler> handlerChain = new ArrayList<Handler>();
+ Binding binding = ((BindingProvider)greeter).getBinding();
+ Handler handler;
+ handler = new TestOutHandler();
+ handlerChain.add(handler);
+ binding.setHandlerChain(handlerChain);
+
greeter.sayHi();
}