You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2017/10/04 11:07:33 UTC
[cxf] 01/03: Setting secure processing to true for DOMUtils
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch 3.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit 93e733396fac61150e800b343e3592587ccfbc23
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Wed Oct 4 11:22:02 2017 +0100
Setting secure processing to true for DOMUtils
# Conflicts:
# core/src/main/java/org/apache/cxf/helpers/DOMUtils.java
---
.../main/java/org/apache/cxf/helpers/DOMUtils.java | 55 +++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)
diff --git a/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java b/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java
index 43a4d69..6c3a912 100644
--- a/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java
+++ b/core/src/main/java/org/apache/cxf/helpers/DOMUtils.java
@@ -59,6 +59,32 @@ public final class DOMUtils {
private static final Map<ClassLoader, DocumentBuilder> DOCUMENT_BUILDERS
= Collections.synchronizedMap(new WeakHashMap<ClassLoader, DocumentBuilder>());
private static final String XMLNAMESPACE = "xmlns";
+<<<<<<< HEAD
+=======
+
+
+
+ static {
+ if (System.getProperty("java.version").startsWith("9")) {
+
+ try {
+ Method[] methods = DOMUtils.class.getClassLoader().
+ loadClass("com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl").getMethods();
+ for (Method method : methods) {
+ if (method.getName().equals("register")) {
+ //this is the SAAJ impl in JDK9
+ setJava9SAAJ(true);
+ break;
+ }
+ }
+ } catch (ClassNotFoundException cnfe) {
+ LogUtils.getL7dLogger(DOMUtils.class).finest(
+ "can't load class com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl");
+ }
+
+ }
+ }
+>>>>>>> 959a067ef2... Setting secure processing to true for DOMUtils
private DOMUtils() {
}
@@ -69,12 +95,16 @@ public final class DOMUtils {
loader = getClassLoader(DOMUtils.class);
}
if (loader == null) {
- return DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ DocumentBuilderFactory f = DocumentBuilderFactory.newInstance();
+ f.setNamespaceAware(true);
+ f.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ return f.newDocumentBuilder();
}
DocumentBuilder factory = DOCUMENT_BUILDERS.get(loader);
if (factory == null) {
DocumentBuilderFactory f2 = DocumentBuilderFactory.newInstance();
f2.setNamespaceAware(true);
+ f2.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true);
factory = f2.newDocumentBuilder();
DOCUMENT_BUILDERS.put(loader, factory);
}
@@ -656,6 +686,29 @@ public final class DOMUtils {
findAllElementsByTagNameNS(elem, nameSpaceURI, localName, ret);
return ret;
}
+<<<<<<< HEAD
+=======
+
+ /**
+ * Try to get the DOM Node from the SAAJ Node with JAVA9
+ * @param node The original node we need check
+ * @return The DOM node
+ */
+ public static Node getDomElement(Node node) {
+ if (node != null && isJava9SAAJ()) {
+ //java9 hack since EA 159
+ try {
+ Method method = node.getClass().getMethod("getDomElement");
+ node = (Node)method.invoke(node);
+ } catch (NoSuchMethodException e) {
+ //best effort to try, do nothing if NoSuchMethodException
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return node;
+ }
+>>>>>>> 959a067ef2... Setting secure processing to true for DOMUtils
private static void findAllElementsByTagNameNS(Element el, String nameSpaceURI, String localName,
List<Element> elementList) {
--
To stop receiving notification emails like this one, please contact
"commits@cxf.apache.org" <co...@cxf.apache.org>.