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 2020/10/06 16:35:41 UTC

[camel-spring-boot] branch master updated: Fix CamelJasyptTest integration test

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

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


The following commit(s) were added to refs/heads/master by this push:
     new b62297e  Fix CamelJasyptTest integration test
b62297e is described below

commit b62297e6257b1438c333c1a99c52625727cf6063
Author: Luigi De Masi <ld...@redhat.com>
AuthorDate: Tue Oct 6 18:10:49 2020 +0200

    Fix CamelJasyptTest integration test
---
 components-starter/camel-jasypt-starter/pom.xml    | 19 +++++
 .../src/main/docs/jasypt-starter.adoc              |  2 +-
 ...JasyptEncryptedPropertiesAutoconfiguration.java | 51 +-----------
 .../JasyptEncryptedPropertiesConfiguration.java    | 12 +--
 .../springboot/JasyptEncryptedPropertiesUtils.java | 91 +++++++++++++++++++++-
 ...ptedPropertiesIvGeneratorAutoDetectionTest.java | 83 ++++++++++++++++++++
 ...esIvGeneratorAutoDetectionBouncyCastleTest.java | 52 +++++++++++++
 ...tedPropertiesIvGeneratorAutoDetectionTest.java} | 43 +++++-----
 .../springboot/EncryptedPropertiesUtilsTest.java   | 54 +++++++++++++
 .../src/test/resources/application.properties      |  2 +-
 10 files changed, 332 insertions(+), 77 deletions(-)

diff --git a/components-starter/camel-jasypt-starter/pom.xml b/components-starter/camel-jasypt-starter/pom.xml
index 6fd7cd5..cf54307 100644
--- a/components-starter/camel-jasypt-starter/pom.xml
+++ b/components-starter/camel-jasypt-starter/pom.xml
@@ -28,6 +28,9 @@
   <packaging>jar</packaging>
   <name>Camel SB Starters :: Jasypt</name>
   <description>Spring-Boot Starter for Camel Jasypt support</description>
+  <properties>
+    <bouncy.castle.version>1.64</bouncy.castle.version>
+  </properties>
   <dependencies>
     <dependency>
       <groupId>org.springframework.boot</groupId>
