cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1546133 - in /cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/feature/transform: AbstractXSLTInterceptor.java XSLTUtils.java
Date Wed, 27 Nov 2013 17:34:34 GMT
Author: dkulp
Date: Wed Nov 27 17:34:34 2013
New Revision: 1546133

URL: http://svn.apache.org/r1546133
Log:
Merged revisions 1546126 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1546126 | dkulp | 2013-11-27 12:28:53 -0500 (Wed, 27 Nov 2013) | 2 lines

  Use our Stax XML parsing for all the parsing to prevent global locks on sax factories and
provide more security

........

Modified:
    cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/feature/transform/AbstractXSLTInterceptor.java
    cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java

Modified: cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/feature/transform/AbstractXSLTInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/feature/transform/AbstractXSLTInterceptor.java?rev=1546133&r1=1546132&r2=1546133&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/feature/transform/AbstractXSLTInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/feature/transform/AbstractXSLTInterceptor.java
Wed Nov 27 17:34:34 2013
@@ -22,16 +22,19 @@ package org.apache.cxf.feature.transform
 
 import java.io.InputStream;
 
-import javax.xml.transform.Source;
+import javax.xml.stream.XMLStreamException;
 import javax.xml.transform.Templates;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamSource;
+import javax.xml.transform.dom.DOMSource;
+
+import org.w3c.dom.Document;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.staxutils.StaxUtils;
 
 
 /**
@@ -57,12 +60,16 @@ public abstract class AbstractXSLTInterc
             if (xsltStream == null) {
                 throw new IllegalArgumentException("Cannot load XSLT from path: " + xsltPath);
             }
-            Source xsltSource = new StreamSource(xsltStream);
-            xsltTemplate = TRANSFORM_FACTORIY.newTemplates(xsltSource);
+            Document doc = StaxUtils.read(xsltStream);
+            xsltTemplate = TRANSFORM_FACTORIY.newTemplates(new DOMSource(doc));
         } catch (TransformerConfigurationException e) {
             throw new IllegalArgumentException(
                                                String.format("Cannot create XSLT template
from path: %s, error: ",
                                                              xsltPath, e.getException()),
e);
+        } catch (XMLStreamException e) {
+            throw new IllegalArgumentException(
+                                               String.format("Cannot create XSLT template
from path: %s, error: ",
+                                                             xsltPath, e.getNestedException()),
e);
         }        
     }
 

Modified: cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java?rev=1546133&r1=1546132&r2=1546133&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/feature/transform/XSLTUtils.java
Wed Nov 27 17:34:34 2013
@@ -24,20 +24,24 @@ import java.io.InputStream;
 import java.io.Reader;
 import java.util.logging.Logger;
 
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
 import javax.xml.transform.Templates;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.dom.DOMResult;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
 
 import org.w3c.dom.Document;
+
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.io.CachedOutputStream;
 import org.apache.cxf.io.CachedWriter;
+import org.apache.cxf.staxutils.StaxSource;
+import org.apache.cxf.staxutils.StaxUtils;
 
 public final class XSLTUtils {
     private static final Logger LOG = LogUtils.getL7dLogger(XSLTUtils.class);
@@ -48,7 +52,8 @@ public final class XSLTUtils {
 
     public static InputStream transform(Templates xsltTemplate, InputStream in) {
         try {
-            StreamSource beforeSource = new StreamSource(in);
+            XMLStreamReader reader = StaxUtils.createXMLStreamReader(in);
+            Source beforeSource = new StaxSource(reader);
             CachedOutputStream out = new CachedOutputStream();
 
             Transformer trans = xsltTemplate.newTransformer();
@@ -64,7 +69,8 @@ public final class XSLTUtils {
 
     public static Reader transform(Templates xsltTemplate, Reader inReader) {
         try {
-            StreamSource beforeSource = new StreamSource(inReader);
+            XMLStreamReader reader = StaxUtils.createXMLStreamReader(inReader);
+            Source beforeSource = new StaxSource(reader);
             CachedWriter outWriter = new CachedWriter();
 
             Transformer trans = xsltTemplate.newTransformer();



Mime
View raw message