mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-05-03 11:20:34 +00:00
Rework
This commit is contained in:
@@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
import io.xpipe.app.comp.base.ButtonComp;
|
||||
import io.xpipe.app.comp.base.HorizontalComp;
|
||||
import io.xpipe.app.comp.base.LabelComp;
|
||||
import io.xpipe.app.comp.base.TextFieldComp;
|
||||
import io.xpipe.app.core.AppI18n;
|
||||
import io.xpipe.app.ext.ValidationException;
|
||||
import io.xpipe.app.platform.OptionsBuilder;
|
||||
@@ -46,7 +45,7 @@ public class PasswordManagerAgentStrategy implements SshIdentityStrategy {
|
||||
return AppI18n.get("passwordManagerEmpty");
|
||||
}
|
||||
|
||||
if (!pwman.getKeyStrategy().supportsAgent()) {
|
||||
if (!pwman.getKeyConfiguration().supportsAgent()) {
|
||||
return AppI18n.get("passwordManagerNoAgentSupport");
|
||||
}
|
||||
|
||||
@@ -87,7 +86,7 @@ public class PasswordManagerAgentStrategy implements SshIdentityStrategy {
|
||||
|
||||
private PasswordManagerKeyConfiguration getConfig() {
|
||||
var pwman = AppPrefs.get().passwordManager().getValue();
|
||||
return pwman != null && pwman.getKeyStrategy() != null && pwman.getKeyStrategy().supportsAgent() ? pwman.getKeyStrategy() : null;
|
||||
return pwman != null && pwman.getKeyConfiguration() != null && pwman.getKeyConfiguration().supportsAgent() ? pwman.getKeyConfiguration() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -40,7 +40,7 @@ public class BitwardenPasswordManager implements PasswordManager {
|
||||
|
||||
private static ShellControl SHELL;
|
||||
private static boolean copied;
|
||||
private final PasswordManagerKeyStrategy agentStrategy;
|
||||
private final PasswordManagerKeyStrategy keyStrategy;
|
||||
|
||||
private static synchronized ShellControl getOrStartShell() throws Exception {
|
||||
if (SHELL == null) {
|
||||
@@ -61,7 +61,7 @@ public class BitwardenPasswordManager implements PasswordManager {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static OptionsBuilder createOptions(Property<BitwardenPasswordManager> p) {
|
||||
var agentStrategy = new SimpleObjectProperty<>(p.getValue().agentStrategy);
|
||||
var agentStrategy = new SimpleObjectProperty<>(p.getValue().keyStrategy);
|
||||
|
||||
AtomicReference<Region> button = new AtomicReference<>();
|
||||
var testButton = new ButtonComp(AppI18n.observable("sync"), new FontIcon("mdi2r-refresh"), () -> {
|
||||
@@ -84,10 +84,10 @@ public class BitwardenPasswordManager implements PasswordManager {
|
||||
|
||||
return new OptionsBuilder()
|
||||
.addComp(testButton)
|
||||
.nameAndDescription("passwordManagerAgentStrategy")
|
||||
.nameAndDescription("passwordManagerKeyStrategy")
|
||||
.sub(agentStrategyChoice.build(), agentStrategy)
|
||||
.bind(() -> {
|
||||
return BitwardenPasswordManager.builder().agentStrategy(agentStrategy.getValue()).build();
|
||||
return BitwardenPasswordManager.builder().keyStrategy(agentStrategy.getValue()).build();
|
||||
}, p);
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ public class BitwardenPasswordManager implements PasswordManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PasswordManagerKeyConfiguration getKeyStrategy() {
|
||||
public PasswordManagerKeyConfiguration getKeyConfiguration() {
|
||||
return new PasswordManagerKeyConfiguration() {
|
||||
@Override
|
||||
public boolean supportsInlineSshKeys() {
|
||||
@@ -268,7 +268,7 @@ public class BitwardenPasswordManager implements PasswordManager {
|
||||
|
||||
@Override
|
||||
public boolean supportsAgent() {
|
||||
return agentStrategy != null;
|
||||
return keyStrategy != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -278,7 +278,7 @@ public class BitwardenPasswordManager implements PasswordManager {
|
||||
|
||||
@Override
|
||||
public SshIdentityStrategy getSshIdentityStrategy(String publicKey, boolean forward) {
|
||||
return agentStrategy.getSshIdentityStrategy(publicKey, forward);
|
||||
return keyStrategy.getSshIdentityStrategy(publicKey, forward);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class DashlanePasswordManager implements PasswordManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PasswordManagerKeyConfiguration getKeyStrategy() {
|
||||
public PasswordManagerKeyConfiguration getKeyConfiguration() {
|
||||
return PasswordManagerKeyConfiguration.none();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class EnpassPasswordManager implements PasswordManager {
|
||||
private final FilePath vaultPath;
|
||||
|
||||
@Override
|
||||
public PasswordManagerKeyConfiguration getKeyStrategy() {
|
||||
public PasswordManagerKeyConfiguration getKeyConfiguration() {
|
||||
return PasswordManagerKeyConfiguration.none();
|
||||
}
|
||||
|
||||
|
||||
@@ -41,40 +41,20 @@ public class KeePassXcPasswordManager implements PasswordManager {
|
||||
private static KeePassXcProxyClient client;
|
||||
|
||||
private final List<KeePassXcAssociationKey> associationKeys;
|
||||
private final PasswordManagerKeyStrategy agentStrategy;
|
||||
private final PasswordManagerKeyStrategy keyStrategy;
|
||||
|
||||
@Override
|
||||
public PasswordManagerKeyConfiguration getKeyStrategy() {
|
||||
return new PasswordManagerKeyConfiguration() {
|
||||
@Override
|
||||
public boolean supportsInlineSshKeys() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsAgent() {
|
||||
return agentStrategy != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsJoinedEntries() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SshIdentityStrategy getSshIdentityStrategy(String publicKey, boolean forward) {
|
||||
return agentStrategy.getSshIdentityStrategy(publicKey, forward);
|
||||
}
|
||||
};
|
||||
public PasswordManagerKeyConfiguration getKeyConfiguration() {
|
||||
return PasswordManagerKeyConfiguration.of(false, false, keyStrategy);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static OptionsBuilder createOptions(Property<KeePassXcPasswordManager> p) {
|
||||
var agentStrategy = new SimpleObjectProperty<>(p.getValue().getAgentStrategy());
|
||||
var keyStrategy = new SimpleObjectProperty<>(p.getValue().getKeyStrategy());
|
||||
var agentStrategyChoice = OptionsChoiceBuilder.builder()
|
||||
.allowNull(true)
|
||||
.available(List.of(PasswordManagerKeyStrategy.KeePassXcOpenSshAgent.class, PasswordManagerKeyStrategy.KeePassXcPageant.class))
|
||||
.property(agentStrategy)
|
||||
.property(keyStrategy)
|
||||
.build();
|
||||
|
||||
var prop = FXCollections.<KeePassXcAssociationKey>observableArrayList();
|
||||
@@ -114,11 +94,11 @@ public class KeePassXcPasswordManager implements PasswordManager {
|
||||
}))
|
||||
.hide(Bindings.isEmpty(prop))
|
||||
.addProperty(prop)
|
||||
.nameAndDescription("passwordManagerAgentStrategy")
|
||||
.sub(agentStrategyChoice.build(), agentStrategy)
|
||||
.nameAndDescription("passwordManagerKeyStrategy")
|
||||
.sub(agentStrategyChoice.build(), keyStrategy)
|
||||
.bind(
|
||||
() -> {
|
||||
return new KeePassXcPasswordManager(prop, agentStrategy.getValue());
|
||||
return new KeePassXcPasswordManager(prop, keyStrategy.getValue());
|
||||
},
|
||||
p);
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ import java.util.stream.Collectors;
|
||||
public class KeeperPasswordManager implements PasswordManager {
|
||||
|
||||
@Override
|
||||
public PasswordManagerKeyConfiguration getKeyStrategy() {
|
||||
return PasswordManagerKeyConfiguration.of(true, true, agentStrategy);
|
||||
public PasswordManagerKeyConfiguration getKeyConfiguration() {
|
||||
return PasswordManagerKeyConfiguration.of(true, true, keyStrategy);
|
||||
}
|
||||
|
||||
private final PasswordManagerKeyStrategy agentStrategy;
|
||||
private final PasswordManagerKeyStrategy keyStrategy;
|
||||
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
|
||||
public interface KeeperAuth {
|
||||
@@ -404,7 +404,7 @@ public class KeeperPasswordManager implements PasswordManager {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static OptionsBuilder createOptions(Property<KeeperPasswordManager> p) {
|
||||
var agentStrategy = new SimpleObjectProperty<>(p.getValue().getAgentStrategy());
|
||||
var agentStrategy = new SimpleObjectProperty<>(p.getValue().getKeyStrategy());
|
||||
var mfa = new SimpleObjectProperty<>(p.getValue().getTwoFactorAuth() != null ? p.getValue().getTwoFactorAuth() : new KeeperAuth.None());
|
||||
|
||||
var choice = OptionsChoiceBuilder.builder()
|
||||
@@ -422,7 +422,7 @@ public class KeeperPasswordManager implements PasswordManager {
|
||||
return new OptionsBuilder()
|
||||
.nameAndDescription("keeper2fa")
|
||||
.sub(choice.build(), mfa)
|
||||
.nameAndDescription("passwordManagerAgentStrategy")
|
||||
.nameAndDescription("passwordManagerKeyStrategy")
|
||||
.sub(agentStrategyChoice.build(), agentStrategy)
|
||||
.bind(
|
||||
() -> {
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.Optional;
|
||||
public class LastpassPasswordManager implements PasswordManager {
|
||||
|
||||
@Override
|
||||
public PasswordManagerKeyConfiguration getKeyStrategy() {
|
||||
public PasswordManagerKeyConfiguration getKeyConfiguration() {
|
||||
return PasswordManagerKeyConfiguration.none();
|
||||
}
|
||||
|
||||
|
||||
@@ -30,16 +30,16 @@ import java.util.regex.Pattern;
|
||||
public class OnePasswordManager implements PasswordManager {
|
||||
|
||||
@Override
|
||||
public PasswordManagerKeyConfiguration getKeyStrategy() {
|
||||
return PasswordManagerKeyConfiguration.of(true, false, agentStrategy);
|
||||
public PasswordManagerKeyConfiguration getKeyConfiguration() {
|
||||
return PasswordManagerKeyConfiguration.of(true, false, keyStrategy);
|
||||
}
|
||||
|
||||
private static ShellControl SHELL;
|
||||
private final PasswordManagerKeyStrategy agentStrategy;
|
||||
private final PasswordManagerKeyStrategy keyStrategy;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public static OptionsBuilder createOptions(Property<OnePasswordManager> p) {
|
||||
var agentStrategy = new SimpleObjectProperty<>(p.getValue().getAgentStrategy());
|
||||
var agentStrategy = new SimpleObjectProperty<>(p.getValue().getKeyStrategy());
|
||||
|
||||
var agentStrategyChoice = OptionsChoiceBuilder.builder()
|
||||
.allowNull(true)
|
||||
@@ -48,10 +48,10 @@ public class OnePasswordManager implements PasswordManager {
|
||||
.build();
|
||||
|
||||
return new OptionsBuilder()
|
||||
.nameAndDescription("passwordManagerAgentStrategy")
|
||||
.nameAndDescription("passwordManagerKeyStrategy")
|
||||
.sub(agentStrategyChoice.build(), agentStrategy)
|
||||
.bind(() -> {
|
||||
return OnePasswordManager.builder().agentStrategy(agentStrategy.getValue()).build();
|
||||
return OnePasswordManager.builder().keyStrategy(agentStrategy.getValue()).build();
|
||||
}, p);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class PassboltPasswordManager implements PasswordManager {
|
||||
private final Path privateKey;
|
||||
|
||||
@Override
|
||||
public PasswordManagerKeyConfiguration getKeyStrategy() {
|
||||
public PasswordManagerKeyConfiguration getKeyConfiguration() {
|
||||
return PasswordManagerKeyConfiguration.none();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public interface PasswordManager {
|
||||
|
||||
String getWebsite();
|
||||
|
||||
PasswordManagerKeyConfiguration getKeyStrategy();
|
||||
PasswordManagerKeyConfiguration getKeyConfiguration();
|
||||
|
||||
default Duration getCacheDuration() {
|
||||
return Duration.ofSeconds(30);
|
||||
|
||||
@@ -33,7 +33,7 @@ public class PasswordManagerCommand implements PasswordManager {
|
||||
ShellScript script;
|
||||
|
||||
@Override
|
||||
public PasswordManagerKeyConfiguration getKeyStrategy() {
|
||||
public PasswordManagerKeyConfiguration getKeyConfiguration() {
|
||||
return PasswordManagerKeyConfiguration.none();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class PsonoPasswordManager implements PasswordManager {
|
||||
private final String serverUrl;
|
||||
|
||||
@Override
|
||||
public PasswordManagerKeyConfiguration getKeyStrategy() {
|
||||
public PasswordManagerKeyConfiguration getKeyConfiguration() {
|
||||
return PasswordManagerKeyConfiguration.none();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ public class WindowsCredentialManager implements PasswordManager {
|
||||
private static boolean loaded = false;
|
||||
|
||||
@Override
|
||||
public PasswordManagerKeyConfiguration getKeyStrategy() {
|
||||
public PasswordManagerKeyConfiguration getKeyConfiguration() {
|
||||
return PasswordManagerKeyConfiguration.none();
|
||||
}
|
||||
|
||||
|
||||
@@ -107,6 +107,7 @@ public class AppJacksonModule extends SimpleModule {
|
||||
var object = JsonNodeFactory.instance.objectNode();
|
||||
object.put("type", "keePassXc");
|
||||
object.set("associationKeys", tree);
|
||||
object.set("keyStrategy", JacksonMapper.getDefault().valueToTree(value.getKeyStrategy()));
|
||||
jgen.writeTree(object);
|
||||
}
|
||||
|
||||
@@ -131,10 +132,14 @@ public class AppJacksonModule extends SimpleModule {
|
||||
return null;
|
||||
}
|
||||
|
||||
var keyStrategyNode = tree.get("keyStrategy");
|
||||
var keyStrategy = keyStrategyNode != null ? JacksonMapper.getDefault().treeToValue(keyStrategyNode, PasswordManagerKeyStrategy.class) : null;
|
||||
|
||||
if (tree.has("associationKey")) {
|
||||
var parsed = JacksonMapper.getDefault()
|
||||
.treeToValue(tree.required("associationKey"), KeePassXcAssociationKey.class);
|
||||
return KeePassXcPasswordManager.builder()
|
||||
.keyStrategy(keyStrategy)
|
||||
.associationKeys(parsed != null ? List.of(parsed) : List.of())
|
||||
.build();
|
||||
} else {
|
||||
@@ -144,6 +149,7 @@ public class AppJacksonModule extends SimpleModule {
|
||||
var parsed = (List<KeePassXcAssociationKey>)
|
||||
JacksonMapper.getDefault().treeToValue(tree.required("associationKeys"), javaType);
|
||||
return KeePassXcPasswordManager.builder()
|
||||
.keyStrategy(keyStrategy)
|
||||
.associationKeys(parsed)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public class PasswordManagerIdentityStore extends IdentityStore
|
||||
return def;
|
||||
}
|
||||
|
||||
var strat = r.getKeyStrategy();
|
||||
var strat = r.getKeyConfiguration();
|
||||
if (strat == null || (!strat.supportsInlineSshKeys() && !strat.supportsAgent())) {
|
||||
return def;
|
||||
}
|
||||
|
||||
+3
-4
@@ -1,6 +1,6 @@
|
||||
package io.xpipe.ext.base.identity;
|
||||
|
||||
import io.xpipe.app.cred.PasswordManagerAgentStrategy;
|
||||
import io.xpipe.app.cred.SshIdentityStrategy;
|
||||
import io.xpipe.app.ext.DataStore;
|
||||
import io.xpipe.app.ext.DataStoreCreationCategory;
|
||||
import io.xpipe.app.ext.GuiDialog;
|
||||
@@ -8,7 +8,6 @@ import io.xpipe.app.platform.OptionsBuilder;
|
||||
import io.xpipe.app.platform.OptionsChoiceBuilder;
|
||||
import io.xpipe.app.prefs.AppPrefs;
|
||||
import io.xpipe.app.prefs.PasswordManagerTestComp;
|
||||
import io.xpipe.app.pwman.PasswordManagerKeyConfiguration;
|
||||
import io.xpipe.app.storage.DataStorageUserHandler;
|
||||
import io.xpipe.app.storage.DataStoreCategory;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
@@ -37,10 +36,10 @@ public class PasswordManagerIdentityStoreProvider extends IdentityStoreProvider
|
||||
var perUser = new SimpleBooleanProperty(st.isPerUser());
|
||||
|
||||
var sshKeyChoice = OptionsChoiceBuilder.builder().allowNull(true)
|
||||
.available(List.of(PasswordManagerAgentStrategy.class)).property(sshKey).build();
|
||||
.available(SshIdentityStrategy.getClasses()).property(sshKey).build();
|
||||
var hideSshKeyChoice = Bindings.createBooleanBinding(() -> {
|
||||
var pwman = AppPrefs.get().passwordManager().getValue();
|
||||
var strat = pwman.getKeyStrategy();
|
||||
var strat = pwman.getKeyConfiguration();
|
||||
return !strat.supportsAgent() ||
|
||||
(strat.supportsJoinedEntries() && strat.supportsInlineSshKeys());
|
||||
});
|
||||
|
||||
Generated
+2
-2
@@ -1997,8 +1997,8 @@ prefsRestartContent=Some options you changed require an application restart to a
|
||||
sshKey=SSH key
|
||||
inlineKey=Retrieve directly from CLI
|
||||
keyAgent=Use agent integration
|
||||
passwordManagerAgentStrategy=SSH key retrieval method
|
||||
passwordManagerAgentStrategyDescription=How and where to retrieve any stored SSH keys from.
|
||||
passwordManagerKeyStrategy=SSH key retrieval method
|
||||
passwordManagerKeyStrategyDescription=How and where to retrieve any stored SSH keys from.
|
||||
sshAgentNoKeys=The agent does not have any keys at the moment
|
||||
sshAgentHasKeys=The agent currently offers the following keys:
|
||||
passwordManagerNoAgentSupport=Password manager does not support retrieving SSH keys
|
||||
|
||||
Reference in New Issue
Block a user