Do not ask authentication in common authenticator for every request; ask only for proxy or pass to explicitly registered authenticators

will fix IDEA-100247 Creating library from Maven asks for proxy authentication credentials
 also changes (same result, less code) fix for IDEA-100094 Git: strange proxy login dialog without proxy enabled when working with https git repository
This commit is contained in:
irengrig
2013-02-08 20:35:07 +04:00
parent 60ae3bf050
commit 7ea74ea400
2 changed files with 6 additions and 10 deletions
@@ -68,6 +68,7 @@ public class IdeaWideAuthenticator extends NonStaticAuthenticator {
ApplicationManager.getApplication().isDisposed()) return null;
LOG.debug("CommonAuthenticator.getPasswordAuthentication generic authentication will be asked");
return myHttpConfigurable.getGenericPromptedAuthentication(prefix, host, getRequestingPrompt(), getRequestingPort(), false);
//return myHttpConfigurable.getGenericPromptedAuthentication(prefix, host, getRequestingPrompt(), getRequestingPort(), false);
return null;
}
}
@@ -56,7 +56,10 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
/**
@@ -309,13 +312,8 @@ public final class GitHttpAdapter {
String url = command.getUrl();
GitHttpCredentialsProvider provider = command.getCredentialsProvider();
final Set<CommonProxy.HostInfo> tried = new HashSet<CommonProxy.HostInfo>();
try {
for (int i = 0; i < 3; i++) {
final CommonProxy.HostInfo hostInfo = getHostInfo(url);
CommonProxy.getInstance().noAuthentication(hostInfo.getProtocol(), hostInfo.getHost(), hostInfo.getPort());
tried.add(hostInfo);
try {
AuthData authData = getUsernameAndPassword(provider.getProject(), provider.getUrl());
if (authData != null) {
@@ -384,9 +382,6 @@ public final class GitHttpAdapter {
}
finally {
log(command, project);
for (CommonProxy.HostInfo info : tried) {
CommonProxy.getInstance().removeNoAuthentication(info.getProtocol(), info.getHost(), info.getPort());
}
}
}