From c84179a751da1e4bb84e7d30ff848c0d197ec6a2 Mon Sep 17 00:00:00 2001 From: Florian Zschocke Date: Wed, 16 Nov 2022 23:08:31 +0100 Subject: [PATCH] Fix issue with not serialisable ed25519 SSH keys Adding Ed25519 keys brings the problem that with the library currently used, the PublicKey instance of that key is not serialisable. This results in an exception when wicket tries to cache the UsersPage. So change the SshKeysPanel so that the PublicKey object is removed from the `SshKey` when the panel is detached. It can be regenerated from the raw key data. --- .../com/gitblit/transport/ssh/SshKey.java | 9 +++++++ .../gitblit/wicket/panels/SshKeysPanel.java | 24 ++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gitblit/transport/ssh/SshKey.java b/src/main/java/com/gitblit/transport/ssh/SshKey.java index 9fd1005a..cfd7310e 100644 --- a/src/main/java/com/gitblit/transport/ssh/SshKey.java +++ b/src/main/java/com/gitblit/transport/ssh/SshKey.java @@ -81,6 +81,15 @@ public class SshKey implements Serializable { return publicKey; } + public void detachPublicKey() + { + if (rawData == null) { + // Make sure the raw data is available + getRawData(); + } + publicKey = null; + } + public String getAlgorithm() { return getPublicKey().getAlgorithm(); } diff --git a/src/main/java/com/gitblit/wicket/panels/SshKeysPanel.java b/src/main/java/com/gitblit/wicket/panels/SshKeysPanel.java index e653a64f..d6c2ca28 100644 --- a/src/main/java/com/gitblit/wicket/panels/SshKeysPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/SshKeysPanel.java @@ -67,7 +67,29 @@ public class SshKeysPanel extends BasePanel { final IModel keyFeedback = Model.of(""); final List keys = new ArrayList(app().keys().getKeys(user.username)); - final ListDataProvider dp = new ListDataProvider(keys); + // Create list data provider that gets rid of the (not serializable EdDSA) PublicKey. + final ListDataProvider dp = new ListDataProvider(keys) { + @Override + public IModel model(final SshKey key) { + return new IModel() { + @Override + public SshKey getObject() { + return key; + } + + @Override + public void setObject(SshKey object) { + // Cannot get set + } + + @Override + public void detach() { + key.detachPublicKey(); + } + }; + } + + }; final DataView keysView = new DataView("keys", dp) { private static final long serialVersionUID = 1L; -- 2.39.5