You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/10/24 13:36:22 UTC

[camel] branch camel-2.21.x updated (642ce34 -> ee9a16e)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch camel-2.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 642ce34  CAMEL-12626: Fixed tracer not working if redelivery turned on error handler.
     new 97832a8  CAMEL-12897 - PGP Decryption in XML DSL not working
     new ee9a16e  CAMEL-12897 - Fixed CS

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/converter/crypto/PGPDataFormatUtil.java  |   8 ++++++
 ...va => SpringPGPDataFormatNoPassPhraseTest.java} |   2 +-
 .../converter/crypto/SpringPGPDataFormatTest.java  |   7 +-----
 .../SpringPGPDataFormatNoPassPhraseTest.xml}       |  28 +++++++++------------
 .../camel/component/crypto/camel-private.pgp       | Bin 0 -> 2547 bytes
 .../apache/camel/component/crypto/camel-public.pgp | Bin 0 -> 1245 bytes
 6 files changed, 22 insertions(+), 23 deletions(-)
 copy components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/{SpringPGPDataFormatTest.java => SpringPGPDataFormatNoPassPhraseTest.java} (94%)
 copy components/{camel-jaxb/src/test/resources/org/apache/camel/example/marshalAndUnmarshalWithRef.xml => camel-crypto/src/test/resources/org/apache/camel/component/crypto/SpringPGPDataFormatNoPassPhraseTest.xml} (65%)
 create mode 100644 components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/camel-private.pgp
 create mode 100644 components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/camel-public.pgp


[camel] 01/02: CAMEL-12897 - PGP Decryption in XML DSL not working

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-2.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 97832a8c6a25d62f329ff3d2a81159e6a7ff4727
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Oct 24 15:07:58 2018 +0200

    CAMEL-12897 - PGP Decryption in XML DSL not working
---
 .../camel/converter/crypto/PGPDataFormatUtil.java  |   8 ++++
 ...va => SpringPGPDataFormatNoPassPhraseTest.java} |   2 +-
 .../converter/crypto/SpringPGPDataFormatTest.java  |   7 +---
 .../crypto/SpringPGPDataFormatNoPassPhraseTest.xml |  43 +++++++++++++++++++++
 .../camel/component/crypto/camel-private.pgp       | Bin 0 -> 2547 bytes
 .../apache/camel/component/crypto/camel-public.pgp | Bin 0 -> 1245 bytes
 6 files changed, 53 insertions(+), 7 deletions(-)

diff --git a/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormatUtil.java b/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormatUtil.java
index a46156e..700a17f 100644
--- a/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormatUtil.java
+++ b/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormatUtil.java
@@ -162,6 +162,14 @@ public final class PGPDataFormatUtil {
                             return privateKey;
                         }
                     }
+                    if (passphrase == null && passphraseAccessor == null) {
+                    	passphrase = "";
+                        PGPPrivateKey privateKey = secKey.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider(provider)
+                                .build(passphrase.toCharArray()));
+                        if (privateKey != null) {
+                            return privateKey;
+                        }
+                    }
                 }
 
             }
diff --git a/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/SpringPGPDataFormatTest.java b/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/SpringPGPDataFormatNoPassPhraseTest.java
similarity index 94%
copy from components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/SpringPGPDataFormatTest.java
copy to components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/SpringPGPDataFormatNoPassPhraseTest.java
index 1c8d6fa..838cb1b 100644
--- a/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/SpringPGPDataFormatTest.java
+++ b/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/SpringPGPDataFormatNoPassPhraseTest.java
@@ -20,7 +20,7 @@ import org.apache.camel.CamelContext;
 import org.apache.camel.spring.SpringCamelContext;
 import org.junit.Test;
 
-public class SpringPGPDataFormatTest extends AbstractPGPDataFormatTest {
+public class SpringPGPDataFormatNoPassPhraseTest extends AbstractPGPDataFormatTest {
 
     protected CamelContext createCamelContext() throws Exception {
         return SpringCamelContext.springCamelContext("/org/apache/camel/component/crypto/SpringPGPDataFormatTest.xml");
diff --git a/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/SpringPGPDataFormatTest.java b/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/SpringPGPDataFormatTest.java
index 1c8d6fa..c311feb 100644
--- a/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/SpringPGPDataFormatTest.java
+++ b/components/camel-crypto/src/test/java/org/apache/camel/converter/crypto/SpringPGPDataFormatTest.java
@@ -23,17 +23,12 @@ import org.junit.Test;
 public class SpringPGPDataFormatTest extends AbstractPGPDataFormatTest {
 
     protected CamelContext createCamelContext() throws Exception {
-        return SpringCamelContext.springCamelContext("/org/apache/camel/component/crypto/SpringPGPDataFormatTest.xml");
+        return SpringCamelContext.springCamelContext("/org/apache/camel/component/crypto/SpringPGPDataFormatNoPassPhraseTest.xml");
     }
 
     @Test
     public void testEncryption() throws Exception {
         doRoundTripEncryptionTests("direct:inline");
     }
-    
-    @Test
-    public void testEncryptionWithKeyRingByteArray() throws Exception {
-        doRoundTripEncryptionTests("direct:pgp-key-ring-byte-array");
-    }
 
 }
diff --git a/components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/SpringPGPDataFormatNoPassPhraseTest.xml b/components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/SpringPGPDataFormatNoPassPhraseTest.xml
new file mode 100644
index 0000000..52917eb
--- /dev/null
+++ b/components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/SpringPGPDataFormatNoPassPhraseTest.xml
@@ -0,0 +1,43 @@
+<?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"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+    <!-- START SNIPPET: pgp-xml-basic -->
+    <dataFormats>
+      <!-- will load the file from classpath by default, but you can prefix with file: to load from file system -->
+      <pgp id="encrypt" keyFileName="org/apache/camel/component/crypto/camel-public.pgp" keyUserid="CamelPGPTest"/>
+      <pgp id="decrypt" keyFileName="org/apache/camel/component/crypto/camel-private.pgp"/>
+    </dataFormats>
+
+    <route>
+      <from uri="direct:inline"/>
+      <marshal ref="encrypt"/>
+      <to uri="mock:encrypted"/>
+      <unmarshal ref="decrypt"/>
+      <to uri="mock:unencrypted"/>
+    </route>
+    
+  </camelContext>
+</beans>
\ No newline at end of file
diff --git a/components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/camel-private.pgp b/components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/camel-private.pgp
new file mode 100644
index 0000000..6f2a010
Binary files /dev/null and b/components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/camel-private.pgp differ
diff --git a/components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/camel-public.pgp b/components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/camel-public.pgp
new file mode 100644
index 0000000..e50ec8d
Binary files /dev/null and b/components/camel-crypto/src/test/resources/org/apache/camel/component/crypto/camel-public.pgp differ


[camel] 02/02: CAMEL-12897 - Fixed CS

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-2.21.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit ee9a16ee8937b7ed3da0172329fe568040a8399d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Oct 24 15:31:14 2018 +0200

    CAMEL-12897 - Fixed CS
---
 .../main/java/org/apache/camel/converter/crypto/PGPDataFormatUtil.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormatUtil.java b/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormatUtil.java
index 700a17f..7118c92 100644
--- a/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormatUtil.java
+++ b/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormatUtil.java
@@ -163,7 +163,7 @@ public final class PGPDataFormatUtil {
                         }
                     }
                     if (passphrase == null && passphraseAccessor == null) {
-                    	passphrase = "";
+                        passphrase = "";
                         PGPPrivateKey privateKey = secKey.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider(provider)
                                 .build(passphrase.toCharArray()));
                         if (privateKey != null) {