Skip to content

Commit

Permalink
#16775 remove exception when no user specified (#17706)
Browse files Browse the repository at this point in the history
* #16775 remove exception when no user specified

* #16775 use system username if username is empty

* #16775 fix credentials dialog prompting when save password
  • Loading branch information
Destrolaric committed Sep 22, 2022
1 parent 981d138 commit a2aed9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,14 @@ protected void execute(@NotNull DBRProgressMonitor monitor) throws Throwable {
monitor.subTask("Initialize tunnel");
String authTypeName = configuration.getStringProperty("authType");
SSHConstants.AuthType authType = CommonUtils.valueOf(SSHConstants.AuthType.class, authTypeName);
DBPAuthInfo dbpAuthInfo = promptCredentialsDialog(authType, configuration);
if (dbpAuthInfo != null) {
if (authType.equals(SSHConstants.AuthType.PASSWORD)) {
configuration.setUserName(dbpAuthInfo.getUserName());
if (!configuration.isSavePassword()) {
DBPAuthInfo dbpAuthInfo = promptCredentialsDialog(authType, configuration);
if (dbpAuthInfo != null) {
if (authType.equals(SSHConstants.AuthType.PASSWORD)) {
configuration.setUserName(dbpAuthInfo.getUserName());
}
configuration.setPassword(dbpAuthInfo.getUserPassword());
}
configuration.setPassword(dbpAuthInfo.getUserPassword());
}
tunnel.initializeHandler(monitor, configuration, connectionConfig);
monitor.worked(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private static SSHHostConfiguration loadConfiguration(@NotNull DBWHandlerConfigu
final SSHConstants.AuthType authType = CommonUtils.valueOf(SSHConstants.AuthType.class, configuration.getStringProperty(prefix + SSHConstants.PROP_AUTH_TYPE), SSHConstants.AuthType.PASSWORD);
final String hostname = configuration.getStringProperty(prefix + DBWHandlerConfiguration.PROP_HOST);
final int port = configuration.getIntProperty(prefix + DBWHandlerConfiguration.PROP_PORT);
final String username;
String username;
final String password;
final boolean savePassword = configuration.isSavePassword();

Expand All @@ -200,9 +200,8 @@ private static SSHHostConfiguration loadConfiguration(@NotNull DBWHandlerConfigu
throw new DBException("SSH port not specified");
}
if (CommonUtils.isEmpty(username)) {
throw new DBException("SSH user not specified");
username = System.getProperty("user.name");
}

final SSHAuthConfiguration authentication;
switch (authType) {
case PUBLIC_KEY: {
Expand Down

0 comments on commit a2aed9e

Please sign in to comment.