This commit is contained in:
crschnick
2026-07-23 06:47:25 +00:00
parent e176286593
commit e922f7933f
4 changed files with 27 additions and 5 deletions
@@ -39,6 +39,8 @@ public abstract class EncryptedValue<T> {
public abstract EncryptedValue<T> withValue(T value);
public abstract EncryptedValue<T> migrated();
@Override
public int hashCode() {
return Objects.hashCode(value);
@@ -94,6 +96,11 @@ public abstract class EncryptedValue<T> {
return of(value);
}
@Override
public EncryptedValue<T> migrated() {
return of(getValue());
}
}
@JsonTypeName("vault")
@@ -105,6 +112,10 @@ public abstract class EncryptedValue<T> {
super(value, secret);
}
@Override
public EncryptedValue<T> migrated() {
return of(getValue());
}
@SneakyThrows
public static <T> VaultKey<T> of(T value) {
if (value == null) {
@@ -1339,8 +1339,8 @@ public abstract class DataStorage {
public void migrate() {
var ordered = storeEntriesSet.stream().sorted(Comparator.<DataStoreEntry>comparingInt(
entry -> entry.getOrderIndex()).reversed()
.thenComparing(entry -> entry.getLastModified()).reversed())
entry -> entry.getOrderIndex())
.thenComparing(entry -> entry.getLastModified()))
.toList();
for (int i = 0; i < ordered.size(); i++) {
var entry = ordered.get(i);
@@ -3,9 +3,13 @@ package io.xpipe.app.storage;
import io.xpipe.app.core.AppCache;
import io.xpipe.app.core.AppProperties;
import io.xpipe.app.core.AppVersion;
import io.xpipe.app.hub.comp.StoreSectionSortMode;
import io.xpipe.app.hub.comp.StoreViewState;
import io.xpipe.app.issue.ErrorEventFactory;
import io.xpipe.app.platform.PlatformThread;
import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.app.secret.EncryptionToken;
import javafx.application.Platform;
import lombok.Data;
import java.io.IOException;
@@ -96,5 +100,9 @@ public class DataStorageMigration {
AppCache.update("vaultMigrated", true);
DataStorage.get().pushManually();
Platform.runLater(() -> {
StoreViewState.get().getGlobalSortMode().setValue(StoreSectionSortMode.INDEX_DESC);
});
}
}
@@ -268,7 +268,7 @@ public class AppJacksonModule extends SimpleModule {
var newEnc = Base64Helper.toBase64Url(oldRaw);
var tree = JsonNodeFactory.instance.objectNode();
tree.put("type", "inPlace");
tree.put("type", "internal");
tree.put("encryptedValue", newEnc);
jgen.writeTree(tree);
}
@@ -331,7 +331,7 @@ public class AppJacksonModule extends SimpleModule {
return (T) PasswordLockSecretValue.builder().encryptedValue(encryptedValueNode.textValue()).build();
}
if ("inPlace".equals(type)) {
if ("internal".equals(type)) {
var r = Base64Helper.fromBase64UrlString(encryptedValueNode.textValue());
var enc = SecretValue.toBase64e(r);
return (T) InPlaceSecretValue.builder().encryptedValue(enc).build();
@@ -403,7 +403,10 @@ public class AppJacksonModule extends SimpleModule {
return;
}
jgen.writeTree(value.getSecret().serialize(value.allowUserSecretKey()));
var rewrite = value.getSecret().requiresRewrite(value.allowUserSecretKey());
var secret = rewrite ? value.migrated().getSecret() : value.getSecret();
jgen.writeTree(secret.serialize(value.allowUserSecretKey()));
}
@Override