cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r830533 - in /cxf/trunk: rt/core/src/main/java/org/apache/cxf/interceptor/ rt/management/src/main/java/org/apache/cxf/management/interceptor/ rt/management/src/test/java/org/apache/cxf/management/interceptor/ rt/ws/addr/src/main/java/org/ap...
Date Wed, 28 Oct 2009 13:33:41 GMT
Author: dkulp
Date: Wed Oct 28 13:33:40 2009
New Revision: 830533

URL: http://svn.apache.org/viewvc?rev=830533&view=rev
Log:
[CXF-2505, CXF-2502, CXF-2489] Bunch of fixes for WS-A + WS-Sec + Mgmt

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
    cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java
    cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java
    cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
    cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
    cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
    cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
    cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java
    cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/server.xml

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java?rev=830533&r1=830532&r2=830533&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/LoggingInInterceptor.java Wed
Oct 28 13:33:40 2009
@@ -60,11 +60,15 @@
     }
 
     protected void logging(Message message) throws Fault {
+        if (message.containsKey(LoggingMessage.ID_KEY)) {
+            return;
+        }
         String id = (String)message.getExchange().get(LoggingMessage.ID_KEY);
         if (id == null) {
             id = LoggingMessage.nextId();
             message.getExchange().put(LoggingMessage.ID_KEY, id);
         }
+        message.put(LoggingMessage.ID_KEY, id);
         final LoggingMessage buffer 
             = new LoggingMessage("Inbound Message\n----------------------------", id);
 

Modified: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java?rev=830533&r1=830532&r2=830533&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java
(original)
+++ cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/AbstractMessageResponseTimeInterceptor.java
Wed Oct 28 13:33:40 2009
@@ -108,7 +108,7 @@
             
             String serviceName = "\"" + service.getName() + "\"";            
             String portName = "\"" + endpoint.getEndpointInfo().getName().getLocalPart()
+ "\"";
-            String operationName = "\"" + opInfo.getName().getLocalPart() + "\"";
+            String operationName = opInfo == null ? null : "\"" + opInfo.getName().getLocalPart()
+ "\"";
             
             StringBuffer buffer = new StringBuffer();
             buffer.append(ManagementConstants.DEFAULT_DOMAIN_NAME + ":");
@@ -123,14 +123,16 @@
             buffer.append(ManagementConstants.PORT_NAME_PROP + "=" + portName);
             String serviceCounterName = buffer.toString();
             
-            buffer.append("," + ManagementConstants.OPERATION_NAME_PROP + "=" + operationName);
-            String operationCounterName = buffer.toString();
-            try {               
+            try {           
                 ObjectName serviceCounter = 
                     new ObjectName(serviceCounterName);                
                 cr.increaseCounter(serviceCounter, mhtr);
-                ObjectName operationCounter = new ObjectName(operationCounterName);
-                cr.increaseCounter(operationCounter, mhtr);                
+                if (operationName != null) {
+                    buffer.append("," + ManagementConstants.OPERATION_NAME_PROP + "=" + operationName);
+                    String operationCounterName = buffer.toString();
+                    ObjectName operationCounter = new ObjectName(operationCounterName);
+                    cr.increaseCounter(operationCounter, mhtr);                
+                }
             } catch (Exception exception) {
                 LOG.log(Level.WARNING, "CREATE_COUNTER_OBJECTNAME_FAILED", exception);
             }

Modified: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java?rev=830533&r1=830532&r2=830533&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java
(original)
+++ cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageInInterceptor.java
Wed Oct 28 13:33:40 2009
@@ -46,7 +46,11 @@
     @Override
     public void handleFault(Message message) {
         Exchange ex = message.getExchange();
-        ex.put(FaultMode.class, message.get(FaultMode.class));
+        FaultMode mode = message.get(FaultMode.class);
+        if (mode == null) {
+            mode = FaultMode.RUNTIME_FAULT;
+        }
+        ex.put(FaultMode.class, mode);
         endHandlingMessage(ex);
     }
 }

Modified: cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java?rev=830533&r1=830532&r2=830533&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
(original)
+++ cxf/trunk/rt/management/src/main/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptor.java
Wed Oct 28 13:33:40 2009
@@ -34,6 +34,9 @@
     
     public void handleMessage(Message message) throws Fault {
         Exchange ex = message.getExchange();
+        if (Boolean.TRUE.equals(message.get(Message.PARTIAL_RESPONSE_MESSAGE))) {
+            return;
+        }
         if (isClient(message)) {
             if (ex.isOneWay()) {
                 message.getInterceptorChain().add(ending);

Modified: cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java?rev=830533&r1=830532&r2=830533&view=diff
==============================================================================
--- cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
(original)
+++ cxf/trunk/rt/management/src/test/java/org/apache/cxf/management/interceptor/ResponseTimeMessageOutInterceptorTest.java
Wed Oct 28 13:33:40 2009
@@ -34,6 +34,7 @@
         // need to increase the counter and is not a client
         setupCounterRepository(true, false);
         setupExchangeForMessage();
+        EasyMock.expect(message.get(Message.PARTIAL_RESPONSE_MESSAGE)).andReturn(Boolean.FALSE).anyTimes();
         EasyMock.expect(message.getExchange()).andReturn(exchange);
         EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.FALSE).anyTimes();
         EasyMock.expect(exchange.getOutMessage()).andReturn(message);
@@ -116,6 +117,7 @@
         setupCounterRepository(true, true);
         setupExchangeForMessage();
         EasyMock.expect(message.getExchange()).andReturn(exchange).anyTimes();
+        EasyMock.expect(message.get(Message.PARTIAL_RESPONSE_MESSAGE)).andReturn(Boolean.FALSE).anyTimes();
         EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();

         EasyMock.expect(exchange.getOutMessage()).andReturn(message);
         EasyMock.expect(exchange.get(FaultMode.class)).andReturn(null);
@@ -146,6 +148,7 @@
     
     @Test
     public void testClientMessageOut() {
+        EasyMock.expect(message.get(Message.PARTIAL_RESPONSE_MESSAGE)).andReturn(Boolean.FALSE).anyTimes();
         EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE);
         EasyMock.expect(message.getExchange()).andReturn(exchange);
         EasyMock.expect(exchange.isOneWay()).andReturn(false);

Modified: cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java?rev=830533&r1=830532&r2=830533&view=diff
==============================================================================
--- cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java (original)
+++ cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/MAPAggregator.java Wed
Oct 28 13:33:40 2009
@@ -165,6 +165,7 @@
      * @param message the current message
      */
     public void  handleFault(Message message) {
+        message.put(MAPAggregator.class.getName(), this);
     }
 
     /**
@@ -342,8 +343,8 @@
                 // request/response MAPs must be aggregated
                 aggregate(message, isFault);
             }
-        } else if (!ContextUtils.isRequestor(message)) {
-            // responder validates incoming MAPs
+        } else if (!ContextUtils.isRequestor(message)) {            
+            //responder validates incoming MAPs
             AddressingPropertiesImpl maps = getMAPs(message, false, false);
             boolean isOneway = message.getExchange().isOneWay();
             if (null == maps && !addressingRequired) {

Modified: cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java?rev=830533&r1=830532&r2=830533&view=diff
==============================================================================
--- cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java (original)
+++ cxf/trunk/rt/ws/addr/src/main/java/org/apache/cxf/ws/addressing/soap/MAPCodec.java Wed
Oct 28 13:33:40 2009
@@ -49,6 +49,7 @@
 import org.apache.cxf.headers.Header;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.Phase;
@@ -58,6 +59,7 @@
 import org.apache.cxf.ws.addressing.ContextUtils;
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 import org.apache.cxf.ws.addressing.JAXWSAConstants;
+import org.apache.cxf.ws.addressing.MAPAggregator;
 import org.apache.cxf.ws.addressing.Names;
 import org.apache.cxf.ws.addressing.ReferenceParametersType;
 import org.apache.cxf.ws.addressing.RelatesToType;
@@ -115,11 +117,31 @@
      */
     public void handleFault(SoapMessage message) {
         AddressingProperties maps = ContextUtils.retrieveMAPs(message, false, true, false);
-        if (ContextUtils.isRequestor(message) 
-            && !message.getExchange().isOneWay()
-            && maps != null) {
-            //fault occured trying to sent the message, remove it
-            uncorrelatedExchanges.remove(maps.getMessageID().getValue());
+        if (!message.getExchange().isOneWay()) {
+            if (ContextUtils.isRequestor(message)
+                && maps != null) {
+                //fault occurred trying to send the message, remove it
+                uncorrelatedExchanges.remove(maps.getMessageID().getValue());
+            } else if (!ContextUtils.isRequestor(message) 
+                && maps == null
+                && !message.containsKey(MAPAggregator.class.getName())) {
+                //fault occurred while processing the incoming message, but possibly
+                //before the MAPAggregator was called.   We need to see if we can
+                //try and map this if at all possible so a FaultTo/ReplyTo can
+                //be properly determined to get the fault back to the rightful
+                //place.
+                for (Interceptor<? extends Message> i : message.getInterceptorChain())
{
+                    if (i instanceof MAPAggregator) {
+                        try {
+                            MAPAggregator agg = (MAPAggregator)i;
+                            agg.handleMessage(message);
+                        } catch (Throwable t) {
+                            //ignore
+                        }
+                        return;
+                    }
+                }
+            }
         }
     }
 

Modified: cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java?rev=830533&r1=830532&r2=830533&view=diff
==============================================================================
--- cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java (original)
+++ cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java Wed Oct 28
13:33:40 2009
@@ -41,6 +41,11 @@
         addBefore(MAPAggregator.class.getName());
     }
    
+    @Override
+    public void handleFault(Message message) {
+        message.put(MAPAggregator.class.getName(), true);
+    }
+
     protected void handle(Message message) throws SequenceFault, RMException {
         LOG.entering(getClass().getName(), "handleMessage");
         

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java?rev=830533&r1=830532&r2=830533&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java
(original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/WSSecurityClientTest.java
Wed Oct 28 13:33:40 2009
@@ -36,11 +36,17 @@
 import javax.xml.ws.handler.Handler;
 import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.http.HTTPBinding;
+import javax.xml.ws.soap.AddressingFeature;
+import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.soap.SOAPFaultException;
 
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.jaxws.DispatchImpl;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.transport.http.HTTPConduit;
 import org.apache.hello_world_soap_http.Greeter;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -170,8 +176,52 @@
         result = source2String(dispatcher.invoke(new StreamSource(is)));
         assertTrue(result.indexOf("Fault") != -1);
     }
+    
+    @Test
+    public void testDecoupledFaultFromSecurity() throws Exception {
+        Dispatch<Source> dispatcher = null;
+        java.io.InputStream is = null;
+        
+        //
+        // Sending no security headers should result in a Fault
+        //
+        dispatcher = createUsernameTokenDispatcher(true);
+        is = getClass().getResourceAsStream("test-data/NoHeadersRequest.xml");
+        try {
+            dispatcher.invoke(new StreamSource(is));
+            fail("exception should have been generated");
+        } catch (SOAPFaultException ex) {
+            assertTrue(ex.getMessage().contains("Security"));
+        }
+
+        //
+        // Sending and empty header should result in a Fault
+        //
+        dispatcher = createUsernameTokenDispatcher(true);
+        is = getClass().getResourceAsStream("test-data/EmptyHeaderRequest.xml");
+        try {
+            dispatcher.invoke(new StreamSource(is));
+            fail("exception should have been generated");
+        } catch (SOAPFaultException ex) {
+            assertTrue(ex.getMessage().contains("Security"));
+        }
+        //
+        // Sending and empty security header should result in a Fault
+        //
+        dispatcher = createUsernameTokenDispatcher(true);
+        is = getClass().getResourceAsStream("test-data/EmptySecurityHeaderRequest.xml");
+        try {
+            dispatcher.invoke(new StreamSource(is));
+            fail("exception should have been generated");
+        } catch (SOAPFaultException ex) {
+            assertTrue(ex.getMessage().contains("Security"));
+        }
 
+    }
     private static Dispatch<Source> createUsernameTokenDispatcher() {
+        return createUsernameTokenDispatcher(false);
+    }
+    private static Dispatch<Source> createUsernameTokenDispatcher(boolean decoupled)
{
         //
         // Set up the client (stolen from JAX-RS system test)
         //
@@ -182,13 +232,14 @@
         );
         service.addPort(
             USERNAME_TOKEN_PORT_QNAME,
-            HTTPBinding.HTTP_BINDING,
+            decoupled ? SOAPBinding.SOAP11HTTP_BINDING : HTTPBinding.HTTP_BINDING, 
             "http://localhost:9000/GreeterService/UsernameTokenPort"
         );
         final Dispatch<Source> dispatcher = service.createDispatch(
             USERNAME_TOKEN_PORT_QNAME,
             Source.class,
-            Service.Mode.MESSAGE
+            Service.Mode.MESSAGE,
+            new AddressingFeature(decoupled, decoupled)
         );
         final java.util.Map<String, Object> requestContext =
             dispatcher.getRequestContext();
@@ -196,6 +247,10 @@
             MessageContext.HTTP_REQUEST_METHOD,
             "POST"
         );
+        if (decoupled) {
+            HTTPConduit cond = (HTTPConduit)((DispatchImpl)dispatcher).getClient().getConduit();
+            cond.getClient().setDecoupledEndpoint("http://localhost:9001/decoupled");
+        }
         return dispatcher;
     }
 

Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/server.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/server.xml?rev=830533&r1=830532&r2=830533&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/server.xml
(original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/security/server.xml
Wed Oct 28 13:33:40 2009
@@ -23,6 +23,8 @@
     xmlns:jaxws="http://cxf.apache.org/jaxws"
     xmlns:test="http://apache.org/hello_world_soap_http"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:wsa="http://cxf.apache.org/ws/addressing"
+    
     xsi:schemaLocation="http://cxf.apache.org/core
         http://cxf.apache.org/schemas/core.xsd
         http://www.springframework.org/schema/beans
@@ -51,6 +53,9 @@
         serviceName="test:GreeterService"
         endpointName="test:UsernameTokenPort"
         >
+        <jaxws:features>
+        	<wsa:addressing/>
+        </jaxws:features>
         <jaxws:inInterceptors>
             <ref bean="UsernameToken_Request"/>
             <bean class="org.apache.cxf.binding.soap.saaj.SAAJInInterceptor"/>



Mime
View raw message