diff --git a/app/src/main/java/io/xpipe/app/password/PasswordManager.java b/app/src/main/java/io/xpipe/app/password/PasswordManager.java index 4c94f5781..e255d19f8 100644 --- a/app/src/main/java/io/xpipe/app/password/PasswordManager.java +++ b/app/src/main/java/io/xpipe/app/password/PasswordManager.java @@ -1,6 +1,7 @@ package io.xpipe.app.password; import io.xpipe.core.process.OsType; +import io.xpipe.core.util.SecretValue; import io.xpipe.core.util.ValidationException; import com.fasterxml.jackson.annotation.JsonTypeInfo; @@ -29,6 +30,12 @@ public interface PasswordManager { return l; } + static class CredentialResult { + + String username; + SecretValue password; + } + default void checkComplete() throws ValidationException {} String retrievePassword(String key); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/identity/IdentityStore.java b/ext/base/src/main/java/io/xpipe/ext/base/identity/IdentityStore.java index 671059d88..cd032b4c2 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/identity/IdentityStore.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/identity/IdentityStore.java @@ -15,7 +15,7 @@ import lombok.experimental.SuperBuilder; @Getter public abstract class IdentityStore implements SelfReferentialStore, DataStore { - String username; + public abstract String getUsername(); public abstract SecretRetrievalStrategy getPassword(); @@ -30,8 +30,4 @@ public abstract class IdentityStore implements SelfReferentialStore, DataStore { getSshIdentity().checkComplete(); } } - - abstract EncryptedValue getEncryptedPassword(); - - abstract EncryptedValue getEncryptedSshIdentity(); } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/identity/LocalIdentityStore.java b/ext/base/src/main/java/io/xpipe/ext/base/identity/LocalIdentityStore.java index 139c764d5..92945fc59 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/identity/LocalIdentityStore.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/identity/LocalIdentityStore.java @@ -18,6 +18,7 @@ import lombok.extern.jackson.Jacksonized; @ToString(callSuper = true) public class LocalIdentityStore extends IdentityStore { + String username; EncryptedValue password; EncryptedValue sshIdentity; @@ -31,12 +32,10 @@ public class LocalIdentityStore extends IdentityStore { return sshIdentity != null ? sshIdentity.getValue() : null; } - @Override EncryptedValue getEncryptedPassword() { return password; } - @Override EncryptedValue getEncryptedSshIdentity() { return sshIdentity; } diff --git a/ext/base/src/main/java/io/xpipe/ext/base/identity/PasswordManagerIdentityStore.java b/ext/base/src/main/java/io/xpipe/ext/base/identity/PasswordManagerIdentityStore.java new file mode 100644 index 000000000..08725c4cb --- /dev/null +++ b/ext/base/src/main/java/io/xpipe/ext/base/identity/PasswordManagerIdentityStore.java @@ -0,0 +1,45 @@ +package io.xpipe.ext.base.identity; + +import com.fasterxml.jackson.annotation.JsonTypeName; +import io.xpipe.app.util.EncryptedValue; +import io.xpipe.app.util.SecretQuery; +import io.xpipe.app.util.SecretRetrievalStrategy; +import io.xpipe.core.store.InternalCacheDataStore; +import io.xpipe.core.store.StatefulDataStore; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import lombok.Value; +import lombok.experimental.SuperBuilder; +import lombok.extern.jackson.Jacksonized; + +@SuperBuilder +@JsonTypeName("passwordManagerIdentity") +@Jacksonized +@Value +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class PasswordManagerIdentityStore extends IdentityStore implements InternalCacheDataStore { + + String key; + + @Override + public String getUsername() { + return ""; + } + + @Override + public SecretRetrievalStrategy getPassword() { + return new SecretRetrievalStrategy() { + + @Override + public SecretQuery query() { + return null; + } + }; + } + + @Override + public SshIdentityStrategy getSshIdentity() { + return null; + } +} diff --git a/ext/base/src/main/java/io/xpipe/ext/base/identity/SyncedIdentityStore.java b/ext/base/src/main/java/io/xpipe/ext/base/identity/SyncedIdentityStore.java index 9adef954c..f33cf6f4b 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/identity/SyncedIdentityStore.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/identity/SyncedIdentityStore.java @@ -20,6 +20,7 @@ import lombok.extern.jackson.Jacksonized; @Jacksonized public class SyncedIdentityStore extends IdentityStore implements UserScopeStore { + String username; // We can encrypt it with only the vault key as // per user stores are additionally encrypted on the entry level EncryptedValue.VaultKey password; @@ -46,12 +47,10 @@ public class SyncedIdentityStore extends IdentityStore implements UserScopeStore } } - @Override EncryptedValue.VaultKey getEncryptedPassword() { return password; } - @Override EncryptedValue.VaultKey getEncryptedSshIdentity() { return sshIdentity; }