if (this.session == null || !this.session.isConnected())
{
doCloseCommunicationLink();
// channel closed. e.g. by freeUnusedResources, but now we need it again
Session session;
UserAuthenticationData authData = null;
try
{
final GenericFileName rootName = (GenericFileName) getRootName();
authData = UserAuthenticatorUtils.authenticate(getFileSystemOptions(),
SftpFileProvider.AUTHENTICATOR_TYPES);
session = SftpClientFactory.createConnection(
rootName.getHostName(),
rootName.getPort(),
UserAuthenticatorUtils.getData(authData, UserAuthenticationData.USERNAME,
UserAuthenticatorUtils.toChar(rootName.getUserName())),
UserAuthenticatorUtils.getData(authData, UserAuthenticationData.PASSWORD,
UserAuthenticatorUtils.toChar(rootName.getPassword())),
getFileSystemOptions());
}
catch (final Exception e)
{
throw new FileSystemException("vfs.provider.sftp/connect.error",
getRootName(),
e);
}
finally
{
UserAuthenticatorUtils.cleanup(authData);
}
this.session = session;
}
try
{
// Use the pooled channel, or create a new one
final ChannelSftp channel;
if (idleChannel != null)
{
channel = idleChannel;
idleChannel = null;
}
else
{
channel = (ChannelSftp) session.openChannel("sftp");
channel.connect();
Boolean userDirIsRoot =
SftpFileSystemConfigBuilder.getInstance().getUserDirIsRoot(getFileSystemOptions());
String workingDirectory = getRootName().getPath();