if(authPolicy.toUpperCase().equals("BASIC"))
{
URL uri = new URL(postUrl);
List<String> authPrefs = new ArrayList<String>(1);
authPrefs.add(AuthPolicy.BASIC);
httpClient.getParams().setParameter(AuthPolicy.AUTH_SCHEME_PRIORITY, authPrefs);
httpClient.getState().setCredentials(new AuthScope(uri.getHost(), uri.getPort(), AuthScope.ANY_REALM),new NTCredentials(username, password, uri.getHost(), domain));
state = httpClient.getState();
}
else
{
if(state != null)
httpClient.setState(state);
}
NTLM/DIGEST同理