challenges.put("basic", new BasicHeader(AUTH.WWW_AUTH, "Basic realm=\"realm1\""));
challenges.put("digest", new BasicHeader(AUTH.WWW_AUTH, "Digest realm=\"realm2\", nonce=\"1234\""));
AuthSchemeRegistry authSchemeRegistry = new AuthSchemeRegistry();
authSchemeRegistry.register("basic", new BasicSchemeFactory());
authSchemeRegistry.register("digest", new DigestSchemeFactory());
context.setAttribute(ClientContext.AUTHSCHEME_REGISTRY, authSchemeRegistry);
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(new AuthScope("somehost", 80, "realm2"),
new UsernamePasswordCredentials("user", "pwd"));