camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aka...@apache.org
Subject svn commit: r1173190 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/model/dataformat/ components/camel-jmx/ components/camel-xmlsecurity/ components/camel-xmlsecurity/src/main/java/org/ap...
Date Tue, 20 Sep 2011 15:24:44 GMT
Author: akarpe
Date: Tue Sep 20 15:24:43 2011
New Revision: 1173190

URL: http://svn.apache.org/viewvc?rev=1173190&view=rev
Log:
CAMEL-4441 Improvement for namespace-awareness in the camel-xmlsecurity component

Added:
    camel/trunk/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/SpringXmlSecurityDataFormatTest.java
    camel/trunk/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/TestHelper.java
    camel/trunk/components/camel-xmlsecurity/src/test/resources/org/
    camel/trunk/components/camel-xmlsecurity/src/test/resources/org/apache/
    camel/trunk/components/camel-xmlsecurity/src/test/resources/org/apache/camel/
    camel/trunk/components/camel-xmlsecurity/src/test/resources/org/apache/camel/dataformat/
    camel/trunk/components/camel-xmlsecurity/src/test/resources/org/apache/camel/dataformat/xmlsecurity/
    camel/trunk/components/camel-xmlsecurity/src/test/resources/org/apache/camel/dataformat/xmlsecurity/SpringXmlSecurityDataFormatTest-context.xml
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XMLSecurityDataFormat.java
    camel/trunk/components/camel-jmx/pom.xml
    camel/trunk/components/camel-xmlsecurity/pom.xml
    camel/trunk/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java
    camel/trunk/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormatTest.java
    camel/trunk/parent/pom.xml

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java?rev=1173190&r1=1173189&r2=1173190&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DataFormatClause.java Tue Sep 20 15:24:43 2011
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.builder;
 
+import java.util.Map;
 import java.util.zip.Deflater;
 
 import org.w3c.dom.Node;
@@ -44,6 +45,7 @@ import org.apache.camel.model.dataformat
 import org.apache.camel.model.dataformat.XMLSecurityDataFormat;
 import org.apache.camel.model.dataformat.XStreamDataFormat;
 import org.apache.camel.model.dataformat.ZipDataFormat;
+import org.apache.camel.util.jsse.KeyStoreParameters;
 
 
 /**
@@ -342,6 +344,14 @@ public class DataFormatClause<T extends 
         XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, secureTagContents);
         return dataFormat(xsdf);
     }
+    
+    /**
+     * Uses the XML Security data format
+     */
+    public T secureXML(String secureTag, Map<String, String> namespaces, boolean secureTagContents) {
+        XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, namespaces, secureTagContents);
+        return dataFormat(xsdf);
+    }
 
     /**
      * Uses the XML Security data format
@@ -350,7 +360,15 @@ public class DataFormatClause<T extends 
         XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, secureTagContents, passPhrase);
         return dataFormat(xsdf);
     }
-
+    
+    /**
+     * Uses the XML Security data format
+     */
+    public T secureXML(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String passPhrase) {
+        XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, namespaces, secureTagContents, passPhrase);
+        return dataFormat(xsdf);
+    }
+    
     /**
      * Uses the XML Security data format
      */
@@ -359,15 +377,67 @@ public class DataFormatClause<T extends 
         return dataFormat(xsdf);
     }
     
+    
     /**
      * Uses the XML Security data format
      */
