CAMEL-24506: camel-jasypt-starter - modern default algorithm and safer usage example - #1931
Open
Croway wants to merge 1 commit into
Open
CAMEL-24506: camel-jasypt-starter - modern default algorithm and safer usage example#1931Croway wants to merge 1 commit into
Croway wants to merge 1 commit into
Conversation
oscerd
approved these changes
Sep 2, 2026
…r usage example The starter defaulted `camel.component.jasypt.algorithm` to `PBEWithMD5AndDES`, a 56-bit DES cipher with MD5-based key derivation, and that value flowed into `EnvironmentStringPBEConfig.setAlgorithm` on every decryption path. The starter already carries `PBEWITHHMACSHA256ANDAES_256` in `JasyptEncryptedPropertiesUtils.ALGORITHMS_THAT_REQUIRE_IV`, so making it the default engages the existing `RandomIvGenerator` path automatically, with no new machinery. The default is now `PBEWITHHMACSHA256ANDAES_256`. This is a breaking change for values encrypted under the previous default; those can still be read by pinning `camel.component.jasypt.algorithm = PBEWithMD5AndDES`. The javadoc and the generated configuration metadata document both the new default and the opt-back. The upstream `camel-jasypt` component leaves the algorithm unset, so it still falls back to the Jasypt library default of `PBEWithMD5AndDES`. Aligning it is a separate change; the documentation therefore spells out that the encryption tooling must be given a matching `-a` and a random IV generator, since the Jasypt CLI installs no IV generator unless asked. The usage example also placed `camel.component.jasypt.password` in the same properties block as the `ENC(...)` value, which defeats the purpose of encrypting it. It now uses `sysenv:JASYPT_PASSWORD`, carries a warning that the master password must not live beside the ciphertext, and documents the `sysenv:` and `sys:` prefixes the code already supports. Tests: `JasyptDefaultAlgorithmTest` covers the default algorithm and its IV generator, an encrypt/decrypt round trip under the default, decryption of a legacy-algorithm value with the opt-back set, and the failure of that value under the new default. `EncryptedPropertiesUtilsTest` is updated for the IV auto-detection now triggered by the default, with a new case for an algorithm that does not require an IV. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Croway
force-pushed
the
CAMEL-24506-jasypt-default-algorithm
branch
from
September 2, 2026 13:12
2e9ae72 to
6dfc59a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
CAMEL-24506 — two items in
camel-jasypt-starter.1. Default algorithm
JasyptEncryptedPropertiesConfigurationdefaultedcamel.component.jasypt.algorithmtoPBEWithMD5AndDES— a 56-bit DES cipher with MD5-based key derivation — and that value flowed intoEnvironmentStringPBEConfig.setAlgorithmon every decryption path.The default is now
PBEWITHHMACSHA256ANDAES_256. No new machinery was needed: the starter already lists that algorithm inJasyptEncryptedPropertiesUtils.ALGORITHMS_THAT_REQUIRE_IV, sogetIVGeneratorinstallsRandomIvGeneratorautomatically (usingcamel.component.jasypt.random-iv-generator-algorithm, defaultSHA1PRNG) wheneveriv-generator-class-nameis not set explicitly.2. Usage example placed the master password beside the ciphertext
src/main/doc/usage.adocshowedcamel.component.jasypt.password = the-master-passwordin the same properties block as theENC(...)value, which removes the benefit of encrypting it. The example now usessysenv:JASYPT_PASSWORD, carries aWARNINGadmonition that the master password must come from the environment or an external secret store and must never live in the same file or repository as the values it protects, and documents thesysenv:/sys:prefixes thatJasyptEncryptedPropertiesUtils.parsePasswordalready supports.While in that file, the encryption command was also corrected:
camel jasypt encrypt --password= --input=is not a real command. It is replaced by the documentedjbang org.apache.camel:camel-jasypt:<camel-version> -c encrypt ...form, with the algorithm and IV generator flags, plus a note that the CLI entrypoint is deprecated in favour of the Jasypt distribution'sencrypt.sh.Behaviour change and how to opt back
This is a breaking change for values encrypted under the old default. Such a value cannot be decrypted with
PBEWITHHMACSHA256ANDAES_256; resolving the property throwsEncryptionOperationNotPossibleException. Either re-encrypt the values, or pin the previous algorithm:camel.component.jasypt.algorithm = PBEWithMD5AndDESAn upgrade-guide entry has been drafted for the
camel-spring-bootsection ofcamel-4x-upgrade-guide-4_23.adocinapache/camel, and will be submitted separately.One practical detail that the docs now call out: the Jasypt CLI installs no IV generator unless asked (
StandardPBEByteEncryptorfalls back toNoIvGenerator), so encryption must be given both the algorithm and a random IV generator, otherwise the value it produces cannot be decrypted at runtime:Upstream coordination
The upstream
camel-jasyptcomponent does not currently match this default.JasyptPropertiesParser.initEncryptoronly callssetAlgorithmwhen thealgorithmfield is non-null, and it is null by default, so the parser falls back to the Jasypt library defaultStandardPBEByteEncryptor.DEFAULT_ALGORITHM=PBEWithMD5AndDES. The same is true of thecamel-jasyptCLI (org.apache.camel.component.jasypt.Main), where-ais optional.The upstream default should follow in a separate change in
apache/camel; this PR does not make it. Until then the starter and the component diverge, which is why the starter documentation now states explicitly that the encryption tooling must be given a matching--algorithm/-a(and IV generator) rather than relying on its default.Tests
New
JasyptDefaultAlgorithmTest(ApplicationContextRunneroverJasyptEncryptedPropertiesAutoconfiguration, so it exercises the real bean wiring rather than the configuration object alone):defaultAlgorithmRequiresAndGetsAnInitializationVector— the configuration and theEnvironmentStringPBEConfigbean both carryPBEWITHHMACSHA256ANDAES_256, and the IV generator is aRandomIvGenerator.defaultAlgorithmEncryptsAndDecrypts— encrypt/decrypt round trip through the auto-configuredStringEncryptorunder the new default.legacyAlgorithmCanBePinnedExplicitly— withcamel.component.jasypt.algorithm=PBEWithMD5AndDES, the IV generator falls back toNoIvGeneratorand a fixed ciphertext produced under the legacy algorithm decrypts correctly (the opt-back).legacyValueIsNotReadableUnderTheDefaultAlgorithm— the same ciphertext fails under the new default, pinning down the breaking change the upgrade note describes.EncryptedPropertiesUtilsTest.noIvGeneratorPropertyTestis updated: a default configuration now auto-detectsRandomIvGenerator. A newnoIvGeneratorPropertyWithAlgorithmThatDoesNotNeedIvTestkeeps theNoIvGeneratorpath covered for an algorithm that does not require an IV.Result of
mvn install -pl components-starter/camel-jasypt-starter:Regenerated and committed:
components-starter/camel-jasypt-starter/src/main/docs/jasypt.jsonanddocs/spring-boot/modules/ROOT/pages/starters/jasypt.adoc(the latter is produced fromsrc/main/doc/*.adocbycamel-spring-boot-generator-maven-plugin:update-starter-doc-page).Claude Code (Opus 5) on behalf of Federico Mariani