cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1079964 - in /cxf/trunk: api/src/main/java/org/apache/cxf/phase/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ rt/bindings/soap/src/main/java/org/apache/...
Date Wed, 09 Mar 2011 19:52:26 GMT
Author: dkulp
Date: Wed Mar  9 19:52:25 2011
New Revision: 1079964

URL: http://svn.apache.org/viewvc?rev=1079964&view=rev
Log:
[CXF-3366] Allow an interceptor before the ReadHeadersInterceptor to
specify the Document to read the headers into
Update SAAJIn to use above to avoid having to copy the headers and such
into a new Document
Allow an Interceptor to specify additional interceptors to add when it
is added.  A "requires this as well" type thing.

Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/phase/AbstractPhaseInterceptor.java
    cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptor.java
    cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapFault.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
    cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JOutInterceptor.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
    cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JOutInterceptor.java

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=1079964&r1=1079963&r2=1079964&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 Wed Mar
 9 19:52:25 2011
@@ -168,6 +168,10 @@ public abstract class AbstractPhaseInter
     public final Set<String> getBefore() {
         return before;
     }
+    
+    public Collection<PhaseInterceptor<? extends Message>> getAdditionalInterceptors()
{
+        return null;
+    }
 
     public final String getId() {
         return id;

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptor.java?rev=1079964&r1=1079963&r2=1079964&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptor.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptor.java Wed Mar  9 19:52:25
2011
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.phase;
 
+import java.util.Collection;
 import java.util.Set;
 
 import org.apache.cxf.interceptor.Interceptor;
@@ -64,5 +65,12 @@ public interface PhaseInterceptor<T exte
      * @return the phase
      */
     String getPhase();
+    
+    /**
+     * Returns a collection of Interceptors that should be added to the chain 
+     * whenever this interceptor is added.   May return null.
+     * @return the collection of interceptors
+     */
+    Collection<PhaseInterceptor<? extends Message>> getAdditionalInterceptors();
 
 }

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java?rev=1079964&r1=1079963&r2=1079964&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/phase/PhaseInterceptorChain.java Wed Mar  9
19:52:25 2011
@@ -191,7 +191,8 @@ public class PhaseInterceptorChain imple
     }
     
     public void add(Interceptor i, boolean force) {
-        PhaseInterceptor pi = (PhaseInterceptor)i;
+        @SuppressWarnings("unchecked")
+        PhaseInterceptor<? extends Message> pi = (PhaseInterceptor)i;
 
         String phaseName = pi.getPhase();        
         Integer phase = nameMap.get(phaseName);
@@ -207,6 +208,13 @@ public class PhaseInterceptorChain imple
 
             insertInterceptor(phase, pi, force);
         }
+        Collection<PhaseInterceptor<? extends Message>> extras 
+            = pi.getAdditionalInterceptors();
+        if (extras != null) {
+            for (PhaseInterceptor<? extends Message> p : extras) {
+                add(p, force);
+            }
+        }
     }
 
 
@@ -481,7 +489,7 @@ public class PhaseInterceptorChain imple
         }
     }
     
