PasswordAuthentication (final @Nls String prefix, final @NlsSafe String host, final String prompt, final int port, final boolean remember) { if (ApplicationManager.getApplication().isUnitTestMode()) { return null; } final Ref<PasswordAuthentication> value = Ref.create(); runAboveAll(() -> { if (isGenericPasswordCanceled(host, port)) { return; } PasswordAuthentication password = getGenericPassword(host, port); if (password != null) { value.set(password); return; } AuthenticationDialog dialog = new AuthenticationDialog(PopupUtil.getActiveComponent(), prefix + ": "+ host, IdeBundle.message("dialog.message.please.enter.credentials.for", prompt), "", "", remember); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { AuthenticationPanel panel = dialog.getPanel(); PasswordAuthentication passwordAuthentication = new PasswordAuthentication(panel.getLogin(), panel.getPassword()); putGenericPassword(host, port, passwordAuthentication, remember && panel.isRememberPassword()); value.set(passwordAuthentication); } else { setGenericPasswordCanceled(host, port); } }); return value.get(); }