int length;
int pos;
static string [] keywords = { "realm", "opaque", "nonce", "algorithm", "qop" };
- static char [] endSeparator = new char[] { '"', ',' };
string [] values = new string [keywords.Length];
public DigestHeaderParser (string header)
pos--;
}
- void SkipNonWhitespace ()
- {
- char c = 'a';
- while (pos < length && c != ' ' && c != '\t' && c != '\r' && c != '\n') {
- c = header [pos++];
- }
- pos--;
- }
-
string GetKey ()
{
SkipWhitespace ();
{
string response = String.Format ("{0}:{1}:", HA1 (username, password), Nonce);
if (QOP != null)
- response += String.Format ("{0}:{1}:{2}:", _nc.ToString ("x8"), CNonce, QOP);
+ response += String.Format ("{0}:{1}:{2}:", _nc.ToString ("X8"), CNonce, QOP);
response += HA2 (webRequest);
return HashToHexString (response);
}
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;
}
}