import org.apache.sshd.client.ClientFactoryManager;
import org.apache.sshd.client.config.hosts.HostConfigEntry;
-import org.apache.sshd.client.keyverifier.KnownHostsServerKeyVerifier.HostEntryPair;
import org.apache.sshd.client.keyverifier.ServerKeyVerifier;
import org.apache.sshd.client.session.ClientSessionImpl;
import org.apache.sshd.common.FactoryManager;
if (verifier instanceof ServerKeyLookup) {
SocketAddress remoteAddress = resolvePeerAddress(
resolveAttribute(JGitSshClient.ORIGINAL_REMOTE_ADDRESS));
- List<HostEntryPair> allKnownKeys = ((ServerKeyLookup) verifier)
+ List<PublicKey> allKnownKeys = ((ServerKeyLookup) verifier)
.lookup(this, remoteAddress);
Set<String> reordered = new LinkedHashSet<>();
- for (HostEntryPair h : allKnownKeys) {
- PublicKey key = h.getServerKey();
+ for (PublicKey key : allKnownKeys) {
if (key != null) {
String keyType = KeyUtils.getKeyType(key);
if (keyType != null) {
}
@Override
- public List<HostEntryPair> lookup(ClientSession session,
+ public List<PublicKey> lookup(ClientSession session,
SocketAddress remote) {
List<HostKeyFile> filesToUse = getFilesToUse(session);
HostKeyHelper helper = new HostKeyHelper();
- List<HostEntryPair> result = new ArrayList<>();
+ List<PublicKey> result = new ArrayList<>();
Collection<SshdSocketAddress> candidates = helper
.resolveHostNetworkIdentities(session, remote);
for (HostKeyFile file : filesToUse) {
KnownHostEntry entry = current.getHostEntry();
for (SshdSocketAddress host : candidates) {
if (entry.isHostMatch(host.getHostName(), host.getPort())) {
- result.add(current);
+ result.add(current.getServerKey());
break;
}
}
package org.eclipse.jgit.internal.transport.sshd;
import java.net.SocketAddress;
+import java.security.PublicKey;
import java.util.List;
-import org.apache.sshd.client.keyverifier.KnownHostsServerKeyVerifier.HostEntryPair;
import org.apache.sshd.client.session.ClientSession;
import org.eclipse.jgit.annotations.NonNull;
public interface ServerKeyLookup {
/**
- * Retrieves all entries for a given remote address.
+ * Retrieves all public keys known for a given remote.
*
* @param session
* needed to determine the config files if specified in the ssh
* @return a possibly empty list of entries found, including revoked ones
*/
@NonNull
- List<HostEntryPair> lookup(ClientSession session, SocketAddress remote);
+ List<PublicKey> lookup(ClientSession session, SocketAddress remote);
}