1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| public ChannelSftp connectSFTP() throws JSchException
{
final JSch jsch = new JSch();
this.sessionSftp = jsch.getSession(this.workstation.getLogin(),
this.workstation.getHostName(),
this.workstation.getPort());
this.sessionSftp.setUserInfo(new UserInfo()
{
public String getPassphrase()
{
return null;
}// end method
public String getPassword()
{
return null;
}// end method
public boolean promptPassphrase(final String string)
{
return false;
}// end method
public boolean promptPassword(final String string)
{
return false;
}// end method
public boolean promptYesNo(final String string)
{
return true;
}// end method
public void showMessage(final String string)
{
System.out.println(string);
}// end method
});
this.sessionSftp.setPassword(this.workstation.getPassword());
this.sessionSftp.connect();
final Channel channel = this.sessionSftp.openChannel("sftp");
channel.connect();
final ChannelSftp channelSftp = (ChannelSftp) channel;
return channelSftp;
}// end method |
Partager