-
Notifications
You must be signed in to change notification settings - Fork 48
Add ExternalKeyProvider SPI for HSM-backed EBICS keys #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
florianpollstaetter-dot
wants to merge
1
commit into
ebics-java:master
Choose a base branch
from
florianpollstaetter-dot:feature/external-key-spi
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+407
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
75 changes: 75 additions & 0 deletions
75
src/main/java/org/kopi/ebics/client/ExternalKeyProvider.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* | ||
| * Copyright (c) 1990-2012 kopiLeft Development SARL, Bizerte, Tunisia | ||
| * | ||
| * This library is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License version 2.1 as published by the Free Software Foundation. | ||
| * | ||
| * This library is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with this library; if not, write to the Free Software | ||
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| * | ||
| */ | ||
|
|
||
| package org.kopi.ebics.client; | ||
|
|
||
| import java.security.PrivateKey; | ||
| import java.security.cert.X509Certificate; | ||
|
|
||
| /** | ||
| * Supplies the A005/X002/E002 key material for a subscriber when the caller | ||
| * holds the private keys outside of the JVM heap (HSM, smartcard, or any other | ||
| * PKCS#11 token). | ||
| * | ||
| * <p>Pass an implementation of this interface to | ||
| * {@link EbicsClient#createUser(java.net.URL, String, String, String, String, | ||
| * String, String, String, String, boolean, boolean, | ||
| * org.kopi.ebics.interfaces.PasswordCallback, ExternalKeyProvider)} or to the | ||
| * matching {@link User} constructor; the library will then skip its built-in | ||
| * {@code KeyUtil.makeKeyPair(...)} path and install the supplied keys and | ||
| * certificates on the {@link User}. This is the seam that allows callers to | ||
| * keep DSGVO / FIPS / ISO 27001 commitments under which an EBICS subscriber's | ||
| * private signing key never resides outside its hardware token. | ||
| * | ||
| * <p>Implementations MUST NOT return a {@link PrivateKey} whose | ||
| * {@link PrivateKey#getEncoded()} is non-null when the key is intended to be | ||
| * HSM-resident — a non-null encoding indicates the key escaped the token. | ||
| * The library does not assert this invariant; callers must. | ||
| * | ||
| * <p>All three role methods must return a non-null {@link KeyMaterial}. Returning | ||
| * {@code null} from any role causes the consuming overload to throw | ||
| * {@link IllegalArgumentException} at the boundary. | ||
| * | ||
| * @since 2.1.0 | ||
| */ | ||
| public interface ExternalKeyProvider { | ||
|
|
||
| /** Bank-technical / electronic-signature key (EBICS role A005). */ | ||
| KeyMaterial a005(); | ||
|
|
||
| /** Identification & authentication key (EBICS role X002). */ | ||
| KeyMaterial x002(); | ||
|
|
||
| /** Encryption key (EBICS role E002). */ | ||
| KeyMaterial e002(); | ||
|
|
||
| /** | ||
| * A {@code (PrivateKey, X509Certificate)} pair for one EBICS role. | ||
| * Both components are required; the compact constructor rejects {@code null}. | ||
| */ | ||
| record KeyMaterial(PrivateKey privateKey, X509Certificate certificate) { | ||
| public KeyMaterial { | ||
| if (privateKey == null) { | ||
| throw new IllegalArgumentException("privateKey must not be null"); | ||
| } | ||
| if (certificate == null) { | ||
| throw new IllegalArgumentException("certificate must not be null"); | ||
| } | ||
| } | ||
| } | ||
| } | ||
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for all these null checks (also in other files) we can use
Objects.requireNonNull