-    public T secureXML(String secureTag, boolean secureTagContents, String recipientKeyAlias, String xmlCipherAlgorithm, String keyCipherAlgorithm) {
+    public T secureXML(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String passPhrase, String xmlCipherAlgorithm) {
+        XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, namespaces, secureTagContents, passPhrase, xmlCipherAlgorithm);
+        return dataFormat(xsdf);
+    }
+    
+    /**
+     * @deprectaed Use {@link #secureXML(String, Map, boolean, String, String, String, String) instead.
+     * Uses the XML Security data format
+     */
+    @Deprecated
+    public T secureXML(String secureTag, boolean secureTagContents, String recipientKeyAlias, String xmlCipherAlgorithm, 
+            String keyCipherAlgorithm) {
         XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, secureTagContents, recipientKeyAlias, xmlCipherAlgorithm, keyCipherAlgorithm);
         return dataFormat(xsdf);
     }
     
     /**
+     * Uses the XML Security data format
+     */
+    public T secureXML(String secureTag, boolean secureTagContents, String recipientKeyAlias, String xmlCipherAlgorithm, 
+            String keyCipherAlgorithm, String keyOrTrustStoreParametersId) {
+        XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, secureTagContents, recipientKeyAlias, xmlCipherAlgorithm, 
+            keyCipherAlgorithm, keyOrTrustStoreParametersId);
+        return dataFormat(xsdf);
+    }
+    
+    /**
+     * Uses the XML Security data format
+     */
+    public T secureXML(String secureTag, boolean secureTagContents, String recipientKeyAlias, String xmlCipherAlgorithm, 
+            String keyCipherAlgorithm, KeyStoreParameters keyOrTrustStoreParameters) {
+        XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, secureTagContents, recipientKeyAlias, xmlCipherAlgorithm, 
+            keyCipherAlgorithm, keyOrTrustStoreParameters);
+        return dataFormat(xsdf);
+    }
+    
+    /**
+     * Uses the XML Security data format
+     */
+    public T secureXML(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String recipientKeyAlias, 
+            String xmlCipherAlgorithm, String keyCipherAlgorithm, String keyOrTrustStoreParametersId) {
+        XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, namespaces, secureTagContents, recipientKeyAlias, xmlCipherAlgorithm, 
+                keyCipherAlgorithm, keyOrTrustStoreParametersId);
+        return dataFormat(xsdf);
+    }
+    
+    /**
+     * Uses the XML Security data format
+     */
+    public T secureXML(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String recipientKeyAlias, 
+            String xmlCipherAlgorithm, String keyCipherAlgorithm, KeyStoreParameters keyOrTrustStoreParameters) {
+        XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, namespaces, secureTagContents, recipientKeyAlias, xmlCipherAlgorithm, 
+                keyCipherAlgorithm, keyOrTrustStoreParameters);
+        return dataFormat(xsdf);
+    }
+    
+    /**
      * Uses the xmlBeans data format
      */
     public T xmlBeans() {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XMLSecurityDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XMLSecurityDataFormat.java?rev=1173190&r1=1173189&r2=1173190&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XMLSecurityDataFormat.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/dataformat/XMLSecurityDataFormat.java Tue Sep 20 15:24:43 2011
@@ -16,20 +16,26 @@
  */
 package org.apache.camel.model.dataformat;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.camel.model.DataFormatDefinition;
 import org.apache.camel.spi.DataFormat;
+import org.apache.camel.spi.NamespaceAware;
+import org.apache.camel.util.jsse.KeyStoreParameters;
 
 /**
  * Represents as XML Security Encrypter/Decrypter {@link DataFormat}
  */
 @XmlRootElement(name = "secureXML")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class XMLSecurityDataFormat extends DataFormatDefinition {
+public class XMLSecurityDataFormat extends DataFormatDefinition implements NamespaceAware {
 
     private static final transient String TRIPLEDES = "http://www.w3.org/2001/04/xmlenc#tripledes-cbc";
 
@@ -45,8 +51,16 @@ public class XMLSecurityDataFormat exten
     private String keyCipherAlgorithm;
     @XmlAttribute
     private String recipientKeyAlias;
+    @XmlAttribute
+    private String keyOrTrustStoreParametersId;
+    
+    @XmlTransient
+    private KeyStoreParameters keyOrTrustStoreParameters;
+    
+    @XmlTransient
+    private Map<String, String> namespaces;
+    
     
-
     public XMLSecurityDataFormat() {
         super("secureXML");
     }
@@ -56,24 +70,102 @@ public class XMLSecurityDataFormat exten
         this.setSecureTag(secureTag);
         this.setSecureTagContents(secureTagContents);
     }
+    
+    public XMLSecurityDataFormat(String secureTag, Map<String, String> namespaces, boolean secureTagContents) {
+        this();
+        this.setSecureTag(secureTag);
+        this.setSecureTagContents(secureTagContents);
+        this.setNamespaces(namespaces);
+    }
 
     public XMLSecurityDataFormat(String secureTag, boolean secureTagContents, String passPhrase) {
         this(secureTag, secureTagContents);
         this.setPassPhrase(passPhrase);
     }
-
+    
+    public XMLSecurityDataFormat(String secureTag, Map<String, String> namespaces, boolean secureTagContents, 
+                                 String passPhrase) {
+        this(secureTag, secureTagContents);
+        this.setPassPhrase(passPhrase);
+        this.setNamespaces(namespaces);
+    }
+    
     public XMLSecurityDataFormat(String secureTag, boolean secureTagContents, String passPhrase,
                                  String xmlCipherAlgorithm) {
         this(secureTag, secureTagContents, passPhrase);
         this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
     }
+    
+    public XMLSecurityDataFormat(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String passPhrase,
+                                 String xmlCipherAlgorithm) {
+        this(secureTag, secureTagContents, passPhrase);
+        this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
+        this.setNamespaces(namespaces);
+    }
+    
+    /**
+     * @deprecated  use {{@link #XMLSecurityDataFormat(String, boolean, String, String, String, String)} or 
+     *                  {{@link #XMLSecurityDataFormat(String, boolean, String, String, String, KeyStoreParameters)} instead
+     */
+    @Deprecated
+    public XMLSecurityDataFormat(String secureTag, boolean secureTagContents, String recipientKeyAlias,
+            String xmlCipherAlgorithm, String keyCipherAlgorithm) {
+        this(secureTag, secureTagContents);
+        this.setRecipientKeyAlias(recipientKeyAlias);
+        this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
+        this.setKeyCipherAlgorithm(keyCipherAlgorithm);
+    }
 
     public XMLSecurityDataFormat(String secureTag, boolean secureTagContents, String recipientKeyAlias,
-                                 String xmlCipherAlgorithm, String keyCipherAlgorithm) {
+                                 String xmlCipherAlgorithm, String keyCipherAlgorithm, String keyOrTrustStoreParametersId) {
+        this(secureTag, secureTagContents);
+        this.setRecipientKeyAlias(recipientKeyAlias);
+        this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
+        this.setKeyCipherAlgorithm(keyCipherAlgorithm);
+        this.setKeyOrTrustStoreParametersId(keyOrTrustStoreParametersId);
+    }
+    
+    public XMLSecurityDataFormat(String secureTag, boolean secureTagContents, String recipientKeyAlias,
+            String xmlCipherAlgorithm, String keyCipherAlgorithm, KeyStoreParameters keyOrTrustStoreParameters) {
+        this(secureTag, secureTagContents);
+        this.setRecipientKeyAlias(recipientKeyAlias);
+        this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
+        this.setKeyCipherAlgorithm(keyCipherAlgorithm);
+        this.setKeyOrTrustStoreParameters(keyOrTrustStoreParameters);
+    }
+    
+    /**
+     * @deprecated  use {{@link #XMLSecurityDataFormat(String, Map, boolean, String, String, String, String)} or 
+     *                  {{@link #XMLSecurityDataFormat(String, Map, boolean, String, String, String, KeyStoreParameters)} instead
+     */
+    @Deprecated
+    public XMLSecurityDataFormat(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String recipientKeyAlias,
+            String xmlCipherAlgorithm, String keyCipherAlgorithm) {
+        this(secureTag, secureTagContents);
+        this.setRecipientKeyAlias(recipientKeyAlias);
+        this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
+        this.setKeyCipherAlgorithm(keyCipherAlgorithm);
+        this.setNamespaces(namespaces);
+    }
+    
+    public XMLSecurityDataFormat(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String recipientKeyAlias,
+            String xmlCipherAlgorithm, String keyCipherAlgorithm, String keyOrTrustStoreParametersId) {
+        this(secureTag, secureTagContents);
+        this.setRecipientKeyAlias(recipientKeyAlias);
+        this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
+        this.setKeyCipherAlgorithm(keyCipherAlgorithm);
+        this.setNamespaces(namespaces);
+        this.setKeyOrTrustStoreParametersId(keyOrTrustStoreParametersId);
+    }
+
+    public XMLSecurityDataFormat(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String recipientKeyAlias,
+            String xmlCipherAlgorithm, String keyCipherAlgorithm, KeyStoreParameters keyOrTrustStoreParameters) {
         this(secureTag, secureTagContents);
         this.setRecipientKeyAlias(recipientKeyAlias);
         this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
         this.setKeyCipherAlgorithm(keyCipherAlgorithm);
+        this.setNamespaces(namespaces);
+        this.setKeyOrTrustStoreParameters(keyOrTrustStoreParameters);
     }
 
     @Override
@@ -102,6 +194,15 @@ public class XMLSecurityDataFormat exten
         if (getRecipientKeyAlias() != null) {
             setProperty(dataFormat, "recipientKeyAlias", getRecipientKeyAlias());
         }
+        if (getKeyOrTrustStoreParametersId() != null) {
+            setProperty(dataFormat, "keyOrTrustStoreParametersId", getKeyOrTrustStoreParametersId());
+        }
+        if (keyOrTrustStoreParameters != null) {
+            setProperty(dataFormat, "keyOrTrustStoreParameters", this.keyOrTrustStoreParameters);
+        }
+        if (namespaces != null) {
+            setProperty(dataFormat, "namespaces", this.namespaces);
+        }
     }
 
     public String getXmlCipherAlgorithm() {
@@ -155,4 +256,26 @@ public class XMLSecurityDataFormat exten
     public String getRecipientKeyAlias() {
         return recipientKeyAlias;
     }
+    
+    public void setKeyOrTrustStoreParametersId(String id) {
+        this.keyOrTrustStoreParametersId = id;
+    }
+    
+    public String getKeyOrTrustStoreParametersId() {
+        return this.keyOrTrustStoreParametersId;
+    }
+    
+    private void setKeyOrTrustStoreParameters(KeyStoreParameters keyOrTrustStoreParameters) {
+        this.keyOrTrustStoreParameters = keyOrTrustStoreParameters;
+        
+    }
+
+    @Override
+    public void setNamespaces(Map<String, String> nspaces) {
+        if (this.namespaces == null) {
+            this.namespaces = new HashMap<String, String>();
+        }
+        this.namespaces.putAll(nspaces);
+    }
+    
 }

Modified: camel/trunk/components/camel-jmx/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jmx/pom.xml?rev=1173190&r1=1173189&r2=1173190&view=diff
==============================================================================
--- camel/trunk/components/camel-jmx/pom.xml (original)
+++ camel/trunk/components/camel-jmx/pom.xml Tue Sep 20 15:24:43 2011
@@ -61,7 +61,7 @@
         <dependency>
             <groupId>xmlunit</groupId>
             <artifactId>xmlunit</artifactId>
-            <version>1.3</version>
+            <version>${xmlunit-version}</version>
             <scope>test</scope>
         </dependency>
     </dependencies>

Modified: camel/trunk/components/camel-xmlsecurity/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-xmlsecurity/pom.xml?rev=1173190&r1=1173189&r2=1173190&view=diff
==============================================================================
--- camel/trunk/components/camel-xmlsecurity/pom.xml (original)
+++ camel/trunk/components/camel-xmlsecurity/pom.xml Tue Sep 20 15:24:43 2011
@@ -35,7 +35,6 @@
     </properties>
 
     <dependencies>
-
         <dependency>
             <groupId>org.apache.camel</groupId>
             <artifactId>camel-core</artifactId>
@@ -50,12 +49,6 @@
             <artifactId>xalan</artifactId>
             <version>${xalan-version}</version>
         </dependency>
-        <dependency>
-            <groupId>xerces</groupId>
-            <artifactId>xercesImpl</artifactId>
-            <version>${xerces-version}</version>
-        </dependency>
-
         <!-- testing -->
         <dependency>
             <groupId>org.apache.camel</groupId>
@@ -72,7 +65,17 @@
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
- 
+        <dependency>
+            <groupId>xmlunit</groupId>
+            <artifactId>xmlunit</artifactId>
+            <version>${xmlunit-version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+            <scope>test</scope>
+        </dependency>        
     </dependencies>
 
 </project>

Modified: camel/trunk/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java?rev=1173190&r1=1173189&r2=1173190&view=diff
==============================================================================
--- camel/trunk/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java (original)
+++ camel/trunk/components/camel-xmlsecurity/src/main/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormat.java Tue Sep 20 15:24:43 2011
@@ -40,29 +40,63 @@ import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
-import org.w3c.dom.traversal.NodeIterator;
 
 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.ExchangeHelper;
 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.xpath.XPathAPI;
+
 
 public class XMLSecurityDataFormat implements DataFormat, CamelContextAware {
 
+    /**
+     * @deprecated  Use {@link #XMLSecurityDataFormat(String, Map, boolean, String, String, String, KeyStoreParameters)} instead.
+     */
+    @Deprecated
     public static final String XML_ENC_RECIPIENT_ALIAS = "CamelXmlEncryptionRecipientAlias";
+    
+    /**
+     * @deprecated  Use {@link #XMLSecurityDataFormat(String, Map, boolean, String, String, String, KeyStoreParameters)} instead.
+     */
+    @Deprecated
     public static final String XML_ENC_TRUST_STORE_URL = "CamelXmlEncryptionTrustStoreUrl";
+    
+    /**
+     * @deprecated  Use {@link #XMLSecurityDataFormat(String, Map, boolean, String, String, String, KeyStoreParameters)} instead.
+     */
+    @Deprecated
     public static final String XML_ENC_TRUST_STORE_PASSWORD = "CamelXmlEncryptionTrustStorePassword";
+    
+    /**
+     * @deprecated  Use {@link #XMLSecurityDataFormat(String, Map, boolean, String, String, String, KeyStoreParameters)} instead.
+     */                 
+    @Deprecated
     public static final String XML_ENC_KEY_STORE_URL = "CamelXmlEncryptionKeyStoreUrl";
+    
+    /**
+     * @deprecated  Use {@link #XMLSecurityDataFormat(String, Map, boolean, String, String, String, KeyStoreParameters)} instead.
+     */
+    @Deprecated
     public static final String XML_ENC_KEY_STORE_PASSWORD = "CamelXmlEncryptionKeyStorePassword";
+    
+    /**
+     * @deprecated  Use {@link #XMLSecurityDataFormat(String, Map, boolean, String, String, String, KeyStoreParameters)} instead.
+     */
+    @Deprecated
     public static final String XML_ENC_KEY_STORE_ALIAS = "CamelXmlEncryptionKeyAlias";
+        
 
     private String xmlCipherAlgorithm;
     private String keyCipherAlgorithm;
@@ -73,12 +107,16 @@ public class XMLSecurityDataFormat imple
     
     private KeyStore keyStore;
     private KeyStore trustStore;
-    private String keyStoreAlias;
+
     private String keyStorePassword;
     private String trustStorePassword;
     private String recipientKeyAlias;
     
+    private KeyStoreParameters keyOrTrustStoreParameters;
+    private String keyOrTrustStoreParametersId;
+    
     private CamelContext camelContext;
+    private DefaultNamespaceContext nsContext = new DefaultNamespaceContext();
         
 
     public XMLSecurityDataFormat() {
@@ -95,6 +133,13 @@ public class XMLSecurityDataFormat imple
         this.setSecureTag(secureTag);
         this.setSecureTagContents(secureTagContents);
     }
+    
+    public XMLSecurityDataFormat(String secureTag, Map<String, String> namespaces, boolean secureTagContents) {
+        this();
+        this.setSecureTag(secureTag);
+        this.setSecureTagContents(secureTagContents);
+        this.setNamespaces(namespaces);
+    }
 
     public XMLSecurityDataFormat(String secureTag, boolean secureTagContents, byte[] passPhrase) {
         this();
@@ -102,6 +147,14 @@ public class XMLSecurityDataFormat imple
         this.setSecureTagContents(secureTagContents);
         this.setPassPhrase(passPhrase);
     }
+    
+    public XMLSecurityDataFormat(String secureTag, Map<String, String> namespaces, boolean secureTagContents, byte[] passPhrase) {
+        this();
+        this.setSecureTag(secureTag);
+        this.setSecureTagContents(secureTagContents);
+        this.setPassPhrase(passPhrase);
+        this.setNamespaces(namespaces);
+    }
 
     public XMLSecurityDataFormat(String secureTag, boolean secureTagContents, byte[] passPhrase, 
                                  String xmlCipherAlgorithm) {
@@ -112,6 +165,11 @@ public class XMLSecurityDataFormat imple
         this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
     }
     
+    /**
+     * @deprecated  use {@link #XMLSecurityDataFormat(String, Map, boolean, String, String, String, String)} or
+     *                  {@link #XMLSecurityDataFormat(String, Map, boolean, String, String, String, KeyStoreParameters)} instead. 
+     */
+    @Deprecated
     public XMLSecurityDataFormat(String secureTag, boolean secureTagContents, String xmlCipherAlgorithm, 
             String keyCipherAlgorithm) {
         this();
@@ -120,21 +178,76 @@ public class XMLSecurityDataFormat imple
         this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
         this.setKeyCipherAlgorithm(keyCipherAlgorithm);
     }
+            
+    /**
+     * @deprecated  use {@link #XMLSecurityDataFormat(String, Map, boolean, String, String, String, String)} or
+     *                  {@link #XMLSecurityDataFormat(String, Map, boolean, String, String, String, KeyStoreParameters)} instead.  
+     */
+    @Deprecated
+    public XMLSecurityDataFormat(String secureTag, boolean secureTagContents, String recipientKeyAlias, 
+            String xmlCipherAlgorithm, String keyCipherAlgorithm) {
+        this();
+        this.setSecureTag(secureTag);
+        this.setSecureTagContents(secureTagContents);
+        this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
+        this.setRecipientKeyAlias(recipientKeyAlias);
+        this.setKeyCipherAlgorithm(keyCipherAlgorithm);
+    }
       
     public XMLSecurityDataFormat(String secureTag, boolean secureTagContents, String recipientKeyAlias, 
-                                 String xmlCipherAlgorithm, String keyCipherAlgorithm) {
+                                 String xmlCipherAlgorithm, String keyCipherAlgorithm, String keyOrTrustStoreParametersId) {
+        this();
+        this.setSecureTag(secureTag);
+        this.setSecureTagContents(secureTagContents);
+        this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
+        this.setRecipientKeyAlias(recipientKeyAlias);
+        this.setKeyCipherAlgorithm(keyCipherAlgorithm);
+        this.setKeyOrTrustStoreParametersId(keyOrTrustStoreParametersId);
+    }
+        
+    public XMLSecurityDataFormat(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String recipientKeyAlias, 
+            String xmlCipherAlgorithm, String keyCipherAlgorithm, String keyOrTrustStoreParametersId) {
+        this();
+        this.setSecureTag(secureTag);
+        this.setSecureTagContents(secureTagContents);
+        this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
+        this.setRecipientKeyAlias(recipientKeyAlias);
+        this.setKeyCipherAlgorithm(keyCipherAlgorithm);
+        this.setNamespaces(namespaces);
+        if (null != keyOrTrustStoreParametersId && !keyOrTrustStoreParametersId.equals("")) {
+            this.keyOrTrustStoreParametersId = keyOrTrustStoreParametersId;
+        }
+    }
+    
+    public XMLSecurityDataFormat(String secureTag, boolean secureTagContents, String recipientKeyAlias, 
+            String xmlCipherAlgorithm, String keyCipherAlgorithm, KeyStoreParameters keyOrTrustStoreParameters) {
+        this();
+        this.setSecureTag(secureTag);
+        this.setSecureTagContents(secureTagContents);
+        this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
+        this.setRecipientKeyAlias(recipientKeyAlias);
+        this.setKeyCipherAlgorithm(keyCipherAlgorithm);
+        this.setKeyOrTrustStoreParameters(keyOrTrustStoreParameters);
+    }
+
+    public XMLSecurityDataFormat(String secureTag, Map<String, String> namespaces, boolean secureTagContents, String recipientKeyAlias, 
+            String xmlCipherAlgorithm, String keyCipherAlgorithm, KeyStoreParameters keyOrTrustStoreParameters) {
         this();
         this.setSecureTag(secureTag);
         this.setSecureTagContents(secureTagContents);
         this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
         this.setRecipientKeyAlias(recipientKeyAlias);
         this.setKeyCipherAlgorithm(keyCipherAlgorithm);
+        this.setNamespaces(namespaces);
+        this.setKeyOrTrustStoreParameters(keyOrTrustStoreParameters);
     }
     
     @Override
     public void setCamelContext(CamelContext camelContext) {
+        this.camelContext = camelContext;
         try {
             setDefaultsFromContext(camelContext);
+
         } catch (Exception e) {
             throw new IllegalStateException("Could not initialize XMLSecurityDataFormat with camelContext. ", e);
         }
@@ -147,14 +260,18 @@ public class XMLSecurityDataFormat imple
     
     /**
      * Sets missing properties that are defined in the Camel context.
+     * @deprecated  this operation populates the data format using depreciated properties and will be
+     *              removed at the end of the deprecation period
      */
+    @Deprecated
     private void setDefaultsFromContext(CamelContext context) throws Exception {
+
         Map<String, String> contextProps = context.getProperties();
-        
+               
         if (this.recipientKeyAlias == null) {
             recipientKeyAlias = contextProps.get(XML_ENC_RECIPIENT_ALIAS);
         }
-        
+
         if (this.trustStore == null && contextProps.containsKey(XML_ENC_TRUST_STORE_URL)) {
             trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
             URL trustStoreUrl = new URL(contextProps.get(XML_ENC_TRUST_STORE_URL));
@@ -170,14 +287,15 @@ public class XMLSecurityDataFormat imple
             if (keyStorePassword == null) {
                 keyStorePassword = contextProps.get(XML_ENC_KEY_STORE_PASSWORD);
             }
-            keyStore.load(keyStoreUrl.openStream(), keyStorePassword.toCharArray());
+            keyStore.load(keyStoreUrl.openStream(), keyStorePassword.toCharArray());    
         }
         
-        if (this.keyStoreAlias == null) {
-            keyStoreAlias = contextProps.get(XML_ENC_KEY_STORE_ALIAS);
+        if (context.getProperties().containsKey(XML_ENC_KEY_STORE_ALIAS) && this.recipientKeyAlias == null) {
+            recipientKeyAlias = contextProps.get(XML_ENC_KEY_STORE_ALIAS);
         }
     }
     
+    
     public void marshal(Exchange exchange, Object graph, OutputStream stream) throws Exception {
         // Retrieve the message body as input stream
         InputStream is = exchange.getContext().getTypeConverter().mandatoryConvertTo(InputStream.class, graph);
@@ -209,6 +327,11 @@ public class XMLSecurityDataFormat imple
         if (null == exchangeRecipientAlias) {
             throw new IllegalStateException("The  recipient's key alias must be defined for asymmetric key encryption.");
         }
+        
+        if (trustStore == null && null != this.keyOrTrustStoreParameters) {
+            trustStore = keyOrTrustStoreParameters.createKeyStore();
+            trustStorePassword = keyOrTrustStoreParameters.getPassword();
+        }
 
         if (null == trustStore) {
             throw new IllegalStateException("A trust store must be defined for asymmetric key encryption.");
@@ -290,13 +413,19 @@ public class XMLSecurityDataFormat imple
             embedKeyInfoInEncryptedData(document, keyCipher, xmlCipher, dataEncryptionKey);
             document = xmlCipher.doFinal(document, document.getDocumentElement());
         } else {
-            NodeIterator iter = XPathAPI.selectNodeIterator(document, secureTag);
-            Node node;
-            while ((node = iter.nextNode()) != null) {
-                embedKeyInfoInEncryptedData(document, keyCipher, xmlCipher, dataEncryptionKey);
-                Document temp = xmlCipher.doFinal(document, (Element) node, getSecureTagContents());
+                          
+            XPathBuilder xpathBuilder = new XPathBuilder(secureTag);
+            xpathBuilder.setNamespaceContext(getNamespaceContext());
+            NodeList nodeList = xpathBuilder.evaluate(exchange, NodeList.class);
+            
+            
+            for (int i = 0; i < nodeList.getLength(); i++) {
+                Node node = nodeList.item(i);
+                document = node.getOwnerDocument();
+                embedKeyInfoInEncryptedData(node.getOwnerDocument(), keyCipher, xmlCipher, dataEncryptionKey);
+                Document temp = xmlCipher.doFinal(node.getOwnerDocument(), (Element) node, getSecureTagContents());
                 document.importNode(temp.getDocumentElement().cloneNode(true), true);
-            }
+            }    
         }
 
         try {
@@ -308,6 +437,7 @@ public class XMLSecurityDataFormat imple
         }
     }
     
+    
     public Object unmarshal(Exchange exchange, Document document) throws Exception {
         InputStream is = ExchangeHelper.getMandatoryInBody(exchange, InputStream.class);
         return unmarshal(exchange, is);
@@ -337,12 +467,18 @@ public class XMLSecurityDataFormat imple
         return decode(exchange, encodedDocument, keyEncryptionKey);
     }
     
-    private Object decodeWithAsymmetricKey(Exchange exchange, Document encodedDocument) throws Exception {        
+    private Object decodeWithAsymmetricKey(Exchange exchange, Document encodedDocument) throws Exception { 
+        
+        if (keyStore == null && null != keyOrTrustStoreParameters) {
+            keyStore = keyOrTrustStoreParameters.createKeyStore();
+            keyStorePassword = keyOrTrustStoreParameters.getPassword();
+        }
+        
         if (this.keyStore ==  null) {
             throw new IllegalStateException("A key store must be defined for asymmetric key decryption.");
         }
         
-        Key keyEncryptionKey = getPrivateKey(this.keyStore, this.keyStoreAlias, this.keyStorePassword);
+        Key keyEncryptionKey = getPrivateKey(this.keyStore, this.recipientKeyAlias, this.keyStorePassword);
         return decode(exchange, encodedDocument, keyEncryptionKey);
     }
     
@@ -354,17 +490,22 @@ public class XMLSecurityDataFormat imple
         if (secureTag.equalsIgnoreCase("")) {
             encodedDocument = xmlCipher.doFinal(encodedDocument, encodedDocument.getDocumentElement());
         } else {
-            NodeIterator iter =
-                XPathAPI.selectNodeIterator(encodedDocument, secureTag);
-            Node node;
-            while ((node = iter.nextNode()) != null) {
+
+            XPathBuilder xpathBuilder = new XPathBuilder(secureTag);
+            xpathBuilder.setNamespaceContext(getNamespaceContext());
+            NodeList nodeList = xpathBuilder.evaluate(exchange, NodeList.class);
+
+
+            for (int i = 0; i < nodeList.getLength(); i++) {
+                Node node = nodeList.item(i);
+                encodedDocument = node.getOwnerDocument();
                 if (getSecureTagContents()) {
                     Document temp = xmlCipher.doFinal(encodedDocument, (Element) node, true);
                     encodedDocument.importNode(temp.getDocumentElement().cloneNode(true), true);
                 } else {
                     NodeList childNodes = node.getChildNodes();
-                    for (int i = 0; i < childNodes.getLength(); i++) {
-                        Node childNode = childNodes.item(i);
+                    for (int j = 0; j < childNodes.getLength(); j++) {
+                        Node childNode = childNodes.item(j);
                         if (childNode.getLocalName().equals("EncryptedData")) {
                             Document temp = xmlCipher.doFinal(encodedDocument, (Element) childNode, false);
                             encodedDocument.importNode(temp.getDocumentElement().cloneNode(true), true);
@@ -462,6 +603,10 @@ public class XMLSecurityDataFormat imple
         }
         return alias;
     }
+     
+    private DefaultNamespaceContext getNamespaceContext() {
+        return this.nsContext;
+    };
 
     public String getXmlCipherAlgorithm() {
         return xmlCipherAlgorithm;
@@ -502,7 +647,7 @@ public class XMLSecurityDataFormat imple
     public void setSecureTag(String secureTag) {
         this.secureTag = secureTag;
     }
-
+    
     public boolean isSecureTagContents() {
         return secureTagContents;
     }
@@ -515,43 +660,118 @@ public class XMLSecurityDataFormat imple
         this.secureTagContents = secureTagContents;
     }
     
+    /**
+     * Gets the KeyStore configured for this data format.
+     * @deprecated  Will change to private access in the future.
+     */
+    @Deprecated
     public KeyStore getKeyStore() {
+        if (keyStore == null && this.keyOrTrustStoreParameters != null) {
+            try {
+                keyStore = keyOrTrustStoreParameters.createKeyStore();
+            } catch (Exception e) {
+                throw new RuntimeException("Unable to create KeyStore with configured KeyStoreParameters. " + e.getMessage(), e);
+            }
+        }
         return this.keyStore;
     }
     
+    /**
+     * @deprecated  Use {@link #getKeyOrTrustStoreParameters()} instead.
+     */
+    @Deprecated  
     public void setKeyStore(KeyStore keyStore) {
         this.keyStore = keyStore;
     }
          
+    /**
+     * @deprecated  Will change to private access in the future. Use {@link #getKeyOrTrustStoreParameters()} instead.
+     */
+    @Deprecated
     public KeyStore getTrustStore() {
+        if (trustStore == null && this.keyOrTrustStoreParameters != null) {
+            try {
+                trustStore = keyOrTrustStoreParameters.createKeyStore();
+            } catch (Exception e) {
+                throw new RuntimeException("Unable to create KeyStore with configured KeyStoreParameters. " + e.getMessage(), e);
+            }
+        }
         return this.trustStore;
     }
     
+    /**
+     * @deprecated  Use {@link #setKeyOrTrustStoreParameters()} instead.
+     */
+    @Deprecated  
     public void setTrustStore(KeyStore trustStore) {
         this.trustStore = trustStore;
     }
-    
-    public String getKeyStoreAlias() {
-        return this.keyStoreAlias;
-    }
-    
-    public void setKeyStoreAlias(String keyStoreAlias) {
-        this.keyStoreAlias = keyStoreAlias;
-    }
-    
+      
+    /**
+     * @deprecated  Will change to private access in the future. Use {@link #getKeyOrTrustStoreParameters()} instead.
+     */
+    @Deprecated
     public String getKeyStorePassword() {
+        if (this.keyOrTrustStoreParameters != null) {
+            return keyOrTrustStoreParameters.getPassword();
+        }
         return this.keyStorePassword;
     }
     
+    /**
+     * @deprecated  Use {@link #setKeyOrTrustStoreParameters()} instead.
+     */
+    @Deprecated
     public void setKeyStorePassword(String keyStorePassword) {
         this.keyStorePassword = keyStorePassword;
     }
     
-    public String getTrustStorePassowrd() {
+    /**
+     * @deprecated  Will change to private access in the future.  Use {@link #setKeyOrTrustStoreParameters()} instead.
+     */
+    @Deprecated
+    public String getTrustStorePassword() {
+        if (this.keyOrTrustStoreParameters != null) {
+            return keyOrTrustStoreParameters.getPassword();
+        }
         return this.trustStorePassword;
     }
     
+    /**
+     * @deprecated  Use {@link #setKeyOrTrustStoreParameters()} instead.
+     */
+    @Deprecated
     public void setTrustStorePassword(String trustStorePassword) {
         this.trustStorePassword = trustStorePassword;
     }
+    
+    public void setKeyOrTrustStoreParameters(KeyStoreParameters parameters) {
+        this.keyOrTrustStoreParameters = parameters;
+    }
+    
+    public KeyStoreParameters getKeyOrTrustStoreParameters() {
+        return this.keyOrTrustStoreParameters;
+    }
+    
+    public void setKeyOrTrustStoreParametersId(String registryId) {
+        this.keyOrTrustStoreParametersId = registryId;
+        if (camelContext != null) {
+            Object parametersObj = camelContext.getRegistry().lookup(this.keyOrTrustStoreParametersId);
+            if (parametersObj instanceof KeyStoreParameters) {
+                this.keyOrTrustStoreParameters = (KeyStoreParameters)parametersObj;
+            } else {
+                throw new IllegalStateException("Could not initialize XMLSecurityDataFormat with camelContext." 
+                        + "The id for the keyOrTrustStoreParameters specified [ " + keyOrTrustStoreParametersId 
+                        + " ] does not identify a KeyStoreParameters bean.");
+            }
+        } 
+    }
+    
+    public String getKeyOrTrustStoreParametersId() {
+        return this.keyOrTrustStoreParametersId;
+    }
+
+    public void setNamespaces(Map<String, String> namespaces) {
+        getNamespaceContext().setNamespaces(namespaces);
+    }
 }

Added: camel/trunk/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/SpringXmlSecurityDataFormatTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/SpringXmlSecurityDataFormatTest.java?rev=1173190&view=auto
==============================================================================
--- camel/trunk/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/SpringXmlSecurityDataFormatTest.java (added)
+++ camel/trunk/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/SpringXmlSecurityDataFormatTest.java Tue Sep 20 15:24:43 2011
@@ -0,0 +1,52 @@
+/**
+ * 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.dataformat.xmlsecurity;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration
+public class SpringXmlSecurityDataFormatTest implements CamelContextAware {
+    
+    CamelContext camelContext;
+    
+    TestHelper testHelper = new TestHelper();
+    
+   
+    @Test
+    public void testPartialPayloadAsymmetricKeyDecryptionCustomNS() throws Exception {
+        testHelper.testDecryption(TestHelper.NS_XML_FRAGMENT, camelContext);
+    }
+
+
+    @Override
+    public void setCamelContext(CamelContext camelContext) {
+        this.camelContext = camelContext;
+    }
+
+
+    @Override
+    public CamelContext getCamelContext() {
+        return camelContext;
+    }
+    
+}

Added: camel/trunk/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/TestHelper.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/TestHelper.java?rev=1173190&view=auto
==============================================================================
--- camel/trunk/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/TestHelper.java (added)
+++ camel/trunk/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/TestHelper.java Tue Sep 20 15:24:43 2011
@@ -0,0 +1,169 @@
+/**
+ * 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.dataformat.xmlsecurity;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.converter.jaxp.XmlConverter;
+import org.apache.log4j.Logger;
+import org.apache.xml.security.encryption.XMLCipher;
+import org.apache.xml.security.encryption.XMLEncryptionException;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLUnit;
+
+import org.junit.Assert;
+
+public class TestHelper {
+    
+    protected static final String NS_XML_FRAGMENT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+        + "<ns1:cheesesites xmlns:ns1=\"http://cheese.xmlsecurity.camel.apache.org/\">" 
+        + "<netherlands>"
+        + "<source>cow</source>"
+        + "<cheese>gouda</cheese>"
+        + "</netherlands>"
+        + "<italy>"
+        + "<source>cow</source>"
+        + "<cheese>gorgonzola</cheese>"
+        + "</italy>"
+        + "<france>"
+        + "<source>goat</source>"
+        + "<cheese>brie</cheese>"
+        + "</france>"
+        + "</ns1:cheesesites>";
+    
+    protected static final String XML_FRAGMENT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+        + "<cheesesites>"
+        + "<netherlands>"
+        + "<source>cow</source>"
+        + "<cheese>gouda</cheese>"
+        + "</netherlands>"
+        + "<italy>"
+        + "<source>cow</source>"
+        + "<cheese>gorgonzola</cheese>"
+        + "</italy>"
+        + "<france>"
+        + "<source>goat</source>"
+        + "<cheese>brie</cheese>"
+        + "</france>"
+        + "</cheesesites>";
+    
+    static final boolean HAS_3DES;
+    static {
+        boolean ok = false;
+        try {
+            org.apache.xml.security.Init.init();
+            XMLCipher.getInstance(XMLCipher.TRIPLEDES_KeyWrap);
+            ok = true;
+        } catch (XMLEncryptionException e) {
+            e.printStackTrace();
+        }
+        HAS_3DES = ok;
+    }
+    
+    Logger log = Logger.getLogger(TestHelper.class);
+
+    protected void sendText(final String fragment, CamelContext context) throws Exception {
+        ProducerTemplate template = context.createProducerTemplate();
+        template.start();
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                // Set the property of the charset encoding
+                exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
+                Message in = exchange.getIn();
+                in.setBody(fragment);
+                log.info("xmlFragment: " + fragment);
+            }
+        });
+    }
+      
+    protected void testEncryption(String fragment, CamelContext context) throws Exception {
+        MockEndpoint resultEndpoint = context.getEndpoint("mock:encrypted", MockEndpoint.class);
+        resultEndpoint.setExpectedMessageCount(1);
+        context.start();
+        sendText(fragment, context);
+        resultEndpoint.assertIsSatisfied(100);
+        Exchange exchange = resultEndpoint.getExchanges().get(0);
+        Document inDoc = getDocumentForInMessage(exchange);
+        if (log.isDebugEnabled()) {
+            logMessage(exchange, inDoc);
+        }
+        Assert.assertTrue("The XML message has no encrypted data.", hasEncryptedData(inDoc));
+    }
+    
+
+    protected void testEncryption(CamelContext context) throws Exception {
+        testEncryption(XML_FRAGMENT, context);
+    }
+    
+    
+    protected void testDecryption(String fragment, CamelContext context) throws Exception {
+        MockEndpoint resultEndpoint = context.getEndpoint("mock:decrypted", MockEndpoint.class);
+        resultEndpoint.setExpectedMessageCount(1);
+        // verify that the message was encrypted before checking that it is decrypted
+        testEncryption(fragment, context);
+
+        resultEndpoint.assertIsSatisfied(100);
+        Exchange exchange = resultEndpoint.getExchanges().get(0);
+        Document inDoc = getDocumentForInMessage(exchange);
+        if (log.isDebugEnabled()) {
+            logMessage(exchange, inDoc);
+        }
+        Assert.assertFalse("The XML message has encrypted data.", hasEncryptedData(inDoc));
+        
+        // verify that the decrypted message matches what was sent
+        Document fragmentDoc = createDocumentfromInputStream(new ByteArrayInputStream(fragment.getBytes()), context);
+        Diff xmlDiff = XMLUnit.compareXML(fragmentDoc, inDoc);
+        
+        Assert.assertTrue("The decrypted document does not match the control document.", xmlDiff.identical());            
+    }
+    
+    protected void testDecryption(CamelContext context) throws Exception {
+        testDecryption(XML_FRAGMENT, context);
+    }
+    
+    private boolean hasEncryptedData(Document doc) throws Exception {
+        NodeList nodeList = doc.getElementsByTagNameNS("http://www.w3.org/2001/04/xmlenc#", "EncryptedData");
+        return nodeList.getLength() > 0;
+    }
+    
+    private void logMessage(Exchange exchange, Document inDoc) throws Exception {
+        XmlConverter converter = new XmlConverter();
+        String xmlStr = converter.toString(inDoc, exchange);
+        log.debug(xmlStr);   
+    }
+    
+    private Document getDocumentForInMessage(Exchange exchange) {
+        byte[] body = exchange.getIn().getBody(byte[].class);
+        Document d = createDocumentfromInputStream(new ByteArrayInputStream(body), exchange.getContext());
+        return d;
+    }
+    
+    private Document createDocumentfromInputStream(InputStream is, CamelContext context) {
+        return context.getTypeConverter().convertTo(Document.class, is);
+    }
+
+}

Modified: camel/trunk/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormatTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormatTest.java?rev=1173190&r1=1173189&r2=1173190&view=diff
==============================================================================
--- camel/trunk/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormatTest.java (original)
+++ camel/trunk/components/camel-xmlsecurity/src/test/java/org/apache/camel/dataformat/xmlsecurity/XMLSecurityDataFormatTest.java Tue Sep 20 15:24:43 2011
@@ -16,62 +16,32 @@
  */
 package org.apache.camel.dataformat.xmlsecurity;
 
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
 import java.net.URL;
 import java.security.KeyStore;
+import java.util.HashMap;
 import java.util.Map;
 
-import javax.crypto.Cipher;
 import javax.xml.transform.OutputKeys;
 
-import org.w3c.dom.Document;
-import org.w3c.dom.NodeList;
-
 import org.apache.camel.Exchange;
-import org.apache.camel.Message;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.jaxp.XmlConverter;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.test.CamelTestSupport;
+import org.apache.camel.util.jsse.KeyStoreParameters;
 import org.apache.xml.security.encryption.XMLCipher;
-import org.apache.xml.security.encryption.XMLEncryptionException;
 import org.junit.Test;
 
 /**
  * Unit test of the encryptXML data format.
  */
 public class XMLSecurityDataFormatTest extends CamelTestSupport {
-    private static final boolean HAS_3DES;
-    static {
-        boolean ok = false;
-        try {
-            XMLCipher.getInstance(XMLCipher.TRIPLEDES_KeyWrap);
-            ok = true;
-        } catch (XMLEncryptionException e) {
-        }
-        HAS_3DES = ok;
-    }
-    
-    private static final String XML_FRAGMENT = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-        + "<cheesesites>"
-        + "<netherlands>"
-        + "<source>cow</source>"
-        + "<cheese>gouda</cheese>"
-        + "</netherlands>"
-        + "<italy>"
-        + "<source>cow</source>"
-        + "<cheese>gorgonzola</cheese>"
-        + "</italy>"
-        + "<france>"
-        + "<source>goat</source>"
-        + "<cheese>brie</cheese>"
-        + "</france>"
-        + "</cheesesites>";
     
     // one could use testCypherAlgorithm = XMLCipher.AES_128 if she had the AES Optional Pack installed
-    private String testCypherAlgorithm = XMLCipher.AES_128;
+    protected static String testCypherAlgorithm = XMLCipher.AES_128;
+    
+    TestHelper xmlsecTestHelper = new TestHelper();
 
     @Override
     public boolean isUseRouteBuilder() {
@@ -83,81 +53,15 @@ public class XMLSecurityDataFormatTest e
         super.setUp();
         context.getProperties().put(XmlConverter.OUTPUT_PROPERTIES_PREFIX + OutputKeys.ENCODING, "UTF-8");
     }
-
-    private void sendText() throws Exception {
-        template.send("direct:start", new Processor() {
-            public void process(Exchange exchange) throws Exception {
-                // Set the property of the charset encoding
-                exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
-                Message in = exchange.getIn();
-                in.setBody(XML_FRAGMENT);
-                log.info("xmlFragment: " + XML_FRAGMENT);
-            }
-        });
-    }
     
-    private void testEncryption() throws Exception {
-        MockEndpoint resultEndpoint = context.getEndpoint("mock:encrypted", MockEndpoint.class);
-        resultEndpoint.setExpectedMessageCount(1);
-        context.start();
-        sendText();
-        resultEndpoint.assertIsSatisfied(100);
-        Exchange exchange = resultEndpoint.getExchanges().get(0);
-        Document inDoc = getDocumentForInMessage(exchange);
-        if (log.isDebugEnabled()) {
-            logMessage(exchange, inDoc);
-        }
-        assertTrue("The XML message has no encrypted data.", hasEncryptedData(inDoc));
-    }
     
-    private void testDecryption() throws Exception {
-        MockEndpoint resultEndpoint = context.getEndpoint("mock:decrypted", MockEndpoint.class);
-        resultEndpoint.setExpectedMessageCount(1);
-        // verify that the message was encrypted before checking that it is decrypted
-        testEncryption();
-
-        resultEndpoint.assertIsSatisfied(100);
-        Exchange exchange = resultEndpoint.getExchanges().get(0);
-        Document inDoc = getDocumentForInMessage(exchange);
-        if (log.isDebugEnabled()) {
-            logMessage(exchange, inDoc);
-        }
-        assertFalse("The XML message has encrypted data.", hasEncryptedData(inDoc));
-        
-        // verify that the decrypted message matches what was sent
-        XmlConverter converter = new XmlConverter();
-        String xmlStr = converter.toString(inDoc, exchange);
-        assertTrue(xmlStr.equals(XML_FRAGMENT));
-    }
-    
-    private boolean hasEncryptedData(Document doc) throws Exception {
-        NodeList nodeList = doc.getElementsByTagNameNS("http://www.w3.org/2001/04/xmlenc#", "EncryptedData");
-        return nodeList.getLength() > 0;
-    }
-    
-    private void logMessage(Exchange exchange, Document inDoc) throws Exception {
-        XmlConverter converter = new XmlConverter();
-        String xmlStr = converter.toString(inDoc, exchange);
-        log.debug(xmlStr);   
-    }
-    
-    private Document getDocumentForInMessage(Exchange exchange) {
-        byte[] body = exchange.getIn().getBody(byte[].class);
-        Document d = createDocumentfromInputStream(new ByteArrayInputStream(body));
-        return d;
-    }
-    
-    private Document createDocumentfromInputStream(InputStream is) {
-        return context.getTypeConverter().convertTo(Document.class, is);
-    }
-
     /*
      * Encryption Tests
      */
     
     @Test
     public void testFullPayloadXMLEncryption() throws Exception {
-        if (!HAS_3DES) {
+        if (!TestHelper.HAS_3DES) {
             return;
         }
         context.addRoutes(new RouteBuilder() {
@@ -167,12 +71,12 @@ public class XMLSecurityDataFormatTest e
                     .to("mock:encrypted");
             }
         });
-        testEncryption();
+        xmlsecTestHelper.testEncryption(context);
     }
 
     @Test
     public void testPartialPayloadXMLContentEncryption() throws Exception {       
-        if (!HAS_3DES) {
+        if (!TestHelper.HAS_3DES) {
             return;
         }
         context.addRoutes(new RouteBuilder() {
@@ -182,12 +86,12 @@ public class XMLSecurityDataFormatTest e
                     .to("mock:encrypted");
             }
         });
-        testEncryption();
+        xmlsecTestHelper.testEncryption(context);
     }
 
     @Test
     public void testPartialPayloadMultiNodeXMLContentEncryption() throws Exception {
-        if (!HAS_3DES) {
+        if (!TestHelper.HAS_3DES) {
             return;
         }
         context.addRoutes(new RouteBuilder() {
@@ -197,12 +101,12 @@ public class XMLSecurityDataFormatTest e
                      .to("mock:encrypted");
             }
         });
-        testEncryption();
+        xmlsecTestHelper.testEncryption(context);
     }
 
     @Test
     public void testPartialPayloadXMLElementEncryptionWithKey() throws Exception {
-        if (!HAS_3DES) {
+        if (!TestHelper.HAS_3DES) {
             return;
         }
         context.addRoutes(new RouteBuilder() {
@@ -212,7 +116,7 @@ public class XMLSecurityDataFormatTest e
                      .to("mock:encrypted");
             }    
         });
-        testEncryption();
+        xmlsecTestHelper.testEncryption(context);
     }
 
     @Test
@@ -231,7 +135,7 @@ public class XMLSecurityDataFormatTest e
                     .to("mock:encrypted");
             }
         });
-        testEncryption();
+        xmlsecTestHelper.testEncryption(context);
     }
 
     @Test
@@ -253,24 +157,27 @@ public class XMLSecurityDataFormatTest e
                     .marshal(xmlEncDataFormat).to("mock:encrypted");
             }
         });
-        testEncryption();
+        xmlsecTestHelper.testEncryption(context);
     }
 
     @Test
     public void testPartialPayloadAsymmetricKeyEncryptionWithContextTruststoreProperties() throws Exception {
+        
+        final KeyStoreParameters tsParameters = new KeyStoreParameters();
+        tsParameters.setPassword("password");
+        tsParameters.setResource("sender.ts");
+        
         Map<String, String> contextProps = context.getProperties();
-        contextProps.put(XMLSecurityDataFormat.XML_ENC_TRUST_STORE_URL, 
-            getClass().getClassLoader().getResource("sender.ts").toString());
         contextProps.put(XMLSecurityDataFormat.XML_ENC_TRUST_STORE_PASSWORD, "password");
  
         context.addRoutes(new RouteBuilder() {
             public void configure() {
                 from("direct:start")
-                    .marshal().secureXML("//cheesesites/italy/cheese", true, "recipient", testCypherAlgorithm, XMLCipher.RSA_v1dot5)
+                    .marshal().secureXML("//cheesesites/italy/cheese", true, "recipient", testCypherAlgorithm, XMLCipher.RSA_v1dot5, tsParameters)
                     .to("mock:encrypted");
             }
         });
-        testEncryption();
+        xmlsecTestHelper.testEncryption(context);
     }
  
     @Test
@@ -278,10 +185,12 @@ public class XMLSecurityDataFormatTest e
         MockEndpoint resultEndpoint = context.getEndpoint("mock:foo", MockEndpoint.class);
         resultEndpoint.setExpectedMessageCount(1);
  
+        final KeyStoreParameters tsParameters = new KeyStoreParameters();
+        tsParameters.setPassword("password");
+        tsParameters.setResource("sender.ts");
+        String tsParametersId = "testTrustStoreParameters";
+        
         Map<String, String> contextProps = context.getProperties();
-        contextProps.put(XMLSecurityDataFormat.XML_ENC_TRUST_STORE_URL,
-            getClass().getClassLoader().getResource("sender.ts").toString());
-        contextProps.put(XMLSecurityDataFormat.XML_ENC_TRUST_STORE_PASSWORD, "password");
  
         context.addRoutes(new RouteBuilder() {
             public void configure() {
@@ -291,11 +200,11 @@ public class XMLSecurityDataFormatTest e
                             exchange.getIn().setHeader(XMLSecurityDataFormat.XML_ENC_RECIPIENT_ALIAS, "recipient");
                         }
                     })
-                    .marshal().secureXML("//cheesesites/italy/cheese", true, null, testCypherAlgorithm, XMLCipher.RSA_v1dot5)
+                    .marshal().secureXML("//cheesesites/italy/cheese", true, null, testCypherAlgorithm, XMLCipher.RSA_v1dot5, tsParameters)
                     .to("mock:encrypted");
             }
         });
-        testEncryption();
+        xmlsecTestHelper.testEncryption(context);
     }
  
     /*
@@ -303,7 +212,7 @@ public class XMLSecurityDataFormatTest e
     */
     @Test
     public void testFullPayloadXMLDecryption() throws Exception {
-        if (!HAS_3DES) {
+        if (!TestHelper.HAS_3DES) {
             return;
         }
         context.addRoutes(new RouteBuilder() {
@@ -313,12 +222,12 @@ public class XMLSecurityDataFormatTest e
                     .unmarshal().secureXML().to("mock:decrypted");
             }
         });
-        testDecryption();
+        xmlsecTestHelper.testDecryption(context);
     }
     
     @Test
     public void testPartialPayloadXMLContentDecryption() throws Exception {
-        if (!HAS_3DES) {
+        if (!TestHelper.HAS_3DES) {
             return;
         }
         context.addRoutes(new RouteBuilder() {
@@ -328,12 +237,12 @@ public class XMLSecurityDataFormatTest e
                     .unmarshal().secureXML("//cheesesites/italy/cheese", true).to("mock:decrypted");
             }
         });
-        testDecryption();
+        xmlsecTestHelper.testDecryption(context);
     }
     
     @Test
     public void testPartialPayloadMultiNodeXMLContentDecryption() throws Exception {
-        if (!HAS_3DES) {
+        if (!TestHelper.HAS_3DES) {
             return;
         }
         context.addRoutes(new RouteBuilder() {
@@ -343,12 +252,12 @@ public class XMLSecurityDataFormatTest e
                     .unmarshal().secureXML("//cheesesites/*/cheese", true).to("mock:decrypted");
             }
         });
-        testDecryption();
+        xmlsecTestHelper.testDecryption(context);
     }
 
     @Test
     public void testPartialPayloadXMLElementDecryptionWithKey() throws Exception {
-        if (!HAS_3DES) {
+        if (!TestHelper.HAS_3DES) {
             return;
         }
         context.addRoutes(new RouteBuilder() {
@@ -358,7 +267,7 @@ public class XMLSecurityDataFormatTest e
                     .unmarshal().secureXML("//cheesesites/france", false, "Just another 24 Byte key").to("mock:decrypted");
             }
         });
-        testDecryption();
+        xmlsecTestHelper.testDecryption(context);
     }
 
     @Test
