HttpClient client = factory.getHttpClient(); //or any method to get a client instance Credentials credentials = new UsernamePasswordCredentials(username, password); client.getState().setCredentials(AuthScope.ANY, credentials);
Java HttpClient Basic Credential 认证
原文:http://www.cnblogs.com/frankyou/p/7112589.html