jenkinsci / java-client-api

A Jenkins API client for Java
MIT License
901 stars 470 forks source link

jenkins auth with Chinese Character failed #437

Open xjliang2007 opened 4 years ago

xjliang2007 commented 4 years ago

error is as follows: Exception in thread "main" org.apache.http.client.HttpResponseException: Invalid password/token for user: ???

I check the source code, the jenkins http client use ascii as default charset when using basic auth, I think it should be modified to use more conveniently.

xjliang2007 commented 4 years ago

I extend the JenkinsHttpClient to workaroud, :( .

public class ClubJenkinsHttpClient extends JenkinsHttpClient {

    public ClubJenkinsHttpClient(URI uri,String username, String password){
        super(uri,  HttpClientBuilder.create(),  username,  password);
        if(getLocalContext() != null){
            getLocalContext().setAttribute("preemptive-auth",new BasicScheme(Charset.forName("UTF-8")));
        }
    }
}