diff --git a/extensions/jasypt/deployment/src/main/java/org/apache/camel/quarkus/component/jasypt/deployment/JasyptProcessor.java b/extensions/jasypt/deployment/src/main/java/org/apache/camel/quarkus/component/jasypt/deployment/JasyptProcessor.java
index bd87b43d0009..4e22772179cb 100644
--- a/extensions/jasypt/deployment/src/main/java/org/apache/camel/quarkus/component/jasypt/deployment/JasyptProcessor.java
+++ b/extensions/jasypt/deployment/src/main/java/org/apache/camel/quarkus/component/jasypt/deployment/JasyptProcessor.java
@@ -81,7 +81,7 @@ static final class CamelJasyptEnabled implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
- return config.enabled;
+ return config.enabled();
}
}
}
diff --git a/extensions/jasypt/deployment/src/main/java/org/apache/camel/quarkus/component/jasypt/deployment/devui/JasyptUtilsDevUIProcessor.java b/extensions/jasypt/deployment/src/main/java/org/apache/camel/quarkus/component/jasypt/deployment/devui/JasyptUtilsDevUIProcessor.java
index fd39facf2877..96abf86c05e8 100644
--- a/extensions/jasypt/deployment/src/main/java/org/apache/camel/quarkus/component/jasypt/deployment/devui/JasyptUtilsDevUIProcessor.java
+++ b/extensions/jasypt/deployment/src/main/java/org/apache/camel/quarkus/component/jasypt/deployment/devui/JasyptUtilsDevUIProcessor.java
@@ -49,7 +49,7 @@ static final class CamelJasyptEnabled implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
- return config.enabled;
+ return config.enabled();
}
}
}
diff --git a/extensions/jasypt/deployment/src/test/java/org/apache/camel/quarkus/component/jasypt/JasyptPasswordNotProvidedTest.java b/extensions/jasypt/deployment/src/test/java/org/apache/camel/quarkus/component/jasypt/JasyptPasswordNotProvidedTest.java
index e7af5c50a64a..1cf46bb3b8ba 100644
--- a/extensions/jasypt/deployment/src/test/java/org/apache/camel/quarkus/component/jasypt/JasyptPasswordNotProvidedTest.java
+++ b/extensions/jasypt/deployment/src/test/java/org/apache/camel/quarkus/component/jasypt/JasyptPasswordNotProvidedTest.java
@@ -17,6 +17,9 @@
package org.apache.camel.quarkus.component.jasypt;
import io.quarkus.test.QuarkusUnitTest;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jasypt.JasyptPropertiesParser;
+import org.apache.camel.component.properties.PropertiesComponent;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
@@ -25,11 +28,27 @@
public class JasyptPasswordNotProvidedTest {
@RegisterExtension
static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
+ .overrideConfigKey("greeting.secret", "ENC(GKJfy64eBDzxUuQCfArd6OjnAaW/oM9e)")
.setExpectedException(IllegalStateException.class)
- .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
+ .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class).addClass(JasyptRoutes.class));
@Test
void passwordNotProvidedThrowsException() {
// Nothing to test as we just verify the application fails to start
}
+
+ public static final class JasyptRoutes extends RouteBuilder {
+ @Override
+ public void configure() {
+ JasyptPropertiesParser jasypt = new JasyptPropertiesParser();
+ jasypt.setPassword("2s3cr3t");
+
+ PropertiesComponent component = (PropertiesComponent) getContext().getPropertiesComponent();
+ jasypt.setPropertiesComponent(component);
+ component.setPropertiesParser(jasypt);
+
+ from("direct:decryptManualConfiguration")
+ .setBody().simple("{{greeting.secret}}");
+ }
+ }
}
diff --git a/extensions/jasypt/deployment/src/test/java/org/apache/camel/quarkus/component/jasypt/JasyptPasswordSysEnvValueMissingTest.java b/extensions/jasypt/deployment/src/test/java/org/apache/camel/quarkus/component/jasypt/JasyptPasswordSysEnvValueMissingTest.java
index 10299440b185..9bf7fbe1de21 100644
--- a/extensions/jasypt/deployment/src/test/java/org/apache/camel/quarkus/component/jasypt/JasyptPasswordSysEnvValueMissingTest.java
+++ b/extensions/jasypt/deployment/src/test/java/org/apache/camel/quarkus/component/jasypt/JasyptPasswordSysEnvValueMissingTest.java
@@ -17,6 +17,9 @@
package org.apache.camel.quarkus.component.jasypt;
import io.quarkus.test.QuarkusUnitTest;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jasypt.JasyptPropertiesParser;
+import org.apache.camel.component.properties.PropertiesComponent;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
@@ -27,12 +30,28 @@ public class JasyptPasswordSysEnvValueMissingTest {
@RegisterExtension
static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
+ .overrideConfigKey("greeting.secret", "ENC(GKJfy64eBDzxUuQCfArd6OjnAaW/oM9e)")
.overrideConfigKey("quarkus.camel.jasypt.password", "sysenv:" + PASSWORD_VAR_NAME)
.setExpectedException(IllegalStateException.class)
- .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
+ .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class).addClass(JasyptRoutes.class));
@Test
void nonExistentPasswordEnvironmentVariableHandledGracefully() {
// Nothing to test as we just verify the application fails to start
}
+
+ public static final class JasyptRoutes extends RouteBuilder {
+ @Override
+ public void configure() {
+ JasyptPropertiesParser jasypt = new JasyptPropertiesParser();
+ jasypt.setPassword("2s3cr3t");
+
+ PropertiesComponent component = (PropertiesComponent) getContext().getPropertiesComponent();
+ jasypt.setPropertiesComponent(component);
+ component.setPropertiesParser(jasypt);
+
+ from("direct:decryptManualConfiguration")
+ .setBody().simple("{{greeting.secret}}");
+ }
+ }
}
diff --git a/extensions/jasypt/deployment/src/test/java/org/apache/camel/quarkus/component/jasypt/JasyptPasswordSysValueMissingTest.java b/extensions/jasypt/deployment/src/test/java/org/apache/camel/quarkus/component/jasypt/JasyptPasswordSysValueMissingTest.java
index b78a6486c5d2..d4f783eba9b7 100644
--- a/extensions/jasypt/deployment/src/test/java/org/apache/camel/quarkus/component/jasypt/JasyptPasswordSysValueMissingTest.java
+++ b/extensions/jasypt/deployment/src/test/java/org/apache/camel/quarkus/component/jasypt/JasyptPasswordSysValueMissingTest.java
@@ -17,6 +17,9 @@
package org.apache.camel.quarkus.component.jasypt;
import io.quarkus.test.QuarkusUnitTest;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jasypt.JasyptPropertiesParser;
+import org.apache.camel.component.properties.PropertiesComponent;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
@@ -27,12 +30,28 @@ public class JasyptPasswordSysValueMissingTest {
@RegisterExtension
static final QuarkusUnitTest CONFIG = new QuarkusUnitTest()
+ .overrideConfigKey("greeting.secret", "ENC(GKJfy64eBDzxUuQCfArd6OjnAaW/oM9e)")
.overrideConfigKey("quarkus.camel.jasypt.password", "sys:" + PASSWORD_PROPERTY_NAME)
.setExpectedException(IllegalStateException.class)
- .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class));
+ .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class).addClass(JasyptRoutes.class));
@Test
void nonExistentPasswordSystemPropertyHandledGracefully() {
// Nothing to test as we just verify the application fails to start
}
+
+ public static final class JasyptRoutes extends RouteBuilder {
+ @Override
+ public void configure() {
+ JasyptPropertiesParser jasypt = new JasyptPropertiesParser();
+ jasypt.setPassword("2s3cr3t");
+
+ PropertiesComponent component = (PropertiesComponent) getContext().getPropertiesComponent();
+ jasypt.setPropertiesComponent(component);
+ component.setPropertiesParser(jasypt);
+
+ from("direct:decryptManualConfiguration")
+ .setBody().simple("{{greeting.secret}}");
+ }
+ }
}
diff --git a/extensions/jasypt/runtime/src/main/java/org/apache/camel/quarkus/component/jasypt/CamelJasyptBuildTimeConfig.java b/extensions/jasypt/runtime/src/main/java/org/apache/camel/quarkus/component/jasypt/CamelJasyptBuildTimeConfig.java
index 074d90955e9f..f0325ee5d4ad 100644
--- a/extensions/jasypt/runtime/src/main/java/org/apache/camel/quarkus/component/jasypt/CamelJasyptBuildTimeConfig.java
+++ b/extensions/jasypt/runtime/src/main/java/org/apache/camel/quarkus/component/jasypt/CamelJasyptBuildTimeConfig.java
@@ -16,21 +16,19 @@
*/
package org.apache.camel.quarkus.component.jasypt;
-import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
+import io.smallrye.config.ConfigMapping;
+import io.smallrye.config.WithDefault;
-/**
- * Note: This class exists mainly for documentation purposes. The actual configuration values
- * are read via the SmallRye config internals within the SecretKeysHandler.
- */
-@ConfigRoot(name = "camel.jasypt", phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
-public class CamelJasyptBuildTimeConfig {
+@ConfigMapping(prefix = "quarkus.camel.jasypt")
+@ConfigRoot(phase = ConfigPhase.BUILD_AND_RUN_TIME_FIXED)
+public interface CamelJasyptBuildTimeConfig {
/**
* Setting this option to false will disable Jasypt integration with Quarkus SmallRye configuration.
* You can however, manually configure Jasypt with Camel in the 'classic' way of manually configuring
* JasyptPropertiesParser and PropertiesComponent. Refer to the usage section for more details.
*/
- @ConfigItem(defaultValue = "true")
- public boolean enabled;
+ @WithDefault("true")
+ boolean enabled();
}
diff --git a/extensions/jasypt/runtime/src/main/java/org/apache/camel/quarkus/component/jasypt/CamelJasyptConfig.java b/extensions/jasypt/runtime/src/main/java/org/apache/camel/quarkus/component/jasypt/CamelJasyptConfig.java
index 420689a1c230..20a9085ace83 100644
--- a/extensions/jasypt/runtime/src/main/java/org/apache/camel/quarkus/component/jasypt/CamelJasyptConfig.java
+++ b/extensions/jasypt/runtime/src/main/java/org/apache/camel/quarkus/component/jasypt/CamelJasyptConfig.java
@@ -16,29 +16,34 @@
*/
package org.apache.camel.quarkus.component.jasypt;
+import java.lang.reflect.InvocationTargetException;
import java.util.Optional;
+import java.util.Set;
-import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
+import io.smallrye.config.ConfigMapping;
+import io.smallrye.config.WithDefault;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.camel.util.StringHelper;
import org.jasypt.encryption.pbe.StandardPBEByteEncryptor;
+import org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig;
+import org.jasypt.encryption.pbe.config.PBEConfig;
+import org.jasypt.iv.NoIvGenerator;
import org.jasypt.iv.RandomIvGenerator;
import org.jasypt.salt.RandomSaltGenerator;
-/**
- * Note: This class exists mainly for documentation purposes. The actual configuration values
- * are read via the SmallRye config internals within the SecretKeysHandler.
- */
-@ConfigRoot(name = "camel.jasypt", phase = ConfigPhase.RUN_TIME)
-public class CamelJasyptConfig {
- static final String NAME = "camel-jasypt";
- static final String DEFAULT_ALGORITHM = StandardPBEByteEncryptor.DEFAULT_ALGORITHM;
+@ConfigMapping(prefix = "quarkus.camel.jasypt")
+@ConfigRoot(phase = ConfigPhase.RUN_TIME)
+public interface CamelJasyptConfig {
+ String NAME = "camel-jasypt";
+ String DEFAULT_ALGORITHM = StandardPBEByteEncryptor.DEFAULT_ALGORITHM;
/**
* The algorithm to be used for decryption.
*/
- @ConfigItem(defaultValue = DEFAULT_ALGORITHM)
- public String algorithm;
+ @WithDefault(DEFAULT_ALGORITHM)
+ String algorithm();
/**
* The master password used by Jasypt for decrypting configuration values.
@@ -48,25 +53,82 @@ public class CamelJasyptConfig {
* sysenv:
will look up the value from the OS system environment with the given key.
*
*/
- @ConfigItem
- public Optional