public override void OnRead(RiftClient From) { try { XmlSerializer xmls = new XmlSerializer(typeof(ClientAuthCertificate)); ClientAuthCertificate Cert = xmls.Deserialize(new MemoryStream(Encoding.UTF8.GetBytes(Certificate))) as ClientAuthCertificate; if (Program.Config.UseCertificate) From.Acct = AccountMgr.Instance.GetAccountBySession(Cert.Sessionkey); else From.Acct = AccountMgr.Instance.GetAccountByPassword(Cert.Username, Cert.Hash); } catch { From.Disconnect(); } if (From.Acct == null) { Log.Error("Authentication", "Failled !"); From.Disconnect(); } else { HandshakeAuthenticationResponse Rp = new HandshakeAuthenticationResponse(); Rp.SessionTicket = (long)BitConverter.ToUInt64(Guid.NewGuid().ToByteArray(), 0); From.Acct.SessionTicket = Rp.SessionTicket; From.Acct.Dirty = true; AccountMgr.AccountDB.SaveObject(From.Acct); From.SendSerialized(Rp); } }
public override void OnRead(RiftClient From) { try { XmlSerializer xmls = new XmlSerializer(typeof(ClientAuthCertificate)); ClientAuthCertificate Cert = xmls.Deserialize(new MemoryStream(Encoding.UTF8.GetBytes(Certificate))) as ClientAuthCertificate; if (Program.Config.UseCertificate) { From.Acct = Program.AcctMgr.GetAccount(Cert.Sessionkey); } else { From.Acct = Program.AcctMgr.GetAccount(Cert.Username, Cert.Hash); } } catch (Exception e) { From.Disconnect(); } if (From.Acct == null) { Log.Error("Authentication", "Failled !"); From.Disconnect(); } else { HandshakeAuthenticationResponse Rp = new HandshakeAuthenticationResponse(); Rp.SessionTicket = (long)BitConverter.ToUInt64(Guid.NewGuid().ToByteArray(), 0); From.Acct.SessionTicket = Rp.SessionTicket; From.Acct.Dirty = true; AccountMgr.AccountDB.SaveObject(From.Acct); From.SendSerialized(Rp); } }