public JenkinsHttpClient(URI uri,String username,String password){
  this(uri);
  if (isNotBlank(username)) {
    CredentialsProvider provider=client.getCredentialsProvider();
    AuthScope scope=new AuthScope(uri.getHost(),uri.getPort(),AuthScope.ANY_REALM);
    UsernamePasswordCredentials credentials=new UsernamePasswordCredentials(username,password);
    provider.setCredentials(scope,credentials);
    localContext=new BasicHttpContext();
    localContext.setAttribute("preemptive-auth",new BasicScheme());
    client.addRequestInterceptor(new PreemptiveAuth(),0);
  }
}

public JenkinsHttpClient ( URI uri , String username , String password ) { this ( uri ) ; if ( isNotBlank ( username ) ) { CredentialsProvider provider = client . getCredentialsProvider ( ) ; AuthScope scope = new AuthScope ( uri . getHost ( ) , uri . getPort ( ) , AuthScope . ANY_REALM ) ; UsernamePasswordCredentials credentials = new UsernamePasswordCredentials ( username , password ) ; provider . setCredentials ( scope , credentials ) ; localContext = new BasicHttpContext ( ) ; localContext . setAttribute ( "preemptive-auth" , new BasicScheme ( ) ) ; client . addRequestInterceptor ( new PreemptiveAuth ( ) , 0 ) ; } }
create an authenticated jenkins http client
