HttpState state = new HttpState();
UsernamePasswordCredentials cred = new UsernamePasswordCredentials("username","password");
state.setCredentials( new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "realm1"), cred);
UsernamePasswordCredentials cred2 = new UsernamePasswordCredentials("uname2","password2");
state.setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, "realm2"), cred2);
AuthScheme authscheme1 = new DigestScheme();
authscheme1.processChallenge(challenge1);
AuthScheme authscheme2 = new DigestScheme();
authscheme2.processChallenge(challenge2);
{
HttpMethod method = new SimpleHttpMethod(new Header("WWW-Authenticate",challenge1));
assertTrue(authenticate(authscheme1, method, null, state));
assertTrue(null != method.getRequestHeader("Authorization"));
Map table = AuthChallengeParser.extractParams(method.getRequestHeader("Authorization").getValue());