public void StreamStartHandle(XmppStream xmppStream, Stream stream, XmppHandlerContext context) { var streamHeader = new StringBuilder(); streamHeader.AppendLine("<?xml version='1.0' encoding='UTF-8'?>"); streamHeader.AppendFormat("<stream:{0} xmlns:{0}='{1}' xmlns='{2}' from='{3}' id='{4}' version='1.0'>", Uri.PREFIX, Uri.STREAM, Uri.CLIENT, stream.To, xmppStream.Id); context.Sender.SendTo(xmppStream, streamHeader.ToString()); var features = new Features(); features.Prefix = Uri.PREFIX; if (xmppStream.Authenticated) { features.AddChild(new Bind()); features.AddChild(new Core.protocol.iq.session.Session()); } else { features.Mechanisms = new Mechanisms(); var listener = (BoshXmppListener)(context.XmppGateway.GetXmppListener("Bosh Listener")); var storage = new DbLdapSettingsStore(); storage.GetLdapSettings(xmppStream.Domain); if (!storage.EnableLdapAuthentication || listener.GetXmppConnection(xmppStream.ConnectionId) != null) { features.Mechanisms.AddChild(new Mechanism(MechanismType.DIGEST_MD5)); } else { features.Mechanisms.AddChild(new Mechanism(MechanismType.PLAIN)); } features.Mechanisms.AddChild(new Element("required")); features.Register = new Register(); } streamHeader.Append(features.ToString()); context.Sender.SendTo(xmppStream, features); }
public void StreamStartHandle(XmppStream xmppStream, Stream stream, XmppHandlerContext context) { var streamHeader = new StringBuilder(); streamHeader.AppendLine("<?xml version='1.0' encoding='UTF-8'?>"); streamHeader.AppendFormat("<stream:{0} xmlns:{0}='{1}' xmlns='{2}' from='{3}' id='{4}' version='1.0'>", Uri.PREFIX, Uri.STREAM, Uri.CLIENT, stream.To, xmppStream.Id); context.Sender.SendTo(xmppStream, streamHeader.ToString()); var features = new Features(); features.Prefix = Uri.PREFIX; if (xmppStream.Authenticated) { features.AddChild(new Bind()); features.AddChild(new Core.protocol.iq.session.Session()); } else { features.Mechanisms = new Mechanisms(); features.Mechanisms.AddChild(new Mechanism(MechanismType.DIGEST_MD5)); features.Mechanisms.AddChild(new Element("required")); features.Register = new Register(); } streamHeader.Append(features.ToString()); context.Sender.SendTo(xmppStream, features); }