Skip to content

Commit

Permalink
eclipse-ditto#985 set supported client side user auth method
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Guggemos <dominik.guggemos@bosch.io>
  • Loading branch information
dguggemos committed Mar 24, 2021
1 parent a534c07 commit 685e9df
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public final class SshTunnelActor extends AbstractActorWithTimers implements Cre
private final String sshHost;
private final int sshPort;
private String sshUser = null;
private String sshUserMethod = null;
private String sshUserAuthMethod = null;
private final ServerKeyVerifier serverKeyVerifier;

@Nullable private ClientSession sshSession = null;
Expand Down Expand Up @@ -161,6 +161,7 @@ private void handleConnectResult(final ConnectFuture connectFuture) throws IOExc
sshSession.addSessionListener(new TunnelSessionListener(getSelf(), logger));
sshSession.addChannelListener(new TunnelChannelListener(getSelf()));
sshSession.setServerKeyVerifier(serverKeyVerifier);
sshSession.setUserAuthFactoriesNames(sshUserAuthMethod);
connection.getSshTunnel()
.map(SshTunnel::getCredentials)
.ifPresent(c -> c.accept(new ClientSessionCredentialsVisitor(sshSession, logger)));
Expand Down Expand Up @@ -299,16 +300,16 @@ public Void clientCertificate(final ClientCertificateCredentials credentials) {
@Override
public Void usernamePassword(final UserPasswordCredentials credentials) {
sshUser = credentials.getUsername();
sshUserMethod = UserAuthMethodFactory.PASSWORD;
logger.debug("Username ({}) for ssh session is '{}'.", sshUserMethod, sshUser);
sshUserAuthMethod = UserAuthMethodFactory.PASSWORD;
logger.debug("Username ({}) for ssh session is '{}'.", sshUserAuthMethod, sshUser);
return null;
}

@Override
public Void sshPublicKeyAuthentication(final SshPublicKeyAuthentication credentials) {
sshUser = credentials.getUsername();
sshUserMethod = UserAuthMethodFactory.PUBLIC_KEY;
logger.debug("Username ({}) for ssh session is '{}'.", sshUserMethod, sshUser);
sshUserAuthMethod = UserAuthMethodFactory.PUBLIC_KEY;
logger.debug("Username ({}) for ssh session is '{}'.", sshUserAuthMethod, sshUser);
return null;
}

Expand Down

0 comments on commit 685e9df

Please sign in to comment.