Skip to content

Commit

Permalink
IDEA-99923 Proxy settings: if one credentials dialog is shown do not …
Browse files Browse the repository at this point in the history
…show another right away

(+ some preparations for automatic tests)
  • Loading branch information
Iris24 committed Jan 31, 2013
1 parent 5e69ea0 commit 6136087
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ public class HttpConfigurable implements PersistentStateComponent<HttpConfigurab
private transient final Object myLock = new Object();
private IdeaWideProxySelector mySelector;
private IdeaWideAuthenticator myAuthenticator;
public transient Getter<PasswordAuthentication> myTestAuthRunnable = new StaticGetter<PasswordAuthentication>(null);
public transient Getter<PasswordAuthentication> myTestGenericAuthRunnable = new StaticGetter<PasswordAuthentication>(null);

public static HttpConfigurable getInstance() {
return ServiceManager.getService(HttpConfigurable.class);
Expand Down Expand Up @@ -187,9 +189,18 @@ private String encode(String password) {
}

public PasswordAuthentication getGenericPromptedAuthentication(final String prefix, final String host, final String prompt, final int port, final boolean remember) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
return myTestGenericAuthRunnable.get();
}
final PasswordAuthentication[] value = new PasswordAuthentication[1];
final Runnable runnable = new Runnable() {
public void run() {
if (isGenericPasswordCanceled(host, port)) return;
final PasswordAuthentication password = getGenericPassword(host, port);
if (password != null) {
value[0] = password;
return;
}
final AuthenticationDialog dlg = new AuthenticationDialog(PopupUtil.getActiveComponent(), prefix + host,
"Please enter credentials for: " + prompt, "", "", remember);
dlg.show();
Expand Down Expand Up @@ -218,10 +229,18 @@ public PasswordAuthentication getPromptedAuthentication(final String host, final
if (ApplicationManager.getApplication() == null || ApplicationManager.getApplication().isDisposeInProgress() ||
ApplicationManager.getApplication().isDisposed()) return null;

if (ApplicationManager.getApplication().isUnitTestMode()) {
return myTestGenericAuthRunnable.get();
}
final String login = PROXY_LOGIN == null ? "" : PROXY_LOGIN;
final PasswordAuthentication[] value = new PasswordAuthentication[1];
final Runnable runnable = new Runnable() {
public void run() {
if (AUTHENTICATION_CANCELLED) return;
if (! StringUtil.isEmptyOrSpaces(PROXY_LOGIN) && ! StringUtil.isEmptyOrSpaces(password)) {
value[0] = new PasswordAuthentication(PROXY_LOGIN, password.toCharArray());
return;
}
final AuthenticationDialog dlg = new AuthenticationDialog(PopupUtil.getActiveComponent(), "Proxy authentication: " + host,
"Please enter credentials for: " + prompt, login, "", KEEP_PROXY_PASSWORD);
dlg.show();
Expand Down

0 comments on commit 6136087

Please sign in to comment.