protected ConnectFuture doConnect(
String username, SocketAddress targetAddress,
AttributeRepository context, SocketAddress localAddress,
KeyIdentityProvider identities, boolean useDefaultIdentities)
throws IOException {
if (connector == null) {
throw new IllegalStateException("SshClient not started. Please call start() method before connecting to a server");
}
ConnectFuture connectFuture = new DefaultConnectFuture(username + "@" + targetAddress, null);
SshFutureListener<IoConnectFuture> listener =
createConnectCompletionListener(
connectFuture, username, targetAddress, identities, useDefaultIdentities);
IoConnectFuture connectingFuture = connector.connect(targetAddress, context, localAddress);
connectingFuture.addListener(listener);
return connectFuture;
}