From 86b6f0007b0e52bd25d9b73e21486620e085900d Mon Sep 17 00:00:00 2001 From: Matthew Johnson Date: Sat, 30 Dec 2006 13:58:45 +0000 Subject: fix sha-1 auth on reference implementation --- org/freedesktop/dbus/Transport.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'org') 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; } } -- cgit v1.2.3