Procházet zdrojové kódy

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.
pull/1438/head
Florian Zschocke před 1 rokem
rodič
revize
c84179a751

+ 9
- 0
src/main/java/com/gitblit/transport/ssh/SshKey.java Zobrazit soubor

@@ -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();
}

+ 23
- 1
src/main/java/com/gitblit/wicket/panels/SshKeysPanel.java Zobrazit soubor

@@ -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;

Načítá se…
Zrušit
Uložit