1010import java .net .PasswordAuthentication ;
1111import java .net .Proxy ;
1212import java .net .URL ;
13- import java .net . URLEncoder ;
13+ import java .nio . charset . StandardCharsets ;
1414import java .util .ArrayList ;
15+ import java .util .Base64 ;
1516import java .util .Iterator ;
1617import java .util .List ;
1718import java .util .Locale ;
@@ -237,9 +238,6 @@ private static String readUrlData( String url, GithubIssueInfo info ) throws Exc
237238 String githubUser = info .getProperty ( ARG_GITHUB_USER );
238239 String githubPass = info .getProperty ( ARG_GITHUB_PASS );
239240 logger .info ( "connecting to url : " +url +" (user:" +githubUser +")" );
240- if ( StringUtils .isNotEmpty ( githubUser ) && StringUtils .isNotEmpty ( githubPass ) ) {
241- url = url .replace ( "api.github.com" , githubUser +":" +URLEncoder .encode ( githubPass , "UTF-8" )+"@api.github.com" );
242- }
243241 HttpURLConnection conn ;
244242 if ( !StringUtils .isEmpty ( proxyHost ) && !StringUtils .isEmpty ( proxyPort ) ) {
245243 logger .debug ( "using proxy : " +proxyHost +":" +proxyPort +" (user:" +proxyUser +")" );
@@ -257,6 +255,11 @@ public PasswordAuthentication getPasswordAuthentication() {
257255 } else {
258256 URL u = new URL ( url );
259257 conn = (HttpURLConnection )u .openConnection ();
258+ if ( StringUtils .isNotEmpty ( githubUser ) && StringUtils .isNotEmpty ( githubPass ) ) {
259+ String encoded = Base64 .getEncoder ().encodeToString ((githubUser +":" +githubPass ).getBytes (StandardCharsets .UTF_8 ));
260+ logger .info ( "Set authentication : " +encoded );
261+ conn .setRequestProperty ("Authorization" , "Basic " +encoded );
262+ }
260263 }
261264 StringBuffer buffer = new StringBuffer ();
262265 if ( conn .getResponseCode () != 200 ) {
0 commit comments