use of org.jetbrains.plugins.github.util.GithubAuthData in project intellij-community by JetBrains.
the class GithubShareProjectTest method checkGithubExists.
protected void checkGithubExists() throws IOException {
GithubAuthData auth = myGitHubSettings.getAuthData();
GithubRepoDetailed githubInfo = GithubApiUtil.getDetailedRepoInfo(new GithubConnection(auth), myLogin1, PROJECT_NAME);
assertNotNull("GitHub repository does not exist", githubInfo);
}
use of org.jetbrains.plugins.github.util.GithubAuthData in project intellij-community by JetBrains.
the class GithubHttpAuthDataProvider method getAuthData.
@Nullable
@Override
public AuthData getAuthData(@NotNull String url) {
if (!GithubUrlUtil.isGithubUrl(url)) {
return null;
}
GithubSettings settings = GithubSettings.getInstance();
if (!settings.isValidGitAuth()) {
return null;
}
String host1 = GithubUrlUtil.getHostFromUrl(settings.getHost());
String host2 = GithubUrlUtil.getHostFromUrl(url);
if (!host1.equalsIgnoreCase(host2)) {
return null;
}
GithubAuthData auth = settings.getAuthData();
switch(auth.getAuthType()) {
case BASIC:
GithubAuthData.BasicAuth basicAuth = auth.getBasicAuth();
assert basicAuth != null;
if (StringUtil.isEmptyOrSpaces(basicAuth.getLogin()) || StringUtil.isEmptyOrSpaces(basicAuth.getPassword())) {
return null;
}
return new AuthData(basicAuth.getLogin(), basicAuth.getPassword());
case TOKEN:
GithubAuthData.TokenAuth tokenAuth = auth.getTokenAuth();
assert tokenAuth != null;
if (StringUtil.isEmptyOrSpaces(tokenAuth.getToken())) {
return null;
}
return new AuthData(tokenAuth.getToken(), "x-oauth-basic");
default:
return null;
}
}
Aggregations