From 106a793c0235c23b7fd60c3d5ba06306a5a06783 Mon Sep 17 00:00:00 2001 From: ishmal Date: Mon, 22 May 2006 06:05:04 +0000 Subject: [PATCH] Clean up registration. Comment out authzid from sasl, as wildfire cant handle it. --- src/pedro/pedrogui.cpp | 8 +++++++- src/pedro/pedroxmpp.cpp | 42 ++++++++++++++++++++++++++++------------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/pedro/pedrogui.cpp b/src/pedro/pedrogui.cpp index 48dfa94e9..0ef33b5c2 100644 --- a/src/pedro/pedrogui.cpp +++ b/src/pedro/pedrogui.cpp @@ -1148,7 +1148,7 @@ bool ConnectDialog::doSetup() table.resize(6, 2); get_vbox()->pack_start(table); - parent.client.setHost("broadway.dynalias.com"); + parent.client.setHost("gristle.org"); parent.client.setPort(5223); parent.client.setUsername(""); parent.client.setPassword(""); @@ -1845,6 +1845,12 @@ void PedroGui::doEvent(const XmppEvent &event) event.getFileSize(), event.getFileHash()); break; } + case XmppEvent::EVENT_REGISTRATION_NEW: + { + status("##### REGISTERED: %s at %s\n", + event.getTo().c_str(), event.getFrom().c_str()); + break; + } default: { printf("unknown event type: %d\n", typ); diff --git a/src/pedro/pedroxmpp.cpp b/src/pedro/pedroxmpp.cpp index 6bce6c10e..0951c6767 100644 --- a/src/pedro/pedroxmpp.cpp +++ b/src/pedro/pedroxmpp.cpp @@ -3313,7 +3313,7 @@ bool XmppClient::saslMd5Authenticate() } DOMString realm = attrs["realm"]; - if (nonce.size()==0) + if (realm.size()==0) { error("login: no SASL realm sent by server"); return false; @@ -3321,8 +3321,8 @@ bool XmppClient::saslMd5Authenticate() status("SASL recv nonce: '%s' realm:'%s'\n", nonce.c_str(), realm.c_str()); - char idBuf[7]; - snprintf(idBuf, 6, "%dsasl", msgId++); + char idBuf[10]; + snprintf(idBuf, 9, "%dsasl", msgId++); DOMString cnonce = Sha1::hashHex((unsigned char *)idBuf, 7); DOMString authzid = username; authzid.append("@"); authzid.append(host); DOMString digest_uri = "xmpp/"; digest_uri.append(host); @@ -3342,8 +3342,10 @@ bool XmppClient::saslMd5Authenticate() md5.append(nonce); md5.append(":"); md5.append(cnonce); - md5.append(":"); - md5.append(authzid); + //RFC2831 says authzid is optional. Wildfire has trouble with authzid's + //md5.append(":"); + //md5.append(authzid); + md5.append(""); DOMString a1 = md5.finishHex(); status("##a1:'%s'", a1.c_str()); @@ -3376,8 +3378,8 @@ bool XmppClient::saslMd5Authenticate() resp.append("cnonce=\""); resp.append(cnonce); resp.append("\","); resp.append("nc=00000001,qop=auth,"); resp.append("digest-uri=\""); resp.append(digest_uri); resp.append("\"," ); - resp.append("authzid=\""); resp.append(authzid); resp.append("\","); - resp.append("response=\""); resp.append(response); resp.append("\","); + //resp.append("authzid=\""); resp.append(authzid); resp.append("\","); + resp.append("response="); resp.append(response); resp.append(","); resp.append("charset=utf-8"); status("sending response:'%s'", resp.c_str()); resp = Base64Encoder::encode(resp); @@ -3607,34 +3609,46 @@ bool XmppClient::inBandRegistration() DOMString recbuf = readStanza(); status("RECV reg: %s", recbuf.c_str()); Element *elem = parser.parse(recbuf); - elem->print(); + //elem->print(); //# does the entity send the "instructions" tag? - bool hasInstructions = - (elem->findElements("instructions").size() > 0); + std::vector fields = elem->findElements("field"); + std::vector fnames; + for (unsigned int i=0; igetAttribute("var"); + if (fname == "FORM_TYPE") + continue; + fnames.push_back(fname); + status("field name:%s", fname.c_str()); + } + delete elem; - if (!hasInstructions) + if (fnames.size() == 0) { error("server did not offer registration"); return false; } + fmt = "" "" "%s" "%s" + "" "" "\n\n"; - if (!write(fmt, toXml(username).c_str(), toXml(password).c_str() )) + if (!write(fmt, toXml(username).c_str(), + toXml(password).c_str() )) return false; recbuf = readStanza(); status("RECV reg: %s", recbuf.c_str()); elem = parser.parse(recbuf); - elem->print(); + //elem->print(); std::vector list = elem->findElements("error"); if (list.size()>0) @@ -3658,6 +3672,8 @@ bool XmppClient::inBandRegistration() delete elem; XmppEvent evt(XmppEvent::EVENT_REGISTRATION_NEW); + evt.setTo(username); + evt.setFrom(host); dispatchXmppEvent(evt); return true; -- 2.30.2