client.getCredentialsProvider().setCredentials(
new AuthScope( targetHost ),
new UsernamePasswordCredentials( user, password ) );
// Create AuthCache instance
AuthCache authCache = new BasicAuthCache();
// Generate BASIC scheme object and add it to the local auth cache
BasicScheme basicAuth = new BasicScheme();
authCache.put( targetHost, basicAuth );
// Add AuthCache to the execution context
BasicHttpContext localContext = new BasicHttpContext();
localContext.setAttribute( ClientContext.AUTH_CACHE, authCache );
HttpGet request = new HttpGet( url.toURI() );