ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r1829457 - /webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java
Date Wed, 18 Apr 2018 16:47:30 GMT
Author: coheigea
Date: Wed Apr 18 16:47:30 2018
New Revision: 1829457

URL: http://svn.apache.org/viewvc?rev=1829457&view=rev
Log:
WSS-624 - Support for SAAJ-RI 1.4.0. Thanks to Andreas Asplund for the patch.
 - This closes #11.

Modified:
    webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java

Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java?rev=1829457&r1=1829456&r2=1829457&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java
(original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java
Wed Apr 18 16:47:30 2018
@@ -65,13 +65,24 @@ import javax.security.auth.callback.Unsu
  */
 public final class WSSecurityUtil {
 
-    private static boolean isJava9SAAJ = false;
+    private static boolean isSAAJ14 = false;
 
     private static final org.slf4j.Logger LOG =
         org.slf4j.LoggerFactory.getLogger(WSSecurityUtil.class);
 
     static {
-        if (System.getProperty("java.version").startsWith("9") || System.getProperty("java.version").startsWith("10"))
{
+        try {
+            Method[] methods = WSSecurityUtil.class.getClassLoader().
+                loadClass("com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl").getMethods();
+            for (Method method : methods) {
+                if (method.getName().equals("register")) {
+                    //this is the 1.4+ SAAJ impl
+                    isSAAJ14 = true;
+                    break;
+                }
+            }
+        } catch (ClassNotFoundException cnfe) {
+            LOG.debug("Can't load class com.sun.xml.messaging.saaj.soap.SOAPDocumentImpl",
cnfe);
 
             try {
                 Method[] methods = WSSecurityUtil.class.getClassLoader().
@@ -79,12 +90,12 @@ public final class WSSecurityUtil {
                 for (Method method : methods) {
                     if (method.getName().equals("register")) {
                         //this is the SAAJ impl in JDK9
-                        isJava9SAAJ = true;
+                        isSAAJ14 = true;
                         break;
                     }
                 }
-            } catch (ClassNotFoundException cnfe) {
-                LOG.debug("can't load class com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl",
cnfe);
+            } catch (ClassNotFoundException cnfe1) {
+                LOG.debug("can't load class com.sun.xml.internal.messaging.saaj.soap.SOAPDocumentImpl",
cnfe1);
             }
         }
     }
@@ -357,7 +368,7 @@ public final class WSSecurityUtil {
             );
         if (header == null) { // no SOAP header at all
             if (doCreate) {
-                if (isJava9SAAJ) {
+                if (isSAAJ14) {
                     try {
                         Node node = null;
                         try {
@@ -616,7 +627,7 @@ public final class WSSecurityUtil {
      */
     public static Element cloneElement(Document doc, Element clonedElement) throws WSSecurityException
{
         clonedElement = (Element)clonedElement.cloneNode(true);
-        if (isJava9SAAJ) {
+        if (isSAAJ14) {
             // here we need regiter the javax.xml.soap.Node with new instance
             clonedElement = (Element)doc.importNode(clonedElement, true);
             clonedElement = (Element)getDomElement(clonedElement);
@@ -631,7 +642,7 @@ public final class WSSecurityUtil {
      * @throws WSSecurityException
      */
     private static Node getDomElement(Node node) throws WSSecurityException {
-        if (node != null && isJava9SAAJ) {
+        if (node != null && isSAAJ14) {
 
             try {
                 Method method = node.getClass().getMethod("getDomElement");



Mime
View raw message