This commit is contained in:
madhurig 2015-11-17 17:26:55 -05:00
Родитель 4e9d6170e9
Коммит 87bfef056c
7 изменённых файлов: 53 добавлений и 32 удалений

Просмотреть файл

@ -123,10 +123,15 @@ public class UrlHelper {
}
// only support http and https (ssh support will come later when the format of the url is better understood)
try {
final String scheme = gitUri.getScheme() != null ? gitUri.getScheme().toLowerCase() : null;
if (HTTPS_PROTOCOL.equals(scheme) || HTTP_PROTOCOL.equals(scheme)) {
return HttpGitUrlParser.tryParse(gitUri, validator);
}
} catch (Throwable t) {
logger.error("tryParse: unexpected error");
logger.warn("tryParse", t);
}
return ParseResult.FAILED;
}

Просмотреть файл

@ -7,6 +7,7 @@
<SOURCES>
<root url="file://$PROJECT_DIR$/lib/src" />
<root url="file://$PROJECT_DIR$/../plugin/src" />
<root url="file://$PROJECT_DIR$/../common/src" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/lib/classes" recursive="false" />
<jarDirectory url="file://$PROJECT_DIR$/lib/src" recursive="false" type="SOURCES" />

Просмотреть файл

@ -25,7 +25,7 @@ ServerContextTable.ProjectColumn=Project
ServerContextTable.RepoColumn=Repository
#Common
Errors.AuthCanceledByUser=Login canceled by the user.
Errors.AuthNotSuccessful=Authenticating to the server for Git repository ''{0}'' was not successful. Please provide valid credentials and try again.
Operation.Errors.LookupCanceled=Lookup operation was canceled by the user
PAT.TokenDesc=VSO IntelliJ Plugin

Просмотреть файл

@ -69,7 +69,7 @@ public class TfPluginBundle {
// Common
@NonNls
public static final String KEY_ERRORS_AUTH_CANCELED_BY_USER = "Errors.AuthCanceledByUser";
public static final String KEY_ERRORS_AUTH_NOT_SUCCESSFUL = "Errors.AuthNotSuccessful";
@NonNls
public static final String KEY_OPERATION_ERRORS_LOOKUP_CANCELED = "Operation.Errors.LookupCanceled";
@NonNls

Просмотреть файл

@ -477,7 +477,7 @@ public class CreatePullRequestModel extends AbstractModel {
TfPluginBundle.message(TfPluginBundle.KEY_PAT_TOKEN_DESC), true);
if (context == null) {
notifyCreateFailedError(project, TfPluginBundle.message(TfPluginBundle.KEY_ERRORS_AUTH_CANCELED_BY_USER));
notifyCreateFailedError(project, TfPluginBundle.message(TfPluginBundle.KEY_ERRORS_AUTH_NOT_SUCCESSFUL, gitRemoteUrl));
return;
}

Просмотреть файл

@ -10,14 +10,19 @@ import com.microsoftopentechnologies.auth.AuthenticationResult;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.NTCredentials;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.net.UnknownHostException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/**
* Static helpers for Authentication
*/
public class AuthHelper {
private final static Logger logger = LoggerFactory.getLogger(AuthHelper.class);
private final static String COMPUTER_NAME = "computername";
public static AuthenticationInfo createAuthenticationInfo(final String serverUri, final Credentials credentials) {
@ -49,10 +54,8 @@ public class AuthHelper {
/**
* This method wraps the normal Async call to authenticate and waits on the result.
*
* @throws Throwable
*/
public static AuthenticationInfo getAuthenticationInfoSynchronously(final AuthenticationProvider provider, final String gitRemoteUrl) throws Throwable {
public static AuthenticationInfo getAuthenticationInfoSynchronously(final AuthenticationProvider provider, final String gitRemoteUrl){
final SettableFuture<AuthenticationInfo> future = SettableFuture.create();
provider.authenticateAsync(gitRemoteUrl, new AuthenticationListener() {
@ -73,7 +76,22 @@ public class AuthHelper {
// Wait for the authentication info object to be ready
// Don't wait any longer than 15 minutes for the user to authenticate
Throwable t = null;
try {
return future.get(15, TimeUnit.MINUTES);
} catch(InterruptedException ie) {
t = ie;
} catch(ExecutionException ee) {
t = ee;
} catch(TimeoutException te) {
t = te;
} finally {
if (t != null) {
logger.error("getAuthenticationInfoSynchronously: failed to get authentication info from user");
logger.warn("getAuthenticationInfoSynchronously", t);
}
}
return null;
}
/**

Просмотреть файл

@ -215,7 +215,6 @@ public class ServerContextManager {
public ServerContext createContextFromRemoteUrl(final String gitRemoteUrl) {
assert !StringUtils.isEmpty(gitRemoteUrl);
try {
// Get matching context from manager
ServerContext context = getActiveContext();
if (context == ServerContext.NO_CONTEXT || context.getGitRepository() == null ||
@ -234,9 +233,6 @@ public class ServerContextManager {
}
return context;
} catch (Throwable ex) {
throw new RuntimeException(ex.getLocalizedMessage(), ex);
}
}
/**
@ -312,7 +308,8 @@ public class ServerContextManager {
final CoreHttpClient coreClient = new CoreHttpClient(client, serverUri);
collection = coreClient.getProjectCollection(parseResult.getCollectionName());
} catch (Throwable throwable) {
//TODO Log the failure
logger.error("validate: failed");
logger.warn("validate", throwable);
return false;
}