mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-08-23 09:46:36 +00:00
Fixes
This commit is contained in:
@@ -66,9 +66,11 @@ public class DataStorageMigration {
|
||||
return (StandardStorage) DataStorage.get();
|
||||
}
|
||||
|
||||
public static void migrate() throws IOException {
|
||||
public static void migrate() throws Exception {
|
||||
var dir = DataStorage.getStorageDirectory();
|
||||
|
||||
DataStorageSyncHandler.getInstance().decryptDataFiles();
|
||||
|
||||
var file = dir.resolve("vaultkey");
|
||||
try {
|
||||
var vaultKey = DataStorageVaultKey.generate();
|
||||
@@ -94,6 +96,8 @@ public class DataStorageMigration {
|
||||
|
||||
AppPrefs.get().save();
|
||||
|
||||
DataStorageSyncHandler.getInstance().commitDataFiles();
|
||||
|
||||
var versionFile = dir.resolve("vaultversion");
|
||||
Files.writeString(versionFile, AppProperties.get().getCanonicalVersion().map(appVersion -> appVersion.toString()).orElse("23.9"));
|
||||
|
||||
|
||||
@@ -52,18 +52,25 @@ public class DataStorageSecret {
|
||||
return null;
|
||||
}
|
||||
|
||||
var jsonNode = secretTree.get(0);
|
||||
var secretNode = jsonNode.get("secret");
|
||||
var uuidNode = jsonNode.get("principal");
|
||||
var iterationNode = jsonNode.get("iteration");
|
||||
var tokenNode = jsonNode.get("token");
|
||||
if (secretNode == null || uuidNode == null || iterationNode == null || tokenNode == null) {
|
||||
return null;
|
||||
for (JsonNode jsonNode : secretTree) {
|
||||
var secretNode = jsonNode.get("secret");
|
||||
var uuidNode = jsonNode.get("principal");
|
||||
var iterationNode = jsonNode.get("iteration");
|
||||
var tokenNode = jsonNode.get("token");
|
||||
if (secretNode == null || uuidNode == null || iterationNode == null || tokenNode == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (uuidNode.asText().equals("be815152-05d2-4094-84d3-f0eea9200d5f")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var secret = VaultKeySecretValue.builder().encryptedValue(SecretValue.toBase64e(Base64Helper.fromBase64UrlString(secretNode.textValue()))).build().inPlace();
|
||||
var token = JacksonMapper.getDefault().treeToValue(tokenNode, EncryptionToken.class);
|
||||
return new DataStorageSecret(token, secretNode, secret.inPlace());
|
||||
}
|
||||
|
||||
var secret = VaultKeySecretValue.builder().encryptedValue(SecretValue.toBase64e(Base64Helper.fromBase64UrlString(secretNode.textValue()))).build().inPlace();
|
||||
var token = JacksonMapper.getDefault().treeToValue(tokenNode, EncryptionToken.class);
|
||||
return new DataStorageSecret(token, secretNode, secret.inPlace());
|
||||
return null;
|
||||
}
|
||||
|
||||
var legacy = JacksonMapper.getDefault().treeToValue(tree, SecretValue.class);
|
||||
|
||||
@@ -11,6 +11,10 @@ public interface DataStorageSyncHandler {
|
||||
return (DataStorageSyncHandler) ProcessControlProvider.get().getStorageSyncHandler();
|
||||
}
|
||||
|
||||
void decryptDataFiles() throws Exception;
|
||||
|
||||
boolean commitDataFiles() throws Exception;
|
||||
|
||||
void pullManually();
|
||||
|
||||
void pushManually();
|
||||
|
||||
@@ -4,12 +4,14 @@ import io.xpipe.app.cred.SshIdentityStrategy;
|
||||
import io.xpipe.app.cred.UsernameStrategy;
|
||||
import io.xpipe.app.ext.StatefulDataStore;
|
||||
import io.xpipe.app.ext.UserScopeStore;
|
||||
import io.xpipe.app.ext.ValidationException;
|
||||
import io.xpipe.app.issue.ErrorEventFactory;
|
||||
import io.xpipe.app.secret.SecretRetrievalStrategy;
|
||||
import io.xpipe.app.storage.DataStorage;
|
||||
import io.xpipe.app.storage.DataStoreEntryRef;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import io.xpipe.app.util.Validators;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import lombok.Value;
|
||||
@@ -91,8 +93,8 @@ public class MultiIdentityStore extends IdentityStore
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkComplete() {
|
||||
getSelectedOrThrow();
|
||||
public void checkComplete() throws ValidationException {
|
||||
Validators.nonNull(getSelected().orElse(null));
|
||||
}
|
||||
|
||||
public UsernameStrategy getUsername() {
|
||||
|
||||
Reference in New Issue
Block a user