private void addAuthentication ( HttpHost host , Credentials credentials , AuthScheme authScheme , HttpClientContext context ) { AuthCache authCache = context . getAuthCache ( ) ; if ( authCache == null ) { authCache = new BasicAuthCache ( ) ; context . setAuthCache ( authCache ) ; } CredentialsProvider credsProvider = context . getCredentialsProvider ( ) ; if ( credsProvider == null ) { credsProvider = new BasicCredentialsProvider ( ) ; context . setCredentialsProvider ( credsProvider ) ; } credsProvider . setCredentials ( new AuthScope ( host ) , credentials ) ; if ( authScheme != null ) { authCache . put ( host , authScheme ) ; } }
Add authentication information for the given host