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 2014/12/23 15:54:55 UTC

[1/3] cxf git commit: Remove a warning in eclipse

Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 0b09918a2 -> d69dcbfcc


Remove a warning in eclipse


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/94e4d753
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/94e4d753
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/94e4d753

Branch: refs/heads/3.0.x-fixes
Commit: 94e4d75369ea6a062f298acddd1c1fffd284c44a
Parents: 0b09918
Author: Daniel Kulp <dk...@apache.org>
Authored: Mon Dec 22 15:27:28 2014 -0500
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Dec 23 09:54:34 2014 -0500

----------------------------------------------------------------------
 rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/94e4d753/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
----------------------------------------------------------------------
diff --git a/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java b/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
index 22b93fa..af50827 100644
--- a/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
+++ b/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/RMManagerTest.java
@@ -531,7 +531,7 @@ public class RMManagerTest extends Assert {
         control.reset();
         setUpEndpointForRecovery(endpoint, ei, si, bi, ii);  
         RMMessage m = control.createMock(RMMessage.class);
-        Capture<Message> mc = new Capture<Message>();
+        Capture<Message> mc = Capture.newInstance();
         setUpRecoverReliableEndpoint(endpoint, conduit, ss, ds, m, mc);        
         control.replay();
         manager.recoverReliableEndpoint(endpoint, conduit);


[3/3] cxf git commit: [CXF-6173] Use configured sizes limits for the SAAJIn processing

Posted by dk...@apache.org.
[CXF-6173] Use configured sizes limits for the SAAJIn processing


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/d69dcbfc
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d69dcbfc
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d69dcbfc

Branch: refs/heads/3.0.x-fixes
Commit: d69dcbfcc67c78c254c050f94c4d29609aec5023
Parents: 60d7bf2
Author: Daniel Kulp <dk...@apache.org>
Authored: Tue Dec 23 09:51:24 2014 -0500
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Dec 23 09:54:41 2014 -0500

----------------------------------------------------------------------
 .../org/apache/cxf/staxutils/StaxUtils.java     | 22 ++++++++
 .../binding/soap/saaj/SAAJInInterceptor.java    |  7 ++-
 ...ispatchClientServerWithHugeResponseTest.java | 56 +++++++++++++++-----
 3 files changed, 72 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/d69dcbfc/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java b/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
index d22a337..52b2246 100644
--- a/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
+++ b/core/src/main/java/org/apache/cxf/staxutils/StaxUtils.java
@@ -230,10 +230,18 @@ public final class StaxUtils {
     }
     
     public static void setInnerElementLevelThreshold(int i) {
+        if (i == -1) {
+            i = 500;
+        }
         innerElementLevelThreshold = i;
+        setProperty(SAFE_INPUT_FACTORY, "com.ctc.wstx.maxElementDepth", i);
     }
     public static void setInnerElementCountThreshold(int i) {
+        if (i == -1) {
+            i = 50000;
+        }
         innerElementCountThreshold = i;
+        setProperty(SAFE_INPUT_FACTORY, "com.ctc.wstx.maxChildrenPerElement", i);
     }
 
     /**
@@ -2102,6 +2110,20 @@ public final class StaxUtils {
         }
     }
     
+    public static boolean isSecureReader(XMLStreamReader reader, Message message) {
+        if (reader instanceof DocumentDepthProperties) {
+            return true;
+        }
+        try {
+            if (reader.getProperty("com.ctc.wstx.maxChildrenPerElement") != null) {
+                return true;
+            }
+        } catch (Exception ex) {
+            //ignore
+        }
+        return false;
+    }
+    
     public static XMLStreamReader configureReader(XMLStreamReader xreader, Message message) throws XMLStreamException {
         Integer messageMaxChildElements = PropertyUtils.getInteger(message, MAX_CHILD_ELEMENTS);
         Integer messageMaxElementDepth = PropertyUtils.getInteger(message, MAX_ELEMENT_DEPTH);

http://git-wip-us.apache.org/repos/asf/cxf/blob/d69dcbfc/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
----------------------------------------------------------------------
diff --git a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
index 0cca461..627d251 100644
--- a/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
+++ b/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
@@ -220,10 +220,15 @@ public class SAAJInInterceptor extends AbstractSoapInterceptor {
                 soapMessage.getSOAPPart().getEnvelope().addHeader();
             }
             
+            //If we have an xmlReader that already is counting the attributes and such
+            //then we don't want to rely on the system level defaults in StaxUtils.copy
+            //CXF-6173
+            boolean secureReader = StaxUtils.isSecureReader(xmlReader, message);
             StaxUtils.copy(xmlReader, 
                            new SAAJStreamWriter(soapMessage.getSOAPPart(), 
                                                 soapMessage.getSOAPPart().getEnvelope().getBody()),
-                           true, true);
+                           true, 
+                           !secureReader);
             DOMSource bodySource = new DOMSource(soapMessage.getSOAPPart().getEnvelope().getBody());
             xmlReader = StaxUtils.createXMLStreamReader(bodySource);
             xmlReader.nextTag();

http://git-wip-us.apache.org/repos/asf/cxf/blob/d69dcbfc/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerWithHugeResponseTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerWithHugeResponseTest.java b/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerWithHugeResponseTest.java
index beb536d..658c074 100644
--- a/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerWithHugeResponseTest.java
+++ b/systests/jaxws/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerWithHugeResponseTest.java
@@ -21,10 +21,10 @@ package org.apache.cxf.systest.dispatch;
 
 import java.io.InputStream;
 import java.net.URL;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 
-
 import javax.xml.namespace.QName;
 import javax.xml.soap.MessageFactory;
 import javax.xml.soap.SOAPMessage;
@@ -34,7 +34,7 @@ import javax.xml.ws.Endpoint;
 import javax.xml.ws.Response;
 import javax.xml.ws.Service;
 
-
+import org.apache.cxf.binding.soap.SoapFault;
 import org.apache.cxf.interceptor.LoggingInInterceptor;
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
 import org.apache.cxf.staxutils.StaxUtils;
@@ -44,7 +44,6 @@ import org.apache.cxf.testutil.common.TestUtil;
 import org.apache.hello_world_soap_http.GreeterImpl;
 import org.apache.hello_world_soap_http.SOAPService;
 
-import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -93,15 +92,13 @@ public class DispatchClientServerWithHugeResponseTest extends AbstractBusClientS
     
     @org.junit.Before
     public void setUp() throws Exception {
-        StaxUtils.setInnerElementCountThreshold(12);
-        StaxUtils.setInnerElementLevelThreshold(12);
         createBus();
         getBus().getOutInterceptors().add(new LoggingOutInterceptor());
         getBus().getInInterceptors().add(new LoggingInInterceptor());
     }
     
-    @AfterClass
-    public static void cleanup() throws Exception {
+    @org.junit.After
+    public void cleanUp() throws Exception {
         StaxUtils.setInnerElementCountThreshold(-1);
         StaxUtils.setInnerElementLevelThreshold(-1);
     }
@@ -125,6 +122,8 @@ public class DispatchClientServerWithHugeResponseTest extends AbstractBusClientS
                                      + "/SOAPDispatchService/SoapDispatchPort");
         
         
+        StaxUtils.setInnerElementCountThreshold(12);
+        StaxUtils.setInnerElementLevelThreshold(12);
 
         InputStream is3 = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq3.xml");
         SOAPMessage soapReqMsg3 = MessageFactory.newInstance().createMessage(null, is3);
@@ -162,6 +161,8 @@ public class DispatchClientServerWithHugeResponseTest extends AbstractBusClientS
                                      + "/SOAPDispatchService/SoapDispatchPort");
         
         
+        StaxUtils.setInnerElementCountThreshold(12);
+        StaxUtils.setInnerElementLevelThreshold(12);
 
         InputStream is3 = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq3.xml");
         SOAPMessage soapReqMsg3 = MessageFactory.newInstance().createMessage(null, is3);
@@ -173,7 +174,24 @@ public class DispatchClientServerWithHugeResponseTest extends AbstractBusClientS
             fail("We should not have encountered a timeout, " 
                 + "should get some exception tell me stackoverflow");
         } catch (Throwable e) {
-            assertTrue(e.getCause().getMessage().startsWith("reach the innerElementLevelThreshold"));
+            if (e.getCause() == null) {
+                throw e;
+            }
+            Throwable t = e.getCause();
+            if (t instanceof SoapFault) {
+                SoapFault sf = (SoapFault)e.getCause();
+                if (sf.getCause() == null) {
+                    throw e;
+                }
+                t = sf.getCause();
+            }
+            if (t.getMessage() == null) {
+                throw e;
+            }
+            
+            String msg = t.getMessage();          
+            assertTrue(msg, msg.startsWith("reach the innerElementLevelThreshold")
+                       || msg.contains("Maximum Element Depth limit"));
         } finally {
             getBus().getInInterceptors().remove(hugeResponseInterceptor);
         }
@@ -190,7 +208,7 @@ public class DispatchClientServerWithHugeResponseTest extends AbstractBusClientS
 
         SOAPService service = new SOAPService(wsdl, SERVICE_NAME);
         assertNotNull(service);
-
+        
         Dispatch<SOAPMessage> disp = service
             .createDispatch(PORT_NAME, SOAPMessage.class, Service.Mode.MESSAGE);
         disp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
@@ -200,6 +218,9 @@ public class DispatchClientServerWithHugeResponseTest extends AbstractBusClientS
         
         
 
+        StaxUtils.setInnerElementCountThreshold(12);
+        StaxUtils.setInnerElementLevelThreshold(12);
+
         InputStream is3 = getClass().getResourceAsStream("resources/GreetMeDocLiteralReq3.xml");
         SOAPMessage soapReqMsg3 = MessageFactory.newInstance().createMessage(null, is3);
         assertNotNull(soapReqMsg3);
@@ -210,14 +231,25 @@ public class DispatchClientServerWithHugeResponseTest extends AbstractBusClientS
         } catch (TimeoutException te) {
             fail("We should not have encountered a timeout, " 
                 + "should get some exception tell me stackoverflow");
-        } catch (Throwable e) {
+        } catch (ExecutionException e) {
             if (e.getCause() == null) {
                 throw e;
             }
-            if (e.getCause().getMessage() == null) {
+            Throwable t = e.getCause();
+            if (t instanceof SoapFault) {
+                SoapFault sf = (SoapFault)e.getCause();
+                if (sf.getCause() == null) {
+                    throw e;
+                }
+                t = sf.getCause();
+            }
+            if (t.getMessage() == null) {
                 throw e;
             }
-            assertTrue(e.getCause().getMessage().startsWith("reach the innerElementCountThreshold"));
+            
+            String msg = t.getMessage();
+            assertTrue(msg, msg.startsWith("reach the innerElementCountThreshold")
+                       || msg.contains("Maximum Number of Child Elements"));
         } finally {
             getBus().getInInterceptors().remove(hugeResponseInterceptor);
         }


[2/3] cxf git commit: Add utility to determin if filename is valid

Posted by dk...@apache.org.
Add utility to determin if filename is valid


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/60d7bf2e
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/60d7bf2e
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/60d7bf2e

Branch: refs/heads/3.0.x-fixes
Commit: 60d7bf2ef1d46516c1b1b921dc1a07de05856124
Parents: 94e4d75
Author: Daniel Kulp <dk...@apache.org>
Authored: Tue Dec 23 09:51:06 2014 -0500
Committer: Daniel Kulp <dk...@apache.org>
Committed: Tue Dec 23 09:54:38 2014 -0500

----------------------------------------------------------------------
 .../java/org/apache/cxf/helpers/FileUtils.java  | 27 +++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/60d7bf2e/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
index 2bafee2..82444d1 100644
--- a/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
+++ b/core/src/main/java/org/apache/cxf/helpers/FileUtils.java
@@ -38,12 +38,37 @@ import org.apache.cxf.common.util.SystemPropertyAction;
 public final class FileUtils {
     private static final int RETRY_SLEEP_MILLIS = 10;
     private static File defaultTempDir;
-    
+    private static final char[] ILLEGAL_CHARACTERS 
+        = {'/', '\n', '\r', '\t', '\0', '\f', '`', '?', '*', '\\', '<', '>', '|', '\"', ':'};    
     
     private FileUtils() {
         
     }
     
+    public boolean isValidFileName(String name) {
+        for (int i = name.length(); i > 0; i--) {
+            char c = name.charAt(i - 1);
+            for (char c2 : ILLEGAL_CHARACTERS) {
+                if (c == c2) {
+                    return false;
+                }
+            }
+        }
+        File file = new File(getDefaultTempDir(), name);
+        boolean isValid = true;
+        try {
+            if (file.exists()) {
+                return true;
+            }
+            if (file.createNewFile()) {
+                file.delete();
+            }
+        } catch (IOException e) {
+            isValid = false;
+        }
+        return isValid;
+    }
+
     public static synchronized File getDefaultTempDir() {
         if (defaultTempDir != null
             && defaultTempDir.exists()) {