-    private void insertInterceptor(int phase, PhaseInterceptor interc, boolean force) {
+    private void insertInterceptor(int phase, PhaseInterceptor<? extends Message> interc,
boolean force) {
         InterceptorHolder ih = new InterceptorHolder(interc, phase);
         if (heads[phase] == null) {
             // no interceptors yet in this phase
@@ -523,10 +531,10 @@ public class PhaseInterceptorChain imple
         } else { // this phase already has interceptors attached
         
             // list of interceptors that the new interceptor should precede
-            Set beforeList = interc.getBefore();
+            Set<String> beforeList = interc.getBefore();
 
             // list of interceptors that the new interceptor should be after
-            Set afterList = interc.getAfter();
+            Set<String> afterList = interc.getAfter();
             
             // firstBefore will hold the first interceptor of a given phase
             // that the interceptor to be added must precede
@@ -548,7 +556,8 @@ public class PhaseInterceptorChain imple
                             || cmp.getAfter().contains(id))) {
                         firstBefore = ih2;
                     } 
-                    if (cmpId != null && afterList.contains(cmpId)) {
+                    if (cmp.getBefore().contains(id) 
+                        || (cmpId != null && afterList.contains(cmpId))) {
                         lastAfter = ih2;
                     }
                     if (!force && cmpId.equals(id)) {
@@ -577,6 +586,16 @@ public class PhaseInterceptorChain imple
             }
             hasAfters[phase] |= !afterList.isEmpty();
             
+            if (firstBefore == null
+                && lastAfter == null
+                && !beforeList.isEmpty()
+                && afterList.isEmpty()) {
+                //if this interceptor has stuff it MUST be before,
+                //but nothing it must be after, just
+                //stick it at the beginning
+                firstBefore = heads[phase];
+            }
+            
             if (firstBefore == null) {
                 //just add new interceptor at the end
                 ih.prev = tails[phase];

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapFault.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapFault.java?rev=1079964&r1=1079963&r2=1079964&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapFault.java (original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/SoapFault.java Wed
Mar  9 19:52:25 2011
@@ -62,6 +62,15 @@ public class SoapFault extends Fault {
     public SoapFault(String message, QName faultCode) {
         super(new Message(message, (ResourceBundle)null), faultCode);
     }
+    public SoapFault(String message, ResourceBundle bundle, QName faultCode) {
+        super(new Message(message, bundle), faultCode);
+    }
+    public SoapFault(String message, ResourceBundle bundle, Throwable t, QName faultCode)
{
+        super(new Message(message, bundle), t, faultCode);
+    }
+    public SoapFault(String message, ResourceBundle bundle, QName faultCode, Object ... params)
{
+        super(new Message(message, bundle, params), faultCode);
+    }
 
     public SoapFault(String message, Throwable t, QName faultCode) {
         super(new Message(message, (ResourceBundle)null), t, faultCode);

Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java?rev=1079964&r1=1079963&r2=1079964&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ReadHeadersInterceptor.java
Wed Mar  9 19:52:25 2011
@@ -103,6 +103,22 @@ public class ReadHeadersInterceptor exte
         bus = b;
     }
 
+    public static SoapVersion readVersion(XMLStreamReader xmlReader, SoapMessage message)
{
+        String ns = xmlReader.getNamespaceURI();
+        if (ns == null || "".equals(ns)) {
+            throw new SoapFault(new Message("NO_NAMESPACE", LOG, xmlReader.getLocalName()),
+                                Soap11.getInstance().getVersionMismatch());
+        }
+        
+        SoapVersion soapVersion = SoapVersionFactory.getInstance().getSoapVersion(ns);
+        if (soapVersion == null) {
+            throw new SoapFault(new Message("INVALID_VERSION", LOG, ns, xmlReader.getLocalName()),
+                                    Soap11.getInstance().getVersionMismatch());
+        }
+        message.setVersion(soapVersion);
+        return soapVersion;
+    }
+    
     public void handleMessage(SoapMessage message) {
         if (isGET(message)) {
             LOG.fine("ReadHeadersInterceptor skipped in HTTP GET method");
@@ -119,31 +135,30 @@ public class ReadHeadersInterceptor exte
         }
 
         try {
-            if (xmlReader.nextTag() == XMLStreamConstants.START_ELEMENT) {
-                String ns = xmlReader.getNamespaceURI();
-                if (ns == null || "".equals(ns)) {
-                    throw new SoapFault(new Message("NO_NAMESPACE", LOG, xmlReader.getLocalName()),
-                                        Soap11.getInstance().getVersionMismatch());
-                }
+            if (xmlReader.getEventType() == XMLStreamConstants.START_ELEMENT 
+                || xmlReader.nextTag() == XMLStreamConstants.START_ELEMENT) {
                 
-                SoapVersion soapVersion = SoapVersionFactory.getInstance().getSoapVersion(ns);
-                if (soapVersion == null) {
-                    throw new SoapFault(new Message("INVALID_VERSION", LOG, ns, xmlReader.getLocalName()),
-                                            Soap11.getInstance().getVersionMismatch());
-                }
+                SoapVersion soapVersion = readVersion(xmlReader, message);
                 if (soapVersion == Soap12.getInstance()
                     && version == Soap11.getInstance()) {
-                    throw new SoapFault(new Message("INVALID_11_VERSION", LOG, ns, xmlReader.getLocalName()),
+                    throw new SoapFault(new Message("INVALID_11_VERSION", LOG, 
+                                                    Soap12.getInstance().getNamespace(),
+                                                    xmlReader.getLocalName()),
                                         Soap11.getInstance().getVersionMismatch());     
              
                 }
-                message.setVersion(soapVersion);
 
                 XMLStreamReader filteredReader = new PartialXMLStreamReader(xmlReader, message.getVersion()
                     .getBody());
 
-                Document doc = StaxUtils.read(filteredReader);
-
-                message.setContent(Node.class, doc);
+                Node nd = message.getContent(Node.class);
+                Document doc = null;
+                if (nd instanceof Document && ((Document)nd).getDocumentElement()
== null) {
+                    doc = (Document)nd;
+                    StaxUtils.readDocElements(doc, doc, filteredReader, false, false);
+                } else {
+                    doc = StaxUtils.read(filteredReader);
+                    message.setContent(Node.class, doc);
+                }
 
                 // Find header
                 // TODO - we could stream read the "known" headers and just DOM read the


Modified: cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java?rev=1079964&r1=1079963&r2=1079964&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
(original)
+++ cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
Wed Mar  9 19:52:25 2011
@@ -21,8 +21,10 @@ package org.apache.cxf.binding.soap.saaj
 
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.List;
 import java.util.ResourceBundle;
 
 import javax.xml.namespace.QName;
@@ -35,6 +37,7 @@ import javax.xml.soap.SOAPFault;
 import javax.xml.soap.SOAPHeader;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.soap.SOAPPart;
+import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.transform.dom.DOMSource;
@@ -50,6 +53,7 @@ import org.apache.cxf.binding.soap.SoapF
 import org.apache.cxf.binding.soap.SoapHeader;
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor;
+import org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor;
 import org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor;
 import org.apache.cxf.binding.soap.interceptor.Soap12FaultInInterceptor;
 import org.apache.cxf.common.i18n.BundleUtils;
@@ -61,7 +65,9 @@ import org.apache.cxf.headers.HeaderProc
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Attachment;
+import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseInterceptor;
 import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.staxutils.W3CDOMStreamWriter;
 
@@ -71,50 +77,117 @@ import org.apache.cxf.staxutils.W3CDOMSt
  */
 @NoJSR250Annotations
 public class SAAJInInterceptor extends AbstractSoapInterceptor {
-    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(SAAJInInterceptor.class);
-    
-    private MessageFactory factory11;
-    private MessageFactory factory12;
-    
+    public static final SAAJInInterceptor INSTANCE = new SAAJInInterceptor();
     
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(SAAJInInterceptor.class);
+    private static final String BODY_FILLED_IN = SAAJInInterceptor.class.getName() + ".BODY_DONE";
+
+    private SAAJPreInInterceptor preInterceptor = SAAJPreInInterceptor.INSTANCE;
+    private List<PhaseInterceptor<? extends Message>> extras 
+        = new ArrayList<PhaseInterceptor<? extends Message>>(1);
     public SAAJInInterceptor() {
         super(Phase.PRE_PROTOCOL);
+        extras.add(preInterceptor);
     }
     public SAAJInInterceptor(String phase) {
         super(phase);
     }
     
-    private synchronized MessageFactory getFactory(SoapMessage message) throws SOAPException
{
-        if (message.getVersion() instanceof Soap11) {
-            if (factory11 == null) { 
-                factory11 = MessageFactory.newInstance();
-            } 
-            return factory11;
+    public Collection<PhaseInterceptor<? extends Message>> getAdditionalInterceptors()
{
+        return extras;
+    }
+
+    /**
+     * This class sets up the Document in the Message so that the ReadHeadersInterceptor
+     * can read directly into the SAAJ document instead of creating a new DOM
+     * that we would need to copy into the SAAJ later.
+     */
+    public static class SAAJPreInInterceptor extends AbstractSoapInterceptor {
+        public static final SAAJPreInInterceptor INSTANCE = new SAAJPreInInterceptor();
+        
+        private MessageFactory factory11;
+        private MessageFactory factory12;
+        
+        public SAAJPreInInterceptor() {
+            super(Phase.READ);
+            addBefore(ReadHeadersInterceptor.class.getName());
         }
-        if (factory12 == null) {
-            factory12 = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+        public void handleMessage(SoapMessage message) throws Fault {
+            if (isGET(message)) {
+                return;
+            }
+            if (isRequestor(message) && message.getExchange().getInMessage() == null)
{
+                //already processed
+                return;
+            }
+            try {
+                XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
+                if (xmlReader == null) {
+                    return;
+                }
+                if (xmlReader.nextTag() == XMLStreamConstants.START_ELEMENT) {
+                    ReadHeadersInterceptor.readVersion(xmlReader, message);
+                }
+                MessageFactory factory = getFactory(message);
+                SOAPMessage soapMessage = factory.createMessage();
+                message.setContent(SOAPMessage.class, soapMessage);
+                
+                SOAPPart part = soapMessage.getSOAPPart();
+                message.setContent(Document.class, part);
+                message.put(BODY_FILLED_IN, Boolean.FALSE);
+
+            } catch (RuntimeException ex) {
+                throw ex;
+            } catch (Exception e) {
+                throw new SoapFault("XML_STREAM_EXC", BUNDLE, e, message.getVersion().getSender());
+            }
+        }
+        public synchronized MessageFactory getFactory(SoapMessage message) throws SOAPException
{
+            if (message.getVersion() instanceof Soap11) {
+                if (factory11 == null) { 
+                    factory11 = MessageFactory.newInstance();
+                } 
+                return factory11;
+            }
+            if (factory12 == null) {
+                factory12 = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
+            }
+            return factory12;
         }
-        return factory12;
     }
     
+    
+    
     public void handleMessage(SoapMessage message) throws Fault {
         if (isGET(message)) {
             return;
         }
+        Boolean bodySet = (Boolean)message.get(BODY_FILLED_IN);
+        if (bodySet != null && bodySet == Boolean.TRUE) {
+            return;
+        }
+        message.put(BODY_FILLED_IN, Boolean.TRUE);
 
         try {
-            MessageFactory factory = getFactory(message);
-            SOAPMessage soapMessage = factory.createMessage();
-            message.setContent(SOAPMessage.class, soapMessage);
-            
+            SOAPMessage soapMessage = message.getContent(SOAPMessage.class);
+            if (soapMessage == null) {
+                MessageFactory factory = preInterceptor.getFactory(message);
+                soapMessage = factory.createMessage();
+                message.setContent(SOAPMessage.class, soapMessage);
+            }
+            XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
+            if (xmlReader == null) {
+                return;
+            }
             SOAPPart part = soapMessage.getSOAPPart();
-            
             Document node = (Document) message.getContent(Node.class);
-            if (node == null) {
-                // replicate 2.1 behavior.
-                part.setContent(new DOMSource(null));
-            } else {
-                StaxUtils.copy(node, new W3CDOMStreamWriter(part));
+            if (node != part) {
+                if (node == null) {
+                    // replicate 2.1 behavior.
+                    part.setContent(new DOMSource(null));
+                } else {
+                    StaxUtils.copy(node, new W3CDOMStreamWriter(part));
+                }
             }
             message.setContent(Node.class, soapMessage.getSOAPPart());
 
@@ -148,7 +221,6 @@ public class SAAJInInterceptor extends A
                 soapMessage.getSOAPPart().getEnvelope().addHeader();
             }
             
-            XMLStreamReader xmlReader = message.getContent(XMLStreamReader.class);
 
             if (hasFault(message, xmlReader)) {
                 SOAPFault soapFault = 

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java?rev=1079964&r1=1079963&r2=1079964&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/AbstractWSS4JInterceptor.java
Wed Mar  9 19:52:25 2011
@@ -21,6 +21,7 @@ package org.apache.cxf.ws.security.wss4j
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URL;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -73,6 +74,9 @@ public abstract class AbstractWSS4JInter
 
     public void postHandleMessage(SoapMessage message) throws Fault {
     }
+    public Collection<PhaseInterceptor<? extends Message>> getAdditionalInterceptors()
{
+        return null;
+    }
 
     public String getPhase() {
         return phase;

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JOutInterceptor.java?rev=1079964&r1=1079963&r2=1079964&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JOutInterceptor.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/PolicyBasedWSS4JOutInterceptor.java
Wed Mar  9 19:52:25 2011
@@ -199,5 +199,10 @@ public class PolicyBasedWSS4JOutIntercep
         public void handleFault(SoapMessage message) {
             //nothing
         }
+
+        public Collection<PhaseInterceptor<? extends org.apache.cxf.message.Message>>

+        getAdditionalInterceptors() {
+            return null;
+        }
     }
 }

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java?rev=1079964&r1=1079963&r2=1079964&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JInInterceptor.java
Wed Mar  9 19:52:25 2011
@@ -21,6 +21,7 @@ package org.apache.cxf.ws.security.wss4j
 import java.io.IOException;
 import java.security.Principal;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -53,6 +54,7 @@ import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.phase.Phase;
+import org.apache.cxf.phase.PhaseInterceptor;
 import org.apache.cxf.security.SecurityContext;
 import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.ws.security.SecurityConstants;
@@ -93,7 +95,6 @@ public class WSS4JInInterceptor extends 
                                                                  null,
                                                                  WSS4JInInterceptor.class.getName()
                                                                      + "-Time");
-    private SAAJInInterceptor saajIn = new SAAJInInterceptor();
     private boolean ignoreActions;
 
     /**
@@ -130,16 +131,22 @@ public class WSS4JInInterceptor extends 
         }
     }
 
+    @Override
+    public Collection<PhaseInterceptor<? extends org.apache.cxf.message.Message>>
+    getAdditionalInterceptors() {
+        List<PhaseInterceptor<? extends org.apache.cxf.message.Message>> extras

+            = new ArrayList<PhaseInterceptor<? extends org.apache.cxf.message.Message>>(1);
+        extras.add(SAAJInInterceptor.SAAJPreInInterceptor.INSTANCE);
+        return extras;
+    }
+
+    
     public void setIgnoreActions(boolean i) {
         ignoreActions = i;
     }
     private SOAPMessage getSOAPMessage(SoapMessage msg) {
-        SOAPMessage doc = msg.getContent(SOAPMessage.class);
-        if (doc == null) {
-            saajIn.handleMessage(msg);
-            doc = msg.getContent(SOAPMessage.class);
-        }
-        return doc;
+        SAAJInInterceptor.INSTANCE.handleMessage(msg);
+        return msg.getContent(SOAPMessage.class);
     }
     
     @Override

Modified: cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JOutInterceptor.java?rev=1079964&r1=1079963&r2=1079964&view=diff
==============================================================================
--- cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JOutInterceptor.java
(original)
+++ cxf/trunk/rt/ws/security/src/main/java/org/apache/cxf/ws/security/wss4j/WSS4JOutInterceptor.java
Wed Mar  9 19:52:25 2011
@@ -18,6 +18,7 @@
  */
 package org.apache.cxf.ws.security.wss4j;
 
+import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
@@ -137,7 +138,7 @@ public class WSS4JOutInterceptor extends
         public WSS4JOutInterceptorInternal() {
             super();
         }
-
+        
         public void handleMessage(SoapMessage mc) throws Fault {
             
             boolean doDebug = LOG.isLoggable(Level.FINE);
@@ -340,5 +341,10 @@ public class WSS4JOutInterceptor extends
                 }
             }
         }
+
+        public Collection<PhaseInterceptor<? extends org.apache.cxf.message.Message>>

+        getAdditionalInterceptors() {
+            return null;
+        }
     }
 }



Mime
View raw message