drools-eclipse/org.guvnor.eclipse.webdav/src/client/org/eclipse/webdav/internal/authentication/DigestAuthority.java
private String credentials(Request request, String realm, String username, String password, String algorithm, String messageQop, String nonce, String nonceCount, String opaque, String cnonce, String method, String digestUri) throws Exception {
        Assert.isNotNull(request);
        Assert.isNotNull(realm);
        Assert.isNotNull(username);
        Assert.isNotNull(password);
        Assert.isNotNull(nonce);
        Assert.isNotNull(method);
        Assert.isNotNull(digestUri);

        StringBuffer buf = new StringBuffer();

        buf.append("Digest username=\""); //$NON-NLS-1$
        buf.append(username);
        buf.append("\""); //$NON-NLS-1$

        buf.append(", realm="); //$NON-NLS-1$
        buf.append(realm);

        if (messageQop != null) {
            buf.append(", qop=\""); //$NON-NLS-1$
            buf.append(messageQop);
            buf.append("\""); //$NON-NLS-1$
        }

        if (algorithm != null) {
            buf.append(", algorithm="); //$NON-NLS-1$
            buf.append(algorithm);
        }

        buf.append(", uri=\""); //$NON-NLS-1$
        buf.append(digestUri);
        buf.append("\""); //$NON-NLS-1$

        buf.append(", nonce="); //$NON-NLS-1$
        buf.append(nonce);

        if (nonceCount != null) {
            buf.append(", nc="); //$NON-NLS-1$
            buf.append(nonceCount);
        }

        if (cnonce != null) {
            buf.append(", cnonce=\""); //$NON-NLS-1$
            buf.append(cnonce);
            buf.append("\""); //$NON-NLS-1$
        }

        if (opaque != null) {
            buf.append(", opaque="); //$NON-NLS-1$
            buf.append(opaque);
        }

        String response = response(request, realm, username, password, algorithm, messageQop, nonce, nonceCount, cnonce, method, digestUri);
        if (response == null) {
            return null;
        }

        buf.append(", response=\""); //$NON-NLS-1$
        buf.append(response);
        buf.append("\""); //$NON-NLS-1$

        return buf.toString();
    }
private String credentials(Request request, String realm, String username, String password, String algorithm, String messageQop, String nonce, String nonceCount, String opaque, String cnonce, String method, String digestUri) throws Exception {
        Assert.isNotNull(request);
        Assert.isNotNull(realm);
        Assert.isNotNull(username);
        Assert.isNotNull(password);
        Assert.isNotNull(nonce);
        Assert.isNotNull(method);
        Assert.isNotNull(digestUri);

        StringBuffer buf = new StringBuffer();

        buf.append("Digest username=\""); //$NON-NLS-1$
        buf.append(username);
        buf.append("\""); //$NON-NLS-1$

        buf.append(", realm="); //$NON-NLS-1$
        buf.append(realm);

        if (messageQop != null) {
            buf.append(", qop=\""); //$NON-NLS-1$
            buf.append(messageQop);
            buf.append("\""); //$NON-NLS-1$
        }

        if (algorithm != null) {
            buf.append(", algorithm="); //$NON-NLS-1$
            buf.append(algorithm);
        }

        buf.append(", uri=\""); //$NON-NLS-1$
        buf.append(digestUri);
        buf.append("\""); //$NON-NLS-1$

        buf.append(", nonce="); //$NON-NLS-1$
        buf.append(nonce);

        if (nonceCount != null) {
            buf.append(", nc="); //$NON-NLS-1$
            buf.append(nonceCount);
        }

        if (cnonce != null) {
            buf.append(", cnonce=\""); //$NON-NLS-1$
            buf.append(cnonce);
            buf.append("\""); //$NON-NLS-1$
        }

        if (opaque != null) {
            buf.append(", opaque="); //$NON-NLS-1$
            buf.append(opaque);
        }

        String response = response(request, realm, username, password, algorithm, messageQop, nonce, nonceCount, cnonce, method, digestUri);
        if (response == null) {
            return null;
        }

        buf.append(", response=\""); //$NON-NLS-1$
        buf.append(response);
        buf.append("\""); //$NON-NLS-1$

        return buf.toString();
    }
Returns the Digest authorization credentials for the given directives.
The credentials have the following form:
<code>
credentials        = "Digest" digest-response
digest-response    = 1#( username | realm | nonce | digest-uri
| response | [ algorithm ] | [cnonce] |
[opaque] | [message-qop] |
[nonce-count]  | [auth-param] )
username            = "username" "=" username-value
username-value    = quoted-string
realm            = "realm" "=" realm-value
realm-value        = quoted-string
nonce            = "nonce" "=" nonce-value
nonce-value        = quoted-string
digest-uri        = "uri" "=" digest-uri-value
digest-uri-value    = request-uri   ; As specified by HTTP/1.1
response            = "response" "=" request-digest
request-digest    = &lt;"&gt; 32LHEX &lt;"&gt;
LHEX                = "0" | "1" | "2" | "3" |
"4" | "5" | "6" | "7" |
"8" | "9" | "a" | "b" |
"c" | "d" | "e" | "f"
algorithm        = "algorithm" "=" ("MD5" | "MD5-sess" | token)
cnonce            = "cnonce" "=" cnonce-value
cnonce-value        = nonce-value
opaque            = "opaque" "=" quoted-string
message-qop        = "qop" "=" qop-value
nonce-count        = "nc" "=" nc-value
nc-value            = 8LHEX
</code>
<P>If the "qop" value is "auth" or "auth-int":
<code>
request-digest    = &lt;"&gt; &lt; KD ( H(A1),        unq(nonce-value)
":" nc-value
":" unq(cnonce-value)
":" unq(qop-value)
":" H(A2)
) &lt;"&gt;
KD(secret, data)    = H(concat(secret, ":", data))
H(data)            = MD5(data)
unq(data)        = unqouted(data)
</code>
<P>If the "qop" directive is not present:
<code>
request-digest    = &lt;"&gt; &lt; KD ( H(A1),
unq(nonce-value)
":" H(A2)
) &lt;"&gt;
</code>
<P>If the "algorithm" directive's value is "MD5" or is unspecified,
then A1 is:
<code>
A1                = unq(username-value) ":" unq(realm-value) ":" passwd
passwd            = &lt; user's password &gt;
</code>
<P>If the "algorithm" directive's value is "MD5-sess", then A1 is:
<code>
A1                = H( unq(username-value) ":" unq(realm-value)
":" passwd )
":" unq(nonce-value) ":" unq(cnonce-value)
</code>
<P>If the "qop" directive's value is "auth" or is unspecified, then
A2 is:
<code>
A2                = Method ":" digest-uri-value
</code>
<P>If the "qop" value is "auth-int", then A2 is:
<code>
A2                = Method ":" digest-uri-value ":" H(entity-body)
</code>
@param request
@param realm
@param username
@param password
@param algorithm
@param messageQop
@param nonce
@param nonceCount
@param opaque
@param cnonce
@param method
@param digestUri
@return           the Digest authorization credentials for the given
directives