@@ -39,6 +42,22 @@
       <artifactId>camel-jasypt</artifactId>
       <version>${camel-version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.assertj</groupId>
+      <artifactId>assertj-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.bouncycastle</groupId>
+      <artifactId>bcprov-debug-jdk15on</artifactId>
+      <version>${bouncy.castle.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.bouncycastle</groupId>
+      <artifactId>bcpkix-jdk15on</artifactId>
+      <version>${bouncy.castle.version}</version>
+      <scope>test</scope>
+    </dependency>
     <!--START OF GENERATED CODE-->
     <dependency>
       <groupId>org.apache.camel.springboot</groupId>
diff --git a/components-starter/camel-jasypt-starter/src/main/docs/jasypt-starter.adoc b/components-starter/camel-jasypt-starter/src/main/docs/jasypt-starter.adoc
index 5b3ed76..1c33d6a 100644
--- a/components-starter/camel-jasypt-starter/src/main/docs/jasypt-starter.adoc
+++ b/components-starter/camel-jasypt-starter/src/main/docs/jasypt-starter.adoc
@@ -29,6 +29,6 @@ The component supports 6 options, which are listed below.
 | *camel.component.jasypt.iv-generator-class-name* | The initialization vector (IV) generator applied in decryption operations. | org.jasypt.iv.NoIvGenerator if the algorithm does not require an initialization vector, org.jasypt.iv.RandomIvGenerator otherwise | String
 | *camel.component.jasypt.salt-generator-class-name* | The salt generator applied in decryption operations. | org.jasypt.salt.RandomSaltGenerator | String
 | *camel.component.jasypt.password* | The master password used by Jasypt for decrypting the values. This option supports prefixes which influence the master password lookup behaviour: sysenv: means to lookup the OS system environment with the given key. sys: means to lookup a JVM system property. |  | String
-| *camel.component.jasypt.provider-class-name* | The class name of the security provider to be used for obtaining the encryption algorithm. | com.sun.crypto.provider.SunJCE | String
+| *camel.component.jasypt.provider-name* | The name of the security provider to be used for obtaining the encryption algorithm. |  | String
 |===
 // spring-boot-auto-configure options: END
diff --git a/components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/JasyptEncryptedPropertiesAutoconfiguration.java b/components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/JasyptEncryptedPropertiesAutoconfiguration.java
index 556d59b..6c299bb 100644
--- a/components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/JasyptEncryptedPropertiesAutoconfiguration.java
+++ b/components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/JasyptEncryptedPropertiesAutoconfiguration.java
@@ -21,14 +21,8 @@ import org.apache.camel.spring.boot.CamelAutoConfiguration;
 import org.jasypt.encryption.StringEncryptor;
 import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
 import org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig;
-import org.jasypt.exceptions.EncryptionInitializationException;
-import org.jasypt.iv.IvGenerator;
-import org.jasypt.iv.NoIvGenerator;
-import org.jasypt.iv.RandomIvGenerator;
 import org.jasypt.salt.RandomSaltGenerator;
 import org.jasypt.salt.SaltGenerator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.boot.autoconfigure.AutoConfigureBefore;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -51,9 +45,9 @@ import org.springframework.core.env.PropertyResolver;
 import java.lang.annotation.Annotation;
 
 import static org.apache.camel.component.jasypt.springboot.JasyptEncryptedPropertiesConfiguration.PREFIX;
-import static org.apache.camel.component.jasypt.springboot.JasyptEncryptedPropertiesUtils.isIVNeeded;
-import static org.apache.camel.util.ObjectHelper.isNotEmpty;
-import static org.apache.camel.util.StringHelper.after;
+import static org.apache.camel.component.jasypt.springboot.JasyptEncryptedPropertiesUtils.getIVGenerator;
+import static org.apache.camel.component.jasypt.springboot.JasyptEncryptedPropertiesUtils.loadClass;
+import static org.apache.camel.component.jasypt.springboot.JasyptEncryptedPropertiesUtils.parsePassword;
 import static org.springframework.boot.context.properties.source.ConfigurationPropertySources.from;
 import static org.springframework.core.ResolvableType.forClass;
 import static org.springframework.core.annotation.AnnotationUtils.findAnnotation;
@@ -64,11 +58,6 @@ import static org.springframework.core.annotation.AnnotationUtils.findAnnotation
 @AutoConfigureBefore(CamelAutoConfiguration.class)
 public class JasyptEncryptedPropertiesAutoconfiguration {
 
-    private static final Logger LOG = LoggerFactory.getLogger(JasyptEncryptedPropertiesAutoconfiguration.class);
-
-    private static final String SYSTEM_ENVIRONMENT_PREFIX = "sysenv:";
-
-    private static final String SYSTEM_PROPERTIES_PREFIX = "sys:";
 
     @Bean
     public JasyptEncryptedPropertiesConfiguration JasyptEncryptedPropertiesAutoconfiguration(final ConfigurableEnvironment environment) {
@@ -94,7 +83,7 @@ public class JasyptEncryptedPropertiesAutoconfiguration {
         environmentStringPBEConfig.setAlgorithm(configuration.getAlgorithm());
         environmentStringPBEConfig.setIvGenerator(getIVGenerator(configuration));
         environmentStringPBEConfig.setSaltGenerator(getSaltGenerator(configuration));
-        environmentStringPBEConfig.setProviderClassName(configuration.getProviderClassName());
+        environmentStringPBEConfig.setProviderName(configuration.getProviderName());
         parsePassword(environmentStringPBEConfig, configuration);
         return environmentStringPBEConfig;
     }
@@ -129,36 +118,4 @@ public class JasyptEncryptedPropertiesAutoconfiguration {
         }
         return new RandomSaltGenerator();
     }
-
-    private IvGenerator getIVGenerator(JasyptEncryptedPropertiesConfiguration configuration) {
-        String ivGeneratorClassName = configuration.getIvGeneratorClassName();
-        IvGenerator ivGenerator = loadClass(ivGeneratorClassName);
-        if (ivGenerator != null) {
-            return ivGenerator;
-        }
-        String algorithm = configuration.getAlgorithm();
-        return isIVNeeded(algorithm) ? new RandomIvGenerator() : new NoIvGenerator();
-    }
-
-    private <T> T loadClass(String className) {
-        try {
-            final Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
-            return (T) clazz.newInstance();
-        } catch (Exception e) {
-            throw new EncryptionInitializationException(e);
-        }
-    }
-
-    private void parsePassword(EnvironmentStringPBEConfig environmentStringPBEConfig, JasyptEncryptedPropertiesConfiguration configuration) {
-        String passwordReference = configuration.getPassword();
-        if (isNotEmpty(passwordReference) && passwordReference.startsWith(SYSTEM_ENVIRONMENT_PREFIX)) {
-            environmentStringPBEConfig.setPasswordEnvName(after(passwordReference, SYSTEM_ENVIRONMENT_PREFIX));
-            return;
-        }
-        if (isNotEmpty(passwordReference) && passwordReference.startsWith(SYSTEM_PROPERTIES_PREFIX)) {
-            environmentStringPBEConfig.setPasswordSysPropertyName(after(passwordReference, SYSTEM_PROPERTIES_PREFIX));
-            return;
-        }
-        environmentStringPBEConfig.setPassword(passwordReference);
-    }
 }
diff --git a/components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/JasyptEncryptedPropertiesConfiguration.java b/components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/JasyptEncryptedPropertiesConfiguration.java
index cad23dd..b4e8a48 100644
--- a/components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/JasyptEncryptedPropertiesConfiguration.java
+++ b/components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/JasyptEncryptedPropertiesConfiguration.java
@@ -60,8 +60,8 @@ public class JasyptEncryptedPropertiesConfiguration {
      * The class name of the security provider to be used for obtaining the encryption
      * algorithm.
      */
-    @Value("${camel.component.jasypt.provider-class-name}")
-    private String providerClassName = "com.sun.crypto.provider.SunJCE";
+    @Value("${camel.component.jasypt.provider-name}")
+    private String providerName;
 
 
     public boolean isEnabled() {
@@ -104,12 +104,12 @@ public class JasyptEncryptedPropertiesConfiguration {
         this.saltGeneratorClassName = saltGeneratorClassName;
     }
 
-    public String getProviderClassName() {
-        return providerClassName;
+    public String getProviderName() {
+        return providerName;
     }
 
-    public void setProviderClassName(String providerClassName) {
-        this.providerClassName = providerClassName;
+    public void setProviderName(String providerName) {
+        this.providerName = providerName;
     }
 }
 
diff --git a/components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/JasyptEncryptedPropertiesUtils.java b/components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/JasyptEncryptedPropertiesUtils.java
index f171f79..1289ae0 100644
--- a/components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/JasyptEncryptedPropertiesUtils.java
+++ b/components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/JasyptEncryptedPropertiesUtils.java
@@ -16,12 +16,28 @@
  */
 package org.apache.camel.component.jasypt.springboot;
 
+import org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig;
+import org.jasypt.exceptions.EncryptionInitializationException;
+import org.jasypt.iv.IvGenerator;
+import org.jasypt.iv.NoIvGenerator;
+import org.jasypt.iv.RandomIvGenerator;
+
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.Set;
 
+import static org.apache.camel.util.ObjectHelper.isNotEmpty;
+import static org.apache.camel.util.StringHelper.after;
+
 public class JasyptEncryptedPropertiesUtils {
 
+    private static final String SYSTEM_ENVIRONMENT_PREFIX = "sysenv:";
+
+    private static final String SYSTEM_PROPERTIES_PREFIX = "sys:";
+
+    /**
+     *  Algorithms that mandatory require initialization vector
+     */
     static final Set<String> ALGORITHMS_THAT_REQUIRE_IV = new HashSet<>(
             Arrays.asList(
                     "PBEWITHHMACSHA1ANDAES_128",
@@ -37,7 +53,80 @@ public class JasyptEncryptedPropertiesUtils {
             )
     );
 
+    /**
+     * test if algorithm requires an initialization vector
+     * @param algorithm the algorithm to test
+     * @return true if the algorithm requires initialization vector, false otherwise
+     */
     static boolean isIVNeeded(String algorithm) {
-        return ALGORITHMS_THAT_REQUIRE_IV.contains(algorithm.toUpperCase());
+        if (isNotBlank(algorithm)) {
+            return ALGORITHMS_THAT_REQUIRE_IV.contains(algorithm.toUpperCase());
+        }
+        return false;
+    }
+
+    /**
+     * Checks if a CharSequence is empty (""), null or whitespace only.
+     * @param cs  the CharSequence to check, may be null
+     * @return true if the CharSequence is null, empty or whitespace only
+     */
+    static boolean isBlank(final CharSequence cs) {
+        final int strLen = cs == null ? 0 : cs.length();
+        if (strLen == 0) {
+            return true;
+        }
+        for (int i = 0; i < strLen; i++) {
+            if (!Character.isWhitespace(cs.charAt(i))) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     * Checks if a CharSequence is not empty (""), not null or not whitespace only.
+     * @param cs the CharSequence to check, may be null
+     * @return true if the CharSequence is not null, not empty or not whitespace only
+     */
+    static boolean isNotBlank(final CharSequence cs) {
+        return !isBlank(cs);
+    }
+
+
+    static void parsePassword(EnvironmentStringPBEConfig environmentStringPBEConfig, JasyptEncryptedPropertiesConfiguration configuration) {
+        String passwordReference = configuration.getPassword();
+        if (isNotEmpty(passwordReference) && passwordReference.startsWith(SYSTEM_ENVIRONMENT_PREFIX)) {
+            environmentStringPBEConfig.setPasswordEnvName(after(passwordReference, SYSTEM_ENVIRONMENT_PREFIX));
+            return;
+        }
+        if (isNotEmpty(passwordReference) && passwordReference.startsWith(SYSTEM_PROPERTIES_PREFIX)) {
+            environmentStringPBEConfig.setPasswordSysPropertyName(after(passwordReference, SYSTEM_PROPERTIES_PREFIX));
+            return;
+        }
+        environmentStringPBEConfig.setPassword(passwordReference);
+    }
+
+    static IvGenerator getIVGenerator(JasyptEncryptedPropertiesConfiguration configuration) {
+        String ivGeneratorClassName = configuration.getIvGeneratorClassName();
+        String algorithm = configuration.getAlgorithm();
+        if (isBlank(ivGeneratorClassName)) {
+            return isIVNeeded(algorithm) ? new RandomIvGenerator() : new NoIvGenerator();
+        }
+        IvGenerator ivGenerator = loadClass(ivGeneratorClassName);
+        return ivGenerator;
+    }
+
+    /**
+     * search and load the class identified by className parameter
+     * @param className fully qualified class name to be loaded
+     * @return a new instance of type className
+     */
+    static <T> T loadClass(String className) {
+        try {
+            final Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className);
+            return (T) clazz.newInstance();
+        } catch (Exception e) {
+            throw new EncryptionInitializationException(e);
+        }
     }
 }
diff --git a/components-starter/camel-jasypt-starter/src/test/java/org/apache/camel/component/jasypt/springboot/AbstractEncryptedPropertiesIvGeneratorAutoDetectionTest.java b/components-starter/camel-jasypt-starter/src/test/java/org/apache/camel/component/jasypt/springboot/AbstractEncryptedPropertiesIvGeneratorAutoDetectionTest.java
new file mode 100644
index 0000000..78b8ff8
--- /dev/null
+++ b/components-starter/camel-jasypt-starter/src/test/java/org/apache/camel/component/jasypt/springboot/AbstractEncryptedPropertiesIvGeneratorAutoDetectionTest.java
@@ -0,0 +1,83 @@
+/*
+ * 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.component.jasypt.springboot;
+
+import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
+import org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig;
+import org.jasypt.iv.NoIvGenerator;
+import org.jasypt.iv.RandomIvGenerator;
+import org.jasypt.salt.RandomSaltGenerator;
+import org.junit.Test;
+import org.junit.runners.Parameterized.Parameter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+
+import static org.apache.camel.component.jasypt.springboot.JasyptEncryptedPropertiesUtils.isIVNeeded;
+import static org.assertj.core.api.Assertions.assertThat;
+
+public abstract class AbstractEncryptedPropertiesIvGeneratorAutoDetectionTest {
+
+    protected  final Logger LOG = LoggerFactory.getLogger(this.getClass());
+
+    protected static final String SUN_JCE_PROVIDER_NAME = "SunJCE";
+    protected static final String BOUNCY_CASTLE_PROVIDER_NAME = "BC";
+
+
+    String stringToEncrypt = "A password-cracker walks into a bar. Orders a beer. Then a Beer. Then a BEER. beer. b33r. BeeR. Be3r. bEeR. bE3R. BeEr";
+    String password = "s0m3R@nD0mP@ssW0rD";
+
+
+    @Parameter
+    public String algorithm;
+
+    protected String provider;
+
+    @Test
+    public void testEncryptionAndDecryption() {
+
+        LOG.info("Testing Algorithm: '{}', requires IV: {}", algorithm, isIVNeeded(algorithm));
+
+        // Create a ByteArrayOutputStream so that we can get the output
+        // from the call to print
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        // Change System.out to point out to our stream
+        System.setOut(new PrintStream(baos));
+
+        EnvironmentStringPBEConfig environmentStringPBEConfig = new EnvironmentStringPBEConfig();
+        environmentStringPBEConfig.setAlgorithm(algorithm);
+        environmentStringPBEConfig.setIvGenerator(isIVNeeded(algorithm)?new RandomIvGenerator():new NoIvGenerator());
+        environmentStringPBEConfig.setSaltGenerator(new RandomSaltGenerator());
+        environmentStringPBEConfig.setProviderName(provider);
+        environmentStringPBEConfig.setPassword(password);
+
+        StandardPBEStringEncryptor standardPBEStringEncryptor = new StandardPBEStringEncryptor();
+        standardPBEStringEncryptor.setConfig(environmentStringPBEConfig);
+
+        // Testing Encryption.
+        String encrypted = standardPBEStringEncryptor.encrypt(stringToEncrypt);
+
+        // Testing Decryption:
+        String actualDecriptedString = standardPBEStringEncryptor.decrypt(encrypted);
+
+        //Assertions
+        assertThat(actualDecriptedString).isEqualTo(stringToEncrypt);
+    }
+
+}
diff --git a/components-starter/camel-jasypt-starter/src/test/java/org/apache/camel/component/jasypt/springboot/EncryptedPropertiesIvGeneratorAutoDetectionBouncyCastleTest.java b/components-starter/camel-jasypt-starter/src/test/java/org/apache/camel/component/jasypt/springboot/EncryptedPropertiesIvGeneratorAutoDetectionBouncyCastleTest.java
new file mode 100644
index 0000000..aa6aad3
--- /dev/null
+++ b/components-starter/camel-jasypt-starter/src/test/java/org/apache/camel/component/jasypt/springboot/EncryptedPropertiesIvGeneratorAutoDetectionBouncyCastleTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.component.jasypt.springboot;
+
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.jasypt.registry.AlgorithmRegistry;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.security.Security;
+import java.util.Collection;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+@RunWith(Parameterized.class)
+public class EncryptedPropertiesIvGeneratorAutoDetectionBouncyCastleTest extends AbstractEncryptedPropertiesIvGeneratorAutoDetectionTest {
+
+    public EncryptedPropertiesIvGeneratorAutoDetectionBouncyCastleTest() {
+        provider = BOUNCY_CASTLE_PROVIDER_NAME;
+    }
+
+    @Before
+    public void setUp(){
+        Security.addProvider( new BouncyCastleProvider());
+    }
+
+
+    @Parameterized.Parameters(name = "{0}")
+    public static Collection<String> data() {
+        return new BouncyCastleProvider().keySet()
+                .stream()
+                .filter(x->((String)x).startsWith("Cipher"))
+                .map(x->((String) x).split("\\.",2)[1])
+                .filter(x->x.startsWith("PBE"))
+                .collect(Collectors.toList());
+    }
+}
diff --git a/components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/JasyptEncryptedPropertiesUtils.java b/components-starter/camel-jasypt-starter/src/test/java/org/apache/camel/component/jasypt/springboot/EncryptedPropertiesIvGeneratorAutoDetectionTest.java
similarity index 51%
copy from components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/JasyptEncryptedPropertiesUtils.java
copy to components-starter/camel-jasypt-starter/src/test/java/org/apache/camel/component/jasypt/springboot/EncryptedPropertiesIvGeneratorAutoDetectionTest.java
index f171f79..bae4d24 100644
--- a/components-starter/camel-jasypt-starter/src/main/java/org/apache/camel/component/jasypt/springboot/JasyptEncryptedPropertiesUtils.java
+++ b/components-starter/camel-jasypt-starter/src/test/java/org/apache/camel/component/jasypt/springboot/EncryptedPropertiesIvGeneratorAutoDetectionTest.java
@@ -16,28 +16,29 @@
  */
 package org.apache.camel.component.jasypt.springboot;
 
-import java.util.Arrays;
-import java.util.HashSet;
+import org.jasypt.registry.AlgorithmRegistry;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.security.Security;
+import java.util.Collection;
 import java.util.Set;
 
-public class JasyptEncryptedPropertiesUtils {
-
-    static final Set<String> ALGORITHMS_THAT_REQUIRE_IV = new HashSet<>(
-            Arrays.asList(
-                    "PBEWITHHMACSHA1ANDAES_128",
-                    "PBEWITHHMACSHA1ANDAES_256",
-                    "PBEWITHHMACSHA224ANDAES_128",
-                    "PBEWITHHMACSHA224ANDAES_256",
-                    "PBEWITHHMACSHA256ANDAES_128",
-                    "PBEWITHHMACSHA256ANDAES_256",
-                    "PBEWITHHMACSHA384ANDAES_128",
-                    "PBEWITHHMACSHA384ANDAES_256",
-                    "PBEWITHHMACSHA512ANDAES_128",
-                    "PBEWITHHMACSHA512ANDAES_256"
-            )
-    );
-
-    static boolean isIVNeeded(String algorithm) {
-        return ALGORITHMS_THAT_REQUIRE_IV.contains(algorithm.toUpperCase());
+@RunWith(Parameterized.class)
+public class EncryptedPropertiesIvGeneratorAutoDetectionTest extends AbstractEncryptedPropertiesIvGeneratorAutoDetectionTest{
+
+
+    public EncryptedPropertiesIvGeneratorAutoDetectionTest() {
+        provider = SUN_JCE_PROVIDER_NAME;
+    }
+
+    @Parameters(name = "{0}")
+    public static Collection<String> data() {
+        Security.removeProvider(BOUNCY_CASTLE_PROVIDER_NAME);
+        return (Set<String>) AlgorithmRegistry.getAllPBEAlgorithms();
     }
+
+
+
 }
diff --git a/components-starter/camel-jasypt-starter/src/test/java/org/apache/camel/component/jasypt/springboot/EncryptedPropertiesUtilsTest.java b/components-starter/camel-jasypt-starter/src/test/java/org/apache/camel/component/jasypt/springboot/EncryptedPropertiesUtilsTest.java
new file mode 100644
index 0000000..a09f011
--- /dev/null
+++ b/components-starter/camel-jasypt-starter/src/test/java/org/apache/camel/component/jasypt/springboot/EncryptedPropertiesUtilsTest.java
@@ -0,0 +1,54 @@
+/*
+ * 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.component.jasypt.springboot;
+
+import org.jasypt.exceptions.EncryptionInitializationException;
+import org.jasypt.iv.IvGenerator;
+import org.jasypt.iv.NoIvGenerator;
+import org.jasypt.iv.RandomIvGenerator;
+import org.junit.Test;
+
+import static org.apache.camel.component.jasypt.springboot.JasyptEncryptedPropertiesUtils.getIVGenerator;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
+
+public class EncryptedPropertiesUtilsTest {
+
+    @Test
+    public void noIvGeneratorPropertyTest(){
+        //IVGenerator is null
+        JasyptEncryptedPropertiesConfiguration configuration = new JasyptEncryptedPropertiesConfiguration();
+        IvGenerator ivGenerator = getIVGenerator(configuration);
+        assertThat(ivGenerator).isInstanceOf(NoIvGenerator.class);
+    }
+
+    @Test
+    public void nonExistentIvGeneratorTest(){
+        JasyptEncryptedPropertiesConfiguration configuration = new JasyptEncryptedPropertiesConfiguration();
+        configuration.setIvGeneratorClassName("com.mycompany.iv.MyNonExixtentIvGenerator");
+        assertThatExceptionOfType(EncryptionInitializationException.class)
+                .isThrownBy(() -> { IvGenerator ivGenerator = getIVGenerator(configuration);});
+    }
+
+    @Test
+    public void randomIvGeneratorTest(){
+        JasyptEncryptedPropertiesConfiguration configuration = new JasyptEncryptedPropertiesConfiguration();
+        configuration.setIvGeneratorClassName("org.jasypt.iv.RandomIvGenerator");
+        IvGenerator ivGenerator = getIVGenerator(configuration);
+        assertThat(ivGenerator).isInstanceOf(RandomIvGenerator.class);
+    }
+}
diff --git a/components-starter/camel-jasypt-starter/src/test/resources/application.properties b/components-starter/camel-jasypt-starter/src/test/resources/application.properties
index e069f2b..25ff1c9 100644
--- a/components-starter/camel-jasypt-starter/src/test/resources/application.properties
+++ b/components-starter/camel-jasypt-starter/src/test/resources/application.properties
@@ -29,4 +29,4 @@ camel.component.jasypt.algorithm= PBEWITHHMACSHA256ANDAES_256
 camel.component.jasypt.password = sysenv:JASYPT_ENCRYPTION_PASSWORD
 camel.component.jasypt.iv-generator-class-name = org.jasypt.iv.RandomIvGenerator
 camel.component.jasypt.salt-generator-class-name = org.jasypt.salt.RandomSaltGenerator
-camel.component.jasypt.provider-class-name = com.sun.crypto.provider.SunJCE
+camel.component.jasypt.provider-name = SunJCE