Make Bouncy Castle optional in phase4-lib - #389
Conversation
Keep standards-defined encryption OIDs as provider-neutral strings so phase4-lib does not require ph-bc merely for algorithm metadata. Preserve the BC-typed OID method lazily for compatibility and keep ph-bc explicit in modules with real BC usage.
56055d4 to
bfdda5f
Compare
|
Thanks for the updated PR. As WSS4J also has some partial dependency on BC, I need to dig a bit further into this one. Also some stuff is loaded purely by the presence in the classpath (SPI). Therefore it's not contained in the last minor version update |
|
Following up on my previous comment — I dug into the indirect BC paths in Which classpath jars actually reference BC bytecodeOf the 70 jars on
The WSS4J path (the "partial dependency" I mentioned)It narrows to exactly one method pair:
So with cryptacular
ph-securityOnly On the SPI / classpath-presence pointTwo things are loaded purely by presence:
For the record, On
|
This replaces #386. I accidentally opened that pull request from the wrong GitHub account; this is the same focused change from my personal account, rebased onto current master.
Why this is desirable
phase4-lib currently makes ph-bc mandatory because ECryptoAlgorithmCrypt and ICryptoAlgorithmCrypt expose ASN1ObjectIdentifier and initialize seven algorithm identifiers from CMSAlgorithm. Those identifiers are standards-defined metadata; phase4-lib does not otherwise invoke a Bouncy Castle implementation from production code.
This means a consumer inherits a crypto-provider dependency merely to initialize/read algorithm metadata, even when its actual AS4 security path is supplied through WSS4J/JCA or when it manages providers explicitly. It also makes basic enum, configuration, and AOT analysis dependent on a provider-specific library.
This is dependency-boundary cleanup, not a claim that AS4 encryption no longer needs cryptographic implementations. In particular, our Peppol application still receives Bouncy Castle independently through peppol-commons and WSS4J/Cryptacular, so this does not reduce that application today. The benefit is that phase4-lib no longer imposes an independent BC edge on every consumer and profiles can state their real requirements explicitly.
Alternative used
No alternative crypto provider is introduced. The seven stable OIDs are stored in their canonical dot-decimal form, and a provider-neutral getOIDString API exposes them. Actual signing/encryption remains unchanged and continues through the existing WSS4J/JCA code.
For compatibility, the existing getOID method remains with the same ASN1ObjectIdentifier return descriptor, is deprecated, and constructs the value lazily. Calling that legacy method still requires ph-bc. Reflection/AOT tooling that eagerly resolves every method descriptor may also still require it until a future major release can remove the BC-typed method.
ph-bc remains explicitly declared in the BDEW production profile, which directly uses BC APIs, and in module tests that directly exercise BC behavior.
Verification
This changes only the direct phase4-lib to ph-bc dependency edge. The independent WSS4J/Cryptacular dependency path is intentionally untouched.