You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2012/02/08 12:43:05 UTC

svn commit: r1241872 - in /santuario/xml-security-java/trunk: ./ src/main/java/org/apache/xml/security/transforms/implementations/ src/main/java/org/apache/xml/security/utils/

Author: coheigea
Date: Wed Feb  8 11:43:04 2012
New Revision: 1241872

URL: http://svn.apache.org/viewvc?rev=1241872&view=rev
Log:
[SANTUARIO-298] - Xalan is still a required dependency

Added:
    santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/JDKXPathFactory.java
    santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XPathFactory.java
    santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XalanXPathFactory.java
Modified:
    santuario/xml-security-java/trunk/CHANGELOG.txt
    santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath.java
    santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath2Filter.java

Modified: santuario/xml-security-java/trunk/CHANGELOG.txt
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/CHANGELOG.txt?rev=1241872&r1=1241871&r2=1241872&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/CHANGELOG.txt (original)
+++ santuario/xml-security-java/trunk/CHANGELOG.txt Wed Feb  8 11:43:04 2012
@@ -1,6 +1,7 @@
 Changelog for "Apache xml-security" <http://santuario.apache.org/>
 
 New in v1.5.1-SNAPSHOT:
+    Fixed SANTUARIO-298 - Xalan is still a required dependency
     Fixed SANTUARIO-299 - StringIndexOutOfBoundsException is thrown during reference verification (if URI = "#")
     Fixed SANTUARIO-297 - Exceptions should use a JDK exception cause mechanism
 

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath.java?rev=1241872&r1=1241871&r2=1241872&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath.java Wed Feb  8 11:43:04 2012
@@ -30,10 +30,9 @@ import org.apache.xml.security.transform
 import org.apache.xml.security.transforms.TransformationException;
 import org.apache.xml.security.transforms.Transforms;
 import org.apache.xml.security.utils.Constants;
-import org.apache.xml.security.utils.JDKXPathAPI;
 import org.apache.xml.security.utils.XMLUtils;
 import org.apache.xml.security.utils.XPathAPI;
-import org.apache.xml.security.utils.XalanXPathAPI;
+import org.apache.xml.security.utils.XPathFactory;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -102,11 +101,8 @@ public class TransformXPath extends Tran
                 );
             }
             
-            XPathAPI xpathAPIInstance = new XalanXPathAPI();
-            if (!XalanXPathAPI.isInstalled()) {
-                xpathAPIInstance = new JDKXPathAPI();
-            }
-
+            XPathFactory xpathFactory = XPathFactory.newInstance();
+            XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
             input.addNodeFilter(new XPathNodeFilter(xpathElement, xpathnode, str, xpathAPIInstance));
             input.setNodeSet(true);
             return input;

Modified: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath2Filter.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath2Filter.java?rev=1241872&r1=1241871&r2=1241872&view=diff
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath2Filter.java (original)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/transforms/implementations/TransformXPath2Filter.java Wed Feb  8 11:43:04 2012
@@ -38,10 +38,9 @@ import org.apache.xml.security.transform
 import org.apache.xml.security.transforms.TransformationException;
 import org.apache.xml.security.transforms.Transforms;
 import org.apache.xml.security.transforms.params.XPath2FilterContainer;
-import org.apache.xml.security.utils.JDKXPathAPI;
 import org.apache.xml.security.utils.XMLUtils;
 import org.apache.xml.security.utils.XPathAPI;
-import org.apache.xml.security.utils.XalanXPathAPI;
+import org.apache.xml.security.utils.XPathFactory;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -112,10 +111,8 @@ public class TransformXPath2Filter exten
                 String str = 
                     XMLUtils.getStrFromNode(xpathContainer.getXPathFilterTextNode());
                 
-                XPathAPI xpathAPIInstance = new XalanXPathAPI();
-                if (!XalanXPathAPI.isInstalled()) {
-                    xpathAPIInstance = new JDKXPathAPI();
-                }
+                XPathFactory xpathFactory = XPathFactory.newInstance();
+                XPathAPI xpathAPIInstance = xpathFactory.newXPathAPI();
                 
                 NodeList subtreeRoots = 
                     xpathAPIInstance.selectNodeList(

Added: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/JDKXPathFactory.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/JDKXPathFactory.java?rev=1241872&view=auto
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/JDKXPathFactory.java (added)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/JDKXPathFactory.java Wed Feb  8 11:43:04 2012
@@ -0,0 +1,33 @@
+/**
+ * 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.xml.security.utils;
+
+
+/**
+ * A Factory to return a JDKXPathAPI instance.
+ */
+public class JDKXPathFactory extends XPathFactory {
+
+    /**
+     * Get a new XPathAPI instance
+     */
+    public XPathAPI newXPathAPI() {
+        return new JDKXPathAPI();
+    }
+}

Added: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XPathFactory.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XPathFactory.java?rev=1241872&view=auto
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XPathFactory.java (added)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XPathFactory.java Wed Feb  8 11:43:04 2012
@@ -0,0 +1,67 @@
+/**
+ * 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.xml.security.utils;
+
+
+/**
+ * A Factory to return an XPathAPI instance. If Xalan is available it returns XalanXPathAPI. If not, then 
+ * it returns JDKXPathAPI.
+ */
+public abstract class XPathFactory {
+
+    private static boolean xalanInstalled;
+    
+    static {
+        try {
+            Class<?> funcTableClass = 
+                ClassLoaderUtils.loadClass("org.apache.xpath.compiler.FunctionTable", XPathFactory.class);
+            if (funcTableClass != null) {
+                xalanInstalled = true;
+            }
+        } catch (Exception e) {
+            //ignore
+        }
+    }
+    
+    protected synchronized static boolean isXalanInstalled() {
+        return xalanInstalled;
+    }
+    
+    /**
+     * Get a new XPathFactory instance
+     */
+    public static XPathFactory newInstance() {
+        if (!isXalanInstalled()) {
+            return new JDKXPathFactory();
+        }
+        // Xalan is available
+        if (XalanXPathAPI.isInstalled()) {
+            return new XalanXPathFactory();
+        }
+        // Some problem was encountered in fixing up the Xalan FunctionTable so fall back to the 
+        // JDK implementation
+        return new JDKXPathFactory();
+    }
+
+    /**
+     * Get a new XPathAPI instance
+     */
+    public abstract XPathAPI newXPathAPI();
+
+}

Added: santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XalanXPathFactory.java
URL: http://svn.apache.org/viewvc/santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XalanXPathFactory.java?rev=1241872&view=auto
==============================================================================
--- santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XalanXPathFactory.java (added)
+++ santuario/xml-security-java/trunk/src/main/java/org/apache/xml/security/utils/XalanXPathFactory.java Wed Feb  8 11:43:04 2012
@@ -0,0 +1,33 @@
+/**
+ * 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.xml.security.utils;
+
+
+/**
+ * A Factory to return a XalanXPathAPI instance.
+ */
+public class XalanXPathFactory extends XPathFactory {
+
+    /**
+     * Get a new XPathAPI instance
+     */
+    public XPathAPI newXPathAPI() {
+        return new XalanXPathAPI();
+    }
+}