in commit-status-publisher-server/src/main/java/jetbrains/buildServer/commitPublisher/github/ChangeStatusUpdater.java [66:94]
private GitHubApi getGitHubApi(@NotNull Map<String, String> params, @NotNull SProject project, @NotNull VcsRoot root) {
final String serverUrl = params.get(C.getServerKey());
if (serverUrl == null || StringUtil.isEmptyOrSpaces(serverUrl)) {
throw new IllegalArgumentException("Failed to read GitHub URL from the feature settings");
}
final GitHubApiAuthenticationType authenticationType = GitHubApiAuthenticationType.parse(params.get(C.getAuthenticationTypeKey()));
switch (authenticationType) {
case PASSWORD_AUTH:
final String username = params.get(C.getUserNameKey());
String password = params.get(C.getPasswordKey());
if (password == null) {
password = params.get(Constants.GITHUB_PASSWORD_DEPRECATED);
}
return myFactory.openGitHubForUser(serverUrl, username, password);
case TOKEN_AUTH:
final String token = params.get(C.getAccessTokenKey());
return myFactory.openGitHubForToken(serverUrl, token);
case STORED_TOKEN:
final String tokenId = params.get(C.getTokenIdKey());
return myFactory.openGitHubForStoredToken(serverUrl, tokenId, project);
case VCS_ROOT:
return getGitHubApiForVcsRootCredentials(project, root, serverUrl);
default:
throw new IllegalArgumentException("Failed to parse authentication type:" + authenticationType);
}
}