From 1fe61f72e201865977bcc4e4ee701f125057de4d Mon Sep 17 00:00:00 2001 From: Johno Crawford Date: Sun, 6 Jan 2013 13:08:41 +0100 Subject: [PATCH 1/2] Password is no longer required for api usage. --- src/main/java/org/kohsuke/github/GitHub.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index a7b2ea8172..277e52d821 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -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 users = new HashMap(); @@ -75,17 +74,17 @@ 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 /api/v3 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 = Base64.encodeBase64String(authorization.getBytes()); } else encodedAuthorization = null; } @@ -93,7 +92,6 @@ private GitHub(String apiUrl, String login, String apiToken, String password) { private GitHub (String apiUrl, String oauthAccessToken) throws IOException { this.apiUrl = apiUrl; - this.password = null; this.encodedAuthorization = null; this.oauthAccessToken = oauthAccessToken; @@ -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); } From f80cb541d59de7edf1ba67fb0f4aadb1a1540ff7 Mon Sep 17 00:00:00 2001 From: Johno Crawford Date: Sun, 6 Jan 2013 21:11:19 +0100 Subject: [PATCH 2/2] Fix base64 encoding. --- src/main/java/org/kohsuke/github/GitHub.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/kohsuke/github/GitHub.java b/src/main/java/org/kohsuke/github/GitHub.java index 277e52d821..e885b89f84 100644 --- a/src/main/java/org/kohsuke/github/GitHub.java +++ b/src/main/java/org/kohsuke/github/GitHub.java @@ -84,7 +84,7 @@ private GitHub(String apiUrl, String login, String apiToken, String password) { if (apiToken!=null || password!=null) { String authorization = password==null ? (login + "/token" + ":" + apiToken) : (login + ':'+password); - encodedAuthorization = Base64.encodeBase64String(authorization.getBytes()); + encodedAuthorization = new String(Base64.encodeBase64(authorization.getBytes())); } else encodedAuthorization = null; }