mirror of
https://github.com/xpipe-io/xpipe.git
synced 2026-04-19 14:09:43 -04:00
Show identity name in error messages for #748
This commit is contained in:
@@ -33,4 +33,6 @@ public abstract class IdentityStore implements SelfReferentialStore, DataStore {
|
||||
getSshIdentity().checkComplete();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract String getName();
|
||||
}
|
||||
|
||||
@@ -99,16 +99,22 @@ public interface IdentityValue {
|
||||
List<DataStoreEntryRef<?>> getDependencies();
|
||||
|
||||
default void checkCompleteUser() throws ValidationException {
|
||||
Validators.nonNull(unwrap().getUsername().hasUser() ? new Object() : null, "Identity username");
|
||||
var n = unwrap().getName();
|
||||
var msg = n != null ? "Username of identity " + n : "Identity username";
|
||||
Validators.nonNull(unwrap().getUsername().hasUser() ? new Object() : null, msg);
|
||||
}
|
||||
|
||||
default void checkCompletePassword() throws ValidationException {
|
||||
Validators.nonNull(unwrap().getPassword(), "Identity password");
|
||||
var n = unwrap().getName();
|
||||
var msg = n != null ? "Password of identity " + n : "Identity password";
|
||||
Validators.nonNull(unwrap().getPassword(), msg);
|
||||
unwrap().getPassword().checkComplete();
|
||||
}
|
||||
|
||||
default void checkCompleteSshIdentity() throws ValidationException {
|
||||
Validators.nonNull(unwrap().getSshIdentity(), "Identity ssh key");
|
||||
var n = unwrap().getName();
|
||||
var msg = n != null ? "SSH key of identity " + n : "Identity SSH key";
|
||||
Validators.nonNull(unwrap().getSshIdentity(), msg);
|
||||
unwrap().getSshIdentity().checkComplete();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import io.xpipe.app.cred.SshIdentityStrategy;
|
||||
import io.xpipe.app.cred.UsernameStrategy;
|
||||
import io.xpipe.app.secret.EncryptedValue;
|
||||
import io.xpipe.app.secret.SecretRetrievalStrategy;
|
||||
import io.xpipe.app.storage.DataStoreEntry;
|
||||
import io.xpipe.app.storage.DataStoreEntryRef;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeName;
|
||||
@@ -41,6 +42,12 @@ public class LocalIdentityStore extends IdentityStore {
|
||||
return sshIdentity != null ? sshIdentity.getValue() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
var inStorage = hasSelfEntry();
|
||||
return inStorage ? getSelfEntry().getName() : null;
|
||||
}
|
||||
|
||||
EncryptedValue<SecretRetrievalStrategy> getEncryptedPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,11 @@ public class MultiIdentityStore extends IdentityStore
|
||||
List<UUID> identities;
|
||||
boolean perUser;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getSelected().map(ref -> ref.getStore().getName()).orElse(null);
|
||||
}
|
||||
|
||||
public List<DataStoreEntryRef<IdentityStore>> getAvailableIdentities() {
|
||||
return identities.stream()
|
||||
.map(uuid -> DataStorage.get().getStoreEntryIfPresent(uuid))
|
||||
|
||||
@@ -41,6 +41,11 @@ public class PasswordManagerIdentityStore extends IdentityStore
|
||||
PasswordManagerAgentStrategy sshKey;
|
||||
boolean perUser;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getSelfEntry().getName();
|
||||
}
|
||||
|
||||
private boolean checkOutdatedOrRefresh() {
|
||||
var instant = getCache("lastQueried", Instant.class, null);
|
||||
if (instant != null) {
|
||||
|
||||
@@ -33,6 +33,11 @@ public class SyncedIdentityStore extends IdentityStore implements UserScopeStore
|
||||
EncryptedValue.VaultKey<SshIdentityStrategy> sshIdentity;
|
||||
boolean perUser;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return getSelfEntry().getName();
|
||||
}
|
||||
|
||||
public UsernameStrategy.Fixed getUsername() {
|
||||
return new UsernameStrategy.Fixed(username);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user