int colonIndex = hostAndPort.indexOf(':');
String host = hostAndPort.substring(0, colonIndex);
String port = hostAndPort.substring(colonIndex + 1);
PasswordSafe passwordSafe = PasswordSafe.getInstance();
final UserAndPassword userAndPassword = getUsernameAndPassword(hostAndPort);
if (userAndPassword == null) return;
if (userAndPassword.user == null || userAndPassword.password == null) {
continue;
}
SiConnectCommand command =
new SiConnectCommand(MksVcs.getInstance(myProject), host, port, userAndPassword.user, userAndPassword.password);
command.execute();
if (!command.foundError() && (command.getServer() != null)) {
servers.add(command.getServer());
try {
MksConfiguration configuration = ApplicationManager.getApplication().getComponent(MksConfiguration.class);
configuration.addRememberedUsername(hostAndPort, userAndPassword.user);
passwordSafe.storePassword(myProject, MksVcs.class, createPasswordKey(hostAndPort, userAndPassword.user),userAndPassword.password);
} catch (PasswordSafeException e) {
reportErrors(Arrays.asList(new VcsException(e)), "unable to store credentials");
}
} else {
reportErrors(command.errors, "unable to connect to " + hostAndPort);