Repository: camel Updated Branches: refs/heads/master dec2bbfcc -> e8fb927b9
CAMEL-7646: Remove cyclic package dependency in xmlsecurity component. Thanks to Franz Forsthofer 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/e8fb927b Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e8fb927b Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e8fb927b Branch: refs/heads/master Commit: e8fb927b9cc045289d6c85888a765e82806aa23e Parents: dec2bbf Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Jul 29 18:02:17 2014 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Jul 29 18:02:17 2014 +0200 ---------------------------------------------------------------------- .../component/xmlsecurity/SantuarioUtil.java | 83 -------------------- .../xmlsecurity/processor/SantuarioUtil.java | 83 ++++++++++++++++++++ .../processor/XmlSignatureProcessor.java | 2 - 3 files changed, 83 insertions(+), 85 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/e8fb927b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/SantuarioUtil.java ---------------------------------------------------------------------- diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/SantuarioUtil.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/SantuarioUtil.java deleted file mode 100644 index a9108a1..0000000 --- a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/SantuarioUtil.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * 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.camel.component.xmlsecurity; - -import java.lang.reflect.Field; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedExceptionAction; -import java.security.Provider; -import java.security.Security; - -import org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI; -import org.apache.xml.security.utils.XMLUtils; - - -public final class SantuarioUtil { - private SantuarioUtil() { - //Helper class - } - - public static void initializeSantuario() { - // 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 static void addSantuarioJSR105Provider() { - AccessController.doPrivileged(new PrivilegedAction<Boolean>() { - public Boolean run() { - String providerName = "ApacheXMLDSig"; - Provider currentProvider = Security.getProvider(providerName); - if (currentProvider == null) { - Security.addProvider(new XMLDSigRI()); - } - return true; - } - }); - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/e8fb927b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/SantuarioUtil.java ---------------------------------------------------------------------- diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/SantuarioUtil.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/SantuarioUtil.java new file mode 100644 index 0000000..b37e3ee --- /dev/null +++ b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/SantuarioUtil.java @@ -0,0 +1,83 @@ +/** + * 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.camel.component.xmlsecurity.processor; + +import java.lang.reflect.Field; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.security.PrivilegedExceptionAction; +import java.security.Provider; +import java.security.Security; + +import org.apache.jcp.xml.dsig.internal.dom.XMLDSigRI; +import org.apache.xml.security.utils.XMLUtils; + + +public final class SantuarioUtil { + private SantuarioUtil() { + //Helper class + } + + public static void initializeSantuario() { + // 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 static void addSantuarioJSR105Provider() { + AccessController.doPrivileged(new PrivilegedAction<Boolean>() { + public Boolean run() { + String providerName = "ApacheXMLDSig"; + Provider currentProvider = Security.getProvider(providerName); + if (currentProvider == null) { + Security.addProvider(new XMLDSigRI()); + } + return true; + } + }); + } + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/camel/blob/e8fb927b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignatureProcessor.java ---------------------------------------------------------------------- diff --git a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignatureProcessor.java b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignatureProcessor.java index 9a425ba..7b50d13 100644 --- a/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignatureProcessor.java +++ b/components/camel-xmlsecurity/src/main/java/org/apache/camel/component/xmlsecurity/processor/XmlSignatureProcessor.java @@ -27,12 +27,10 @@ import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import org.xml.sax.SAXException; - import org.apache.camel.BytesSource; import org.apache.camel.Message; import org.apache.camel.Processor; import org.apache.camel.component.validator.DefaultLSResourceResolver; -import org.apache.camel.component.xmlsecurity.SantuarioUtil; import org.apache.camel.component.xmlsecurity.api.XmlSignatureConstants; import org.apache.camel.component.xmlsecurity.api.XmlSignatureException; import org.apache.camel.converter.IOConverter;