public override void Parse(Node e) { if (e.GetType() == typeof(protocol.sasl.Challenge)) { protocol.sasl.Challenge c = e as protocol.sasl.Challenge; sasl.DigestMD5.Step1 step1 = new sasl.DigestMD5.Step1(c.TextBase64); if (step1.Rspauth == null) { //response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9ImduYXVjayIscmVhbG09IiIsbm9uY2U9IjM4MDQzMjI1MSIsY25vbmNlPSIxNDE4N2MxMDUyODk3N2RiMjZjOWJhNDE2ZDgwNDI4MSIsbmM9MDAwMDAwMDEscW9wPWF1dGgsZGlnZXN0LXVyaT0ieG1wcC9qYWJiZXIucnUiLGNoYXJzZXQ9dXRmLTgscmVzcG9uc2U9NDcwMTI5NDU4Y2EwOGVjYjhhYTIxY2UzMDhhM2U5Nzc sasl.DigestMD5.Step2 s2 = new agsXMPP.sasl.DigestMD5.Step2(step1, base.Username, base.Password, base.Server); protocol.sasl.Response r = new agsXMPP.protocol.sasl.Response(s2.ToString()); base.XmppClientConnection.Send(r); } else { // SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/> base.XmppClientConnection.Send(new protocol.sasl.Response()); } } }
public override void Parse(Node e) { if ( e.GetType() == typeof(protocol.sasl.Challenge) ) { protocol.sasl.Challenge c = e as protocol.sasl.Challenge; sasl.DigestMD5.Step1 step1 = new sasl.DigestMD5.Step1(c.TextBase64); if (step1.Rspauth == null) { //response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">dXNlcm5hbWU9ImduYXVjayIscmVhbG09IiIsbm9uY2U9IjM4MDQzMjI1MSIsY25vbmNlPSIxNDE4N2MxMDUyODk3N2RiMjZjOWJhNDE2ZDgwNDI4MSIsbmM9MDAwMDAwMDEscW9wPWF1dGgsZGlnZXN0LXVyaT0ieG1wcC9qYWJiZXIucnUiLGNoYXJzZXQ9dXRmLTgscmVzcG9uc2U9NDcwMTI5NDU4Y2EwOGVjYjhhYTIxY2UzMDhhM2U5Nzc sasl.DigestMD5.Step2 s2 = new agsXMPP.sasl.DigestMD5.Step2(step1, base.Username, base.Password, base.Server); protocol.sasl.Response r = new agsXMPP.protocol.sasl.Response(s2.ToString()); base.XmppClientConnection.Send(r); } else { // SEND: <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/> base.XmppClientConnection.Send(new protocol.sasl.Response()); } } }
//private bool SendToAllResource(Account account, Element msg) //{ // bool bSend = false; // if (this.m_Server.ClientConnections.ContainsKey(account)) // { // Dictionary<string, XmppSeverConnection> connections = this.m_Server.ClientConnections[account]; // foreach (KeyValuePair<string, XmppSeverConnection> connection in connections) // { // bSend = true; // connection.Value.Send(msg); // } // } // return bSend; //} private void ProcessResponse(agsXMPP.protocol.sasl.Response response) { string strResponse = response.TextBase64.Trim(); if (strResponse == string.Empty) { agsXMPP.protocol.sasl.Success success = new agsXMPP.protocol.sasl.Success(); Send(success); m_StreamParser.Reset(); m_AuthenticatedClient = true; //if (this.OnClientStart != null) //{ // this.OnClientStart(this.m_ClientAccount, this); //} } else { if (!this.m_AuthenticatedClient && this.clientMechanismType == agsXMPP.protocol.sasl.MechanismType.DIGEST_MD5) { agsXMPP.sasl.DigestMD5.Step2 step2 = new agsXMPP.sasl.DigestMD5.Step2(strResponse); string strOldResponse = step2.Response; foreach (Account account in m_Server.AccountManager.Accounts) { //this.m_Server.ClientConnections[account] = if (step2.Username == account.UserID.ToLower()) { step2.Password = account.Password; step2.GenerateResponse(); string strNewResponse = step2.Response; if (strOldResponse == strNewResponse) { agsXMPP.protocol.sasl.Challenge challenge = new agsXMPP.protocol.sasl.Challenge(); challenge.TextBase64 = "rspauth=ea40f60335c427b5527b84dbabcdfffd"; Send(challenge); this.m_ClientAccount = account; return; } else { StringBuilder sb = new StringBuilder(); agsXMPP.protocol.sasl.Failure failure = new agsXMPP.protocol.sasl.Failure(); failure.AddTag("not-authorized"); sb.Append(failure.ToString()); Send(sb.ToString()); sb.Remove(0, sb.Length); sb.Append("</stream:stream>"); Send(sb.ToString()); EndClientConnection(); return; } } } } else { } } }