void JabberClient::auth_digest() { AuthRequest *req = new AuthRequest(this); req->start_element("query"); req->add_attribute("xmlns", "jabber:iq:auth"); req->text_tag("username", data.owner.ID); string digest = m_id; digest += getPassword().utf8(); SHA_CTX c; unsigned char md[SHA_DIGEST_LENGTH]; SHA1_Init(&c); SHA1_Update(&c, digest.c_str(),(unsigned long)digest.length()); SHA1_Final(md, &c); digest = ""; for (unsigned i = 0; i < SHA_DIGEST_LENGTH; i++){ char b[3]; sprintf(b, "%02x",md[i]); digest += b; } req->text_tag("digest", digest.c_str()); req->text_tag("resource", data.owner.Resource); req->send(); m_requests.push_back(req); }
void JabberClient::auth_register() { AuthRequest *req = new AuthRequest(this); req->start_element("query"); req->add_attribute("xmlns", "jabber:iq:register"); req->text_tag("username", data.owner.ID); req->text_tag("password", getPassword()); req->send(); m_requests.push_back(req); }
void JabberClient::auth_plain() { AuthRequest *req = new AuthRequest(this); req->start_element("query"); req->add_attribute("xmlns", "jabber:iq:auth"); QString username = data.owner.getId(); username = getToken(username, '@'); req->text_tag("username", username); req->text_tag("password", getPassword()); req->text_tag("resource", data.owner.getResource()); req->send(); m_requests.push_back(req); }
void JabberClient::auth_digest() { AuthRequest *req = new AuthRequest(this); req->start_element("query"); req->add_attribute("xmlns", "jabber:iq:auth"); QString username = data.owner.getId(); username = getToken(username, '@'); req->text_tag("username", username); QString digest = m_id; digest += getPassword(); QByteArray md = QCryptographicHash::hash(digest.toUtf8(), QCryptographicHash::Sha1); digest = QString::null; for (int i = 0; i < md.size(); i++){ char b[3]; sprintf(b, "%02x", md[i] & 0xFF); digest += b; } req->text_tag("digest", digest); req->text_tag("resource", data.owner.getResource()); req->send(); m_requests.push_back(req); }