提交 1cc59b2a 编写于 作者: S Serge Rider

#1115 SSH tunnel password acquire fix


Former-commit-id: d37a8dfb
上级 f47df9f3
......@@ -641,8 +641,8 @@ public class DataSourceDescriptor
}
log.debug("Connect with '" + getName() + "' (" + getId() + ")");
final String oldName = getConnectionConfiguration().getUserName();
final String oldPassword = getConnectionConfiguration().getUserPassword();
//final String oldName = getConnectionConfiguration().getUserName();
//final String oldPassword = getConnectionConfiguration().getUserPassword();
if (!isSavePassword()) {
// Ask for password
if (!DataSourceHandler.askForPassword(this, null)) {
......@@ -650,14 +650,6 @@ public class DataSourceDescriptor
return false;
}
}
for (DBWHandlerConfiguration handler : getConnectionConfiguration().getDeclaredHandlers()) {
if (handler.isEnabled() && handler.isSecured() && !handler.isSavePassword()) {
if (!DataSourceHandler.askForPassword(this, handler)) {
DataSourceHandler.updateDataSourceObject(this);
return false;
}
}
}
processEvents(monitor, DBPConnectionEventType.BEFORE_CONNECT);
......@@ -680,6 +672,25 @@ public class DataSourceDescriptor
monitor.subTask("Initialize tunnel");
tunnel = tunnelConfiguration.createHandler(DBWTunnel.class);
try {
if (tunnel.needsPassword(tunnelConfiguration)) {
if (!DataSourceHandler.askForPassword(this, tunnelConfiguration)) {
DataSourceHandler.updateDataSourceObject(this);
tunnel = null;
return false;
}
}
/*
for (DBWHandlerConfiguration handler : getConnectionConfiguration().getDeclaredHandlers()) {
if (handler.isEnabled() && handler.isSecured() && !handler.isSavePassword()) {
if (!DataSourceHandler.askForPassword(this, handler)) {
DataSourceHandler.updateDataSourceObject(this);
return false;
}
}
}
*/
tunnelConnectionInfo = tunnel.initializeTunnel(monitor, registry.getPlatform(), tunnelConfiguration, connectionInfo);
} catch (Exception e) {
throw new DBCException("Can't initialize tunnel", e);
......
......@@ -31,6 +31,11 @@ import java.io.IOException;
*/
public class HTTPTunnelImpl implements DBWTunnel {
@Override
public boolean needsPassword(DBWHandlerConfiguration configuration) {
return false;
}
@Override
public DBPConnectionConfiguration initializeTunnel(DBRProgressMonitor monitor, DBPPlatform platform, DBWHandlerConfiguration configuration, DBPConnectionConfiguration connectionInfo)
throws DBException, IOException
......
......@@ -191,6 +191,19 @@ public class SSHTunnelImpl implements DBWTunnel {
}
}
@Override
public boolean needsPassword(DBWHandlerConfiguration configuration) {
if (!configuration.isEnabled() || !configuration.isSecured()) {
return false;
}
String sshAuthType = configuration.getProperties().get(SSHConstants.PROP_AUTH_TYPE);
SSHConstants.AuthType authType = SSHConstants.AuthType.PASSWORD;
if (sshAuthType != null) {
authType = SSHConstants.AuthType.valueOf(sshAuthType);
}
return authType == SSHConstants.AuthType.PASSWORD && !configuration.isSavePassword();
}
@Override
public void invalidateHandler(DBRProgressMonitor monitor) throws DBException, IOException {
boolean isAlive = session != null && session.isConnected();
......
......@@ -29,6 +29,8 @@ import java.io.IOException;
*/
public interface DBWTunnel extends DBWNetworkHandler {
boolean needsPassword(DBWHandlerConfiguration configuration);
DBPConnectionConfiguration initializeTunnel(DBRProgressMonitor monitor, DBPPlatform platform, DBWHandlerConfiguration configuration, DBPConnectionConfiguration connectionInfo)
throws DBException, IOException;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册