gnodet opened a new pull request, #26467: URL: https://github.com/apache/camel/pull/26467
## Summary Fixes CAMEL-24716: `XMLSecurityDataFormat` now accepts the Java constant names listed in the model's `@Metadata(enums=...)` annotations — `AES_256_GCM`, `RSA_OAEP`, `SHA256`, `MGF1_SHA256`, etc. — as aliases for the corresponding W3C algorithm URIs. ## Root Cause The model's `@Metadata` annotations for four properties expose XMLCipher / EncryptionConstants Java constant names as valid enum values: | Property | Example enum value | Expected by XMLCipher | |---|---|---| | `xmlCipherAlgorithm` | `AES_256_GCM` | `http://www.w3.org/2009/xmlenc11#aes256-gcm` | | `keyCipherAlgorithm` | `RSA_OAEP` | `http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p` | | `digestAlgorithm` | `SHA256` | `http://www.w3.org/2001/04/xmlenc#sha256` | | `mgfAlgorithm` | `MGF1_SHA256` | `http://www.w3.org/2009/xmlenc11#mgf1sha256` | The YAML/XML DSL schema exposed these constant names as valid values. However `XMLSecurityDataFormat` stored them verbatim and passed them to `XMLCipher.getInstance()` and URI-equality comparisons that only understand W3C URIs. No name-to-URI mapping existed anywhere. Result: any route written with the schema-documented enum values would throw `XMLEncryptionException: Null or empty transformation` at runtime. Additionally the `defaultValue` for `xmlCipherAlgorithm` in the model was set to the erroneous string `"AES-256-GCM"` (hyphen-separated, matching neither an enum value nor a URI). ## Fix - Add a static `ALGORITHM_NAME_TO_URI` map in `XMLSecurityDataFormat` covering all four property groups (14 cipher/key/digest/MGF algorithm constants). - Add a package-visible `resolveAlgorithm(String)` helper: returns the mapped URI if the input is a known constant name, otherwise returns the input unchanged (so existing routes that pass URIs directly continue to work). - Call `resolveAlgorithm()` in the four setters: `setXmlCipherAlgorithm`, `setKeyCipherAlgorithm`, `setDigestAlgorithm`, `setMgfAlgorithm`. - Fix `defaultValue = "AES-256-GCM"` → `"AES_256_GCM"` in the model and regenerate the affected JSON descriptors and ModelWriter/YamlModelWriter. ## Test New test class `XmlSecurityConstantNameTest` with 7 tests: - Unit tests for `resolveAlgorithm()` covering all 19 entries in the map, pass-through of raw URIs, and null handling. - End-to-end encrypt/decrypt tests using constant names for: - Symmetric AES-256-GCM (`AES_256_GCM`) - Symmetric AES-128 (`AES_128`) - Asymmetric RSA-OAEP (`RSA_OAEP`, `AES_128`) - Asymmetric RSA-OAEP-11 with SHA-256 digest and MGF1-SHA-256 (`RSA_OAEP_11`, `SHA256`, `MGF1_SHA256`) All 186 tests in `camel-xmlsecurity` pass. --- _Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
