Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Password is no longer required for api usage and fix for broken base64 encoding. #27

Merged
merged 2 commits into from
Jan 7, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/main/java/org/kohsuke/github/GitHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
public class GitHub {
/*package*/ final String login;
/*package*/ final String encodedAuthorization;
/*package*/ final String password;
/*package*/ final String apiToken;

private final Map<String,GHUser> users = new HashMap<String, GHUser>();
Expand All @@ -75,25 +74,24 @@ private GitHub(String login, String apiToken, String password) {
* The URL of GitHub (or GitHub enterprise) API endpoint, such as "https://api.github.com" or
* "http://ghe.acme.com/api/v3". Note that GitHub Enterprise has <tt>/api/v3</tt> in the URL.
* For historical reasons, this parameter still accepts the bare domain name, but that's considered deprecated.
* Password is also considered deprecated as it is no longer required for api usage.
*/
private GitHub(String apiUrl, String login, String apiToken, String password) {
if (apiUrl.endsWith("/")) apiUrl = apiUrl.substring(0, apiUrl.length()-1); // normalize
this.apiUrl = apiUrl;
this.login = login;
this.apiToken = apiToken;
this.password = password;

if (apiToken!=null || password!=null) {
String userpassword = password==null ? (login + "/token" + ":" + apiToken) : (login + ':'+password);
encodedAuthorization = Base64.encodeBase64String(userpassword.getBytes());
String authorization = password==null ? (login + "/token" + ":" + apiToken) : (login + ':'+password);
encodedAuthorization = new String(Base64.encodeBase64(authorization.getBytes()));
} else
encodedAuthorization = null;
}

private GitHub (String apiUrl, String oauthAccessToken) throws IOException {

this.apiUrl = apiUrl;
this.password = null;
this.encodedAuthorization = null;

this.oauthAccessToken = oauthAccessToken;
Expand Down Expand Up @@ -126,9 +124,6 @@ public static GitHub connect() throws IOException {
* For historical reasons, this parameter still accepts the bare domain name, but that's considered deprecated.
*/
public static GitHub connectToEnterprise(String apiUrl, String login, String apiToken) {
// not exposing password because the login process still assumes https://github.com/
// if we are to fix this, fix that by getting rid of createWebClient() and replace the e-mail service hook
// with GitHub API.
return new GitHub(apiUrl,login,apiToken,null);
}

Expand Down