RequestDigest { String calculateHashA2() { return hash(algorithm, String.format("%s:%s", method, requestURI), "ISO-8859-1"); } RequestDigest(UsernamePasswordChallenge challenge, HTTPMethod method, URI requestURI, Digest serverDigest); String toHeaderValue(); static RequestDigest newInstance(UsernamePasswordChallenge challenge, HTTPRequest request, Digest digest);  }
@Test public void testCalculateHashA2() { 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("71998c64aea37ae77020c49c00f73fa8", requestDigest.calculateHashA2()); }