diff options
author | Matthew Johnson <mjj29@hecate.trinhall.cam.ac.uk> | 2006-12-30 13:58:45 +0000 |
---|---|---|
committer | Matthew Johnson <mjj29@hecate.trinhall.cam.ac.uk> | 2006-12-30 13:58:45 +0000 |
commit | 86b6f0007b0e52bd25d9b73e21486620e085900d (patch) | |
tree | 2b64d74cea1b28b66afd39f922be29db7c846bda /org | |
parent | 4b79e35c681dd819c09a218db144f6aa83cc432f (diff) |
fix sha-1 auth on reference implementation
Diffstat (limited to 'org')
-rw-r--r-- | org/freedesktop/dbus/Transport.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/org/freedesktop/dbus/Transport.java b/org/freedesktop/dbus/Transport.java index 7544104..5d6e3bb 100644 --- a/org/freedesktop/dbus/Transport.java +++ b/org/freedesktop/dbus/Transport.java @@ -309,7 +309,11 @@ public class Transport switch (auth) { case AUTH_SHA: String[] reply=stupidlyDecode(c.getData()).split(" "); - if (3 != reply.length) return ERROR; + if (Debug.debug) Debug.print(Debug.VERBOSE, Arrays.toString(reply)); + if (3 != reply.length) { + if (Debug.debug) Debug.print(Debug.DEBUG, "Reply is not length 3"); + return ERROR; + } String context = reply[0]; String ID = reply[1]; String serverchallenge = reply[2]; @@ -324,8 +328,14 @@ public class Transport Message.marshallintBig(System.currentTimeMillis(), buf, 0, 8); String clientchallenge = stupidlyEncode(md.digest(buf)); md.reset(); - String cookie = findCookie(context, ID); - if (null == cookie) return ERROR; + long start = System.currentTimeMillis(); + String cookie = null; + while (null == cookie && (System.currentTimeMillis()-start) < LOCK_TIMEOUT) + cookie = findCookie(context, ID); + if (null == cookie) { + if (Debug.debug) Debug.print(Debug.DEBUG, "Did not find a cookie in context "+context+" with ID "+ID); + return ERROR; + } String response = serverchallenge+":"+clientchallenge+":"+cookie; buf = md.digest(response.getBytes()); if (Debug.debug) Debug.print(Debug.VERBOSE, "Response: "+response+" hash: "+Hexdump.format(buf)); @@ -333,6 +343,7 @@ public class Transport c.setResponse(stupidlyEncode(clientchallenge+" "+response)); return OK; default: + if (Debug.debug) Debug.print(Debug.DEBUG, "Not DBUS_COOKIE_SHA1 authtype."); return ERROR; } } |