You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2020/10/07 08:34:09 UTC
[camel-quarkus] branch master updated: Crypto (JCE) native support
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new bc1e569 Crypto (JCE) native support
bc1e569 is described below
commit bc1e5696684fe20e81d645fabcc06e5ff838df7f
Author: James Netherton <ja...@gmail.com>
AuthorDate: Tue Oct 6 11:51:43 2020 +0100
Crypto (JCE) native support
Fixes #1593
---
.../ROOT/pages/reference/extensions/crypto.adoc | 14 ++-
.../ROOT/partials/reference/components/crypto.adoc | 6 +-
.../partials/reference/dataformats/crypto.adoc | 6 +-
.../ROOT/partials/reference/dataformats/pgp.adoc | 6 +-
.../component/crypto/it/CryptoResource.java | 77 -------------
extensions-jvm/pom.xml | 1 -
extensions-support/bouncycastle/deployment/pom.xml | 8 --
...ssor.java => BouncyCastleSupportProcessor.java} | 17 ++-
extensions-support/bouncycastle/runtime/pom.xml | 8 ++
.../support/bouncycastle/BouncyCastleRecorder.java | 38 +++++++
.../crypto/deployment/pom.xml | 4 +
.../crypto/deployment/CryptoProcessor.java | 18 +--
{extensions-jvm => extensions}/crypto/pom.xml | 1 -
.../crypto/runtime/pom.xml | 5 +
.../main/resources/META-INF/quarkus-extension.yaml | 3 +-
extensions/pom.xml | 1 +
.../crypto}/pom.xml | 79 ++++++++++---
.../component/crypto/it/CryptoResource.java | 124 +++++++++++++++++++++
.../quarkus/component/crypto/it/CryptoRoutes.java | 69 ++++++++++++
.../src/main/resources/application.properties | 17 +++
.../crypto/src/main/resources/crypto.jks | Bin 0 -> 3734 bytes
.../crypto/src/main/resources/pubring.pgp | Bin 0 -> 2814 bytes
.../crypto/src/main/resources/secring.pgp | Bin 0 -> 5570 bytes
.../quarkus/component/crypto/it/CryptoIT.java | 32 +-----
.../quarkus/component/crypto/it/CryptoTest.java | 111 ++++++++++++++++++
integration-tests/pom.xml | 1 +
pom.xml | 1 +
tooling/scripts/test-categories.yaml | 1 +
28 files changed, 485 insertions(+), 163 deletions(-)
diff --git a/docs/modules/ROOT/pages/reference/extensions/crypto.adoc b/docs/modules/ROOT/pages/reference/extensions/crypto.adoc
index 5c70642..0444719 100644
--- a/docs/modules/ROOT/pages/reference/extensions/crypto.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/crypto.adoc
@@ -2,15 +2,15 @@
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
= Crypto (JCE)
:cq-artifact-id: camel-quarkus-crypto
-:cq-native-supported: false
-:cq-status: Preview
+:cq-native-supported: true
+:cq-status: Stable
:cq-description: Sign and verify exchanges using the Signature Service of the Java Cryptographic Extension (JCE).
:cq-deprecated: false
:cq-jvm-since: 1.1.0
-:cq-native-since: n/a
+:cq-native-since: 1.2.0
[.badges]
-[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native##[.badge-unsupported]##unsupported##
+[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native since##[.badge-supported]##1.2.0##
Sign and verify exchanges using the Signature Service of the Java Cryptographic Extension (JCE).
@@ -33,3 +33,9 @@ Please refer to the above links for usage and configuration details.
----
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
+
+== SSL in native mode
+
+This extension auto-enables SSL support in native mode. Hence you do not need to add
+`quarkus.ssl.native=true` to your `application.properties` yourself. See also
+https://quarkus.io/guides/native-and-ssl[Quarkus SSL guide].
diff --git a/docs/modules/ROOT/partials/reference/components/crypto.adoc b/docs/modules/ROOT/partials/reference/components/crypto.adoc
index 6d72d0a..7be969e 100644
--- a/docs/modules/ROOT/partials/reference/components/crypto.adoc
+++ b/docs/modules/ROOT/partials/reference/components/crypto.adoc
@@ -2,11 +2,11 @@
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
:cq-artifact-id: camel-quarkus-crypto
:cq-artifact-id-base: crypto
-:cq-native-supported: false
-:cq-status: Preview
+:cq-native-supported: true
+:cq-status: Stable
:cq-deprecated: false
:cq-jvm-since: 1.1.0
-:cq-native-since: n/a
+:cq-native-since: 1.2.0
:cq-camel-part-name: crypto
:cq-camel-part-title: Crypto (JCE)
:cq-camel-part-description: Sign and verify exchanges using the Signature Service of the Java Cryptographic Extension (JCE).
diff --git a/docs/modules/ROOT/partials/reference/dataformats/crypto.adoc b/docs/modules/ROOT/partials/reference/dataformats/crypto.adoc
index 9eadd76..7e0a40a 100644
--- a/docs/modules/ROOT/partials/reference/dataformats/crypto.adoc
+++ b/docs/modules/ROOT/partials/reference/dataformats/crypto.adoc
@@ -2,11 +2,11 @@
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
:cq-artifact-id: camel-quarkus-crypto
:cq-artifact-id-base: crypto
-:cq-native-supported: false
-:cq-status: Preview
+:cq-native-supported: true
+:cq-status: Stable
:cq-deprecated: false
:cq-jvm-since: 1.1.0
-:cq-native-since: n/a
+:cq-native-since: 1.2.0
:cq-camel-part-name: crypto
:cq-camel-part-title: Crypto (Java Cryptographic Extension)
:cq-camel-part-description: Encrypt and decrypt messages using Java Cryptography Extension (JCE).
diff --git a/docs/modules/ROOT/partials/reference/dataformats/pgp.adoc b/docs/modules/ROOT/partials/reference/dataformats/pgp.adoc
index 2787d7e..3977d73 100644
--- a/docs/modules/ROOT/partials/reference/dataformats/pgp.adoc
+++ b/docs/modules/ROOT/partials/reference/dataformats/pgp.adoc
@@ -2,11 +2,11 @@
// This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
:cq-artifact-id: camel-quarkus-crypto
:cq-artifact-id-base: crypto
-:cq-native-supported: false
-:cq-status: Preview
+:cq-native-supported: true
+:cq-status: Stable
:cq-deprecated: false
:cq-jvm-since: 1.1.0
-:cq-native-since: n/a
+:cq-native-since: 1.2.0
:cq-camel-part-name: pgp
:cq-camel-part-title: PGP
:cq-camel-part-description: Encrypt and decrypt messages using Java Cryptographic Extension (JCE) and PGP.
diff --git a/extensions-jvm/crypto/integration-test/src/main/java/org/apache/camel/quarkus/component/crypto/it/CryptoResource.java b/extensions-jvm/crypto/integration-test/src/main/java/org/apache/camel/quarkus/component/crypto/it/CryptoResource.java
deleted file mode 100644
index 112b8db..0000000
--- a/extensions-jvm/crypto/integration-test/src/main/java/org/apache/camel/quarkus/component/crypto/it/CryptoResource.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.quarkus.component.crypto.it;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.apache.camel.CamelContext;
-import org.jboss.logging.Logger;
-
-@Path("/crypto")
-@ApplicationScoped
-public class CryptoResource {
-
- private static final Logger LOG = Logger.getLogger(CryptoResource.class);
-
- private static final String COMPONENT_CRYPTO = "crypto";
- private static final String DATAFORMAT_CRYPTO = "crypto";
- private static final String DATAFORMAT_PGP = "pgp";
- @Inject
- CamelContext context;
-
- @Path("/load/component/crypto")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public Response loadComponentCrypto() throws Exception {
- /* This is an autogenerated test */
- if (context.getComponent(COMPONENT_CRYPTO) != null) {
- return Response.ok().build();
- }
- LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_CRYPTO);
- return Response.status(500, COMPONENT_CRYPTO + " could not be loaded from the Camel context").build();
- }
-
- @Path("/load/dataformat/crypto")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public Response loadDataformatCrypto() throws Exception {
- /* This is an autogenerated test */
- if (context.resolveDataFormat(DATAFORMAT_CRYPTO) != null) {
- return Response.ok().build();
- }
- LOG.warnf("Could not load [%s] from the Camel context", DATAFORMAT_CRYPTO);
- return Response.status(500, DATAFORMAT_CRYPTO + " could not be loaded from the Camel context").build();
- }
-
- @Path("/load/dataformat/pgp")
- @GET
- @Produces(MediaType.TEXT_PLAIN)
- public Response loadDataformatPgp() throws Exception {
- /* This is an autogenerated test */
- if (context.resolveDataFormat(DATAFORMAT_PGP) != null) {
- return Response.ok().build();
- }
- LOG.warnf("Could not load [%s] from the Camel context", DATAFORMAT_PGP);
- return Response.status(500, DATAFORMAT_PGP + " could not be loaded from the Camel context").build();
- }
-}
diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml
index de159fc..d86a722 100644
--- a/extensions-jvm/pom.xml
+++ b/extensions-jvm/pom.xml
@@ -58,7 +58,6 @@
<module>cometd</module>
<module>corda</module>
<module>couchbase</module>
- <module>crypto</module>
<module>debezium-mongodb</module>
<module>digitalocean</module>
<module>djl</module>
diff --git a/extensions-support/bouncycastle/deployment/pom.xml b/extensions-support/bouncycastle/deployment/pom.xml
index 50bd224..69b6486 100644
--- a/extensions-support/bouncycastle/deployment/pom.xml
+++ b/extensions-support/bouncycastle/deployment/pom.xml
@@ -38,14 +38,6 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-bouncycastle</artifactId>
</dependency>
- <dependency>
- <artifactId>bcprov-jdk15on</artifactId>
- <groupId>org.bouncycastle</groupId>
- </dependency>
- <dependency>
- <artifactId>bcpkix-jdk15on</artifactId>
- <groupId>org.bouncycastle</groupId>
- </dependency>
</dependencies>
<build>
diff --git a/extensions-support/bouncycastle/deployment/src/main/java/org/apache/camel/quarkus/support/bouncycastle/deployment/BouncycastleSupportProcessor.java b/extensions-support/bouncycastle/deployment/src/main/java/org/apache/camel/quarkus/support/bouncycastle/deployment/BouncyCastleSupportProcessor.java
similarity index 81%
rename from extensions-support/bouncycastle/deployment/src/main/java/org/apache/camel/quarkus/support/bouncycastle/deployment/BouncycastleSupportProcessor.java
rename to extensions-support/bouncycastle/deployment/src/main/java/org/apache/camel/quarkus/support/bouncycastle/deployment/BouncyCastleSupportProcessor.java
index c940eeb..3de6333 100644
--- a/extensions-support/bouncycastle/deployment/src/main/java/org/apache/camel/quarkus/support/bouncycastle/deployment/BouncycastleSupportProcessor.java
+++ b/extensions-support/bouncycastle/deployment/src/main/java/org/apache/camel/quarkus/support/bouncycastle/deployment/BouncyCastleSupportProcessor.java
@@ -20,14 +20,18 @@ import java.util.Arrays;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.annotations.ExecutionTime;
+import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
+import io.quarkus.deployment.builditem.ShutdownContextBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem;
+import org.apache.camel.quarkus.support.bouncycastle.BouncyCastleRecorder;
import org.jboss.jandex.IndexView;
-public class BouncycastleSupportProcessor {
+public class BouncyCastleSupportProcessor {
static final String FEATURE = "camel-support-bouncycastle";
@BuildStep
@@ -45,7 +49,6 @@ public class BouncycastleSupportProcessor {
n.startsWith("org.bouncycastle.jcajce.provider.symmetric.") ||
n.startsWith("org.bouncycastle.jcajce.provider.asymmetric.") ||
n.startsWith("org.bouncycastle.jcajce.provider.keystore."))
- .sorted()
.toArray(String[]::new);
return new ReflectiveClassBuildItem(false, false, dtos);
@@ -58,12 +61,18 @@ public class BouncycastleSupportProcessor {
@BuildStep
void secureRandomConfiguration(BuildProducer<RuntimeReinitializedClassBuildItem> reinitialized) {
- for (String s : Arrays.asList(
+ for (String reinitialziedClassName : Arrays.asList(
"java.security.SecureRandom",
"org.bouncycastle.crypto.CryptoServicesRegistrar",
"org.bouncycastle.jcajce.provider.drbg.DRBG$NonceAndIV",
"org.bouncycastle.jcajce.provider.drbg.DRBG$Default")) {
- reinitialized.produce(new RuntimeReinitializedClassBuildItem(s));
+ reinitialized.produce(new RuntimeReinitializedClassBuildItem(reinitialziedClassName));
}
}
+
+ @BuildStep
+ @Record(ExecutionTime.STATIC_INIT)
+ public void registerBouncyCastleProvider(BouncyCastleRecorder recorder, ShutdownContextBuildItem shutdownContextBuildItem) {
+ recorder.registerBouncyCastleProvider(shutdownContextBuildItem);
+ }
}
diff --git a/extensions-support/bouncycastle/runtime/pom.xml b/extensions-support/bouncycastle/runtime/pom.xml
index 892e302..eade217 100644
--- a/extensions-support/bouncycastle/runtime/pom.xml
+++ b/extensions-support/bouncycastle/runtime/pom.xml
@@ -52,6 +52,14 @@
<artifactId>quarkus-core</artifactId>
</dependency>
<dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk15on</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcpkix-jdk15on</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</dependency>
diff --git a/extensions-support/bouncycastle/runtime/src/main/java/org/apache/camel/quarkus/support/bouncycastle/BouncyCastleRecorder.java b/extensions-support/bouncycastle/runtime/src/main/java/org/apache/camel/quarkus/support/bouncycastle/BouncyCastleRecorder.java
new file mode 100644
index 0000000..fe0d3ee
--- /dev/null
+++ b/extensions-support/bouncycastle/runtime/src/main/java/org/apache/camel/quarkus/support/bouncycastle/BouncyCastleRecorder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.quarkus.support.bouncycastle;
+
+import java.security.Security;
+
+import io.quarkus.runtime.ShutdownContext;
+import io.quarkus.runtime.annotations.Recorder;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+
+@Recorder
+public class BouncyCastleRecorder {
+
+ public void registerBouncyCastleProvider(ShutdownContext shutdownContext) {
+ BouncyCastleProvider provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
+ shutdownContext.addShutdownTask(new Runnable() {
+ @Override
+ public void run() {
+ Security.removeProvider(provider.getName());
+ }
+ });
+ }
+}
diff --git a/extensions-jvm/crypto/deployment/pom.xml b/extensions/crypto/deployment/pom.xml
similarity index 93%
rename from extensions-jvm/crypto/deployment/pom.xml
rename to extensions/crypto/deployment/pom.xml
index 4cd0024..aa400db 100644
--- a/extensions-jvm/crypto/deployment/pom.xml
+++ b/extensions/crypto/deployment/pom.xml
@@ -38,6 +38,10 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-bouncycastle-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-crypto</artifactId>
</dependency>
</dependencies>
diff --git a/extensions-jvm/crypto/deployment/src/main/java/org/apache/camel/quarkus/component/crypto/deployment/CryptoProcessor.java b/extensions/crypto/deployment/src/main/java/org/apache/camel/quarkus/component/crypto/deployment/CryptoProcessor.java
similarity index 62%
rename from extensions-jvm/crypto/deployment/src/main/java/org/apache/camel/quarkus/component/crypto/deployment/CryptoProcessor.java
rename to extensions/crypto/deployment/src/main/java/org/apache/camel/quarkus/component/crypto/deployment/CryptoProcessor.java
index 25694e7..60a3645 100644
--- a/extensions-jvm/crypto/deployment/src/main/java/org/apache/camel/quarkus/component/crypto/deployment/CryptoProcessor.java
+++ b/extensions/crypto/deployment/src/main/java/org/apache/camel/quarkus/component/crypto/deployment/CryptoProcessor.java
@@ -17,16 +17,11 @@
package org.apache.camel.quarkus.component.crypto.deployment;
import io.quarkus.deployment.annotations.BuildStep;
-import io.quarkus.deployment.annotations.ExecutionTime;
-import io.quarkus.deployment.annotations.Record;
+import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
-import io.quarkus.deployment.pkg.steps.NativeBuild;
-import org.apache.camel.quarkus.core.JvmOnlyRecorder;
-import org.jboss.logging.Logger;
class CryptoProcessor {
- private static final Logger LOG = Logger.getLogger(CryptoProcessor.class);
private static final String FEATURE = "camel-crypto";
@BuildStep
@@ -34,13 +29,8 @@ class CryptoProcessor {
return new FeatureBuildItem(FEATURE);
}
- /**
- * Remove this once this extension starts supporting the native mode.
- */
- @BuildStep(onlyIf = NativeBuild.class)
- @Record(value = ExecutionTime.RUNTIME_INIT)
- void warnJvmInNative(JvmOnlyRecorder recorder) {
- JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time
- recorder.warnJvmInNative(FEATURE); // warn at runtime
+ @BuildStep
+ ExtensionSslNativeSupportBuildItem activeNativeSSLSupport() {
+ return new ExtensionSslNativeSupportBuildItem(FEATURE);
}
}
diff --git a/extensions-jvm/crypto/pom.xml b/extensions/crypto/pom.xml
similarity index 97%
rename from extensions-jvm/crypto/pom.xml
rename to extensions/crypto/pom.xml
index e8b5ad2..96e6e94 100644
--- a/extensions-jvm/crypto/pom.xml
+++ b/extensions/crypto/pom.xml
@@ -35,6 +35,5 @@
<modules>
<module>deployment</module>
<module>runtime</module>
- <module>integration-test</module>
</modules>
</project>
diff --git a/extensions-jvm/crypto/runtime/pom.xml b/extensions/crypto/runtime/pom.xml
similarity index 93%
rename from extensions-jvm/crypto/runtime/pom.xml
rename to extensions/crypto/runtime/pom.xml
index 754424e..ea842f7 100644
--- a/extensions-jvm/crypto/runtime/pom.xml
+++ b/extensions/crypto/runtime/pom.xml
@@ -34,6 +34,7 @@
<properties>
<camel.quarkus.jvmSince>1.1.0</camel.quarkus.jvmSince>
+ <camel.quarkus.nativeSince>1.2.0</camel.quarkus.nativeSince>
</properties>
<dependencyManagement>
@@ -54,6 +55,10 @@
<artifactId>camel-quarkus-core</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-bouncycastle</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-crypto</artifactId>
</dependency>
diff --git a/extensions-jvm/crypto/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/crypto/runtime/src/main/resources/META-INF/quarkus-extension.yaml
similarity index 97%
rename from extensions-jvm/crypto/runtime/src/main/resources/META-INF/quarkus-extension.yaml
rename to extensions/crypto/runtime/src/main/resources/META-INF/quarkus-extension.yaml
index 1ec146d..77cc425 100644
--- a/extensions-jvm/crypto/runtime/src/main/resources/META-INF/quarkus-extension.yaml
+++ b/extensions/crypto/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -24,9 +24,8 @@
name: "Camel Crypto (JCE)"
description: "Sign and verify exchanges using the Signature Service of the Java Cryptographic Extension (JCE)"
metadata:
- unlisted: true
guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/crypto.html"
categories:
- "integration"
status:
- - "preview"
+ - "stable"
diff --git a/extensions/pom.xml b/extensions/pom.xml
index b2d2574..6dbc4ab 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -86,6 +86,7 @@
<module>controlbus</module>
<module>couchdb</module>
<module>cron</module>
+ <module>crypto</module>
<module>csv</module>
<module>dataformat</module>
<module>debezium-mysql</module>
diff --git a/extensions-jvm/crypto/integration-test/pom.xml b/integration-tests/crypto/pom.xml
similarity index 53%
rename from extensions-jvm/crypto/integration-test/pom.xml
rename to integration-tests/crypto/pom.xml
index 40c5062..33d1d9b 100644
--- a/extensions-jvm/crypto/integration-test/pom.xml
+++ b/integration-tests/crypto/pom.xml
@@ -23,25 +23,14 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
- <artifactId>camel-quarkus-build-parent-it</artifactId>
+ <artifactId>camel-quarkus-integration-tests</artifactId>
<version>1.2.0-SNAPSHOT</version>
- <relativePath>../../../poms/build-parent-it/pom.xml</relativePath>
</parent>
- <artifactId>camel-quarkus-crypto-integration-test</artifactId>
- <name>Camel Quarkus :: Crypto (JCE) :: Integration Test</name>
+ <artifactId>camel-quarkus-integration-test-crypto</artifactId>
+ <name>Camel Quarkus :: Integration Tests :: Crypto (JCE)</name>
<description>Integration tests for Camel Quarkus Crypto (JCE) extension</description>
- <properties>
- <!-- mvnd, a.k.a. Maven Daemon: https://github.com/mvndaemon/mvnd -->
- <!-- The following rule tells mvnd to build the listed deployment modules before this module. -->
- <!-- This is important because mvnd builds modules in parallel by default. The deployment modules are not -->
- <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. -->
- <!-- Please update the rule whenever you change the dependencies of this module by running -->
- <!-- mvn process-resources -Pformat from the root directory -->
- <mvnd.builder.rule>camel-quarkus-crypto-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule>
- </properties>
-
<dependencyManagement>
<dependencies>
<dependency>
@@ -60,6 +49,10 @@
<artifactId>camel-quarkus-crypto</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct</artifactId>
+ </dependency>
+ <dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
@@ -75,6 +68,34 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
+
+ <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-crypto-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
</dependencies>
<build>
@@ -92,4 +113,34 @@
</plugin>
</plugins>
</build>
+
+ <profiles>
+ <profile>
+ <id>native</id>
+ <activation>
+ <property>
+ <name>native</name>
+ </property>
+ </activation>
+ <properties>
+ <quarkus.package.type>native</quarkus.package.type>
+ </properties>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-failsafe-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>integration-test</goal>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
diff --git a/integration-tests/crypto/src/main/java/org/apache/camel/quarkus/component/crypto/it/CryptoResource.java b/integration-tests/crypto/src/main/java/org/apache/camel/quarkus/component/crypto/it/CryptoResource.java
new file mode 100644
index 0000000..ca7c397
--- /dev/null
+++ b/integration-tests/crypto/src/main/java/org/apache/camel/quarkus/component/crypto/it/CryptoResource.java
@@ -0,0 +1,124 @@
+/*
+ * 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.quarkus.component.crypto.it;
+
+import java.io.InputStream;
+import java.security.KeyStore;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.SecureRandom;
+import java.security.cert.Certificate;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+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.crypto.DigitalSignatureConstants;
+
+@Path("/crypto")
+public class CryptoResource {
+
+ public static final String MESSAGE = "Hello Camel Quarkus Crypto";
+ private static final String ALIAS = "bob";
+ private static final String KEYSTORE = "crypto.jks";
+ private static final String KEYSTORE_PASSWORD = "letmein";
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @Path("/signature/sign")
+ @POST
+ public byte[] sign() {
+ Exchange exchange = producerTemplate.request("direct:sign", new Processor() {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ exchange.getMessage().setBody(MESSAGE);
+ }
+ });
+ Message message = exchange.getMessage();
+ return message.getHeader(DigitalSignatureConstants.SIGNATURE, byte[].class);
+ }
+
+ @Path("/signature/verify")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ public void verify(String signature) {
+ producerTemplate.sendBodyAndHeader("direct:verify", MESSAGE, DigitalSignatureConstants.SIGNATURE, signature);
+ }
+
+ @Path("/encrypt")
+ @POST
+ public byte[] encryptPayload(String payload) {
+ return producerTemplate.requestBody("direct:marshal", payload, byte[].class);
+ }
+
+ @Path("/decrypt")
+ @POST
+ @Produces(MediaType.TEXT_PLAIN)
+ public String decryptPgpPayload(byte[] payload) {
+ return producerTemplate.requestBody("direct:unmarshal", payload, String.class);
+ }
+
+ @Path("/encrypt/pgp")
+ @POST
+ public byte[] encryptPgpPayload(String payload) {
+ return producerTemplate.requestBody("direct:marshalPgp", payload, byte[].class);
+ }
+
+ @Path("/decrypt/pgp")
+ @POST
+ @Produces(MediaType.TEXT_PLAIN)
+ public String decryptPayload(byte[] payload) {
+ return producerTemplate.requestBody("direct:unmarshalPgp", payload, String.class);
+ }
+
+ @javax.enterprise.inject.Produces
+ public KeyStore keyStore() throws Exception {
+ KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
+ try (InputStream in = getClass().getResourceAsStream("/" + KEYSTORE)) {
+ keystore.load(in, KEYSTORE_PASSWORD.toCharArray());
+ }
+ return keystore;
+ }
+
+ @javax.enterprise.inject.Produces
+ @Named
+ public PrivateKey myPrivateKey(KeyStore keyStore) throws Exception {
+ return (PrivateKey) keyStore.getKey(ALIAS, KEYSTORE_PASSWORD.toCharArray());
+ }
+
+ @javax.enterprise.inject.Produces
+ @Named
+ public PublicKey myPublicKey(KeyStore keyStore) throws Exception {
+ Certificate cert = keyStore.getCertificate(ALIAS);
+ return cert.getPublicKey();
+ }
+
+ @javax.enterprise.inject.Produces
+ @Named
+ public SecureRandom customSecureRandom() {
+ return new SecureRandom();
+ }
+}
diff --git a/integration-tests/crypto/src/main/java/org/apache/camel/quarkus/component/crypto/it/CryptoRoutes.java b/integration-tests/crypto/src/main/java/org/apache/camel/quarkus/component/crypto/it/CryptoRoutes.java
new file mode 100644
index 0000000..6ba8bee
--- /dev/null
+++ b/integration-tests/crypto/src/main/java/org/apache/camel/quarkus/component/crypto/it/CryptoRoutes.java
@@ -0,0 +1,69 @@
+/*
+ * 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.quarkus.component.crypto.it;
+
+import java.security.NoSuchAlgorithmException;
+
+import javax.crypto.KeyGenerator;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.converter.crypto.CryptoDataFormat;
+import org.apache.camel.converter.crypto.PGPDataFormat;
+
+public class CryptoRoutes extends RouteBuilder {
+
+ @Override
+ public void configure() throws Exception {
+
+ // Crypto component
+ from("direct:sign")
+ .to("crypto:sign:basic?privateKey=#myPrivateKey&algorithm=SHA1withDSA&provider=SUN&secureRandom=#customSecureRandom");
+
+ from("direct:verify")
+ .to("crypto:verify:basic?publicKey=#myPublicKey&algorithm=SHA1withDSA&provider=SUN&secureRandom=#customSecureRandom");
+
+ // Crypto data format
+ CryptoDataFormat cryptoDataFormat = getCryptoDataFormat();
+ from("direct:marshal")
+ .marshal(cryptoDataFormat);
+
+ from("direct:unmarshal")
+ .unmarshal(cryptoDataFormat);
+
+ // PGP data format
+ PGPDataFormat encrypt = getPgpDataFormat("pubring.pgp");
+ PGPDataFormat decrypt = getPgpDataFormat("secring.pgp");
+ from("direct:marshalPgp")
+ .marshal(encrypt);
+
+ from("direct:unmarshalPgp")
+ .unmarshal(decrypt);
+ }
+
+ private CryptoDataFormat getCryptoDataFormat() throws NoSuchAlgorithmException {
+ KeyGenerator generator = KeyGenerator.getInstance("DES");
+ return new CryptoDataFormat("DES", generator.generateKey());
+ }
+
+ private PGPDataFormat getPgpDataFormat(String keyFile) {
+ PGPDataFormat encrypt = new PGPDataFormat();
+ encrypt.setKeyFileName(keyFile);
+ encrypt.setKeyUserid("sdude@nowhere.net");
+ encrypt.setPassword("sdude");
+ return encrypt;
+ }
+}
diff --git a/integration-tests/crypto/src/main/resources/application.properties b/integration-tests/crypto/src/main/resources/application.properties
new file mode 100644
index 0000000..e7eb376
--- /dev/null
+++ b/integration-tests/crypto/src/main/resources/application.properties
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+quarkus.camel.native.resources.include-patterns=*.jks,*.pgp
diff --git a/integration-tests/crypto/src/main/resources/crypto.jks b/integration-tests/crypto/src/main/resources/crypto.jks
new file mode 100644
index 0000000..7db483e
Binary files /dev/null and b/integration-tests/crypto/src/main/resources/crypto.jks differ
diff --git a/integration-tests/crypto/src/main/resources/pubring.pgp b/integration-tests/crypto/src/main/resources/pubring.pgp
new file mode 100644
index 0000000..21029c6
Binary files /dev/null and b/integration-tests/crypto/src/main/resources/pubring.pgp differ
diff --git a/integration-tests/crypto/src/main/resources/secring.pgp b/integration-tests/crypto/src/main/resources/secring.pgp
new file mode 100644
index 0000000..36af553
Binary files /dev/null and b/integration-tests/crypto/src/main/resources/secring.pgp differ
diff --git a/extensions-jvm/crypto/integration-test/src/test/java/org/apache/camel/quarkus/component/crypto/it/CryptoTest.java b/integration-tests/crypto/src/test/java/org/apache/camel/quarkus/component/crypto/it/CryptoIT.java
similarity index 52%
rename from extensions-jvm/crypto/integration-test/src/test/java/org/apache/camel/quarkus/component/crypto/it/CryptoTest.java
rename to integration-tests/crypto/src/test/java/org/apache/camel/quarkus/component/crypto/it/CryptoIT.java
index 3c17370..e87d7e3 100644
--- a/extensions-jvm/crypto/integration-test/src/test/java/org/apache/camel/quarkus/component/crypto/it/CryptoTest.java
+++ b/integration-tests/crypto/src/test/java/org/apache/camel/quarkus/component/crypto/it/CryptoIT.java
@@ -16,35 +16,9 @@
*/
package org.apache.camel.quarkus.component.crypto.it;
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import org.junit.jupiter.api.Test;
+import io.quarkus.test.junit.NativeImageTest;
-@QuarkusTest
-class CryptoTest {
-
- @Test
- public void loadComponentCrypto() {
- /* A simple autogenerated test */
- RestAssured.get("/crypto/load/component/crypto")
- .then()
- .statusCode(200);
- }
-
- @Test
- public void loadDataformatCrypto() {
- /* A simple autogenerated test */
- RestAssured.get("/crypto/load/dataformat/crypto")
- .then()
- .statusCode(200);
- }
-
- @Test
- public void loadDataformatPgp() {
- /* A simple autogenerated test */
- RestAssured.get("/crypto/load/dataformat/pgp")
- .then()
- .statusCode(200);
- }
+@NativeImageTest
+class CryptoIT extends CryptoTest {
}
diff --git a/integration-tests/crypto/src/test/java/org/apache/camel/quarkus/component/crypto/it/CryptoTest.java b/integration-tests/crypto/src/test/java/org/apache/camel/quarkus/component/crypto/it/CryptoTest.java
new file mode 100644
index 0000000..45c471b
--- /dev/null
+++ b/integration-tests/crypto/src/test/java/org/apache/camel/quarkus/component/crypto/it/CryptoTest.java
@@ -0,0 +1,111 @@
+/*
+ * 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.quarkus.component.crypto.it;
+
+import java.nio.charset.StandardCharsets;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import org.apache.commons.codec.binary.Base64;
+import org.junit.jupiter.api.Test;
+
+import static org.apache.camel.quarkus.component.crypto.it.CryptoResource.MESSAGE;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@QuarkusTest
+class CryptoTest {
+
+ @Test
+ public void signAndVerifySignature() {
+ // Encrypt message
+ byte[] signatureBytes = RestAssured.given()
+ .post("/crypto/signature/sign")
+ .then()
+ .statusCode(200)
+ .extract()
+ .body()
+ .asByteArray();
+
+ assertTrue(Base64.isBase64(signatureBytes));
+
+ // Verify bad signature fails
+ byte[] badSignature = "an invalid signature".getBytes(StandardCharsets.UTF_8);
+
+ RestAssured.given()
+ .body(Base64.encodeBase64String(badSignature))
+ .post("/crypto/signature/verify")
+ .then()
+ .statusCode(500);
+
+ // Verify valid signature
+ String signature = new String(signatureBytes, StandardCharsets.UTF_8);
+
+ RestAssured.given()
+ .body(signature)
+ .post("/crypto/signature/verify")
+ .then()
+ .statusCode(204);
+ }
+
+ @Test
+ public void encryptDecryptMessage() {
+ byte[] encrypted = RestAssured.given()
+ .body(MESSAGE)
+ .post("/crypto/encrypt")
+ .then()
+ .statusCode(200)
+ .extract()
+ .body()
+ .asByteArray();
+
+ String decrypted = RestAssured.given()
+ .body(encrypted)
+ .post("/crypto/decrypt")
+ .then()
+ .statusCode(200)
+ .extract()
+ .body()
+ .asString();
+
+ assertEquals(MESSAGE, decrypted);
+ }
+
+ @Test
+ public void encryptDecryptPgpMessage() {
+ byte[] encrypted = RestAssured.given()
+ .body(MESSAGE)
+ .post("/crypto/encrypt/pgp")
+ .then()
+ .statusCode(200)
+ .extract()
+ .body()
+ .asByteArray();
+
+ String decrypted = RestAssured.given()
+ .body(encrypted)
+ .post("/crypto/decrypt/pgp")
+ .then()
+ .statusCode(200)
+ .extract()
+ .body()
+ .asString();
+
+ assertEquals(MESSAGE, decrypted);
+ }
+
+}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index 3941940..2b30730 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -78,6 +78,7 @@
<module>compression</module>
<module>consul</module>
<module>couchdb</module>
+ <module>crypto</module>
<module>csv</module>
<module>dataformat</module>
<module>dataformats-json</module>
diff --git a/pom.xml b/pom.xml
index e24561c..b0e652e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -400,6 +400,7 @@
<exclude>**/*.mvel</exclude>
<exclude>**/*.p12</exclude>
<exclude>**/*.pem</exclude>
+ <exclude>**/*.pgp</exclude>
<exclude>**/*.proto</exclude>
<exclude>**/*.txt</exclude>
<exclude>**/.factorypath</exclude>
diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml
index 5e651e5..db2d809 100644
--- a/tooling/scripts/test-categories.yaml
+++ b/tooling/scripts/test-categories.yaml
@@ -85,6 +85,7 @@ dozer-social:
- twitter
- master
- syndication
+ - crypto
messaging-networking1:
- activemq
- amqp