@@ -369,6 +278,7 @@ public class XMLSecurityDataFormatTest e
             (byte) 0x10, (byte) 0x11, (byte) 0x12, (byte) 0x13,
             (byte) 0x14, (byte) 0x15, (byte) 0x16, (byte) 0x17};
         final String passCode = new String(bits128);
+  
         context.addRoutes(new RouteBuilder() {
             public void configure() {
                 from("direct:start")
@@ -376,55 +286,78 @@ public class XMLSecurityDataFormatTest e
                     .unmarshal().secureXML("//cheesesites/italy", true, passCode, XMLCipher.AES_128).to("mock:decrypted");
             }
         });
-        testDecryption();
+        xmlsecTestHelper.testDecryption(context);
     }
 
     @Test
     public void testFullPayloadAsymmetricKeyDecryption() throws Exception {
-
-        Map<String, String> contextProps = context.getProperties();
-        // context properties for encryption
-        contextProps.put(XMLSecurityDataFormat.XML_ENC_TRUST_STORE_URL, getClass().getClassLoader().getResource("sender.ts").toString());
-        contextProps.put(XMLSecurityDataFormat.XML_ENC_TRUST_STORE_PASSWORD, "password");
-        contextProps.put(XMLSecurityDataFormat.XML_ENC_RECIPIENT_ALIAS, "recipient");
-
-        // context properties for decryption
-        contextProps.put(XMLSecurityDataFormat.XML_ENC_KEY_STORE_URL, getClass().getClassLoader().getResource("recipient.ks").toString());
-        contextProps.put(XMLSecurityDataFormat.XML_ENC_KEY_STORE_PASSWORD, "password");
-        contextProps.put(XMLSecurityDataFormat.XML_ENC_KEY_STORE_ALIAS, "recipient");
+                      
+        final KeyStoreParameters tsParameters = new KeyStoreParameters();
+        tsParameters.setPassword("password");
+        tsParameters.setResource("sender.ts");
+        
+        final KeyStoreParameters ksParameters = new KeyStoreParameters();
+        ksParameters.setPassword("password");
+        ksParameters.setResource("recipient.ks");
 
         context.addRoutes(new RouteBuilder() {
             public void configure() {
                 from("direct:start")
-                    .marshal().secureXML("", true, null, testCypherAlgorithm, XMLCipher.RSA_v1dot5).to("mock:encrypted")
-                    .unmarshal().secureXML("", true, null, testCypherAlgorithm, XMLCipher.RSA_v1dot5).to("mock:decrypted");
+                    .marshal().secureXML("", true, "recipient", testCypherAlgorithm, XMLCipher.RSA_v1dot5, tsParameters).to("mock:encrypted")
+                    .unmarshal().secureXML("", true, "recipient", testCypherAlgorithm, XMLCipher.RSA_v1dot5, ksParameters).to("mock:decrypted");
             }
         });
-        testDecryption();
+        xmlsecTestHelper.testDecryption(context);
     }
 
     @Test
     public void testPartialPayloadAsymmetricKeyDecryption() throws Exception {
+                
+        final Map<String, String> namespaces = new HashMap<String, String>();
+        namespaces.put("ns1", "http://cheese.xmlsecurity.camel.apache.org/");
+        
+        final KeyStoreParameters tsParameters = new KeyStoreParameters();
+        tsParameters.setPassword("password");
+        tsParameters.setResource("sender.ts");
+        
+        final KeyStoreParameters ksParameters = new KeyStoreParameters();
+        ksParameters.setPassword("password");
+        ksParameters.setResource("recipient.ks");
 
-        Map<String, String> contextProps = context.getProperties();
-
-        // context properties for encryption
-        contextProps.put(XMLSecurityDataFormat.XML_ENC_TRUST_STORE_URL, getClass().getClassLoader().getResource("sender.ts").toString());
-        contextProps.put(XMLSecurityDataFormat.XML_ENC_TRUST_STORE_PASSWORD, "password");
-        contextProps.put(XMLSecurityDataFormat.XML_ENC_RECIPIENT_ALIAS, "recipient");
+        context.addRoutes(new RouteBuilder() {
+            public void configure() {
+                from("direct:start")
+                    .marshal().secureXML("//ns1:cheesesites/italy", namespaces, true, "recipient", testCypherAlgorithm, XMLCipher.RSA_v1dot5, tsParameters).to("mock:encrypted")
+                    .unmarshal().secureXML("//ns1:cheesesites/italy", namespaces, true, "recipient", testCypherAlgorithm, XMLCipher.RSA_v1dot5, ksParameters).to("mock:decrypted");
+            }
+        });
+        xmlsecTestHelper.testDecryption(TestHelper.NS_XML_FRAGMENT, context);
+    }
+    
+    @Test
+    public void testPartialPayloadAsymmetricKeyDecryptionCustomNS() throws Exception {
+        
+        final KeyStoreParameters tsParameters = new KeyStoreParameters();
+        tsParameters.setPassword("password");
+        tsParameters.setResource("sender.ts");
+        
+        final KeyStoreParameters ksParameters = new KeyStoreParameters();
+        ksParameters.setPassword("password");
+        ksParameters.setResource("recipient.ks");
+        
+        
+        final Map<String, String> namespaces = new HashMap<String, String>();
+        namespaces.put("cust", "http://cheese.xmlsecurity.camel.apache.org/");
 
-        // context properties for decryption
-        contextProps.put(XMLSecurityDataFormat.XML_ENC_KEY_STORE_URL, getClass().getClassLoader().getResource("recipient.ks").toString());
-        contextProps.put(XMLSecurityDataFormat.XML_ENC_KEY_STORE_PASSWORD, "password");
-        contextProps.put(XMLSecurityDataFormat.XML_ENC_KEY_STORE_ALIAS, "recipient");
 
         context.addRoutes(new RouteBuilder() {
             public void configure() {
                 from("direct:start")
-                    .marshal().secureXML("//cheesesites/italy", true, null, testCypherAlgorithm, XMLCipher.RSA_v1dot5).to("mock:encrypted")
-                    .unmarshal().secureXML("//cheesesites/italy", true, null, testCypherAlgorithm, XMLCipher.RSA_v1dot5).to("mock:decrypted");
+                    .marshal().secureXML("//cust:cheesesites/italy", namespaces, true, "recipient", testCypherAlgorithm, XMLCipher.RSA_v1dot5, tsParameters).to("mock:encrypted")
+                    .unmarshal().secureXML("//cust:cheesesites/italy", namespaces, true, "recipient", testCypherAlgorithm, XMLCipher.RSA_v1dot5, ksParameters).to("mock:decrypted");
             }
         });
-        testDecryption();
+        xmlsecTestHelper.testDecryption(TestHelper.NS_XML_FRAGMENT, context);
     }
