You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/10/03 12:54:29 UTC
[1/5] git commit: CAMEL-6817: Throw PGPException instead of NPE.
Thanks to Milan Baran for the patch.
Updated Branches:
refs/heads/camel-2.11.x fb5156065 -> 4b92dcb83
refs/heads/camel-2.12.x 7066fd532 -> 652a05f5d
refs/heads/master a49053bd7 -> e90d061b2
CAMEL-6817: Throw PGPException instead of NPE. Thanks to Milan Baran 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/22f26e29
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/22f26e29
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/22f26e29
Branch: refs/heads/master
Commit: 22f26e297ce87a8e2859972389d86c9ffee59932
Parents: a49053b
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Oct 3 12:18:43 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 3 12:18:43 2013 +0200
----------------------------------------------------------------------
.../camel/converter/crypto/PGPDataFormatUtil.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/22f26e29/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormatUtil.java
----------------------------------------------------------------------
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 0916075..aa4b9c7 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
@@ -16,8 +16,6 @@
*/
package org.apache.camel.converter.crypto;
-
-
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -149,6 +147,9 @@ public final class PGPDataFormatUtil {
PGPObjectFactory factory = new PGPObjectFactory(PGPUtil.getDecoderStream(encryptedInput));
PGPEncryptedDataList enc;
Object o = factory.nextObject();
+ if (o == null) {
+ throw new PGPException("Provided input is not encrypted.");
+ }
if (o instanceof PGPEncryptedDataList) {
enc = (PGPEncryptedDataList) o;
} else {
@@ -157,11 +158,16 @@ public final class PGPDataFormatUtil {
encryptedInput.reset(); // nextObject() method reads from the InputStream, so rewind it!
Iterator<?> encryptedDataObjects = enc.getEncryptedDataObjects();
PGPPrivateKey privateKey = null;
- PGPPublicKeyEncryptedData encryptedData;
+ PGPPublicKeyEncryptedData encryptedData = null;
while (privateKey == null && encryptedDataObjects.hasNext()) {
encryptedData = (PGPPublicKeyEncryptedData) encryptedDataObjects.next();
PGPSecretKey pgpSecKey = pgpSec.getSecretKey(encryptedData.getKeyID());
- privateKey = pgpSecKey.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(passphrase.toCharArray()));
+ if (pgpSecKey != null) {
+ privateKey = pgpSecKey.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(passphrase.toCharArray()));
+ }
+ }
+ if (privateKey == null && pgpSec.size() > 0 && encryptedData != null) {
+ throw new PGPException("Provided input is encrypted with unknown pair of keys.");
}
return privateKey;
}
[3/5] git commit: CAMEL-6806: Fixed bean component when having 2+
custom annotated methods to not pick the single non annotated method if
exists, but should be ambigious instead. Thanks to Larry Han for patch.
Posted by da...@apache.org.
CAMEL-6806: Fixed bean component when having 2+ custom annotated methods to not pick the single non annotated method if exists, but should be ambigious instead. Thanks to Larry Han for patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e90d061b
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e90d061b
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e90d061b
Branch: refs/heads/master
Commit: e90d061b2326ada52dd566bf895db5882f179b9f
Parents: 22f26e2
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Oct 3 12:53:36 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 3 12:53:36 2013 +0200
----------------------------------------------------------------------
.../apache/camel/component/bean/BeanInfo.java | 2 +-
.../component/bean/BeanHandlerMethodTest.java | 33 ++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/e90d061b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
index 19d7ad3..53c1254 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
@@ -528,7 +528,7 @@ public class BeanInfo {
if (noParameters && localOperationsWithNoBody.size() == 1) {
// if there was a method name configured and it has no parameters, then use the method with no body (eg no parameters)
return localOperationsWithNoBody.get(0);
- } else if (!noParameters && localOperationsWithBody.size() == 1) {
+ } else if (!noParameters && localOperationsWithBody.size() == 1 && localOperationsWithCustomAnnotation.isEmpty()) {
// if there is one method with body then use that one
return localOperationsWithBody.get(0);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/e90d061b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
index 8313e83..c0300dc 100644
--- a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
@@ -20,6 +20,7 @@ import org.apache.camel.Body;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.Handler;
+import org.apache.camel.Header;
import org.apache.camel.impl.DefaultExchange;
/**
@@ -83,6 +84,19 @@ public class BeanHandlerMethodTest extends ContextTestSupport {
}
}
+ public void testNoHandlerAmbigious() throws Exception {
+ BeanInfo info = new BeanInfo(context, MyNoHandlerBean.class);
+
+ Exchange exchange = new DefaultExchange(context);
+ MyNoHandlerBean pojo = new MyNoHandlerBean();
+ try {
+ info.createInvocation(pojo, exchange);
+ fail("Should throw exception");
+ } catch (AmbiguousMethodCallException e) {
+ assertEquals(3, e.getMethods().size());
+ }
+ }
+
public static class MyNoDummyBean {
public String hello(@Body String hi) {
@@ -138,6 +152,25 @@ public class BeanHandlerMethodTest extends ContextTestSupport {
}
+ public static class MyNoHandlerBean {
+
+ public String hello(@Body String input, @Header("name") String name, @Header("age") int age) {
+ fail("Should not invoke me");
+ return null;
+ }
+
+ public String greeting(@Body String input, @Header("name") String name) {
+ fail("Should not invoke me");
+ return null;
+ }
+
+ public String bye(String input) {
+ fail("Should not invoke me");
+ return null;
+ }
+
+ }
+
public static class MyReallyDummyBean {
@Handler
[2/5] git commit: CAMEL-6817: Throw PGPException instead of NPE.
Thanks to Milan Baran for the patch.
Posted by da...@apache.org.
CAMEL-6817: Throw PGPException instead of NPE. Thanks to Milan Baran 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/44f8c1b9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/44f8c1b9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/44f8c1b9
Branch: refs/heads/camel-2.12.x
Commit: 44f8c1b98d457ed63390af081e5295a28b1bc61f
Parents: 7066fd5
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Oct 3 12:18:43 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 3 12:19:02 2013 +0200
----------------------------------------------------------------------
.../camel/converter/crypto/PGPDataFormatUtil.java | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/44f8c1b9/components/camel-crypto/src/main/java/org/apache/camel/converter/crypto/PGPDataFormatUtil.java
----------------------------------------------------------------------
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 0916075..aa4b9c7 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
@@ -16,8 +16,6 @@
*/
package org.apache.camel.converter.crypto;
-
-
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -149,6 +147,9 @@ public final class PGPDataFormatUtil {
PGPObjectFactory factory = new PGPObjectFactory(PGPUtil.getDecoderStream(encryptedInput));
PGPEncryptedDataList enc;
Object o = factory.nextObject();
+ if (o == null) {
+ throw new PGPException("Provided input is not encrypted.");
+ }
if (o instanceof PGPEncryptedDataList) {
enc = (PGPEncryptedDataList) o;
} else {
@@ -157,11 +158,16 @@ public final class PGPDataFormatUtil {
encryptedInput.reset(); // nextObject() method reads from the InputStream, so rewind it!
Iterator<?> encryptedDataObjects = enc.getEncryptedDataObjects();
PGPPrivateKey privateKey = null;
- PGPPublicKeyEncryptedData encryptedData;
+ PGPPublicKeyEncryptedData encryptedData = null;
while (privateKey == null && encryptedDataObjects.hasNext()) {
encryptedData = (PGPPublicKeyEncryptedData) encryptedDataObjects.next();
PGPSecretKey pgpSecKey = pgpSec.getSecretKey(encryptedData.getKeyID());
- privateKey = pgpSecKey.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(passphrase.toCharArray()));
+ if (pgpSecKey != null) {
+ privateKey = pgpSecKey.extractPrivateKey(new JcePBESecretKeyDecryptorBuilder().setProvider("BC").build(passphrase.toCharArray()));
+ }
+ }
+ if (privateKey == null && pgpSec.size() > 0 && encryptedData != null) {
+ throw new PGPException("Provided input is encrypted with unknown pair of keys.");
}
return privateKey;
}
[4/5] git commit: CAMEL-6806: Fixed bean component when having 2+
custom annotated methods to not pick the single non annotated method if
exists, but should be ambigious instead. Thanks to Larry Han for patch.
Posted by da...@apache.org.
CAMEL-6806: Fixed bean component when having 2+ custom annotated methods to not pick the single non annotated method if exists, but should be ambigious instead. Thanks to Larry Han for patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/652a05f5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/652a05f5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/652a05f5
Branch: refs/heads/camel-2.12.x
Commit: 652a05f5d95c26b828c824eb7653eab04330f19c
Parents: 44f8c1b
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Oct 3 12:53:36 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 3 12:53:51 2013 +0200
----------------------------------------------------------------------
.../apache/camel/component/bean/BeanInfo.java | 2 +-
.../component/bean/BeanHandlerMethodTest.java | 33 ++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/652a05f5/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
index 19d7ad3..53c1254 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
@@ -528,7 +528,7 @@ public class BeanInfo {
if (noParameters && localOperationsWithNoBody.size() == 1) {
// if there was a method name configured and it has no parameters, then use the method with no body (eg no parameters)
return localOperationsWithNoBody.get(0);
- } else if (!noParameters && localOperationsWithBody.size() == 1) {
+ } else if (!noParameters && localOperationsWithBody.size() == 1 && localOperationsWithCustomAnnotation.isEmpty()) {
// if there is one method with body then use that one
return localOperationsWithBody.get(0);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/652a05f5/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
index 8313e83..c0300dc 100644
--- a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
@@ -20,6 +20,7 @@ import org.apache.camel.Body;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.Handler;
+import org.apache.camel.Header;
import org.apache.camel.impl.DefaultExchange;
/**
@@ -83,6 +84,19 @@ public class BeanHandlerMethodTest extends ContextTestSupport {
}
}
+ public void testNoHandlerAmbigious() throws Exception {
+ BeanInfo info = new BeanInfo(context, MyNoHandlerBean.class);
+
+ Exchange exchange = new DefaultExchange(context);
+ MyNoHandlerBean pojo = new MyNoHandlerBean();
+ try {
+ info.createInvocation(pojo, exchange);
+ fail("Should throw exception");
+ } catch (AmbiguousMethodCallException e) {
+ assertEquals(3, e.getMethods().size());
+ }
+ }
+
public static class MyNoDummyBean {
public String hello(@Body String hi) {
@@ -138,6 +152,25 @@ public class BeanHandlerMethodTest extends ContextTestSupport {
}
+ public static class MyNoHandlerBean {
+
+ public String hello(@Body String input, @Header("name") String name, @Header("age") int age) {
+ fail("Should not invoke me");
+ return null;
+ }
+
+ public String greeting(@Body String input, @Header("name") String name) {
+ fail("Should not invoke me");
+ return null;
+ }
+
+ public String bye(String input) {
+ fail("Should not invoke me");
+ return null;
+ }
+
+ }
+
public static class MyReallyDummyBean {
@Handler
[5/5] git commit: CAMEL-6806: Fixed bean component when having 2+
custom annotated methods to not pick the single non annotated method if
exists, but should be ambigious instead. Thanks to Larry Han for patch.
Posted by da...@apache.org.
CAMEL-6806: Fixed bean component when having 2+ custom annotated methods to not pick the single non annotated method if exists, but should be ambigious instead. Thanks to Larry Han for patch.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/4b92dcb8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/4b92dcb8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/4b92dcb8
Branch: refs/heads/camel-2.11.x
Commit: 4b92dcb83e52e51eecb8c259fa8a966816ac6c07
Parents: fb51560
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Oct 3 12:53:36 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 3 12:54:05 2013 +0200
----------------------------------------------------------------------
.../apache/camel/component/bean/BeanInfo.java | 2 +-
.../component/bean/BeanHandlerMethodTest.java | 33 ++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/4b92dcb8/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
index 583d6ad..ac84909 100644
--- a/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
+++ b/camel-core/src/main/java/org/apache/camel/component/bean/BeanInfo.java
@@ -514,7 +514,7 @@ public class BeanInfo {
if (noParameters && localOperationsWithNoBody.size() == 1) {
// if there was a method name configured and it has no parameters, then use the method with no body (eg no parameters)
return localOperationsWithNoBody.get(0);
- } else if (!noParameters && localOperationsWithBody.size() == 1) {
+ } else if (!noParameters && localOperationsWithBody.size() == 1 && localOperationsWithCustomAnnotation.isEmpty()) {
// if there is one method with body then use that one
return localOperationsWithBody.get(0);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/4b92dcb8/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
index 8313e83..c0300dc 100644
--- a/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/bean/BeanHandlerMethodTest.java
@@ -20,6 +20,7 @@ import org.apache.camel.Body;
import org.apache.camel.ContextTestSupport;
import org.apache.camel.Exchange;
import org.apache.camel.Handler;
+import org.apache.camel.Header;
import org.apache.camel.impl.DefaultExchange;
/**
@@ -83,6 +84,19 @@ public class BeanHandlerMethodTest extends ContextTestSupport {
}
}
+ public void testNoHandlerAmbigious() throws Exception {
+ BeanInfo info = new BeanInfo(context, MyNoHandlerBean.class);
+
+ Exchange exchange = new DefaultExchange(context);
+ MyNoHandlerBean pojo = new MyNoHandlerBean();
+ try {
+ info.createInvocation(pojo, exchange);
+ fail("Should throw exception");
+ } catch (AmbiguousMethodCallException e) {
+ assertEquals(3, e.getMethods().size());
+ }
+ }
+
public static class MyNoDummyBean {
public String hello(@Body String hi) {
@@ -138,6 +152,25 @@ public class BeanHandlerMethodTest extends ContextTestSupport {
}
+ public static class MyNoHandlerBean {
+
+ public String hello(@Body String input, @Header("name") String name, @Header("age") int age) {
+ fail("Should not invoke me");
+ return null;
+ }
+
+ public String greeting(@Body String input, @Header("name") String name) {
+ fail("Should not invoke me");
+ return null;
+ }
+
+ public String bye(String input) {
+ fail("Should not invoke me");
+ return null;
+ }
+
+ }
+
public static class MyReallyDummyBean {
@Handler