}
/** Gets a new AuthorizationHeader based on current authentication attributes. */
public AuthorizationHeader getAuthorizationHeader()
{ AuthorizationHeader ah=new AuthorizationHeader("Digest");
ah.addUsernameParam(username);
ah.addRealmParam(realm);
ah.addNonceParam(nonce);
ah.addUriParam(uri);
if (algorithm!=null) ah.addAlgorithParam(algorithm);
if (opaque!=null) ah.addOpaqueParam(opaque);
/*
if (qop!=null) ah.addQopParam(qop);
if (nc!=null) ah.addNcParam(nc);
*/
if (qop!=null)
{
ah.addQopParam(qop);
if (qop.equalsIgnoreCase("auth-int") || qop.equalsIgnoreCase("auth"))
{
// qop requires cnonce and nc as per rfc2617
cnonce=HEX(MD5(Long.toString(System.currentTimeMillis()))); // unique hopefully
ah.addCnonceParam(cnonce);
nc="00000001"; // always 1 since cnonce should be unique - avoids having to have a static counter
ah.addNcParam(nc);
}
}
String response=getResponse();
ah.addResponseParam(response);
return ah;
}