feat(client): ExternalKeyProvider SPI for HSM-managed A005/X002/E002 keys#1
Open
florianpollstaetter-dot wants to merge 1 commit into
Open
feat(client): ExternalKeyProvider SPI for HSM-managed A005/X002/E002 keys#1florianpollstaetter-dot wants to merge 1 commit into
florianpollstaetter-dot wants to merge 1 commit into
Conversation
…002 keys
Closes the gap that forces in-process generation of EBICS subscriber RSA key
pairs. Callers that hold the private keys in an HSM, smartcard, or any other
PKCS#11 token can now pass an ExternalKeyProvider; the library installs the
supplied (PrivateKey, X509Certificate) triples on the User and skips
KeyUtil.makeKeyPair(...) for that subscriber. No PKCS#12 is written for an
externally-keyed user, so the heap-key duplicate path stays cold.
The change is additive and non-breaking: existing createUser(...) callers see
no behaviour change.
Surface:
* New interface org.kopi.ebics.client.ExternalKeyProvider with the
KeyMaterial(PrivateKey, X509Certificate) record. Compact constructor
rejects null components at the boundary.
* New User constructor accepting an ExternalKeyProvider; bypasses
CertificateManager.create().
* New EbicsClient.createUser(..., ExternalKeyProvider) overload that
produces the user, persists bank/partner/user, and writes the
INI/HIA letters (public-key bytes only) without writing PKCS#12.
JUnit coverage:
* UserExternalKeysTest#constructorAssignsExternalKeysVerbatim verifies the
supplied PrivateKey instances reach the User unchanged (no internal
KeyPair generation overwrites them) and that the public keys returned by
the User match the supplied certificates for all three roles.
* UserExternalKeysTest#nullProviderRejected and #partialProviderRejected
cover the boundary checks; partial errors name the offending role.
* UserExternalKeysTest#keyMaterialRecordRejects{Null,Null}* verify the
record-level null guards.
Motivated by DSGVO + ISO 27001 commitments under which EBICS subscriber
A005/X002 private keys must never reside outside their hardware token.
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.
Summary
Adds an additive, non-breaking SPI that lets callers supply A005/X002/E002 key material from an HSM, smartcard, or any PKCS#11 token. When used, the library skips
KeyUtil.makeKeyPair(...)and the PKCS#12 export for that subscriber — closing the heap-key duplicate path that would otherwise defeat HSM-resident custody.org.kopi.ebics.client.ExternalKeyProviderwith aKeyMaterial(PrivateKey, X509Certificate)record (null-guarded compact constructor).User(..., ExternalKeyProvider)constructor that installs supplied keys/certs and bypassesCertificateManager.create().EbicsClient.createUser(..., ExternalKeyProvider)overload that produces the user, persists bank/partner/user, and writes the INI/HIA letters (public-key bytes only) without writing PKCS#12.Existing
createUser(...)callers see no behaviour change.Tracked downstream as ORA-2311 / ORA-2322. This intra-fork PR exists to drive the fork's GitHub Actions CI (build + tests) before the upstream PR is opened against
ebics-java/ebics-java-client.Test plan
UserExternalKeysTest#constructorAssignsExternalKeysVerbatim— proves suppliedPrivateKeyinstances reach theUserunchanged for all three roles (no library-sideKeyPairoverwrites them) and that the public keys returned by theUsermatch the supplied certificates.UserExternalKeysTest#nullProviderRejected— null provider →IllegalArgumentException.UserExternalKeysTest#partialProviderRejected— provider with a nullx002()→IllegalArgumentExceptionwhose message names the offending role.UserExternalKeysTest#keyMaterialRecordRejectsNullPrivateKey/…NullCertificate— record-level null guards.Java CI with Maven) green on this PR.