src/HTTPClient/DefaultAuthHandler.java
/**
     * Calculates the digest of the request body. This was in RFC-2069
     * and draft-ietf-http-authentication-00.txt, but has subsequently
     * been removed. Here for backwards compatibility.
     */
Calculates the digest of the request body.
Calculates the digest of the request body .
private static String calc_digest(RoRequest req, String A1_hash,
				      String nonce)
    {
	if (req.getStream() != null)
	    return "";
	int ct=-1, ce=-1, lm=-1, ex=-1, dt=-1;
	for (int idx=0; idx<req.getHeaders().length; idx++)
	{
	    String name = req.getHeaders()[idx].getName();
	    if (name.equalsIgnoreCase("Content-type"))
		ct = idx;
	    else if (name.equalsIgnoreCase("Content-Encoding"))
		ce = idx;
	    else if (name.equalsIgnoreCase("Last-Modified"))
		lm = idx;
	    else if (name.equalsIgnoreCase("Expires"))
		ex = idx;
	    else if (name.equalsIgnoreCase("Date"))
		dt = idx;
	}
	NVPair[] hdrs = req.getHeaders();
	byte[] entity_body = (req.getData() == null ? NUL : req.getData());
	String entity_hash = MD5.hexDigest(entity_body);
	String entity_info = MD5.hexDigest(req.getRequestURI() + ":" +
	     (ct == -1 ? "" : hdrs[ct].getValue()) + ":" +
	     entity_body.length + ":" +
	     (ce == -1 ? "" : hdrs[ce].getValue()) + ":" +
	     (lm == -1 ? "" : hdrs[lm].getValue()) + ":" +
	     (ex == -1 ? "" : hdrs[ex].getValue()));
	String entity_digest = A1_hash + ":" + nonce + ":" + req.getMethod() +
			":" + (dt == -1 ? "" : hdrs[dt].getValue()) +
			":" + entity_info + ":" + entity_hash;
	if (Log.isEnabled(Log.AUTH))
	{
	    Log.write(Log.AUTH, "Auth:  Entity-Info: '" + req.getRequestURI() + ":" +
		 (ct == -1 ? "" : hdrs[ct].getValue()) + ":" +
		 entity_body.length + ":" +
		 (ce == -1 ? "" : hdrs[ce].getValue()) + ":" +
		 (lm == -1 ? "" : hdrs[lm].getValue()) + ":" +
		 (ex == -1 ? "" : hdrs[ex].getValue()) +"'");
	    Log.write(Log.AUTH, "Auth:  Entity-Body: '" + entity_hash + "'");
	    Log.write(Log.AUTH, "Auth:  Entity-Digest: '" + entity_digest + "'");
	}
	return MD5.hexDigest(entity_digest);
    }
private static String calc_digest ( RoRequest req , String A1_hash , String nonce ) { if ( req . getStream ( ) != null ) return "" ; int ct = - 1 , ce = - 1 , lm = - 1 , ex = - 1 , dt = - 1 ; for ( int idx = 0 ; idx < req . getHeaders ( ) . length ; idx ++ ) { String name = req . getHeaders ( ) [ idx ] . getName ( ) ; if ( name . equalsIgnoreCase ( "Content-type" ) ) ct = idx ; else if ( name . equalsIgnoreCase ( "Content-Encoding" ) ) ce = idx ; else if ( name . equalsIgnoreCase ( "Last-Modified" ) ) lm = idx ; else if ( name . equalsIgnoreCase ( "Expires" ) ) ex = idx ; else if ( name . equalsIgnoreCase ( "Date" ) ) dt = idx ; } NVPair [ ] hdrs = req . getHeaders ( ) ; byte [ ] entity_body = ( req . getData ( ) == null ? NUL : req . getData ( ) ) ; String entity_hash = MD5 . hexDigest ( entity_body ) ; String entity_info = MD5 . hexDigest ( req . getRequestURI ( ) + ":" + ( ct == - 1 ? "" : hdrs [ ct ] . getValue ( ) ) + ":" + entity_body . length + ":" + ( ce == - 1 ? "" : hdrs [ ce ] . getValue ( ) ) + ":" + ( lm == - 1 ? "" : hdrs [ lm ] . getValue ( ) ) + ":" + ( ex == - 1 ? "" : hdrs [ ex ] . getValue ( ) ) ) ; String entity_digest = A1_hash + ":" + nonce + ":" + req . getMethod ( ) + ":" + ( dt == - 1 ? "" : hdrs [ dt ] . getValue ( ) ) + ":" + entity_info + ":" + entity_hash ; if ( Log . isEnabled ( Log . AUTH ) ) { Log . write ( Log . AUTH , "Auth:  Entity-Info: '" + req . getRequestURI ( ) + ":" + ( ct == - 1 ? "" : hdrs [ ct ] . getValue ( ) ) + ":" + entity_body . length + ":" + ( ce == - 1 ? "" : hdrs [ ce ] . getValue ( ) ) + ":" + ( lm == - 1 ? "" : hdrs [ lm ] . getValue ( ) ) + ":" + ( ex == - 1 ? "" : hdrs [ ex ] . getValue ( ) ) + "'" ) ; Log . write ( Log . AUTH , "Auth:  Entity-Body: '" + entity_hash + "'" ) ; Log . write ( Log . AUTH , "Auth:  Entity-Digest: '" + entity_digest + "'" ) ; } return MD5 . hexDigest ( entity_digest ) ; }
Calculates the digest of the request body.
Calculates the digest of the request body .