}
value = header.Substring (beginQ, pos - beginQ);
- pos += 2;
+ pos += useQuote ? 2 : 1;
return true;
}
}
// build the hash object (only MD5 is defined in RFC2617)
if ((parser.Algorithm == null) || (parser.Algorithm.ToUpper ().StartsWith ("MD5")))
- hash = HashAlgorithm.Create ("MD5");
+ hash = MD5.Create ();
return true;
}
auth.AppendFormat ("response=\"{0}\", ", Response (userName, password, request));
if (QOP != null) { // quality of protection (server decision)
- auth.AppendFormat ("qop={0}, ", QOP);
+ auth.AppendFormat ("qop=\"{0}\", ", QOP);
}
lock (this) {
class DigestClient : IAuthenticationModule
{
- static Hashtable cache;
-
- public DigestClient () {}
-
+ static readonly Hashtable cache = Hashtable.Synchronized (new Hashtable ());
+
static Hashtable Cache {
get {
- lock (typeof (DigestClient)) {
- if (cache == null) {
- cache = Hashtable.Synchronized (new Hashtable ());
- } else {
- CheckExpired (cache.Count);
- }
-
- return cache;
+ lock (cache.SyncRoot) {
+ CheckExpired (cache.Count);
}
+
+ return cache;
}
}
if (request == null)
return null;
- int hashcode = request.Address.GetHashCode () ^ credentials.GetHashCode ();
+ DigestSession currDS = new DigestSession();
+ if (!currDS.Parse (challenge))
+ return null;
+
+ int hashcode = request.Address.GetHashCode () ^ credentials.GetHashCode () ^ currDS.Nonce.GetHashCode ();
DigestSession ds = (DigestSession) Cache [hashcode];
bool addDS = (ds == null);
if (addDS)
- ds = new DigestSession ();
-
- if (!ds.Parse (challenge))
+ ds = currDS;
+ else if (!ds.Parse (challenge))
return null;
if (addDS)