private void ProcessAuthIQ(IQ iq) { if (iq.Type == IqType.get) { AuthIq authIq = new AuthIq(IqType.result); authIq.Namespace = agsXMPP.Uri.CLIENT; authIq.Id = iq.Id; tempAuthName = ((Auth)iq.Query).Username; authIq.Query.Username = tempAuthName; authIq.Query.Password = string.Empty; authIq.Query.Digest = string.Empty; authIq.Query.Resource = string.Empty; Send(authIq); } else if (iq.Type == IqType.set) { Auth auth = iq.Query as Auth; IQ newIq = new IQ(IqType.error); newIq.Id = iq.Id; string strTemp = string.Empty; foreach (Account account in m_Server.AccountManager.Accounts) { if (account.UserID != auth.Username) { continue; } strTemp = agsXMPP.util.Hash.Sha1Hash(this.SessionId); if (strTemp == auth.Digest) { m_AuthenticatedClient = true; this.m_ClientAccount = account; break; } strTemp = agsXMPP.util.Hash.Sha1Hash(this.SessionId + account.Password); if (strTemp == auth.Digest) { m_AuthenticatedClient = true; this.m_ClientAccount = account; break; } break; } if (m_AuthenticatedClient == true) { this.strBindResource = auth.Resource; Dictionary<string, XmppSeverConnection> bindedConnections = null; if (this.m_Server.ClientConnections.ContainsKey(this.m_ClientAccount)) { bindedConnections = this.m_Server.ClientConnections[this.m_ClientAccount]; } if (bindedConnections == null) { bindedConnections = new Dictionary<string, XmppSeverConnection>(); } if (!bindedConnections.ContainsKey(strBindResource)) { newIq.Type = IqType.result; bindedConnections[strBindResource] = this; this.m_Server.ClientConnections[this.m_ClientAccount] = bindedConnections; //if (this.OnClientStart != null) //{ // this.OnClientStart(this.m_ClientAccount, this); //} } else { newIq.Type = IqType.error; } } Send(newIq); if (newIq.Type == IqType.error) { Stop(); } } else { } }
internal void RequestLoginInfo() { AuthIq iq = new AuthIq(IqType.get, new Jid(base.Server)); iq.Query.Username = this.m_Username; IqGrabber.SendIq(iq, new IqCB(OnGetAuthInfo), null); }