mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-04-23 08:00:56 -04:00
Fix NPE for vault key
This commit is contained in:
@@ -32,6 +32,12 @@ import javax.crypto.SecretKey;
|
||||
|
||||
public abstract class DataStorage {
|
||||
|
||||
protected static SecretKey secretKey;
|
||||
|
||||
public static SecretKey getSecretKey() {
|
||||
return get() != null ? get().getVaultKey() : secretKey;
|
||||
}
|
||||
|
||||
public static final UUID ALL_CONNECTIONS_CATEGORY_UUID = UUID.fromString("bfb0b51a-e7a3-4ce4-8878-8d4cb5828d6c");
|
||||
public static final UUID ALL_SCRIPTS_CATEGORY_UUID = UUID.fromString("19024cf9-d192-41a9-88a6-a22694cf716a");
|
||||
public static final UUID PREDEFINED_SCRIPTS_CATEGORY_UUID = UUID.fromString("5faf1d71-0efc-4293-8b70-299406396973");
|
||||
|
||||
@@ -483,11 +483,13 @@ public class StandardStorage extends DataStorage {
|
||||
var s = Files.readString(file);
|
||||
var id = new String(Base64.getDecoder().decode(s), StandardCharsets.UTF_8);
|
||||
vaultKey = EncryptionKey.getVaultSecretKey(id);
|
||||
secretKey = vaultKey;
|
||||
} else {
|
||||
FileUtils.forceMkdir(dir.toFile());
|
||||
var id = UUID.randomUUID().toString();
|
||||
Files.writeString(file, Base64.getEncoder().encodeToString(id.getBytes(StandardCharsets.UTF_8)));
|
||||
vaultKey = EncryptionKey.getVaultSecretKey(id);
|
||||
secretKey = vaultKey;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public class EncryptionToken {
|
||||
return isVault;
|
||||
}
|
||||
|
||||
var key = DataStorage.get().getVaultKey();
|
||||
var key = DataStorage.getSecretKey();
|
||||
var s = decode(key);
|
||||
return (isVault = s.equals("xpipe"));
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class VaultKeySecretValue extends AesSecretValue {
|
||||
|
||||
@Override
|
||||
protected SecretKey getSecretKey() throws InvalidKeySpecException {
|
||||
return DataStorage.get().getVaultKey();
|
||||
return DataStorage.getSecretKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user