RequestDigest { String calculateHashA1() { StringBuilder a1 = new StringBuilder(); a1.append(challenge.getIdentifier()); a1.append(':'); a1.append(serverDigest.getScheme().getRealm()); a1.append(':'); a1.append(challenge.getPassword()); return hash(algorithm, a1.toString(), "US-ASCII"); } RequestDigest(UsernamePasswordChallenge challenge, HTTPMethod method, URI requestURI, Digest serverDigest); String toHeaderValue(); static RequestDigest newInstance(UsernamePasswordChallenge challenge, HTTPRequest request, Digest digest);  }
@Test public void testCalculateHashA1() { AuthScheme scheme = new AuthScheme(AuthDirectivesParser.parse("Digest realm=\"realm1\", nonce=\"f2a3f18799759d4f1a1c068b92b573cb\"").iterator().next()); Digest digest = new Digest(new HTTPHost("http", "localhost", -1), scheme); assertEquals("f2a3f18799759d4f1a1c068b92b573cb", digest.getNonce()); RequestDigest requestDigest = new RequestDigest( new UsernamePasswordChallenge("username", "password"), HTTPMethod.GET, URI.create("/"), digest ); assertEquals("37ddcec9c022371a3dd7d500dfc81297", requestDigest.calculateHashA1()); }