+    
 }

Added: camel/trunk/components/camel-xmlsecurity/src/test/resources/org/apache/camel/dataformat/xmlsecurity/SpringXmlSecurityDataFormatTest-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-xmlsecurity/src/test/resources/org/apache/camel/dataformat/xmlsecurity/SpringXmlSecurityDataFormatTest-context.xml?rev=1173190&view=auto
==============================================================================
--- camel/trunk/components/camel-xmlsecurity/src/test/resources/org/apache/camel/dataformat/xmlsecurity/SpringXmlSecurityDataFormatTest-context.xml (added)
+++ camel/trunk/components/camel-xmlsecurity/src/test/resources/org/apache/camel/dataformat/xmlsecurity/SpringXmlSecurityDataFormatTest-context.xml Tue Sep 20 15:24:43 2011
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xmlns:context="http://www.springframework.org/schema/context"
+	xmlns:camel="http://camel.apache.org/schema/spring"
+	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
+		http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd" >
+		
+	<!--  key store configuration -->
+	<camel:keyStoreParameters id="keyStoreParams" resource="./recipient.ks" password="password" />
+    
+    <!--  trust store configuration -->                          
+    <camel:keyStoreParameters id="trustStoreParams" resource="./sender.ts" password="password"/>
+		
+    <!--  This route demonstrates the XML spring configuration of partial-payload encryption and decryption for
+          an XML document with namespaces.  The domain namespace prefix (cheese) is declared in the camel context 
+          definition and can be used in the secureTag selector that defines the content to encrypt or decrypt 
+    -->
+    <camelContext id="springXmlSecurityDataFormatTestCamelContext" 
+                  xmlns="http://camel.apache.org/schema/spring"
+                  xmlns:cheese="http://cheese.xmlsecurity.camel.apache.org/">        
+        <route>
+            <from uri="direct://start"/>
+                 <marshal>
+                    <secureXML
+                        secureTag="//cheese:cheesesites/italy"
+                        secureTagContents="true"
+                        xmlCipherAlgorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"       
+                        keyCipherAlgorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"
+                        recipientKeyAlias="recipient"
+                        keyOrTrustStoreParametersId="trustStoreParams" />
+                </marshal>            
+            <to uri="mock:encrypted"/>
+            <to uri="direct://encrypted"/>
+        </route>
+        <route>    
+            <from uri="direct://encrypted"/>
+                <unmarshal>
+                    <secureXML
+                        secureTag="//cheese:cheesesites/italy"
+                        secureTagContents="true"
+                        xmlCipherAlgorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"
+                        keyCipherAlgorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"
+                        recipientKeyAlias="recipient"
+                        keyOrTrustStoreParametersId="keyStoreParams" />
+                </unmarshal>                           
+            <to uri="mock://decrypted"/>
+        </route>
+    </camelContext>
+
+</beans>

Modified: camel/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/parent/pom.xml?rev=1173190&r1=1173189&r2=1173190&view=diff
==============================================================================
--- camel/trunk/parent/pom.xml (original)
+++ camel/trunk/parent/pom.xml Tue Sep 20 15:24:43 2011
@@ -157,6 +157,7 @@
     <xmlsec-version>1.4.5</xmlsec-version>
     <xerces-version>2.9.1</xerces-version>
     <xalan-version>2.7.1</xalan-version>
+    <xmlunit-version>1.3</xmlunit-version>
     <xmlbeans-version>2.5.0</xmlbeans-version>
     <zookeeper-version>3.3.3</zookeeper-version>
     <!-- used by camel archetypes -->



Mime
View raw message