ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1152928 - /webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSConfig.java
Date Mon, 01 Aug 2011 20:52:30 GMT
Author: dkulp
Date: Mon Aug  1 20:52:30 2011
New Revision: 1152928

URL: http://svn.apache.org/viewvc?rev=1152928&view=rev
Log:
Go out of the way to set the ignoreLinebreaks flag to true in xmlsec as
it seems to be causing issues in OpenSaml (and they attempt to set it to
true as well, but they init after we do)

Modified:
    webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSConfig.java

Modified: webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSConfig.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSConfig.java?rev=1152928&r1=1152927&r2=1152928&view=diff
==============================================================================
--- webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSConfig.java (original)
+++ webservices/wss4j/trunk/src/main/java/org/apache/ws/security/WSSConfig.java Mon Aug  1
20:52:30 2011
@@ -19,6 +19,7 @@
 
 package org.apache.ws.security;
 
+import java.lang.reflect.Field;
 import java.security.Provider;
 import java.security.Security;
 import java.util.HashMap;
@@ -30,6 +31,7 @@ import org.apache.ws.security.action.Act
 import org.apache.ws.security.processor.Processor;
 import org.apache.ws.security.util.Loader;
 import org.apache.ws.security.util.UUIDGenerator;
+import org.apache.ws.security.util.XMLUtils;
 import org.apache.ws.security.validate.Validator;
 
 /**
@@ -354,9 +356,35 @@ public class WSSConfig {
         addJceProviders = value;
     }
     
+    private static void setXmlSecIgnoreLineBreak() {
+        //really need to make sure ignoreLineBreaks is set to
+        boolean wasSet = false;
+        try {
+            // Don't override if it was set explicitly
+            String lineBreakPropName = "org.apache.xml.security.ignoreLineBreaks";
+            if (System.getProperty(lineBreakPropName) == null) {
+                System.setProperty(lineBreakPropName, "true");
+            } else {
+                wasSet = true;
+            }
+        } catch (Throwable t) { //NOPMD
+            //ignore
+        }
+        org.apache.xml.security.Init.init();
+        if (!wasSet) {
+            try {
+                Field f = XMLUtils.class.getDeclaredField("ignoreLineBreaks");
+                f.setAccessible(true);
+                f.set(null, Boolean.TRUE);
+            } catch (Throwable t) { //NOPMD
+                //ignore
+            }
+        }
+    }
+    
     public static synchronized void init() {
         if (!staticallyInitialized) {
-            org.apache.xml.security.Init.init();
+            setXmlSecIgnoreLineBreak();
             if (addJceProviders) {
                 addJceProvider("XMLDSig", "org.jcp.xml.dsig.internal.dom.XMLDSigRI");
                 addJceProvider("BC", "org.bouncycastle.jce.provider.BouncyCastleProvider");



Mime
View raw message