oscerd opened a new pull request, #28098: URL: https://github.com/apache/camel/pull/28098
Fixes [CAMEL-25794](https://issues.apache.org/jira/browse/CAMEL-25794). ## Problem `PQCComponent` autowires default key material for most algorithms, but three advertised constants were missing from the switches and fell through `default: break;` — **HSS** and **XMSSMT** in the signature switch, **SNTRUPrime** in the KEM switch. `PQCDefaultHSSMaterial`, `PQCDefaultXMSSMTMaterial` and `PQCDefaultSNTRUPrimeMaterial` all exist but had **no reference anywhere** in `src/main` or `src/test` — dead code. A route such as `pqc:x?operation=sign&signatureAlgorithm=XMSSMT` with no registry bean started cleanly, because `doStart()` still builds the `Signature`, and then failed on the first exchange with a `NullPointerException` at `signerForExchange.initSign(keyPair.getPrivate())`. The component documentation listed the first two as the defaults for those algorithms, so the behaviour contradicted the docs as well. ## Fix The three missing `case` arms, following the existing idiom. Also corrects the reference table: HSS had a JCA algorithm name of `HSS`, but BouncyCastle 1.86 registers only `KeyPairGenerator.LMS`, `Signature.LMS` and `KeyFactory.LMS` — there is no `HSS` service, and the enum correctly maps `HSS("LMS", "BC")`. A reader following the table would have got `NoSuchAlgorithmException`. Its default parameter spec is corrected too: `PQCDefaultHSSMaterial` builds a 2-level LMS hierarchy using the `W2` OTS parameter, not the `W1` of plain LMS. ## Tests New `PQCDefaultMaterialAutowiringTest` sweeps **both enums** with `@EnumSource` — 21 cases — asserting every constant gets a key pair and a signer/key generator from the URI alone. Against `main` exactly three fail (`HSS`, `XMSSMT`, `SNTRUPrime`); all 21 pass with the change. Sweeping the enum rather than adding three point tests means a constant added in future without a matching switch arm fails immediately instead of at the first exchange — which is how all three of these slipped through. Full `camel-pqc` build green: 260 tests, 0 failures. ## Note on the catalog mirror `catalog/.../docs/pqc-component.adoc` is updated alongside the component doc, as CI's uncommitted-changes check requires. I produced it by copying the source doc rather than by running the catalog generator: `camel-catalog` has test-scoped dependencies on `camel-allcomponents`, `camel-core-all`, `camel-jsonpath`, `camel-jq`, `camel-groovy`, `camel-semantic` and `camel-typesafe-ai` at `4.24.0-SNAPSHOT`, which would mean building most of the reactor locally. The mirror is a byte-for-byte copy of the source doc — verified before and after — so the result is identical to what the generator emits, but flagging it in case CI disagrees. ## Follow-up thought, not done here The real defect class is the silent `default: break;`. A fail-fast when the switch leaves no key material would be better than relying on test coverage, but it has to be scoped to the sign/verify operations only — the lifecycle operations legitimately run without a signer. The parameterised-factory refactor proposed in CAMEL-25802 would remove the switch altogether. --- _Reported, analysed and fixed by Claude Code (AI agent) on behalf of @oscerd._ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
