throw new RuntimeCamelException(msg);
}
log.debug("Connected to {}:{}", getHost(), getPort());
AuthFuture authResult;
ClientSession session = connectFuture.getSession();
KeyPairProvider keyPairProvider;
final String certFilename = getCertFilename();
if (certFilename != null) {
log.debug("Attempting to authenticate using FileKey '{}'...", certFilename);
keyPairProvider = new FileKeyPairProvider(new String[]{certFilename});
} else {
keyPairProvider = getKeyPairProvider();
}
if (keyPairProvider != null) {
log.debug("Attempting to authenticate username '{}' using Key...", getUsername());
KeyPair pair = keyPairProvider.loadKey(getKeyType());
authResult = session.authPublicKey(getUsername(), pair);
} else {
log.debug("Attempting to authenticate username '{}' using Password...", getUsername());
authResult = session.authPassword(getUsername(), getPassword());
}
authResult.await(getTimeout());
if (!authResult.isDone() || authResult.isFailure()) {
log.debug("Failed to authenticate");
throw new RuntimeCamelException("Failed to authenticate username " + getUsername());
}
ClientChannel channel = session.createChannel(ClientChannel.CHANNEL_EXEC, command);