Various fixes

This commit is contained in:
crschnick
2025-01-10 17:40:14 +00:00
parent c02c88f7d1
commit abc87bb265
9 changed files with 46 additions and 28 deletions
@@ -52,7 +52,7 @@ public interface ExternalRdpClientType extends PrefsChoiceValue {
}
if (input.get("username").isEmpty()) {
return input;
//return input;
}
var pass = configuration.getPassword();
@@ -15,6 +15,7 @@ import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.Window;
public class AskpassAlert {
@@ -57,6 +58,12 @@ public class AskpassAlert {
return;
}
var hasInternalFocus = Window.getWindows().stream().filter(window -> window != stage)
.anyMatch(window -> window instanceof Stage s && s.focusedProperty().get());
if (hasInternalFocus) {
return;
}
if (lastRun == 0) {
lastRun = now;
return;
@@ -71,6 +78,7 @@ public class AskpassAlert {
if (!hasFocus) {
regainedFocusCount++;
}
stage.requestFocus();
lastRun = now;
}
@@ -39,7 +39,7 @@ public class RdpConfig {
}
content.lines().forEach(s -> {
var split = s.split(":");
var split = s.split(":", 3);
if (split.length < 2) {
return;
}
@@ -69,21 +69,14 @@ public class IdentityChoice {
.nonNullIf(inPlaceSelected.and(new SimpleBooleanProperty(requirePassword)))
.disable(refSelected)
.hide(refSelected)
.name("keyAuthentication")
.description("keyAuthenticationDescription")
.longDescription("base:sshKey")
.sub(
SshIdentityStrategyHelper.identity(
gateway != null ? gateway : new SimpleObjectProperty<>(),
identityStrategy,
null,
false),
identityStrategy)
.nonNullIf(inPlaceSelected.and(new SimpleBooleanProperty(keyInput)))
.disable(refSelected)
.hide(refSelected.or(new SimpleBooleanProperty(!keyInput)))
.addProperty(ref)
.bind(
.addProperty(ref);
if (keyInput) {
options.name("keyAuthentication").description("keyAuthenticationDescription").longDescription("base:sshKey").sub(
SshIdentityStrategyHelper.identity(gateway != null ? gateway : new SimpleObjectProperty<>(), identityStrategy, null, false),
identityStrategy).nonNullIf(inPlaceSelected).disable(refSelected).hide(
refSelected);
}
options.bind(
() -> {
if (ref.get() != null) {
return IdentityValue.Ref.builder()
@@ -26,6 +26,8 @@ import javafx.beans.property.SimpleStringProperty;
import javafx.beans.value.ObservableValue;
import javafx.collections.ListChangeListener;
import javafx.scene.control.ListCell;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.HBox;
import atlantafx.base.theme.Styles;
@@ -99,7 +101,8 @@ public class IdentitySelectComp extends Comp<CompStructure<HBox>> {
});
});
return new SimpleCompStructure<>(layout.createStructure().get());
var structure = layout.createStructure();
return new SimpleCompStructure<>(structure.get());
}
private String formatName(DataStoreEntry storeEntry) {
@@ -191,6 +194,15 @@ public class IdentitySelectComp extends Comp<CompStructure<HBox>> {
selectedReference);
struc.get().promptTextProperty().bind(binding);
});
combo.apply(struc -> {
struc.get().addEventFilter(KeyEvent.KEY_PRESSED,event -> {
if (event.getCode() == KeyCode.ESCAPE && !allowUserInput) {
selectedReference.setValue(null);
prop.setValue(null);
event.consume();
}
});
});
return combo;
}
}
@@ -23,10 +23,12 @@ public abstract class IdentityStore implements SelfReferentialStore, DataStore {
@Override
public void checkComplete() throws Throwable {
Validators.nonNull(getPassword());
Validators.nonNull(getSshIdentity());
getPassword().checkComplete();
getSshIdentity().checkComplete();
if (getPassword() != null) {
getPassword().checkComplete();
}
if (getSshIdentity() != null) {
getSshIdentity().checkComplete();
}
}
abstract EncryptedValue<SecretRetrievalStrategy> getEncryptedPassword();
@@ -27,7 +27,7 @@ public abstract class IdentityStoreProvider implements DataStoreProvider {
@Override
public List<String> getSearchableTerms(DataStore store) {
IdentityStore s = store.asNeeded();
return List.of(s.getUsername());
return s.getUsername() != null ? List.of(s.getUsername()) : List.of();
}
@Override
@@ -24,8 +24,12 @@ public interface IdentityValue {
return new InPlace(identityStore);
}
static IdentityValue.InPlace empty() {
return of(null, null,null);
static IdentityValue.InPlace none() {
var s = LocalIdentityStore.builder()
.password(EncryptedValue.of(new SecretRetrievalStrategy.None()))
.sshIdentity(EncryptedValue.of(new SshIdentityStrategy.None()))
.build();
return of(s);
}
static IdentityValue.InPlace of(String user) {
@@ -38,8 +42,8 @@ public interface IdentityValue {
static IdentityValue.InPlace of(String user, SecretRetrievalStrategy password, SshIdentityStrategy sshIdentity) {
var s = LocalIdentityStore.builder().username(user)
.password(EncryptedValue.of(password != null ? password : new SecretRetrievalStrategy.None()))
.sshIdentity(EncryptedValue.of(sshIdentity != null ? sshIdentity : new SshIdentityStrategy.None()))
.password(password != null ? EncryptedValue.of(password) : null)
.sshIdentity(sshIdentity != null ? EncryptedValue.of(sshIdentity) : null)
.build();
return of(s);
}
@@ -186,7 +186,6 @@ public class SshIdentityStrategyHelper {
return new OptionsBuilder()
.longDescription("base:sshKey")
.choice(identityMethodSelected, map)
.nonNull()
.bindChoice(
() -> {
return switch (identityMethodSelected.get()) {