You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/08/09 09:45:50 UTC
[3/3] git commit: CAMEL-6619: Ignore line braeks in xmlsecurity.
Thanks to Colm for the patch.
CAMEL-6619: Ignore line braeks in xmlsecurity. Thanks to Colm for the patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d62ba5fd
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d62ba5fd
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d62ba5fd
Branch: refs/heads/camel-2.10.x
Commit: d62ba5fd0b3f87944bcf40555ff6d74728b9407d
Parents: 0cc229d
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Aug 9 09:44:50 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Aug 9 09:45:23 2013 +0200
----------------------------------------------------------------------
.../xmlsecurity/XMLSecurityDataFormat.java | 40 ++++++++++++++++++--
1 file changed, 37 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/d62ba5fd/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java
index 5b2c9f3..923a7c5 100755
--- a/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java
+++ b/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java
@@ -19,12 +19,16 @@ package org.apache.camel.dataformat.xmlsecurity;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.reflect.Field;
import java.net.URL;
+import java.security.AccessController;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedExceptionAction;
import java.security.PublicKey;
import java.security.spec.InvalidKeySpecException;
import java.util.Arrays;
@@ -40,22 +44,20 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-
import org.apache.camel.CamelContext;
import org.apache.camel.CamelContextAware;
import org.apache.camel.Exchange;
-
import org.apache.camel.builder.xml.DefaultNamespaceContext;
import org.apache.camel.builder.xml.XPathBuilder;
import org.apache.camel.spi.DataFormat;
import org.apache.camel.util.IOHelper;
import org.apache.camel.util.jsse.KeyStoreParameters;
-
import org.apache.xml.security.encryption.EncryptedData;
import org.apache.xml.security.encryption.EncryptedKey;
import org.apache.xml.security.encryption.XMLCipher;
import org.apache.xml.security.encryption.XMLEncryptionException;
import org.apache.xml.security.keys.KeyInfo;
+import org.apache.xml.security.utils.XMLUtils;
public class XMLSecurityDataFormat implements DataFormat, CamelContextAware {
@@ -125,7 +127,39 @@ public class XMLSecurityDataFormat implements DataFormat, CamelContextAware {
this.passPhrase = "Just another 24 Byte key".getBytes();
this.secureTag = "";
this.secureTagContents = true;
+
+ // Set ignoreLineBreaks to true
+ boolean wasSet = false;
+ try {
+ // Don't override if it was set explicitly
+ wasSet = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+ public Boolean run() {
+ String lineBreakPropName = "org.apache.xml.security.ignoreLineBreaks";
+ if (System.getProperty(lineBreakPropName) == null) {
+ System.setProperty(lineBreakPropName, "true");
+ return false;
+ }
+ return true;
+ }
+ });
+ } catch (Throwable t) { //NOPMD
+ //ignore
+ }
org.apache.xml.security.Init.init();
+ if (!wasSet) {
+ try {
+ AccessController.doPrivileged(new PrivilegedExceptionAction<Boolean>() {
+ public Boolean run() throws Exception {
+ Field f = XMLUtils.class.getDeclaredField("ignoreLineBreaks");
+ f.setAccessible(true);
+ f.set(null, Boolean.TRUE);
+ return false;
+ }
+ });
+ } catch (Throwable t) { //NOPMD
+ //ignore
+ }
+ }
}
public XMLSecurityDataFormat(String secureTag, boolean secureTagContents) {