*/
public Session createSession(int timeout) throws JSchException {
if (tunnelHostName == null) {
Session session =
JSchUtilities.createJSch().getSession(userName, hostName, 22);
session.setUserInfo(new SWTUserInfo() {
@Override
public String getPassword() {
return HadoopServer.this.password;
}
@Override
public void setPassword(String pass) {
HadoopServer.this.password = pass;
}
});
if (!session.isConnected()) {
try {
session.connect();
} catch (JSchException jse) {
// Reset password in case the authentication failed
if (jse.getMessage().equals("Auth fail"))
this.password = null;
throw jse;
}
}
return session;
} else {
createSshTunnel();
Session session =
JSchUtilities.createJSch().getSession(userName, "localhost",
tunnelPort);
session.setUserInfo(new SWTUserInfo() {
@Override
public String getPassword() {
return HadoopServer.this.password;
}