summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Zschocke <f.zschocke+git@gmail.com>2022-11-16 23:08:31 +0100
committerFlorian Zschocke <f.zschocke+git@gmail.com>2022-11-16 23:14:44 +0100
commitc84179a751da1e4bb84e7d30ff848c0d197ec6a2 (patch)
tree584ba5625fa8816c5e8e4874f0937d0fe080474d
parent5fd9d9ef7955bda0129f6e971626c4c1b9dbbc2d (diff)
downloadgitblit-c84179a751da1e4bb84e7d30ff848c0d197ec6a2.tar.gz
gitblit-c84179a751da1e4bb84e7d30ff848c0d197ec6a2.zip
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.
-rw-r--r--src/main/java/com/gitblit/transport/ssh/SshKey.java9
-rw-r--r--src/main/java/com/gitblit/wicket/panels/SshKeysPanel.java24
2 files changed, 32 insertions, 1 deletions
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<String> keyFeedback = Model.of("");
final List<SshKey> keys = new ArrayList<SshKey>(app().keys().getKeys(user.username));
- final ListDataProvider<SshKey> dp = new ListDataProvider<SshKey>(keys);
+ // Create list data provider that gets rid of the (not serializable EdDSA) PublicKey.
+ final ListDataProvider<SshKey> dp = new ListDataProvider<SshKey>(keys) {
+ @Override
+ public IModel<SshKey> model(final SshKey key) {
+ return new IModel<SshKey>() {
+ @Override
+ public SshKey getObject() {
+ return key;
+ }
+
+ @Override
+ public void setObject(SshKey object) {
+ // Cannot get set
+ }
+
+ @Override
+ public void detach() {
+ key.detachPublicKey();
+ }
+ };
+ }
+
+ };
final DataView<SshKey> keysView = new DataView<SshKey>("keys", dp) {
private static final long serialVersionUID = 1L;