Author: hadrian
Date: Wed Jun  8 21:36:49 2011
New Revision: 1133563

URL: http://svn.apache.org/viewvc?rev=1133563&view=rev
Log:
CAMEL-4061. Part 1/2. Patch applied with thanks to Rich

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

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=1133563&r1=1133562&r2=1133563&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
 Wed Jun  8 21:36:49 2011
@@ -356,7 +356,15 @@ public class DataFormatClause<T extends 
         XMLSecurityDataFormat xsdf = new XMLSecurityDataFormat(secureTag, 
secureTagContents, passPhrase, xmlCipherAlgorithm);
         return dataFormat(xsdf);
     }
-
+    
+    /**
+     * Uses the XML Security data format
+     */
+    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 xmlBeans data format
      */

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=1133563&r1=1133562&r2=1133563&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
 Wed Jun  8 21:36:49 2011
@@ -41,6 +41,11 @@ public class XMLSecurityDataFormat exten
     private String secureTag;
     @XmlAttribute
     private Boolean secureTagContents;
+    @XmlAttribute
+    private String keyCipherAlgorithm;
+    @XmlAttribute
+    private String recipientKeyAlias;
+    
 
     public XMLSecurityDataFormat() {
         super("secureXML");
@@ -61,11 +66,21 @@ public class XMLSecurityDataFormat exten
 
     public XMLSecurityDataFormat(String secureTag, boolean secureTagContents, 
String passPhrase,
                                  String xmlCipherAlgorithm) {
-        this();
+       this();
         this.setSecureTag(secureTag);
         this.setSecureTagContents(secureTagContents);
-        this.setPassPhrase(passPhrase);
         this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
+        this.setKeyCipherAlgorithm(keyCipherAlgorithm);
+    }
+    
+    public XMLSecurityDataFormat(String secureTag, boolean secureTagContents, 
String recipientKeyAlias, 
+               String xmlCipherAlgorithm, String keyCipherAlgorithm) {
+       this();
+        this.setSecureTag(secureTag);
+        this.setSecureTagContents(secureTagContents);
+        this.setRecipientKeyAlias(recipientKeyAlias);
+        this.setXmlCipherAlgorithm(xmlCipherAlgorithm);
+        this.setKeyCipherAlgorithm(keyCipherAlgorithm);
     }
 
     @Override
@@ -79,7 +94,7 @@ public class XMLSecurityDataFormat exten
         setProperty(dataFormat, "secureTagContents", isSecureTagContents());
 
         if (passPhrase != null) {
-            setProperty(dataFormat, "passPhrase", getPassPhrase());
+            setProperty(dataFormat, "passPhrase", getPassPhrase().getBytes());
         } else {
             setProperty(dataFormat, "passPhrase", "Just another 24 Byte 
key".getBytes());
         }
@@ -88,6 +103,12 @@ public class XMLSecurityDataFormat exten
         } else {
             setProperty(dataFormat, "xmlCipherAlgorithm", TRIPLEDES);
         }
+        if(getKeyCipherAlgorithm() != null) {
+               setProperty(dataFormat, "keyCipherAlgorithm", 
getKeyCipherAlgorithm());
+        }
+        if(getRecipientKeyAlias() != null) {
+               setProperty(dataFormat, "recipientKeyAlias", 
getRecipientKeyAlias());
+        }
     }
 
     public String getXmlCipherAlgorithm() {
@@ -125,4 +146,20 @@ public class XMLSecurityDataFormat exten
     public boolean isSecureTagContents() {
         return secureTagContents != null && secureTagContents;
     }
+    
+    public void setKeyCipherAlgorithm(String keyCipherAlgorithm) {
+       this.keyCipherAlgorithm = keyCipherAlgorithm;
+    }
+    
+    public String getKeyCipherAlgorithm() {
+       return keyCipherAlgorithm;
+    }
+    
+    public void setRecipientKeyAlias(String recipientKeyAlias) {
+        this.recipientKeyAlias = recipientKeyAlias;
+    }
+    
+    public String getRecipientKeyAlias() {
+       return recipientKeyAlias;
+    }
 }


Reply via email to