question: 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 ) ; } }
target:  Create an authenticated Jenkins HTTP client